You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

387 lines
12 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 收藏 -->
  4. <div>
  5. <span @click="favoriteFunction()">
  6. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  7. </span>
  8. </div>
  9. <!-- 条件查询 -->
  10. <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
  11. <el-form-item :label="'检验方法'">
  12. <el-input v-model="searchData.methodName" style="width: 120px"></el-input>
  13. </el-form-item>
  14. <el-form-item :label="' '">
  15. <el-button type="primary" @click="getDataList()">查询</el-button>
  16. <el-button type="primary" @click="addModal()">新增</el-button>
  17. <download-excel
  18. :fields="fields()"
  19. :data="exportData"
  20. type="xls"
  21. :name="exportName"
  22. :header="exportHeader"
  23. :footer="exportFooter"
  24. :fetch="createExportData"
  25. :before-generate="startDownload"
  26. :before-finish="finishDownload"
  27. worksheet="导出信息"
  28. class="el-button el-button--primary el-button--medium">
  29. {{ "导出" }}
  30. </download-excel>
  31. </el-form-item>
  32. </el-form>
  33. <!-- 展示列表 -->
  34. <el-table
  35. :height="height"
  36. :data="dataList"
  37. border
  38. v-loading="dataListLoading"
  39. style="width: 100%;">
  40. <el-table-column
  41. v-for="(item,index) in columnList" :key="index"
  42. :sortable="item.columnSortable"
  43. :prop="item.columnProp"
  44. :header-align="item.headerAlign"
  45. :show-overflow-tooltip="item.showOverflowTooltip"
  46. :align="item.align"
  47. :fixed="item.fixed==''?false:item.fixed"
  48. :min-width="item.columnWidth"
  49. :label="item.columnLabel">
  50. <template slot-scope="scope">
  51. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  52. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column
  56. fixed="right"
  57. header-align="center"
  58. align="center"
  59. width="160"
  60. label="操作">
  61. <template slot-scope="scope">
  62. <a type="text" size="small" @click="updateModal(scope.row)">修改</a>
  63. <a type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <!-- 新增和修改 -->
  68. <el-dialog title="检验方法" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="430px">
  69. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  70. <el-form-item label="检验方法名称:">
  71. <el-input v-model="modalData.methodName" style="width: 120px"></el-input>
  72. </el-form-item>
  73. </el-form>
  74. <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
  75. <el-form-item label="检验方法说明:">
  76. <el-input v-model="modalData.methodRemark" style="width: 254px"></el-input>
  77. </el-form-item>
  78. </el-form>
  79. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  80. <el-button type="primary" @click="saveData()">保存</el-button>
  81. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  82. </el-footer>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script>
  87. import {
  88. qcMethodSearch, // 检验方法查询
  89. qcMethodSave, // 检验方法新增
  90. qcMethodUpdate, // 检验方法修改
  91. qcMethodDelete, // 检验方法删除
  92. } from "@/api/qc/qc.js"
  93. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  94. export default {
  95. watch: {
  96. },
  97. data () {
  98. return {
  99. // 是否收藏
  100. favorite: false,
  101. // 导出 start
  102. exportData: [],
  103. exportName: "检验方法" + this.dayjs().format('YYYYMMDDHHmmss'),
  104. exportHeader: ["检验方法"],
  105. exportFooter: [],
  106. exportList:[],
  107. // 导出 end
  108. searchData: {
  109. methodNo: '',
  110. methodName: '',
  111. },
  112. height: 200,
  113. dataList: [],
  114. dataListLoading: false,
  115. modalFlag: false,
  116. modalDisableFlag: false,
  117. methodData: {
  118. methodNo: '',
  119. valueNo: '',
  120. availableValue: '',
  121. createBy: this.$store.state.user.name
  122. },
  123. modalData: {
  124. flag: '',
  125. methodNo: '',
  126. methodName: '',
  127. createBy: this.$store.state.user.name,
  128. methodRemark: '',
  129. },
  130. // 标头展示
  131. columnList: [
  132. {
  133. columnProp: 'methodNo',
  134. headerAlign: 'center',
  135. align: 'left',
  136. columnLabel: '方法编码',
  137. columnHidden: false,
  138. columnImage: false,
  139. columnSortable: false,
  140. sortLv: 0,
  141. status: true,
  142. fixed: '',
  143. },
  144. {
  145. columnProp: 'methodName',
  146. headerAlign: 'center',
  147. align: 'left',
  148. columnLabel: '方法名称',
  149. columnHidden: false,
  150. columnImage: false,
  151. columnSortable: false,
  152. sortLv: 0,
  153. status: true,
  154. fixed: '',
  155. },
  156. {
  157. columnProp: 'methodRemark',
  158. headerAlign: 'center',
  159. align: 'left',
  160. columnLabel: '方法说明',
  161. columnHidden: false,
  162. columnImage: false,
  163. columnSortable: false,
  164. sortLv: 0,
  165. status: true,
  166. fixed: '',
  167. },
  168. {
  169. columnProp: 'createDate',
  170. headerAlign: 'center',
  171. align: 'left',
  172. columnLabel: '创建时间',
  173. columnHidden: false,
  174. columnImage: false,
  175. columnSortable: false,
  176. sortLv: 0,
  177. status: true,
  178. fixed: '',
  179. },
  180. {
  181. columnProp: 'createBy',
  182. headerAlign: 'center',
  183. align: 'left',
  184. columnLabel: '创建人',
  185. columnHidden: false,
  186. columnImage: false,
  187. columnSortable: false,
  188. sortLv: 0,
  189. status: true,
  190. fixed: '',
  191. },
  192. ]
  193. }
  194. },
  195. mounted () {
  196. this.$nextTick(() => {
  197. this.height = window.innerHeight - 180
  198. })
  199. },
  200. created () {
  201. this.getDataList()
  202. this.favoriteIsOk()
  203. },
  204. methods: {
  205. // 查询获取数据列表
  206. getDataList () {
  207. qcMethodSearch(this.searchData).then(({data}) => {
  208. this.dataList = data.rows
  209. })
  210. },
  211. // 新增按钮
  212. addModal () {
  213. this.modalData = {
  214. flag: '1',
  215. createBy: this.$store.state.user.name,
  216. methodNo: '',
  217. methodName: '',
  218. methodRemark: '',
  219. }
  220. this.modalDisableFlag = false
  221. this.modalFlag = true
  222. },
  223. // 修改按钮
  224. updateModal (row) {
  225. this.modalData = {
  226. flag: '2',
  227. createBy: this.$store.state.user.name,
  228. methodNo: row.methodNo,
  229. methodName: row.methodName,
  230. methodRemark: row.methodRemark,
  231. }
  232. this.modalDisableFlag = true
  233. this.modalFlag = true
  234. },
  235. // 删除方法
  236. deleteModal (row) {
  237. this.$confirm(`是否删除这个检验方法?`, '提示', {
  238. confirmButtonText: '确定',
  239. cancelButtonText: '取消',
  240. type: 'warning'
  241. }).then(() => {
  242. qcMethodDelete(row).then(({data}) => {
  243. if (data && data.code == 0) {
  244. this.getDataList()
  245. this.$message({
  246. message: '操作成功',
  247. type: 'success',
  248. duration: 1500,
  249. onClose: () => {
  250. }
  251. })
  252. } else {
  253. this.$alert(data.msg, '错误', {
  254. confirmButtonText: '确定'
  255. })
  256. }
  257. })
  258. }).catch(() => {
  259. })
  260. },
  261. // 新增/修改方法
  262. saveData () {
  263. if (this.modalData.methodName == '' || this.modalData.methodName == null) {
  264. this.$alert('请输入检验方法名称!', '错误', {
  265. confirmButtonText: '确定'
  266. })
  267. return false
  268. }
  269. if (this.modalData.flag == '1') { // 新增
  270. qcMethodSave(this.modalData).then(({data}) => {
  271. if (data && data.code == 0) {
  272. this.getDataList()
  273. this.modalFlag = false
  274. this.$message({
  275. message: '操作成功',
  276. type: 'success',
  277. duration: 1500,
  278. onClose: () => {
  279. }
  280. })
  281. } else {
  282. this.$alert(data.msg, '错误', {
  283. confirmButtonText: '确定'
  284. })
  285. }
  286. })
  287. } else { // 修改
  288. qcMethodUpdate(this.modalData).then(({data}) => {
  289. if (data && data.code == 0) {
  290. this.getDataList()
  291. this.modalFlag = false
  292. this.$message({
  293. message: '操作成功',
  294. type: 'success',
  295. duration: 1500,
  296. onClose: () => {
  297. }
  298. })
  299. } else {
  300. this.$alert(data.msg, '错误', {
  301. confirmButtonText: '确定'
  302. })
  303. }
  304. })
  305. }
  306. },
  307. // 校验用户是否收藏
  308. favoriteIsOk() {
  309. let userFavorite = {
  310. userId: this.$store.state.user.id,
  311. languageCode: this.$i18n.locale
  312. }
  313. console.log(this.$route.meta.menuId)
  314. userFavoriteList(userFavorite).then(({data}) => {
  315. for (let i = 0; i < data.list.length; i++) {
  316. // let flag=false;
  317. if(this.$route.meta.menuId==data.list[i].menuId){
  318. this.favorite = true
  319. // flag=true;
  320. }
  321. }
  322. })
  323. },
  324. // 收藏 OR 取消收藏
  325. favoriteFunction() {
  326. let userFavorite = {
  327. userId: this.$store.state.user.id,
  328. functionId: this.$route.meta.menuId,
  329. }
  330. if (this.favorite) {
  331. // 取消收藏
  332. this.$confirm(`确定取消收藏`, '提示', {
  333. confirmButtonText: '确定',
  334. cancelButtonText: '取消',
  335. type: 'warning'
  336. }).then(() => {
  337. removeUserFavorite(userFavorite).then(({data}) => {
  338. this.$message.success(data.msg)
  339. this.favorite = false
  340. })
  341. })
  342. } else {
  343. // 收藏
  344. saveUserFavorite(userFavorite).then(({data}) => {
  345. this.$message.success(data.msg)
  346. this.favorite = true
  347. })
  348. }
  349. },
  350. //导出excel
  351. async createExportData() {
  352. this.searchData.limit = -1
  353. this.searchData.page = 1
  354. await qcMethodSearch(this.searchData).then(({data}) => {
  355. this.exportList= data.rows;
  356. })
  357. return this.exportList;
  358. },
  359. startDownload() {
  360. // this.exportData = this.dataList
  361. },
  362. finishDownload() {
  363. },
  364. fields() {
  365. let json = "{"
  366. this.columnList.forEach((item, index) => {
  367. if (index == this.columnList.length - 1) {
  368. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  369. } else {
  370. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  371. }
  372. })
  373. json += "}"
  374. let s = eval("(" + json + ")")
  375. return s
  376. },
  377. // 导出 end
  378. }
  379. }
  380. </script>