checkDetails.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. <template>
  2. <ele-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :close-on-click-modal="false"
  7. @close="handleClose"
  8. resizable
  9. maxable
  10. width="80%"
  11. append-to-body
  12. >
  13. <div
  14. v-if="(type == 'detail' || type == 'edit') && form.processInstanceId"
  15. class="switch"
  16. :maxable="true"
  17. style="margin-bottom: 20px"
  18. >
  19. <div class="switch_left">
  20. <ul>
  21. <li
  22. v-for="item in tabOptions"
  23. :key="item.key"
  24. :class="{ active: activeComp == item.key }"
  25. @click="activeComp = item.key"
  26. >
  27. {{ item.name }}
  28. </li>
  29. </ul>
  30. </div>
  31. </div>
  32. <bpmDetail
  33. v-if="activeComp == 'bpm' && form && form.processInstanceId"
  34. :id="form.processInstanceId"
  35. >
  36. </bpmDetail>
  37. <el-form
  38. v-if="activeComp == 'main'"
  39. ref="formRef"
  40. :model="form"
  41. :rules="rules"
  42. label-width="100px"
  43. :disabled="type == 'detail'"
  44. >
  45. <header-title title="基本信息"></header-title>
  46. <el-row :gutter="10">
  47. <el-col :span="8">
  48. <el-form-item label="放行单编码">
  49. <el-input
  50. v-model="form.code"
  51. placeholder="系统自动生成"
  52. disabled
  53. ></el-input>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="8">
  57. <el-form-item label="放行单名称" prop="name">
  58. <el-input v-model="form.name" placeholder="请输入"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. </el-row>
  62. <header-title title="物品清单">
  63. <el-button type="primary" icon="el-icon-plus" @click="openAddModel">
  64. 添加
  65. </el-button>
  66. </header-title>
  67. <ele-pro-table
  68. ref="table"
  69. row-key="userId"
  70. :columns="ordersColumns"
  71. :datasource="form.orders"
  72. >
  73. <template v-slot:action="{ row }">
  74. <el-link
  75. icon="el-icon-view"
  76. type="primary"
  77. :underline="false"
  78. @click="openWorkOrderDetail(row)"
  79. >详情</el-link
  80. >
  81. <el-link
  82. v-if="type != 'detail'"
  83. icon="el-icon-delete"
  84. type="danger"
  85. :underline="false"
  86. @click="deleteRow(row)"
  87. >删除</el-link
  88. >
  89. </template>
  90. </ele-pro-table>
  91. <el-button
  92. type="primary"
  93. style="margin-bottom: 15px"
  94. @click="getKitCheck"
  95. :loading="butLoading"
  96. >
  97. 规则齐套检查
  98. </el-button>
  99. <header-title title="生产放行规则"> </header-title>
  100. <ele-pro-table
  101. ref="scTable"
  102. row-key="id"
  103. :columns="detailsColumns"
  104. :datasource="scDetails"
  105. >
  106. <template v-slot:isPass="{ row }">
  107. <el-radio-group v-model="row.isPass">
  108. <el-radio :label="1">是</el-radio>
  109. <el-radio :label="0">否</el-radio>
  110. </el-radio-group>
  111. </template>
  112. <template v-slot:remark="{ row }">
  113. <el-input
  114. type="textarea"
  115. v-model="row.remark"
  116. placeholder="请输入备注"
  117. :rows="1"
  118. ></el-input>
  119. </template>
  120. </ele-pro-table>
  121. <table
  122. class="detail-table"
  123. key="first-table"
  124. style="width: 500px; margin: 15px 0"
  125. >
  126. <tr>
  127. <td>结论</td>
  128. <td>
  129. <el-radio-group v-model="form.workConclution">
  130. <el-radio :label="0">不符合规定</el-radio>
  131. <el-radio :label="1">符合规定</el-radio>
  132. </el-radio-group>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>验收人</td>
  137. <td @click="openSelectUser(0)">
  138. <div class="mask-box">
  139. <el-input
  140. v-model="form.workCheckUserName"
  141. placeholder="请输选择验收人"
  142. readonly
  143. ></el-input>
  144. </div>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td>验收时间</td>
  149. <td>
  150. <el-date-picker
  151. v-model="form.workCheckTime"
  152. type="datetime"
  153. placeholder="选择日期时间"
  154. style="width: 100%"
  155. value-format="yyyy-MM-dd HH:mm:ss"
  156. ></el-date-picker>
  157. </td>
  158. </tr>
  159. </table>
  160. <header-title title="质检放行规则"></header-title>
  161. <ele-pro-table
  162. ref="zjTable"
  163. row-key="id"
  164. :columns="detailsColumns"
  165. :datasource="zjDetails"
  166. >
  167. <template v-slot:isPass="{ row }">
  168. <el-radio-group v-model="row.isPass">
  169. <el-radio :label="1">是</el-radio>
  170. <el-radio :label="0">否</el-radio>
  171. </el-radio-group>
  172. </template>
  173. <template v-slot:remark="{ row }">
  174. <el-input
  175. type="textarea"
  176. v-model="row.remark"
  177. placeholder="请输入备注"
  178. :rows="1"
  179. ></el-input>
  180. </template>
  181. </ele-pro-table>
  182. <table
  183. class="detail-table"
  184. key="tow"
  185. style="width: 500px; margin: 15px 0"
  186. >
  187. <tr>
  188. <td>结论</td>
  189. <td>
  190. <el-radio-group v-model="form.qualityConclution">
  191. <el-radio :label="0">不符合规定</el-radio>
  192. <el-radio :label="1">符合规定</el-radio>
  193. </el-radio-group>
  194. </td>
  195. </tr>
  196. <tr>
  197. <td>验收人</td>
  198. <td>
  199. <div class="mask-box" @click="openSelectUser(1)">
  200. <el-input
  201. v-model="form.qualityCheckUserName"
  202. placeholder="请输选择验收人"
  203. readonly
  204. ></el-input>
  205. </div>
  206. </td>
  207. </tr>
  208. <tr>
  209. <td>验收时间</td>
  210. <td>
  211. <el-date-picker
  212. v-model="form.qualityCheckTime"
  213. type="datetime"
  214. placeholder="选择日期时间"
  215. style="width: 100%"
  216. value-format="yyyy-MM-dd HH:mm:ss"
  217. ></el-date-picker>
  218. </td>
  219. </tr>
  220. </table>
  221. <!-- 选择生产工单 -->
  222. <selectWorkOrder
  223. ref="selectWorkOrderRef"
  224. :where="workOrderWhere"
  225. :autoClose="false"
  226. @confirm="selectWorkOrderConfirm"
  227. ></selectWorkOrder>
  228. <!-- 选择用户 -->
  229. <SelectUser
  230. ref="SelectUserRef"
  231. v-model="showSelectUser"
  232. @selectUserFinished="selectUserFinished"
  233. ></SelectUser>
  234. </el-form>
  235. <template v-slot:footer>
  236. <el-button
  237. v-if="type != 'detail' && !form.approvalStatus"
  238. type="primary"
  239. @click="submit('submit')"
  240. :loading="butLoading"
  241. >保存并提交</el-button
  242. >
  243. <el-button
  244. v-if="type != 'detail' && !form.approvalStatus"
  245. type="primary"
  246. @click="submit('save')"
  247. :loading="butLoading"
  248. >保存</el-button
  249. >
  250. <el-button @click="handleClose">取 消</el-button>
  251. </template>
  252. <detailsPop ref="detailsRef"> </detailsPop>
  253. <process-submit-dialog
  254. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  255. v-if="processSubmitDialogFlag"
  256. ref="processSubmitDialogRef"
  257. :isNotNeedProcess="false"
  258. ></process-submit-dialog>
  259. </ele-modal>
  260. </template>
  261. <script>
  262. import dictMixins from '@/mixins/dictMixins';
  263. import selectWorkOrder from './selectWorkOrder.vue';
  264. import { checklisttemplateGetById } from '@/api/checklisttemplate/index';
  265. import SelectUser from '@/components/select/SelectUser/index.vue';
  266. import {
  267. checklistrecordSave,
  268. checklistrecordGetById,
  269. checklistrecordUpdate,
  270. checklistrecordKitCheck
  271. } from '@/api/checklistrecord/index';
  272. import bpmTask from '@/components/bpmTask/bpmTask.vue';
  273. import bpmDetail from '@/views/bpm/processInstance/detail.vue';
  274. import detailsPop from '@/views/produceOrder/components/details/index.vue';
  275. import { getById as getworkOrderById } from '@/api/produceOrder/index';
  276. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  277. export default {
  278. mixins: [dictMixins],
  279. components: {
  280. selectWorkOrder,
  281. SelectUser,
  282. bpmTask,
  283. bpmDetail,
  284. detailsPop,
  285. processSubmitDialog
  286. },
  287. props: {
  288. // 保存是否关闭弹窗
  289. saveClose: {
  290. type: Boolean,
  291. default: false
  292. }
  293. },
  294. data() {
  295. const formBaseData = {
  296. id: null,
  297. approvalStatus: null,
  298. checklistType: 0,
  299. code: '',
  300. createUserName: '',
  301. details: [],
  302. name: '',
  303. orders: [],
  304. processInstanceId: '',
  305. qualityCheckTime: '',
  306. qualityCheckUserId: null,
  307. qualityCheckUserName: '',
  308. qualityConclution: null,
  309. templateId: 0,
  310. templateName: '',
  311. workCheckTime: '',
  312. workCheckUserId: null,
  313. workCheckUserName: '',
  314. workConclution: null
  315. };
  316. return {
  317. visible: false,
  318. title: '放行申请单',
  319. formBaseData,
  320. form: JSON.parse(JSON.stringify(formBaseData)),
  321. rules: {
  322. name: [
  323. { required: true, message: '请输入放行单名称', trigger: 'blur' },
  324. { required: true, message: '请输入放行单名称', trigger: 'change' }
  325. ]
  326. },
  327. // 类型 add / edit / detail
  328. type: '',
  329. // 生产工单查询条件
  330. workOrderWhere: {
  331. statusList: ['6'],
  332. queryTermination: 0
  333. },
  334. loading: false,
  335. butLoading: false,
  336. tabOptions: [
  337. { key: 'main', name: '放行单详情' },
  338. { key: 'bpm', name: '流程详情' }
  339. ],
  340. // 当前选项
  341. activeComp: 'main',
  342. showSelectUser: false,
  343. // 0 生产验收人 1 质检验收人
  344. selectUserType: 0,
  345. processSubmitDialogFlag: false
  346. };
  347. },
  348. watch: {
  349. 'form.details': {
  350. handler(details) {
  351. console.log('details', details);
  352. // 区分生产放行规则 质检放行规则
  353. // 根据 审核结果修改 结论
  354. const scDetails = details.filter((item) => item.checkType == 1);
  355. const zjDetails = details.filter((item) => item.checkType == 2);
  356. // 当workConclution全为1 则为1 否则为0
  357. if (scDetails.length > 0) {
  358. const allPass = scDetails
  359. .map((item) => item.isPass)
  360. .every((val) => val === 1);
  361. this.form.workConclution = allPass ? 1 : 0;
  362. } else {
  363. this.form.workConclution = null;
  364. }
  365. if (zjDetails.length > 0) {
  366. const allPass = zjDetails
  367. .map((item) => item.isPass)
  368. .every((val) => val == 1);
  369. this.form.qualityConclution = allPass ? 1 : 0;
  370. } else {
  371. this.form.qualityConclution = null;
  372. }
  373. },
  374. deep: true
  375. },
  376. processSubmitDialogFlag(val) {
  377. if (!val) {
  378. // 关闭后 刷新详情
  379. if (this.form.id) {
  380. this.$emit('reload');
  381. this.$nextTick(() => {
  382. this.handleClose();
  383. });
  384. }
  385. }
  386. }
  387. },
  388. computed: {
  389. ordersColumns() {
  390. return [
  391. {
  392. width: 55,
  393. type: 'index',
  394. columnKey: 'index',
  395. label: '序号',
  396. align: 'center'
  397. },
  398. {
  399. prop: 'batchNo',
  400. label: '批次号',
  401. align: 'center',
  402. minWidth: 110,
  403. showOverflowTooltip: true
  404. },
  405. {
  406. prop: 'productCode',
  407. label: '产品编码',
  408. align: 'center',
  409. minWidth: 110,
  410. showOverflowTooltip: true
  411. },
  412. {
  413. prop: 'productName',
  414. label: '产品名称',
  415. align: 'center',
  416. minWidth: 110,
  417. showOverflowTooltip: true
  418. },
  419. {
  420. prop: 'workOrderCode',
  421. label: '生产工单号',
  422. align: 'center',
  423. minWidth: 110,
  424. showOverflowTooltip: true
  425. },
  426. {
  427. prop: 'formingNum',
  428. label: '要求生产数量',
  429. align: 'center',
  430. minWidth: 110,
  431. showOverflowTooltip: true
  432. },
  433. {
  434. prop: 'formedNum',
  435. label: '实际生产数量',
  436. align: 'center',
  437. minWidth: 110,
  438. showOverflowTooltip: true
  439. },
  440. {
  441. prop: 'specification',
  442. label: '规格',
  443. align: 'center',
  444. minWidth: 110,
  445. showOverflowTooltip: true
  446. },
  447. {
  448. prop: 'productModel',
  449. label: '型号',
  450. align: 'center',
  451. minWidth: 110,
  452. showOverflowTooltip: true
  453. },
  454. {
  455. label: '操作',
  456. columnKey: 'action',
  457. slot: 'action',
  458. minWidth: 120
  459. }
  460. ];
  461. },
  462. // 生产放行规则
  463. scDetails() {
  464. return this.form.details.filter((item) => item.checkType == 1);
  465. },
  466. // 质检放行规则
  467. zjDetails() {
  468. return this.form.details.filter((item) => item.checkType == 2);
  469. },
  470. detailsColumns() {
  471. return [
  472. {
  473. width: 55,
  474. type: 'index',
  475. columnKey: 'index',
  476. label: '序号',
  477. align: 'center'
  478. },
  479. {
  480. prop: 'mainIndicatorName',
  481. label: '指标名称',
  482. align: 'center',
  483. minWidth: 110,
  484. showOverflowTooltip: true
  485. },
  486. {
  487. prop: 'isPass',
  488. label: '审核结果',
  489. align: 'center',
  490. slot: 'isPass',
  491. minWidth: 110,
  492. showOverflowTooltip: true
  493. },
  494. {
  495. prop: 'remark',
  496. label: '备注',
  497. align: 'center',
  498. slot: 'remark',
  499. minWidth: 110,
  500. showOverflowTooltip: true
  501. }
  502. ];
  503. }
  504. },
  505. methods: {
  506. // 外部调用,打开弹窗
  507. open(type, data) {
  508. console.log('data , type', data, type);
  509. this.type = type;
  510. if (type == 'add') {
  511. this.title = '放行申请单';
  512. // 生产放心单名称 = 模版名称+年月日+3位数
  513. this.form.name = `${data.templateName}${new Date()
  514. .toLocaleDateString()
  515. .replace(/\//g, '')}${String(
  516. Math.floor(Math.random() * 1000)
  517. ).padStart(3, '0')}`;
  518. this.form.templateId = data.templateId;
  519. this.form.templateName = data.templateName;
  520. this.form.checklistType = data.checklistType;
  521. // 处理携带的生产工单
  522. if (data.workOrderList && data.workOrderList.length) {
  523. this.selectWorkOrderConfirm(data.workOrderList);
  524. }
  525. // 根据模版id 查询模版详情
  526. this.getTemplateDetails(data.templateId);
  527. } else if (type == 'edit') {
  528. this.title = '放行申请单';
  529. this.getCheckDetails(data.id);
  530. } else if (type == 'detail') {
  531. this.title = '放行单详情';
  532. this.getCheckDetails(data.id);
  533. } else {
  534. this.title = '审批';
  535. }
  536. this.visible = true;
  537. },
  538. // 关闭时清理表单
  539. handleClose() {
  540. this.form = JSON.parse(JSON.stringify(this.formBaseData));
  541. this.activeComp = 'main';
  542. this.$nextTick(() => {
  543. // 关闭流程里 visible 可能已变为 false(v-if 卸载整块内容),或当前在 BPM 页签时表单未挂载
  544. this.$refs.formRef?.clearValidate();
  545. this.visible = false;
  546. });
  547. },
  548. // 提交
  549. // submit(type) {
  550. // console.log('this.form', this.form);
  551. // this.$refs.formRef.validate(async (valid, invalidFields) => {
  552. // if (valid) {
  553. // // 必须要有物品清单
  554. // if (this.form.orders.length == 0) {
  555. // this.$message.warning('请添加物品清单');
  556. // return;
  557. // }
  558. // this.butLoading = true;
  559. // try {
  560. // if (type == 'save') {
  561. // // 存在id 则更新
  562. // if (this.form.id) {
  563. // await checklistrecordUpdate(this.form);
  564. // this.$message.success('操作成功,已保存到放行单列表');
  565. // } else {
  566. // this.form.createUserName = this.$store.state.user.info.name;
  567. // const data = await checklistrecordSave(this.form);
  568. // this.$message.success('操作成功,已保存到放行单列表');
  569. // this.form.id = data;
  570. // this.getCheckDetails(this.form.id);
  571. // }
  572. // } else {
  573. // // submit 保存并提交审核
  574. // // 存在id 则更新
  575. // if (this.form.id) {
  576. // await checklistrecordUpdate(this.form);
  577. // } else {
  578. // this.form.createUserName = this.$store.state.user.info.name;
  579. // const data = await checklistrecordSave(this.form);
  580. // this.form.id = data;
  581. // await this.getCheckDetails(this.form.id);
  582. // }
  583. // this.openApproval();
  584. // }
  585. // this.butLoading = false;
  586. // this.$emit('reload');
  587. // } catch (error) {
  588. // this.butLoading = false;
  589. // }
  590. // } else {
  591. // // 转换为数组
  592. // const firstErrorField = Object.values(invalidFields);
  593. // if (firstErrorField.length > 0) {
  594. // this.$message.warning(firstErrorField[0][0].message);
  595. // }
  596. // return false;
  597. // }
  598. // });
  599. // },
  600. submit(type) {
  601. this.$refs.formRef.validate(async (valid, invalidFields) => {
  602. if (valid) {
  603. // 必须要有物品清单
  604. if (this.form.orders.length == 0) {
  605. this.$message.warning('请添加物品清单');
  606. return;
  607. }
  608. this.butLoading = true;
  609. const text = type == 'save' ? '保存中...' : '提交中...';
  610. const loading = this.$loading({
  611. lock: true,
  612. text,
  613. spinner: 'el-icon-loading',
  614. background: 'rgba(0, 0, 0, 0.7)'
  615. });
  616. try {
  617. if (type == 'save') {
  618. // 存在id 则更新
  619. if (this.form.id) {
  620. await checklistrecordUpdate(this.form);
  621. this.$message.success('操作成功,已保存到放行单列表');
  622. } else {
  623. this.form.createUserName = this.$store.state.user.info.name;
  624. const data = await checklistrecordSave(this.form);
  625. this.$message.success('操作成功,已保存到放行单列表');
  626. this.form.id = data;
  627. this.getCheckDetails(this.form.id);
  628. }
  629. } else {
  630. if (this.form.id) {
  631. await checklistrecordUpdate(this.form);
  632. } else {
  633. this.form.createUserName = this.$store.state.user.info.name;
  634. const data = await checklistrecordSave(this.form);
  635. this.form.id = data;
  636. await this.getCheckDetails(this.form.id);
  637. }
  638. this.openApproval();
  639. }
  640. // this.visible = false;
  641. this.$emit('reload');
  642. } catch (error) {
  643. console.error(error);
  644. } finally {
  645. this.butLoading = false;
  646. loading.close();
  647. }
  648. } else {
  649. // 转换为数组
  650. const firstErrorField = Object.values(invalidFields);
  651. if (firstErrorField.length > 0) {
  652. this.$message.warning(firstErrorField[0][0].message);
  653. }
  654. return false;
  655. }
  656. });
  657. },
  658. // 选择生产工单
  659. openAddModel() {
  660. this.$refs.selectWorkOrderRef?.open();
  661. },
  662. // 选择生产工单确认
  663. selectWorkOrderConfirm(selection) {
  664. const selectList = selection.map((i) => {
  665. return {
  666. formedNum: i.formedNum,
  667. batchNo: i.batchNo,
  668. createUserName: i.createUserName,
  669. formingNum: i.formingNum,
  670. produceRoutingId: i.produceRoutingId,
  671. produceRoutingName: i.produceRoutingName,
  672. productCode: i.productCode,
  673. productModel: i.productModel,
  674. productName: i.productName,
  675. recordId: i.recordId,
  676. specification: i.specification,
  677. workOrderCode: i.code,
  678. workOrderId: i.id
  679. };
  680. });
  681. console.log('selectList', selectList);
  682. // 判断是否同一产品 同一批次
  683. if (selectList.length != 0) {
  684. const productCode = selectList[0].productCode;
  685. const batchNo = selectList[0].batchNo;
  686. const isSame = selectList.every(
  687. (item) =>
  688. item.productCode === productCode && item.batchNo === batchNo
  689. );
  690. const isSameOrders = this.form.orders.every(
  691. (item) =>
  692. item.productCode === productCode && item.batchNo === batchNo
  693. );
  694. if (!isSame || !isSameOrders) {
  695. this.$message.warning('请选择同产品同批次号工单发起批量放行');
  696. return;
  697. }
  698. // 去重
  699. const existingWorkOrderIds = this.form.orders.map(
  700. (order) => order.workOrderId
  701. );
  702. const newOrders = selectList.filter(
  703. (item) => !existingWorkOrderIds.includes(item.workOrderId)
  704. );
  705. this.form.orders = [...this.form.orders, ...newOrders];
  706. }
  707. // 关闭弹窗
  708. this.$refs.selectWorkOrderRef?.handleClose();
  709. },
  710. // 删除行
  711. deleteRow(row) {
  712. this.form.orders = this.form.orders.filter(
  713. (item) => item.workOrderId !== row.workOrderId
  714. );
  715. },
  716. // 获取模板详情
  717. async getTemplateDetails(id) {
  718. this.loading = true;
  719. try {
  720. const data = await checklisttemplateGetById(id);
  721. console.log('模板详情', data);
  722. // 详情
  723. this.form.details = data.details;
  724. this.loading = false;
  725. this.setDefaultValue();
  726. } catch (error) {
  727. this.loading = false;
  728. }
  729. },
  730. // 获取放行单详情
  731. async getCheckDetails(id) {
  732. this.loading = true;
  733. try {
  734. const data = await checklistrecordGetById(id);
  735. this.$util.assignObject(this.form, data);
  736. console.log('this.form', this.form);
  737. if (this.type == 'edit' || this.type == 'add') {
  738. this.setDefaultValue();
  739. }
  740. this.loading = false;
  741. } catch (error) {
  742. this.loading = false;
  743. }
  744. },
  745. // 设置默认值
  746. setDefaultValue() {
  747. // 编辑时 设置默认值
  748. if (!this.form.qualityCheckUserId) {
  749. // 设置为当前用户
  750. this.form.qualityCheckUserId = this.$store.state.user.info.id;
  751. this.form.qualityCheckUserName = this.$store.state.user.info.name;
  752. }
  753. if (!this.form.workCheckUserId) {
  754. // 设置为当前用户
  755. this.form.workCheckUserId = this.$store.state.user.info.id;
  756. this.form.workCheckUserName = this.$store.state.user.info.name;
  757. }
  758. if (!this.form.qualityCheckTime) {
  759. this.form.qualityCheckTime = this.$util.toDateString(
  760. new Date(),
  761. 'yyyy-MM-dd HH:mm:ss'
  762. );
  763. }
  764. if (!this.form.workCheckTime) {
  765. this.form.workCheckTime = this.$util.toDateString(
  766. new Date(),
  767. 'yyyy-MM-dd HH:mm:ss'
  768. );
  769. }
  770. },
  771. // 规则齐套检查
  772. async getKitCheck() {
  773. // 判断 是否有需要自动检查的项
  774. const hasAutoCheck = this.form.details.some((item) => item.isAutoCheck);
  775. if (!hasAutoCheck) {
  776. console.log('this.form.details', this.form.details);
  777. this.$message.warning('当前没有需要自动检查的规则');
  778. return;
  779. }
  780. // 必须要有物品清单
  781. if (this.form.orders.length == 0) {
  782. this.$message.warning('请添加物品清单');
  783. return;
  784. }
  785. if (!this.form.id) {
  786. this.$message.warning('请先保存放行单');
  787. return;
  788. }
  789. try {
  790. this.butLoading = true;
  791. const data = await checklistrecordKitCheck(this.form.id);
  792. console.log('规则齐套检查', data);
  793. // 把检查结果赋值给对应的明细
  794. this.form.details = this.form.details.map((item) => {
  795. const checkItem = data.find((d) => d.id === item.id);
  796. console.log('checkItem 存在', checkItem);
  797. if (checkItem && item.isAutoCheck) {
  798. return {
  799. ...item,
  800. isPass: checkItem.isPass
  801. };
  802. }
  803. return item;
  804. });
  805. console.log('规则齐套检查', this.form.details);
  806. this.butLoading = false;
  807. this.$message.success('规则齐套检查完成!');
  808. } catch (error) {
  809. this.butLoading = false;
  810. }
  811. },
  812. // 打开选择用户
  813. openSelectUser(type) {
  814. this.selectUserType = type;
  815. this.showSelectUser = true;
  816. },
  817. selectUserFinished(userInfo) {
  818. console.log('userInfo', userInfo);
  819. console.log('this.selectUserType', this.selectUserType);
  820. if (this.selectUserType == 0) {
  821. this.form.workCheckUserId = userInfo.id;
  822. this.form.workCheckUserName = userInfo.name;
  823. } else {
  824. this.form.qualityCheckUserId = userInfo.id;
  825. this.form.qualityCheckUserName = userInfo.name;
  826. }
  827. },
  828. async openWorkOrderDetail(row) {
  829. console.log('row', row);
  830. const info = await getworkOrderById(row.workOrderId);
  831. this.$refs.detailsRef.open(info);
  832. },
  833. // 提交审批
  834. openApproval() {
  835. const row = this.form;
  836. console.log('row', row);
  837. let businessType = this.getDictValue(
  838. '放行类型',
  839. row.checklistType + ''
  840. );
  841. console.log('businessType', businessType);
  842. this.processSubmitDialogFlag = true;
  843. this.$nextTick(async () => {
  844. let params = {
  845. businessId: row.id,
  846. businessKey: 'work_order_checklist_approval',
  847. formCreateUserId: row.createUserId,
  848. variables: {
  849. businessCode: row.code,
  850. businessName: '放行单',
  851. businessType: businessType
  852. }
  853. };
  854. if (this.clientEnvironmentId == 5) {
  855. // 嘉实环境
  856. const data = await getCategoryByCode(row.orders[0]?.productCode);
  857. // 判断品类
  858. if (data && data.categoryLevelCodePath?.includes('W3-209')) {
  859. // 药品
  860. params.businessKey = 'work_order_checklist_approval1';
  861. } else {
  862. // 器械
  863. params.businessKey = 'work_order_checklist_approval';
  864. }
  865. }
  866. console.log('params', params);
  867. this.$refs.processSubmitDialogRef.init(params);
  868. });
  869. }
  870. }
  871. };
  872. </script>
  873. <style scoped lang="scss">
  874. .detail-table {
  875. border: 1px solid #ebeef5;
  876. // 实线边框
  877. border-collapse: collapse;
  878. td {
  879. border: none;
  880. padding: 10px 15px;
  881. border: 1px solid #ebeef5;
  882. &:first-child {
  883. font-weight: 600;
  884. background: #f5f7fa;
  885. width: 130px;
  886. text-align: center;
  887. }
  888. }
  889. }
  890. .mask-box {
  891. position: relative;
  892. &::after {
  893. content: '';
  894. width: 100%;
  895. height: 100%;
  896. position: absolute;
  897. top: 0;
  898. left: 0;
  899. background: rgba(0, 0, 0, 0);
  900. cursor: pointer;
  901. }
  902. }
  903. </style>