index.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <seek-page
  5. :seekList="seekList"
  6. @search="search"
  7. ref="search"
  8. :keyValue="'qms-inspectionWork-index-search'"
  9. ></seek-page>
  10. <ele-pro-table
  11. ref="table"
  12. :columns="columns"
  13. :datasource="datasource"
  14. :pageSize="20"
  15. :pageSizes="[20, 30, 40, 50, 100]"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. row-key="id"
  19. @selection-change="selectionChangeHandle"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar>
  23. <el-button
  24. v-if="$hasPermission('qms:quality_work_order:close')"
  25. size="small"
  26. type="primary"
  27. class="ele-btn-icon"
  28. @click="batchClose"
  29. :disabled="selection.length === 0"
  30. >
  31. 批量关闭
  32. </el-button>
  33. </template>
  34. <template v-slot:code="{ row }">
  35. <el-link
  36. type="primary"
  37. :underline="false"
  38. @click="openDetails(row)"
  39. >{{ row.code }}</el-link
  40. >
  41. </template>
  42. <template v-slot:sourceCode="{ row }">
  43. <div>
  44. <el-link
  45. type="primary"
  46. :underline="false"
  47. @click="openWorkDetails(row)"
  48. >
  49. {{
  50. row.qualityPlanCode ? row.qualityPlanCode : row.workOrderCode
  51. }}</el-link
  52. >
  53. </div>
  54. </template>
  55. <template v-slot:files="scope">
  56. <el-link
  57. v-for="link in scope.row.files"
  58. :key="link.id"
  59. type="primary"
  60. :underline="false"
  61. @click="downloadFile(link)"
  62. >{{ link.name }}</el-link
  63. >
  64. </template>
  65. <template v-slot:qualityType="{ row }">{{
  66. getDictValue('质检计划类型', row.qualityType)
  67. }}</template>
  68. <template v-slot:qualityMode="{ row }">{{
  69. getDictValue('取样类型', row.qualityMode)
  70. }}</template>
  71. <template v-slot:accessory="scope">
  72. <el-link
  73. v-for="link in scope.row.accessory"
  74. :key="link.id"
  75. type="primary"
  76. :underline="false"
  77. @click="downloadFile(link)"
  78. >{{ link.name }}</el-link
  79. >
  80. </template>
  81. <!-- 操作列 -->
  82. <template v-slot:action="{ row }">
  83. <el-link
  84. type="primary"
  85. :underline="false"
  86. @click="addSampleOpen(row)"
  87. v-if="
  88. $hasPermission('qms:samplingrecord:save') &&
  89. ![1, 2].includes(row.status) &&
  90. row.sampleQuantity < row.total &&
  91. row.isPendingSample != 1
  92. "
  93. >请样</el-link
  94. >
  95. <el-link
  96. type="primary"
  97. :underline="false"
  98. @click="sampleCollection(row)"
  99. v-if="![1, 2].includes(row.status) && row.isPendingSample == 1"
  100. >收样</el-link
  101. >
  102. <el-link
  103. type="primary"
  104. :underline="false"
  105. v-if="
  106. row.status == 0 &&
  107. $hasPermission('qms:quality_work_order:update') &&
  108. row.isPendingSample != 1
  109. "
  110. @click="openEdit('edit', row)"
  111. >报工</el-link
  112. >
  113. <el-link
  114. type="primary"
  115. :underline="false"
  116. v-if="
  117. row.status == 0 &&
  118. $hasPermission('qms:quality_work_order:transfer')
  119. "
  120. @click="openTransfer(row.id)"
  121. >转派</el-link
  122. >
  123. <el-link
  124. type="primary"
  125. :underline="false"
  126. v-if="
  127. row.status == 0 &&
  128. row.isPendingSample != 1 &&
  129. $hasPermission('qms:quality_work_order:qualityInspectionSend')
  130. "
  131. @click="qualityInspectionSend(row, 1)"
  132. >质检派单</el-link
  133. >
  134. <el-link
  135. type="primary"
  136. :underline="false"
  137. v-if="
  138. row.status == 0 &&
  139. row.isPendingSample != 1 &&
  140. $hasPermission('qms:quality_work_order:request')
  141. "
  142. @click="qualityInspectionSend(row, 2)"
  143. >质检请托</el-link
  144. >
  145. <el-link
  146. v-if="$hasPermission('qms:quality_work_order:certificate')"
  147. type="primary"
  148. :underline="false"
  149. @click="openNumber(row)"
  150. >合格证</el-link
  151. >
  152. <jimureportBrowse
  153. style="display: inline-block; margin-left: 5px"
  154. v-if="
  155. row.status == 1 &&
  156. $hasPermission('qms:quality_work_order:qualityReport')
  157. "
  158. text="质检报告"
  159. :businessId="row.id"
  160. businessCode="qmsqualityinspectionprint"
  161. ></jimureportBrowse>
  162. <el-dropdown
  163. trigger="click"
  164. v-if="
  165. row.status == 1 &&
  166. isReportApproval == 1 &&
  167. (!row.reportApprovalStatus || row.reportApprovalStatus == 0) &&
  168. isEmptyObject(row.reportTemplateJson) &&
  169. $hasPermission('qms:quality_work_order:generateReport')
  170. "
  171. >
  172. <el-link type="primary" :underline="false">生成质检报告</el-link>
  173. <el-dropdown-menu slot="dropdown">
  174. <el-dropdown-item
  175. v-for="item in reportTemplateList"
  176. :key="item.id"
  177. @click.native="generateReportApproval(row, item)"
  178. >{{ item.name
  179. }}{{
  180. '(' +
  181. item.versionSymbol +
  182. item.bigVersion +
  183. item.versionMark +
  184. item.smallVersion +
  185. ')'
  186. }}</el-dropdown-item
  187. >
  188. </el-dropdown-menu>
  189. </el-dropdown>
  190. <el-link
  191. v-if="
  192. row.status == 1 &&
  193. isReportApproval == 1 &&
  194. row.reportApprovalStatus &&
  195. !isEmptyObject(row.reportTemplateJson) &&
  196. $hasPermission('qms:quality_work_order:generateReport')
  197. "
  198. type="primary"
  199. :underline="false"
  200. @click="openReport(row)"
  201. >查看质检报告</el-link
  202. >
  203. <!-- 质检报告审批 -->
  204. <el-link
  205. v-if="
  206. row.status == 1 &&
  207. isReportApproval == 1 &&
  208. !row.reportApprovalStatus &&
  209. $hasPermission('qms:quality_work_order:qualityReportApproval')
  210. "
  211. type="primary"
  212. :underline="false"
  213. @click="reportApprovalSubmit(row)"
  214. >质检报告审批</el-link
  215. >
  216. <el-popconfirm
  217. class="ele-action"
  218. title="确定要关闭吗?"
  219. @confirm="close(row)"
  220. v-if="
  221. row.status == 0 &&
  222. row.qualityType == 2 &&
  223. $hasPermission('qms:quality_work_order:close')
  224. "
  225. >
  226. <template v-slot:reference>
  227. <el-link type="warning" :underline="false"> 关闭 </el-link>
  228. </template>
  229. </el-popconfirm>
  230. </template>
  231. <template v-slot:templateList="{ row }">
  232. <div style="width: 250px; max-height: 60px; overflow: auto">
  233. <el-tag
  234. v-for="(item, index) in row.templateList"
  235. :key="item.inspectionName + index"
  236. :type="
  237. inspectionProjectStatus.find(
  238. (ProjectStatus) => ProjectStatus.value == item.status
  239. )?.type
  240. "
  241. effect="dark"
  242. style="margin-top: 4px"
  243. >
  244. <span
  245. :title="
  246. inspectionProjectStatus.find(
  247. (ProjectStatus) => ProjectStatus.value == item.status
  248. )?.label
  249. "
  250. >
  251. {{ item.inspectionName }}
  252. </span>
  253. </el-tag>
  254. </div>
  255. </template>
  256. </ele-pro-table>
  257. </el-card>
  258. <Certificate
  259. @search="search"
  260. v-if="addOpen"
  261. :rowData="rowData"
  262. :addOpen="addOpen"
  263. @closeModel="closeModel"
  264. />
  265. <Transfer
  266. v-if="transferVisible"
  267. :transferVisible.sync="transferVisible"
  268. @success="transferConfirm"
  269. :id="transferId"
  270. ></Transfer>
  271. <process-submit-dialog
  272. api-fun-name="qmsReportApprovalAPI"
  273. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  274. :isCloseRefresh="false"
  275. v-if="processSubmitDialogFlag"
  276. ref="processSubmitDialogRef"
  277. @reload="search"
  278. ></process-submit-dialog>
  279. <addSample ref="addSampleRef" @reload="search"></addSample>
  280. <inspectionProjectTaskSend
  281. ref="inspectionProjectTaskSendRef"
  282. @reload="search"
  283. ></inspectionProjectTaskSend>
  284. <component
  285. :is="targetComponent"
  286. ref="targetComponentRef"
  287. v-if="targetComponent"
  288. :key="targetComponent"
  289. :isView="isView"
  290. :visible.sync="targetVisible"
  291. :row="currentRow"
  292. :item="currentItem"
  293. @reload="search"
  294. :type="'0'"
  295. ></component>
  296. <mesWorkOrder ref="mesWorkOrderRef"></mesWorkOrder>
  297. </div>
  298. </template>
  299. <script>
  300. import Certificate from './components/Certificate.vue';
  301. import search from './components/search.vue';
  302. import addSample from '@/views/sample/sampleRecord/components/addSample.vue';
  303. import jimureportBrowse from '@/components/jimureport/browseModal.vue';
  304. import Transfer from './components/transfer.vue';
  305. import mesWorkOrder from './components/mesWorkOrder.vue';
  306. import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
  307. import inspectionProjectTaskSend from '@/views/inspectionProjectTask/components/inspectionProjectTaskSend.vue';
  308. import {
  309. getList,
  310. removeItem,
  311. getDetailById,
  312. closeWorkList,
  313. verificationQualityInspector,
  314. closeWork,
  315. sampleCollection,
  316. checkByQualityWorkOrderId
  317. } from '@/api/inspectionWork';
  318. // import { getWorkorderById } from '@/api/inspectionWork';
  319. import { queryTodo } from '@/api/bpm/task';
  320. import dictMixins from '@/mixins/dictMixins';
  321. import { getFile } from '@/api/system/file';
  322. import { getByCode } from '@/api/system/dictionary-data';
  323. import { parameterGetByCode } from '@/api/main/index';
  324. import tabMixins from '@/mixins/tableColumnsMixin';
  325. import { getCategoryByCode } from '@/api/main/index';
  326. import { getQmsReportTemplatePageList } from '@/api/inspectionWork';
  327. import inspection_report1 from '../inspectionReport/template/inspection_report1.vue';
  328. import inspection_report2 from '../inspectionReport/template/inspection_report2.vue';
  329. import { inspectionProjectStatus } from '@/enum/dict.js';
  330. import { recordingMethodList } from '@/utils/util.js';
  331. export default {
  332. mixins: [dictMixins, tabMixins],
  333. components: {
  334. search,
  335. jimureportBrowse,
  336. Certificate,
  337. Transfer,
  338. processSubmitDialog,
  339. addSample,
  340. inspectionProjectTaskSend,
  341. inspection_report1,
  342. inspection_report2,
  343. mesWorkOrder
  344. },
  345. data() {
  346. return {
  347. inspectionProjectStatus,
  348. cacheKeyUrl: 'qsm-c2e9664a-inspectionWork',
  349. targetComponent: null,
  350. isView: false,
  351. targetVisible: false,
  352. currentRow: {},
  353. currentItem: {},
  354. columns: [
  355. // 新增多选列
  356. {
  357. width: 45,
  358. type: 'selection',
  359. columnKey: 'selection',
  360. align: 'center',
  361. reserveSelection: true
  362. },
  363. {
  364. type: 'index',
  365. columnKey: 'index',
  366. align: 'center',
  367. label: '序号',
  368. width: 55,
  369. showOverflowTooltip: true,
  370. fixed: 'left'
  371. },
  372. {
  373. prop: 'code',
  374. label: '质检工单编码',
  375. slot: 'code',
  376. align: 'center',
  377. width: 180,
  378. showOverflowTooltip: true,
  379. fixed: 'left'
  380. },
  381. {
  382. prop: 'name',
  383. slot: 'name',
  384. width: 120,
  385. label: '质检工单名称',
  386. align: 'center',
  387. showOverflowTooltip: true
  388. },
  389. {
  390. label: '来源单号',
  391. prop: 'sourceCode',
  392. slot: 'sourceCode',
  393. align: 'center',
  394. width: 160,
  395. showOverflowTooltip: true
  396. },
  397. {
  398. label: '类型',
  399. prop: 'qualityType',
  400. slot: 'qualityType',
  401. align: 'center',
  402. width: 120,
  403. showOverflowTooltip: true
  404. },
  405. {
  406. label: '质检方式',
  407. prop: 'qualityMode',
  408. slot: 'qualityMode',
  409. align: 'center',
  410. width: 120,
  411. showOverflowTooltip: true
  412. },
  413. {
  414. prop: 'qualityName',
  415. label: '接收人',
  416. align: 'center',
  417. width: 120,
  418. showOverflowTooltip: true,
  419. formatter: (row) => {
  420. if (row.qualityName) {
  421. return row.qualityName;
  422. }
  423. return row.qualityNames || '';
  424. }
  425. },
  426. {
  427. prop: 'executeUserName',
  428. label: '执行人',
  429. align: 'center',
  430. width: 120,
  431. showOverflowTooltip: true,
  432. formatter: (row) => {
  433. return row.executeUserName || '';
  434. }
  435. },
  436. {
  437. prop: 'qualityTime',
  438. label: '质检时间',
  439. align: 'center',
  440. width: 120,
  441. showOverflowTooltip: true
  442. },
  443. {
  444. prop: 'productCode',
  445. width: 120,
  446. label: '编码',
  447. align: 'center',
  448. showOverflowTooltip: true
  449. },
  450. {
  451. prop: 'productName',
  452. width: 120,
  453. label: '名称',
  454. align: 'center',
  455. showOverflowTooltip: true
  456. },
  457. {
  458. prop: 'batchNo',
  459. label: '批次号',
  460. align: 'center',
  461. width: 120,
  462. showOverflowTooltip: true
  463. },
  464. {
  465. prop: 'inspectionTeamName',
  466. label: '送检班组',
  467. align: 'center',
  468. width: 120,
  469. showOverflowTooltip: true
  470. },
  471. {
  472. prop: 'createUserName',
  473. label: '送检人',
  474. align: 'center',
  475. width: 120,
  476. showOverflowTooltip: true
  477. },
  478. {
  479. prop: 'specification',
  480. label: '规格',
  481. align: 'center',
  482. showOverflowTooltip: true
  483. },
  484. {
  485. prop: 'brandNo',
  486. label: '牌号',
  487. align: 'center',
  488. showOverflowTooltip: true
  489. },
  490. {
  491. prop: 'colorKey',
  492. label: '颜色',
  493. align: 'center',
  494. showOverflowTooltip: true
  495. },
  496. {
  497. prop: 'produceTaskName',
  498. label: '工序',
  499. align: 'center',
  500. width: 120,
  501. showOverflowTooltip: true
  502. },
  503. {
  504. prop: 'total',
  505. label: '总数量',
  506. align: 'center',
  507. showOverflowTooltip: true
  508. },
  509. {
  510. prop: 'qualifiedNumber',
  511. label: '合格数',
  512. align: 'center',
  513. showOverflowTooltip: true
  514. },
  515. {
  516. prop: 'qualificationRate',
  517. label: '合格率',
  518. align: 'center',
  519. showOverflowTooltip: true
  520. },
  521. {
  522. prop: 'noQualifiedNumber',
  523. label: '不合格数',
  524. align: 'center',
  525. showOverflowTooltip: true
  526. },
  527. {
  528. prop: 'noQualificationRate',
  529. label: '不合格率',
  530. align: 'center',
  531. showOverflowTooltip: true
  532. },
  533. {
  534. prop: 'hours',
  535. label: '工时',
  536. align: 'center',
  537. showOverflowTooltip: true
  538. },
  539. {
  540. label: '附件',
  541. prop: 'accessory',
  542. align: 'center',
  543. slot: 'accessory',
  544. showOverflowTooltip: true
  545. },
  546. {
  547. label: '创建时间',
  548. prop: 'createTime',
  549. align: 'center',
  550. width: 160
  551. },
  552. {
  553. prop: 'recordingMethod',
  554. label: '记录方法',
  555. align: 'center',
  556. formatter: (row) => {
  557. return (
  558. recordingMethodList.find(
  559. (item) => item.value == row.recordingMethod
  560. )?.label || ''
  561. );
  562. },
  563. width: 130,
  564. showOverflowTooltip: true
  565. },
  566. {
  567. label: '进度',
  568. prop: 'templateList',
  569. slot: 'templateList',
  570. align: 'center',
  571. width: 250
  572. },
  573. {
  574. prop: 'status',
  575. label: '状态',
  576. align: 'center',
  577. width: 80,
  578. formatter: (row, column, cellValue) => {
  579. // 状态(0未报工;1已报工;2已关闭;3待取样)
  580. switch (cellValue) {
  581. case 0:
  582. return '未报工';
  583. case 1:
  584. return '已报工';
  585. case 2:
  586. return '已关闭';
  587. case 3:
  588. return '待请样';
  589. default:
  590. return '';
  591. }
  592. },
  593. fixed: 'right'
  594. },
  595. {
  596. columnKey: 'action',
  597. label: '操作',
  598. align: 'center',
  599. width: 200,
  600. resizable: false,
  601. slot: 'action',
  602. fixed: 'right'
  603. }
  604. ],
  605. formData: {
  606. certificateNumber: ''
  607. },
  608. processSubmitDialogFlag: false,
  609. rowData: {},
  610. // typeList: [], //类型列表
  611. // qualityMode: [], //取样类型
  612. // 状态(0未报工;1已报工;2已关闭;3待取样)
  613. statusList: [
  614. {
  615. value: 0,
  616. label: '未报工'
  617. },
  618. {
  619. value: 1,
  620. label: '已报工'
  621. }
  622. // ,
  623. // {
  624. // value: 2,
  625. // label: '已关闭'
  626. // },
  627. // {
  628. // value: 3,
  629. // label: '待取样'
  630. // }
  631. ],
  632. addOpen: false,
  633. transferVisible: false,
  634. transferId: '',
  635. isReportApproval: 0,
  636. selection: [], // 存储选中的行数据
  637. reportTemplateList: [], // 报表模板列表
  638. templateArr: ['inspection_report1', 'ABBCCC']
  639. };
  640. },
  641. created() {
  642. this.requestDict('质检计划类型');
  643. this.requestDict('不良品处理类型');
  644. this.requestDict('取样类型');
  645. this.getCode();
  646. this.getReportTemplateList();
  647. // this.getTnspectionPlanType();
  648. // this.getQualityMethodCode();
  649. },
  650. computed: {
  651. seekList() {
  652. return [
  653. {
  654. label: '工单编码:',
  655. value: 'code',
  656. type: 'input',
  657. placeholder: ''
  658. },
  659. {
  660. label: '工单名称:',
  661. value: 'name',
  662. type: 'input',
  663. placeholder: ''
  664. },
  665. {
  666. label: '来源单号:',
  667. value: 'sourceCode',
  668. type: 'input',
  669. placeholder: ''
  670. },
  671. {
  672. label: '类型:',
  673. value: 'qualityType',
  674. type: 'DictSelection',
  675. dictName: '质检计划类型',
  676. placeholder: ''
  677. },
  678. {
  679. label: '质检方式:',
  680. value: 'qualityMode',
  681. type: 'DictSelection',
  682. dictName: '取样类型',
  683. placeholder: ''
  684. },
  685. {
  686. label: '编码:',
  687. value: 'productCode',
  688. type: 'input',
  689. placeholder: ''
  690. },
  691. {
  692. label: '名称:',
  693. value: 'productName',
  694. type: 'input',
  695. placeholder: ''
  696. },
  697. {
  698. label: '质检人:',
  699. value: 'qualityName',
  700. type: 'input',
  701. placeholder: ''
  702. },
  703. {
  704. label: '状态:',
  705. value: 'status',
  706. type: 'select',
  707. placeholder: '',
  708. planList: this.statusList
  709. },
  710. {
  711. label: '记录方法:',
  712. value: 'recordingMethod',
  713. type: 'select',
  714. placeholder: '',
  715. planList: recordingMethodList
  716. }
  717. ];
  718. },
  719. clientEnvironmentId() {
  720. return this.$store.state.user.info.clientEnvironmentId;
  721. }
  722. },
  723. methods: {
  724. getReportTemplateList() {
  725. getQmsReportTemplatePageList({
  726. pageNum: 1,
  727. pageSize: 999,
  728. isEnabled: 1
  729. })
  730. .then((res) => {
  731. this.reportTemplateList = res.list;
  732. console.log('reportTemplateList', this.reportTemplateList);
  733. })
  734. .catch((err) => {
  735. console.error('获取报表模板列表失败:', err);
  736. // this.$message.error('获取报表模板列表失败:' + (err.message || '操作异常'));
  737. });
  738. },
  739. generateReportApproval(row, item) {
  740. console.log('item~~~', item);
  741. console.log('generateReportApproval', row, item);
  742. this.targetComponent = item.code;
  743. this.isView = false;
  744. this.currentRow = row;
  745. this.currentItem = item;
  746. // this.$refs.targetComponentRef.open(item, row);
  747. this.$nextTick(() => {
  748. // this.$refs.targetComponentRef.open(row, isView);
  749. this.targetVisible = true;
  750. console.log('targetVisible~~~~', this.targetVisible);
  751. });
  752. },
  753. async openReport(row) {
  754. // console.log('openReport', row);
  755. const data = await getDetailById(row.id);
  756. console.log(data, 'data');
  757. this.targetComponent = row.reportTemplateCode;
  758. this.isView = true;
  759. this.currentRow = row;
  760. this.currentRow.reportApprovalTaskVos =
  761. data.data.reportApprovalTaskVos || {};
  762. this.$nextTick(() => {
  763. this.targetVisible = true;
  764. });
  765. },
  766. selectionChangeHandle(val) {
  767. this.selection = val;
  768. },
  769. async addSampleOpen(row) {
  770. const code = await verificationQualityInspector(row.id);
  771. if (code == '-1') {
  772. return;
  773. }
  774. const is = await checkByQualityWorkOrderId(row.id);
  775. if (is) {
  776. this.$message.warning('此工单存在未处理完的请样记录,请检查!');
  777. return;
  778. }
  779. this.$refs.addSampleRef.open('add', row);
  780. },
  781. async sampleCollection(row) {
  782. const code = await verificationQualityInspector(row.id);
  783. if (code == '-1') {
  784. return;
  785. }
  786. sampleCollection({ id: row.id }).then((res) => {
  787. this.$message.success('收样成功');
  788. this.search();
  789. });
  790. },
  791. // 批量关闭
  792. batchClose() {
  793. const validRows = this.selection.filter(
  794. (row) => row.status === 0 && row.qualityType === 2
  795. );
  796. if (validRows.length === 0) {
  797. this.$message.warning('所选工单中没有可关闭的工单');
  798. return;
  799. }
  800. this.$confirm(`确定关闭选中的 ${validRows.length} 个工单吗?`, '提示', {
  801. confirmButtonText: '确定',
  802. cancelButtonText: '取消',
  803. type: 'warning'
  804. }).then(async () => {
  805. try {
  806. await closeWorkList(validRows.map((row) => row.id));
  807. this.$refs.table.clearSelection();
  808. this.search();
  809. } catch (err) {
  810. this.$message.error('批量关闭失败:' + (err.message || '操作异常'));
  811. }
  812. });
  813. },
  814. reportApprovalSubmit(res) {
  815. this.processSubmitDialogFlag = true;
  816. this.$nextTick(async () => {
  817. let params = {
  818. businessId: res.id,
  819. businessKey: 'qms_report_approval',
  820. formCreateUserId: res.createUserId,
  821. variables: {
  822. businessCode: res.code,
  823. businessName: res.name,
  824. businessType: '质检报告单'
  825. }
  826. };
  827. if (this.clientEnvironmentId == 5) {
  828. const data = await getCategoryByCode(res.productCode);
  829. if (data && data.categoryLevelCodePath?.includes('W3-209')) {
  830. params.businessKey = 'qms_report_approval1';
  831. } else {
  832. params.businessKey = 'qms_report_approval';
  833. }
  834. }
  835. this.$refs.processSubmitDialogRef.init(params);
  836. });
  837. },
  838. getCode() {
  839. parameterGetByCode({
  840. code: 'qms_report_approval'
  841. }).then((res) => {
  842. this.isReportApproval = res.value;
  843. });
  844. },
  845. //质检项派单
  846. async qualityInspectionSend(row, type) {
  847. const code = await verificationQualityInspector(row.id);
  848. if (code == '-1') {
  849. return;
  850. }
  851. this.$refs.inspectionProjectTaskSendRef.open(row, type);
  852. },
  853. async datasource({ page, where, limit }) {
  854. try {
  855. await queryTodo({});
  856. } catch (err) {
  857. console.error('调用queryTodo失败:', err);
  858. }
  859. return getList({
  860. ...where,
  861. pageNum: page,
  862. size: limit
  863. });
  864. },
  865. search(where) {
  866. this.$refs.table.reload({
  867. where: where
  868. // page: 1
  869. });
  870. },
  871. isEmptyObject(obj) {
  872. return Object.keys(obj).length === 0;
  873. },
  874. async openEdit(type, row) {
  875. const menusList = this.$store.state.user.menus;
  876. let found = false;
  877. if (type == 'edit') {
  878. const code = await verificationQualityInspector(row.id);
  879. if (code == '-1') {
  880. return;
  881. }
  882. }
  883. for (const item of menusList) {
  884. if (item.children) {
  885. for (const item2 of item.children) {
  886. if (item2.path === '/inspectionWork/edit') {
  887. found = true;
  888. const id = type !== 'add' ? row.id : '';
  889. const qualityType = type !== 'add' ? row.qualityType : null;
  890. const qualityTimeStart = row.qualityTimeStart || '';
  891. this.$router.push({
  892. path: '/inspectionWork/edit',
  893. query: {
  894. type,
  895. id,
  896. qualityType,
  897. qualityTimeStart
  898. }
  899. });
  900. return;
  901. }
  902. }
  903. }
  904. }
  905. if (!found) {
  906. this.$message.error('请到角色管理配置菜单权限!');
  907. }
  908. },
  909. openDetails(row) {
  910. let id = row.id;
  911. this.$router.push({
  912. path: '/inspectionWork/details',
  913. query: { id, path: '/inspectionWork', name: '工单' }
  914. });
  915. },
  916. openWorkDetails(row) {
  917. if (row.qualityPlanCode) {
  918. } else {
  919. this.$refs.mesWorkOrderRef.open(row);
  920. }
  921. },
  922. downloadFile(file) {
  923. getFile({ objectName: file.storePath }, file.name);
  924. },
  925. remove(row) {
  926. removeItem([row.id])
  927. .then((message) => {
  928. this.$message.success(message);
  929. this.done();
  930. })
  931. .catch((e) => {});
  932. },
  933. done() {
  934. this.$refs.search.search();
  935. },
  936. openNumber(row) {
  937. this.formData.certificateNumber = row.certificateNumber;
  938. this.rowData = row;
  939. this.addOpen = true;
  940. },
  941. closeModel() {
  942. this.addOpen = false;
  943. },
  944. async close(row) {
  945. const code = await verificationQualityInspector(row.id);
  946. if (code == '-1') {
  947. return;
  948. }
  949. await closeWork(row);
  950. this.done();
  951. },
  952. // async getTnspectionPlanType() {
  953. // let res = await getByCode('inspection_plan_type');
  954. // if (res?.code == 0) {
  955. // let list = res.data.map((item) => {
  956. // let key = Object.keys(item)[0];
  957. // return { value: key, label: item[key] };
  958. // });
  959. // this.typeList = list;
  960. // }
  961. // },
  962. // async getQualityMethodCode() {
  963. // let res = await getByCode('quality_method_code');
  964. // if (res?.code == 0) {
  965. // let list = res.data.map((item) => {
  966. // let key = Object.keys(item)[0];
  967. // return { value: key, label: item[key] };
  968. // });
  969. // this.qualityMode = list;
  970. // }
  971. // },
  972. async openTransfer(id) {
  973. const code = await verificationQualityInspector(id);
  974. if (code == '-1') {
  975. return;
  976. }
  977. this.transferVisible = true;
  978. this.transferId = id;
  979. },
  980. transferConfirm(id) {
  981. this.transferVisible = false;
  982. this.$message.success('转派成功');
  983. this.done();
  984. }
  985. }
  986. };
  987. </script>