list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <el-card shadow="never">
  3. <seekPage :seekList="seekList" :maxLength="4" @search="reload"></seekPage>
  4. <ele-pro-table
  5. ref="table"
  6. row-key="id"
  7. :columns="columns"
  8. :datasource="datasource"
  9. cacheKey="batchRecordBefore"
  10. :cache-key="cacheKeyUrl"
  11. autoAmendPage
  12. :pageSize="20"
  13. height="600px"
  14. >
  15. <!-- 操作列 -->
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar>
  18. <el-button
  19. v-if="
  20. $hasPermission('mes:producetaskrulerecord:tempsu') ||
  21. $hasPermission('mes:producetaskrulerecord:tempsus') ||
  22. $hasPermission('mes:producetaskrecordrulesrecord:saveorupdate') ||
  23. $hasPermission('mes:producetaskrecordrulesrecord:sus')
  24. "
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="openEdit('add', null)"
  30. >
  31. 新建
  32. </el-button>
  33. </template>
  34. <template v-slot:code="{ row }">
  35. <el-link
  36. type="primary"
  37. :underline="false"
  38. @click="openEdit('detail', row)"
  39. >
  40. {{ row.code }}
  41. </el-link>
  42. <!-- <template v-slot:approvalStatus="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. @click="openEdit('detail', row, 'bpm')"
  47. >
  48. {{ approvalStatusText(row) }}
  49. </el-link>
  50. </template> -->
  51. </template>
  52. <template v-slot:action="{ row }">
  53. <div>
  54. <el-link
  55. v-if="
  56. row.executeStatus == 0 ||
  57. (row.executeStatus == 1 && row.itemType == 2)
  58. "
  59. type="primary"
  60. :underline="false"
  61. @click="openEdit('edit', row)"
  62. >
  63. 编辑
  64. </el-link>
  65. <!-- <el-popconfirm
  66. v-if="
  67. row.executeStatus == 0 ||
  68. (row.executeStatus == 1 && row.itemType == 2) ||
  69. (row.executeStatus == 1 && row.itemType == 3)
  70. "
  71. title="确定要报工此记录吗?"
  72. class="ele-action"
  73. @confirm="execute(row)"
  74. >
  75. <template v-slot:reference>
  76. <el-link type="primary" :underline="false"> 报工 </el-link>
  77. </template>
  78. </el-popconfirm> -->
  79. <el-link
  80. type="primary"
  81. :underline="false"
  82. @click="openEdit('edit', row)"
  83. v-if="
  84. row.executeStatus == 0 ||
  85. (row.executeStatus == 1 && row.itemType == 2) ||
  86. (row.executeStatus == 1 && row.itemType == 3)
  87. "
  88. >
  89. 报工
  90. </el-link>
  91. <el-link
  92. v-if="
  93. row.executeStatus == 2 &&
  94. $hasPermission('mes:producetaskrecordrulesrecord:res')
  95. "
  96. type="primary"
  97. :underline="false"
  98. @click="openEdit('edit', row)"
  99. >
  100. 重新报工
  101. </el-link>
  102. <el-link
  103. v-if="row.approvalStatus === 0"
  104. type="primary"
  105. :underline="false"
  106. @click="openApproval(row)"
  107. >
  108. 提交
  109. </el-link>
  110. <el-popconfirm
  111. v-if="
  112. row.executeStatus == 0 &&
  113. $hasPermission('mes:producetaskrecordrulesrecord:logicdelete')
  114. "
  115. title="确定要删除此用户吗?"
  116. class="ele-action"
  117. @confirm="deleteById(row)"
  118. >
  119. <template v-slot:reference>
  120. <el-link type="danger" :underline="false"> 删除 </el-link>
  121. </template>
  122. </el-popconfirm>
  123. </div>
  124. </template>
  125. </ele-pro-table>
  126. <!-- 编辑添加组件 -->
  127. <editModal
  128. ref="detailsRef"
  129. :reportWorkType="reportWorkType"
  130. @reload="reload"
  131. ></editModal>
  132. <!-- 记录规则 执行 -->
  133. <releaseRulesDialog
  134. ref="releaseRulesDialogRef"
  135. @reload="reload"
  136. :isTempRecord="1"
  137. />
  138. <programRulesDialog
  139. ref="programRulesDialogRef"
  140. @reload="reload"
  141. :isTempRecord="1"
  142. />
  143. <taskDialog ref="taskDialogRef" @reload="reload" :isTempRecord="1" />
  144. <process-submit-dialog
  145. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  146. v-if="processSubmitDialogFlag"
  147. ref="processSubmitDialogRef"
  148. @reload="reload"
  149. :isNotNeedProcess="false"
  150. ></process-submit-dialog>
  151. </el-card>
  152. </template>
  153. <script>
  154. import dictMixins from '@/mixins/dictMixins';
  155. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  156. import {
  157. producetaskrulerecordPage,
  158. logicDeleteById,
  159. saveRuleRecord
  160. } from '@/api/producetaskrulerecord/index';
  161. import editModal from './editModal.vue';
  162. import { parameterGetByCode } from '@/api/system/dictionary-data';
  163. import releaseRulesDialog from '@/views/produce/components/prenatalExamination/releaseRulesDialog.vue';
  164. import programRulesDialog from '@/views/produce/components/prenatalExamination/programRulesDialog.vue';
  165. import taskDialog from '@/views/produce/components/prenatalExamination/taskDialog.vue';
  166. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  167. import {
  168. queryListByWorkOrderId,
  169. saveOrUpdateAndSubmit
  170. } from '@/api/producetaskrecordrulesrecord/index.js';
  171. export default {
  172. components: {
  173. editModal,
  174. releaseRulesDialog,
  175. programRulesDialog,
  176. processSubmitDialog,
  177. taskDialog
  178. },
  179. name: 'batchRecordTable',
  180. mixins: [dictMixins, tableColumnsMixin],
  181. props: {
  182. // 1-产前准备,2-过程监测,3-产后检查
  183. reportWorkType: {
  184. type: Number,
  185. default: 1
  186. }
  187. },
  188. data() {
  189. return {
  190. // 表格字段
  191. columns: [
  192. {
  193. width: 50,
  194. type: 'index',
  195. columnKey: 'index',
  196. label: '序号',
  197. align: 'center'
  198. },
  199. {
  200. label: '记录编码',
  201. prop: 'code',
  202. minWidth: 150,
  203. slot: 'code'
  204. },
  205. {
  206. label: '产品编码',
  207. prop: 'productCode',
  208. minWidth: 180
  209. },
  210. {
  211. label: '产品名称',
  212. prop: 'productName',
  213. minWidth: 180
  214. },
  215. {
  216. label: '批次号',
  217. prop: 'batchNo',
  218. minWidth: 150
  219. },
  220. {
  221. label: '生产工单号',
  222. prop: 'workOrderCode',
  223. minWidth: 180
  224. },
  225. {
  226. label: '类型',
  227. prop: 'itemType',
  228. formatter: (row) => {
  229. return this.getDictValue('事项类型', row.itemType + '');
  230. }
  231. },
  232. {
  233. label: '配置执行方式',
  234. prop: 'executeMethod',
  235. minWidth: 150,
  236. formatter: (row) => {
  237. return this.getDictValue('执行方式', row.executeMethod + '');
  238. }
  239. },
  240. {
  241. label: '事项名称',
  242. prop: 'ruleName',
  243. minWidth: 180,
  244. formatter: (row) => {
  245. return row.ruleName || row.itemTaskName;
  246. }
  247. },
  248. {
  249. label: '记录执行方式',
  250. prop: 'recordRulesExecuteMethodName',
  251. minWidth: 180
  252. },
  253. {
  254. label: '状态',
  255. minWidth: 80,
  256. prop: 'executeStatus',
  257. formatter: (row) => {
  258. switch (row.executeStatus) {
  259. case 0:
  260. return '未报工';
  261. case 1:
  262. return '执行中';
  263. default:
  264. return '已报工';
  265. }
  266. }
  267. },
  268. {
  269. label: '审核状态',
  270. prop: 'approvalStatus',
  271. minWidth: 90,
  272. formatter: (row) => {
  273. switch (row.approvalStatus) {
  274. case 0:
  275. return '未提交';
  276. case 1:
  277. return '审核中';
  278. case 2:
  279. return '审核通过';
  280. case 3:
  281. return '审核不通过';
  282. case 4:
  283. return '终止审核中';
  284. case 5:
  285. return '终止审核通过';
  286. case 7:
  287. return '流程废止';
  288. default:
  289. return '';
  290. }
  291. }
  292. },
  293. {
  294. label: '创建人',
  295. prop: 'createUserName',
  296. minWidth: 150
  297. },
  298. {
  299. label: '创建时间',
  300. prop: 'createTime',
  301. minWidth: 150
  302. },
  303. {
  304. label: '操作',
  305. columnKey: 'action',
  306. slot: 'action',
  307. showOverflowTooltip: true,
  308. minWidth: 150,
  309. align: 'center',
  310. fixed: 'right'
  311. }
  312. ],
  313. // 是否展示处理按钮
  314. showBut: false,
  315. showReleaseRulesDialog: false,
  316. processSubmitDialogFlag: false,
  317. butLoading: false
  318. };
  319. },
  320. computed: {
  321. seekList() {
  322. return [
  323. {
  324. label: '记录编码:',
  325. value: 'code',
  326. type: 'input',
  327. placeholder: '请输入'
  328. },
  329. {
  330. label: '生产工单号:',
  331. value: 'workOrderCode',
  332. type: 'input',
  333. placeholder: '请输入'
  334. },
  335. {
  336. label: '类型:',
  337. value: 'itemType',
  338. type: 'select',
  339. placeholder: '请选择',
  340. planList: this.getDictListByName('事项类型')
  341. },
  342. {
  343. label: '产品名称:',
  344. value: 'productName',
  345. type: 'input',
  346. placeholder: '请输入'
  347. },
  348. {
  349. label: '状态:',
  350. value: 'executeStatus',
  351. type: 'select',
  352. placeholder: '请选择',
  353. planList: [
  354. {
  355. label: '未报工',
  356. value: 0
  357. },
  358. {
  359. label: '执行中',
  360. value: 1
  361. },
  362. {
  363. label: '已报工',
  364. value: 2
  365. }
  366. ]
  367. }
  368. ];
  369. },
  370. cacheKeyUrl() {
  371. return `mes-batchRecordTableRules-reportWorkType-${this.reportWorkType}`;
  372. }
  373. },
  374. created() {
  375. this.requestDict('事项类型');
  376. this.requestDict('报工类型');
  377. this.requestDict('执行方式');
  378. this.parameterGetByCode();
  379. },
  380. methods: {
  381. // 刷新表格
  382. reload(where = {}) {
  383. this.$nextTick(() => {
  384. this.$refs.table.reload({
  385. page: 1,
  386. where,
  387. reportWorkType: this.reportWorkType
  388. });
  389. });
  390. },
  391. /* 表格数据源 */
  392. datasource({ page, limit, where, order }) {
  393. return producetaskrulerecordPage({
  394. ...where,
  395. ...order,
  396. pageNum: page,
  397. size: limit,
  398. reportWorkType: this.reportWorkType
  399. });
  400. },
  401. // 打开编辑新增
  402. openEdit(type, row) {
  403. this.$refs.detailsRef.open(type, row);
  404. },
  405. // 删除临时记录
  406. async deleteById(item) {
  407. await logicDeleteById(item.id);
  408. this.$message.warning('删除成功!');
  409. this.reload();
  410. },
  411. // 查询是否显示处理按钮
  412. async parameterGetByCode() {
  413. const data = await parameterGetByCode({
  414. code: 'form_submission_requires_approval',
  415. moduleCode: 'mes_'
  416. });
  417. this.showBut = data?.tenantId == '1';
  418. console.log('是否显示处理按钮(审批)', this.showBut);
  419. },
  420. // 提交审批
  421. openApproval(row) {
  422. console.log('row', row);
  423. this.processSubmitDialogFlag = true;
  424. // 类型
  425. let businessType = '';
  426. if (this.reportWorkType == 1) {
  427. businessType = '产前准备';
  428. } else if (this.reportWorkType == 2) {
  429. businessType = '过程监测';
  430. } else if (this.reportWorkType == 3) {
  431. businessType = '产后检查';
  432. } else {
  433. businessType = '生产统计';
  434. }
  435. this.$nextTick(() => {
  436. let params = {
  437. businessId: row.id,
  438. businessKey: 'mes_produce_task_record_rule_check',
  439. formCreateUserId: row.createUserId,
  440. variables: {
  441. businessCode: row.code,
  442. businessName: '批记录',
  443. businessType: businessType
  444. }
  445. };
  446. this.$refs.processSubmitDialogRef.init(params);
  447. });
  448. },
  449. // 执行
  450. async execute(row) {
  451. console.log('row', row);
  452. const currentItem = { ...row, recordId: row.id };
  453. if (row.executeMethod == 1) {
  454. // 设备保养计划相关逻辑
  455. this.$refs.programRulesDialogRef.init(currentItem, currentItem, {
  456. name: row.produceTaskName
  457. });
  458. return;
  459. }
  460. if (row.executeMethod == 2) {
  461. return this.releaseRulesSaveOrSubmit(row);
  462. }
  463. // 任务确认
  464. this.saveRuleRecord(row);
  465. },
  466. // 任务确认报工
  467. async saveRuleRecord(row) {
  468. this.butLoading = true;
  469. await saveRuleRecord(row);
  470. this.$message.success('报工成功!');
  471. this.butLoading = false;
  472. this.reload();
  473. },
  474. // 记录规则报工
  475. async releaseRulesSaveOrSubmit(row) {
  476. this.butLoading = true;
  477. if (row.produceTaskId) {
  478. const pickDetails = await queryListByWorkOrderId({
  479. workOrderId: row.workOrderId,
  480. recordId: row.id,
  481. produceTaskId: row.produceTaskId,
  482. ruleId: row.ruleId
  483. });
  484. row.pickDetails = pickDetails;
  485. }
  486. await saveOrUpdateAndSubmit(row);
  487. this.$message.success('报工成功!');
  488. this.butLoading = false;
  489. this.reload();
  490. },
  491. approvalStatusText(row) {
  492. switch (row.approvalStatus) {
  493. case 0:
  494. return '未提交';
  495. case 1:
  496. return '审核中';
  497. case 2:
  498. return '审核通过';
  499. case 3:
  500. return '审核不通过';
  501. case 4:
  502. return '终止审核中';
  503. case 5:
  504. return '终止审核通过';
  505. case 7:
  506. return '流程废止';
  507. default:
  508. return '';
  509. }
  510. }
  511. }
  512. };
  513. </script>
  514. <style lang="scss" scoped></style>