index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <seek-page
  5. v-if="renderFlag"
  6. :seekList="seekList"
  7. @search="search"
  8. ref="search"
  9. ></seek-page>
  10. <!-- <search ref="search" @search="search"></search> -->
  11. <ele-pro-table
  12. ref="table"
  13. :columns="columns"
  14. :datasource="datasource"
  15. height="calc(100vh - 400px)"
  16. tool-class="ele-toolbar-form"
  17. row-key="id"
  18. @selection-change="selectionChangeHandle"
  19. :page-size="20"
  20. @columns-change="handleColumnChange"
  21. :cache-key="cacheKeyUrl"
  22. >
  23. <template v-slot:qualitySchemeTemplateCode="{ row }">
  24. <el-link
  25. type="primary"
  26. :underline="false"
  27. @click="addOrUpdateHandle('view', row.id)"
  28. >
  29. {{ row.qualitySchemeTemplateCode }}
  30. </el-link>
  31. </template>
  32. <template v-slot:toolbar>
  33. <el-button
  34. size="small"
  35. type="primary"
  36. icon="el-icon-plus"
  37. class="ele-btn-icon"
  38. @click="addOrUpdateHandle('add')"
  39. >
  40. 新增
  41. </el-button>
  42. <el-button
  43. size="small"
  44. type="danger"
  45. icon="el-icon-delete"
  46. class="ele-btn-icon"
  47. @click="deleteHandle()"
  48. :disabled="selection.length <= 0"
  49. >
  50. 批量删除
  51. </el-button>
  52. </template>
  53. <template v-slot:status="{ row }">
  54. {{ row.status ? '启用' : '停用' }}
  55. </template>
  56. <!-- 操作列 -->
  57. <template v-slot:action="{ row }">
  58. <el-link
  59. type="primary"
  60. :underline="false"
  61. icon="el-icon-tickets"
  62. @click="copyData(row)"
  63. >
  64. 复制
  65. </el-link>
  66. <el-link
  67. type="primary"
  68. :underline="false"
  69. icon="el-icon-edit"
  70. @click="approvalSubmit(row)"
  71. v-if="row.isUpdate != 1 && [0, 3].includes(row.approvalStatus)"
  72. >
  73. 发布
  74. </el-link>
  75. <el-link
  76. type="primary"
  77. :underline="false"
  78. icon="el-icon-edit"
  79. @click="addOrUpdateHandle('edit', row.id, true)"
  80. v-if="row.isUpdate != 1 && [2].includes(row.approvalStatus)"
  81. >
  82. 变更
  83. </el-link>
  84. <!-- <el-link
  85. type="primary"
  86. :underline="false"
  87. icon="el-icon-edit"
  88. @click="updateStatus(row) && [0, 3].includes(row.approvalStatus)"
  89. v-if="row.status == 1"
  90. >
  91. 不启用
  92. </el-link>
  93. <el-link
  94. type="primary"
  95. :underline="false"
  96. icon="el-icon-edit"
  97. @click="updateStatus(row) && [0, 3].includes(row.approvalStatus)"
  98. v-if="row.status == 0"
  99. >
  100. 启用
  101. </el-link> -->
  102. <el-link
  103. type="primary"
  104. :underline="false"
  105. v-if="[0, 3].includes(row.approvalStatus)"
  106. icon="el-icon-edit"
  107. @click="addOrUpdateHandle('edit', row.id)"
  108. >
  109. 修改
  110. </el-link>
  111. <el-link
  112. type="danger"
  113. :underline="false"
  114. icon="el-icon-delete"
  115. v-if="[0, 3].includes(row.approvalStatus)"
  116. @click="deleteHandle(row.id)"
  117. >
  118. 删除
  119. </el-link>
  120. </template>
  121. </ele-pro-table>
  122. </el-card>
  123. <!-- 弹窗, 新增 / 修改 -->
  124. <AddOrUpdate
  125. ref="addOrUpdateRef"
  126. @refreshDataList="getDataList"
  127. ></AddOrUpdate>
  128. <processSubmitDialog
  129. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  130. v-if="processSubmitDialogFlag"
  131. ref="processSubmitDialogRef"
  132. @reload="search"
  133. ></processSubmitDialog>
  134. </div>
  135. </template>
  136. <script>
  137. import AddOrUpdate from './AddorUpdate';
  138. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  139. import dictMixins from '@/mixins/dictMixins';
  140. import {
  141. getList,
  142. removeItem,
  143. update,
  144. copyData,
  145. updateStatus
  146. } from '@/api/inspectionTemplate';
  147. import tabMixins from '@/mixins/tableColumnsMixin';
  148. export default {
  149. mixins: [dictMixins, tabMixins],
  150. components: {
  151. AddOrUpdate,
  152. processSubmitDialog
  153. // search
  154. },
  155. computed: {},
  156. data() {
  157. return {
  158. processSubmitDialogFlag: false,
  159. cacheKeyUrl: 'qsm-c2e9664a-inspectionTemplate',
  160. seekList: [
  161. {
  162. label: '名称:',
  163. value: 'qualitySchemeTemplateName',
  164. type: 'input',
  165. placeholder: ''
  166. },
  167. {
  168. label: '编码:',
  169. value: 'qualitySchemeTemplateCode',
  170. type: 'input',
  171. placeholder: ''
  172. },
  173. // {
  174. // label: '类型:',
  175. // value: 'type',
  176. // type: 'select',
  177. // placeholder: '',
  178. // planList: []
  179. // },
  180. {
  181. label: '类型:',
  182. value: 'type',
  183. type: 'DictSelection',
  184. dictName: '质检计划类型',
  185. placeholder: ''
  186. },
  187. {
  188. label: '状态:',
  189. value: 'status',
  190. type: 'select',
  191. planList: [
  192. { value: 0, label: '停用' },
  193. { value: 1, label: '启用' }
  194. ],
  195. placeholder: ''
  196. }
  197. ],
  198. dataForm: {
  199. key: ''
  200. },
  201. selection: [],
  202. //
  203. columns: [
  204. {
  205. width: 45,
  206. type: 'selection',
  207. columnKey: 'selection',
  208. align: 'center',
  209. selectable: (row, index) => {
  210. return [0, 3].includes(row.approvalStatus);
  211. },
  212. reserveSelection: true
  213. },
  214. {
  215. columnKey: 'index',
  216. label: '序号',
  217. type: 'index',
  218. width: 55,
  219. align: 'center',
  220. showOverflowTooltip: true,
  221. fixed: 'left'
  222. },
  223. {
  224. prop: 'type',
  225. label: '类型',
  226. showOverflowTooltip: true,
  227. align: 'center',
  228. minWidth: 110,
  229. formatter: (row, column, cellValue) => {
  230. return this.getDictName('质检计划类型', cellValue);
  231. }
  232. },
  233. {
  234. prop: 'qualitySchemeTemplateCode',
  235. slot: 'qualitySchemeTemplateCode',
  236. label: '检测方案编码',
  237. showOverflowTooltip: true,
  238. align: 'center',
  239. minWidth: 110
  240. },
  241. {
  242. prop: 'qualitySchemeTemplateName',
  243. label: '检测方案名称',
  244. align: 'center',
  245. minWidth: 150
  246. },
  247. {
  248. label: '工序名称',
  249. prop: 'taskName',
  250. align: 'center'
  251. },
  252. {
  253. label: '版本号',
  254. prop: 'version',
  255. align: 'center',
  256. formatter: (row) => {
  257. return `${row.versionSymbol}${row.bigVersion}${row.versionMark}${row.smallVersion}`;
  258. }
  259. },
  260. {
  261. label: '创建人',
  262. prop: 'createUserName',
  263. align: 'center'
  264. },
  265. {
  266. label: '创建时间',
  267. prop: 'createTime',
  268. align: 'center',
  269. width: 170
  270. },
  271. // {
  272. // label: '启用时间',
  273. // prop: '启用时间',
  274. // align: 'center'
  275. // },
  276. {
  277. label: '停用时间',
  278. prop: 'updateTime',
  279. align: 'center',
  280. formatter: (row) => {
  281. if (row.status != 1) {
  282. return row.updateTime;
  283. }
  284. },
  285. width: 170
  286. },
  287. {
  288. label: '状态',
  289. prop: 'status',
  290. slot: 'status',
  291. align: 'center'
  292. },
  293. {
  294. label: '发布状态',
  295. prop: 'approvalStatus',
  296. formatter: (row) => {
  297. return row.approvalStatus == 0
  298. ? '待发布'
  299. : row.approvalStatus == 1
  300. ? '审批中'
  301. : row.approvalStatus == 2
  302. ? '已发布'
  303. : '审核不通过';
  304. },
  305. align: 'center'
  306. },
  307. {
  308. prop: 'templateRemark',
  309. label: '备注',
  310. showOverflowTooltip: true,
  311. align: 'center',
  312. minWidth: 110
  313. },
  314. {
  315. columnKey: 'action',
  316. label: '操作',
  317. width: 260,
  318. align: 'center',
  319. resizable: false,
  320. slot: 'action',
  321. fixed: 'right'
  322. }
  323. ],
  324. typeList: [],
  325. renderFlag: false
  326. };
  327. },
  328. async created() {
  329. // const res = await this.requestDict('质检计划类型');
  330. // console.log(res, 'res 000');
  331. // this.typeList = res.map((item) => {
  332. // console.log(item,'item')
  333. // // let values = Object.keys(item);
  334. // // return {
  335. // // value: Number(values[0]),
  336. // // label: item[values[0]]
  337. // // };
  338. // return {
  339. // value: item.dictCode,
  340. // label: item.dictValue
  341. // };
  342. // });
  343. // const index = this.seekList.findIndex((item) => item.value === 'type');
  344. // this.$set(this.seekList, index, );
  345. this.renderFlag = true;
  346. },
  347. methods: {
  348. // 获取数据列表
  349. datasource({ page, where, limit }) {
  350. return getList({
  351. ...where,
  352. pageNum: page,
  353. size: limit
  354. });
  355. },
  356. // 多选
  357. selectionChangeHandle(val) {
  358. this.selection = val;
  359. },
  360. // 新增 / 修改
  361. addOrUpdateHandle(type, id, isChange) {
  362. this.$refs.addOrUpdateRef.init(type, id, isChange);
  363. },
  364. async approvalSubmit(res) {
  365. this.processSubmitDialogFlag = true;
  366. this.$nextTick(() => {
  367. let params = {
  368. businessId: res.id,
  369. businessKey: 'qms_quality_template_release',
  370. formCreateUserId: res.createUserId,
  371. variables: {
  372. businessCode: res.qualitySchemeTemplateCode,
  373. businessName: res.qualitySchemeTemplateName,
  374. businessType: this.getDictName('质检计划类型', res.type)
  375. }
  376. };
  377. this.$refs.processSubmitDialogRef.init(params);
  378. });
  379. },
  380. // 删除
  381. deleteHandle(id) {
  382. var ids = id
  383. ? [id]
  384. : this.selection.map((item) => {
  385. return item.id;
  386. });
  387. this.$confirm(`确定要删除选中的方案吗?`, '提示', {
  388. confirmButtonText: '确定',
  389. cancelButtonText: '取消',
  390. type: 'warning'
  391. }).then(() => {
  392. removeItem(ids)
  393. .then(({ message }) => {
  394. this.$message.success('操作成功');
  395. this.getDataList();
  396. })
  397. .catch((e) => {});
  398. });
  399. },
  400. getDataList() {
  401. this.$refs.search.search();
  402. },
  403. search(where) {
  404. this.$refs.table.reload({
  405. where: where,
  406. page: 1
  407. });
  408. },
  409. //上下架操作
  410. updateStatus(row) {
  411. let dataForm = {};
  412. let status = row.status === 1 ? 0 : 1;
  413. dataForm['status'] = status;
  414. dataForm['id'] = row.id;
  415. updateStatus(dataForm)
  416. .then((res) => {
  417. this.loading = false;
  418. this.$message.success('操作成功!');
  419. this.visible = false;
  420. this.getDataList();
  421. })
  422. .catch((e) => {
  423. this.loading = false;
  424. });
  425. },
  426. copyData(row) {
  427. console.log(row.id);
  428. copyData(row.id).then((res) => {
  429. console.log(res);
  430. this.$message.success('复制成功!');
  431. this.getDataList();
  432. });
  433. }
  434. }
  435. };
  436. </script>