pendingBatchRecordTable.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. <template>
  2. <div>
  3. <seek-page :seekList="seekList" @search="search"></seek-page>
  4. <ele-pro-table
  5. ref="table"
  6. row-key="id"
  7. :columns="columns"
  8. :datasource="datasource"
  9. :cache-key="cacheKeyUrl"
  10. :selection.sync="selection"
  11. autoAmendPage
  12. height="var(--batch-record-table-height)"
  13. >
  14. <template v-slot:toolbar>
  15. <print-selector
  16. v-if="printOptions.length"
  17. :options="printOptions"
  18. @select="handlePrint"
  19. />
  20. </template>
  21. </ele-pro-table>
  22. <unqualified-product-review ref="unqualifiedProductReviewRef" />
  23. <product-release-approval ref="productReleaseApproval" />
  24. <sampling-form ref="samplingForm" />
  25. </div>
  26. </template>
  27. <script>
  28. import printSelector from '../printSelector.vue';
  29. import unqualifiedProductReview from '../../print/electrodeBatchRecord/unqualifiedProductReview.vue';
  30. import productReleaseApproval from '../../print/electrodeBatchRecord/productReleaseApproval.vue';
  31. import samplingForm from '../../print/electrodeBatchRecord/samplingForm.vue';
  32. import {
  33. checklistrecordBatchRecordPage,
  34. checklistrecordQueryPrint
  35. } from '@/api/checklistrecord/index';
  36. import {
  37. samplingRecordsBatchRecordPage,
  38. querySamplingPrint
  39. } from '@/api/samplingRecords';
  40. import {
  41. batchRecordPage as unacceptedProductPage,
  42. queryPrint as queryUnacceptedProductPrint
  43. } from '@/api/unacceptedProduct/index';
  44. import { getByCode } from '@/api/system/dictionary-data';
  45. import { reviewStatus } from '@/enum/dict';
  46. import { recordingMethodList } from '@/utils/util.js';
  47. import dictMixins from '@/mixins/dictMixins';
  48. import { buildReleaseOrderPrintData } from '../../utils/releaseOrderPrint';
  49. import {
  50. buildSamplingFormPrintData,
  51. getSamplingPrintIds
  52. } from '../../utils/samplingFormPrint';
  53. export default {
  54. name: 'pendingBatchRecordTable',
  55. mixins: [dictMixins],
  56. components: {
  57. printSelector,
  58. unqualifiedProductReview,
  59. productReleaseApproval,
  60. samplingForm
  61. },
  62. props: {
  63. tableQuery: {
  64. type: Object,
  65. default: () => {
  66. return {};
  67. }
  68. },
  69. tableType: {
  70. type: String,
  71. default: ''
  72. }
  73. },
  74. data() {
  75. return {
  76. selection: [],
  77. tableData: [],
  78. unacceptedProductPrintOptions: [
  79. {
  80. key: 'unqualifiedProductReview',
  81. label: '不合格品通知及评审处置表',
  82. code: 'TR.D-060/ZL'
  83. }
  84. ],
  85. releaseOrderPrintOptions: [
  86. {
  87. key: 'productReleaseApproval',
  88. label: '成品放行审批单',
  89. code: 'ZL-065'
  90. }
  91. ],
  92. samplePrintOptions: [
  93. {
  94. key: 'samplingForm',
  95. label: '取样单',
  96. code: 'ZL-041'
  97. }
  98. ],
  99. disposeList: []
  100. };
  101. },
  102. computed: {
  103. isSample() {
  104. return this.tableType === 'sample';
  105. },
  106. isUnacceptedProduct() {
  107. return this.tableType === 'unacceptedProduct';
  108. },
  109. isReleaseOrder() {
  110. return this.tableType === 'releaseOrder';
  111. },
  112. cacheKeyUrl() {
  113. return `batchRecord-${this.tableType || 'pending'}-table`;
  114. },
  115. printOptions() {
  116. if (this.isSample) {
  117. return this.samplePrintOptions;
  118. }
  119. if (this.isReleaseOrder) {
  120. return this.releaseOrderPrintOptions;
  121. }
  122. if (this.isUnacceptedProduct) {
  123. return this.unacceptedProductPrintOptions;
  124. }
  125. return [];
  126. },
  127. seekList() {
  128. if (this.isReleaseOrder) {
  129. return [
  130. {
  131. label: '放行单编码:',
  132. value: 'code',
  133. type: 'input',
  134. placeholder: '请输入'
  135. },
  136. {
  137. label: '放行单名称:',
  138. value: 'name',
  139. type: 'input',
  140. placeholder: '请输入'
  141. },
  142. {
  143. label: '审核状态:',
  144. value: 'approvalStatus',
  145. type: 'select',
  146. placeholder: '请选择',
  147. planList: [
  148. { value: 0, label: '未提交' },
  149. { value: 1, label: '审核中' },
  150. { value: 2, label: '审核通过' },
  151. { value: 3, label: '审核不通过' }
  152. ]
  153. }
  154. ];
  155. }
  156. if (this.isSample) {
  157. return [
  158. {
  159. label: '检测工单编码:',
  160. value: 'qualityWorkOrderCode',
  161. type: 'input',
  162. placeholder: '请输入',
  163. labelWidth: 120
  164. },
  165. {
  166. label: '取样记录编码:',
  167. value: 'code',
  168. type: 'input',
  169. placeholder: '请输入',
  170. labelWidth: 120
  171. },
  172. {
  173. label: '类型:',
  174. value: 'qualityType',
  175. type: 'DictSelection',
  176. dictName: '质检计划类型',
  177. placeholder: '请选择'
  178. },
  179. {
  180. label: '记录方法:',
  181. value: 'recordingMethod',
  182. type: 'select',
  183. placeholder: '请选择',
  184. planList: recordingMethodList
  185. }
  186. ];
  187. }
  188. return [
  189. {
  190. label: '编码:',
  191. value: 'unqualifiedProductsCode',
  192. type: 'input',
  193. placeholder: '请输入'
  194. },
  195. {
  196. label: '来源编码:',
  197. value: 'sourceCode',
  198. type: 'input',
  199. placeholder: '请输入'
  200. },
  201. {
  202. label: '物品编码:',
  203. value: 'categoryCode',
  204. type: 'input',
  205. placeholder: '请输入'
  206. },
  207. {
  208. label: '状态:',
  209. value: 'status',
  210. type: 'select',
  211. placeholder: '请选择',
  212. planList: [
  213. { value: 0, label: '待处置' },
  214. { value: 1, label: '部分处置' },
  215. { value: 2, label: '处置完成' }
  216. ]
  217. }
  218. ];
  219. },
  220. columns() {
  221. if (this.isReleaseOrder) {
  222. return [
  223. {
  224. width: 45,
  225. type: 'selection',
  226. columnKey: 'selection',
  227. align: 'center',
  228. fixed: 'left'
  229. },
  230. {
  231. width: 50,
  232. type: 'index',
  233. columnKey: 'index',
  234. label: '序号',
  235. align: 'center'
  236. },
  237. {
  238. prop: 'code',
  239. label: '放行单编码',
  240. align: 'center',
  241. minWidth: 130,
  242. showOverflowTooltip: true
  243. },
  244. {
  245. prop: 'name',
  246. label: '放行单名称',
  247. align: 'center',
  248. minWidth: 150,
  249. showOverflowTooltip: true
  250. },
  251. {
  252. prop: 'checklistType',
  253. label: '放行类型',
  254. align: 'center',
  255. minWidth: 120,
  256. showOverflowTooltip: true,
  257. formatter: (row) =>
  258. this.getDictValue('放行类型', row.checklistType + '')
  259. },
  260. {
  261. prop: 'productCode',
  262. label: '产品编码',
  263. align: 'center',
  264. minWidth: 140,
  265. showOverflowTooltip: true,
  266. formatter: (row) => this.getOrderField(row, 'productCode')
  267. },
  268. {
  269. prop: 'productName',
  270. label: '产品名称',
  271. align: 'center',
  272. minWidth: 150,
  273. showOverflowTooltip: true,
  274. formatter: (row) => this.getOrderField(row, 'productName')
  275. },
  276. {
  277. prop: 'batchNo',
  278. label: '批次号',
  279. align: 'center',
  280. minWidth: 120,
  281. showOverflowTooltip: true,
  282. formatter: (row) => this.getOrderField(row, 'batchNo')
  283. },
  284. {
  285. prop: 'workOrderCode',
  286. label: '生产工单号',
  287. align: 'center',
  288. minWidth: 150,
  289. showOverflowTooltip: true,
  290. formatter: (row) => this.getOrderField(row, 'workOrderCode')
  291. },
  292. {
  293. prop: 'formingNum',
  294. label: '要求生产数量',
  295. align: 'center',
  296. minWidth: 120,
  297. showOverflowTooltip: true,
  298. formatter: (row) => this.getOrderField(row, 'formingNum')
  299. },
  300. {
  301. prop: 'formedNum',
  302. label: '实际生产数量',
  303. align: 'center',
  304. minWidth: 120,
  305. showOverflowTooltip: true,
  306. formatter: (row) => this.getOrderField(row, 'formedNum')
  307. },
  308. {
  309. prop: 'specification',
  310. label: '规格',
  311. align: 'center',
  312. minWidth: 120,
  313. showOverflowTooltip: true,
  314. formatter: (row) => this.getOrderField(row, 'specification')
  315. },
  316. {
  317. prop: 'productModel',
  318. label: '型号',
  319. align: 'center',
  320. minWidth: 120,
  321. showOverflowTooltip: true,
  322. formatter: (row) => this.getOrderField(row, 'productModel')
  323. },
  324. {
  325. prop: 'approvalStatus',
  326. label: '审核',
  327. align: 'center',
  328. minWidth: 120,
  329. showOverflowTooltip: true,
  330. formatter: (row) =>
  331. this.getApprovalStatusLabel(row.approvalStatus)
  332. },
  333. {
  334. prop: 'createTime',
  335. label: '创建时间',
  336. align: 'center',
  337. minWidth: 160,
  338. showOverflowTooltip: true
  339. },
  340. {
  341. columnKey: 'action',
  342. label: '操作',
  343. align: 'center',
  344. minWidth: 110,
  345. fixed: 'right'
  346. }
  347. ];
  348. }
  349. if (this.isSample) {
  350. return [
  351. {
  352. width: 45,
  353. type: 'selection',
  354. columnKey: 'selection',
  355. align: 'center',
  356. fixed: 'left'
  357. },
  358. {
  359. width: 50,
  360. type: 'index',
  361. columnKey: 'index',
  362. label: '序号',
  363. align: 'center'
  364. },
  365. {
  366. prop: 'code',
  367. label: '取样记录编码',
  368. align: 'center',
  369. minWidth: 150,
  370. showOverflowTooltip: true
  371. },
  372. {
  373. prop: 'qualityWorkOrderCode',
  374. label: '检测工单编码',
  375. align: 'center',
  376. minWidth: 150,
  377. showOverflowTooltip: true
  378. },
  379. {
  380. prop: 'qualityWorkOrderName',
  381. label: '检测工单名称',
  382. align: 'center',
  383. minWidth: 140,
  384. showOverflowTooltip: true
  385. },
  386. {
  387. prop: 'sourceCode',
  388. label: '来源单号',
  389. align: 'center',
  390. minWidth: 150,
  391. showOverflowTooltip: true
  392. },
  393. {
  394. prop: 'qualityType',
  395. label: '类型',
  396. align: 'center',
  397. minWidth: 100,
  398. showOverflowTooltip: true,
  399. formatter: (row) =>
  400. this.getDictValue('质检计划类型', row.qualityType)
  401. },
  402. {
  403. prop: 'qualityMode',
  404. label: '检测方式',
  405. align: 'center',
  406. minWidth: 100,
  407. showOverflowTooltip: true,
  408. formatter: (row) => (row.qualityMode == 1 ? '全检' : '抽检')
  409. },
  410. {
  411. prop: 'productCode',
  412. label: '编码',
  413. align: 'center',
  414. minWidth: 110,
  415. showOverflowTooltip: true
  416. },
  417. {
  418. prop: 'productName',
  419. label: '名称',
  420. align: 'center',
  421. minWidth: 120,
  422. showOverflowTooltip: true
  423. },
  424. {
  425. prop: 'batchNo',
  426. label: '批次号',
  427. align: 'center',
  428. minWidth: 110,
  429. showOverflowTooltip: true
  430. },
  431. {
  432. prop: 'specification',
  433. label: '规格',
  434. align: 'center',
  435. minWidth: 110,
  436. showOverflowTooltip: true
  437. },
  438. {
  439. prop: 'modelType',
  440. label: '型号',
  441. align: 'center',
  442. minWidth: 110,
  443. showOverflowTooltip: true
  444. },
  445. {
  446. prop: 'brandNo',
  447. label: '牌号',
  448. align: 'center',
  449. minWidth: 110,
  450. showOverflowTooltip: true
  451. },
  452. {
  453. prop: 'produceTaskName',
  454. label: '工序名称',
  455. align: 'center',
  456. minWidth: 120,
  457. showOverflowTooltip: true
  458. },
  459. {
  460. prop: 'conditionType',
  461. label: '取样类型',
  462. align: 'center',
  463. minWidth: 110,
  464. showOverflowTooltip: true,
  465. formatter: (row) => (row.conditionType == 1 ? '整样' : '小样')
  466. },
  467. {
  468. prop: 'recordingMethod',
  469. label: '记录方法',
  470. align: 'center',
  471. minWidth: 110,
  472. showOverflowTooltip: true,
  473. formatter: (row) =>
  474. recordingMethodList.find(
  475. (item) => item.value == row.recordingMethod
  476. )?.label || ''
  477. },
  478. {
  479. prop: 'pleasePurpose',
  480. label: '取样目的',
  481. align: 'center',
  482. minWidth: 120,
  483. showOverflowTooltip: true
  484. },
  485. {
  486. prop: 'sampleQuantity',
  487. label: '取样数量',
  488. align: 'center',
  489. minWidth: 110,
  490. showOverflowTooltip: true
  491. },
  492. {
  493. prop: 'measureUnit',
  494. label: '单位',
  495. align: 'center',
  496. minWidth: 90,
  497. showOverflowTooltip: true
  498. },
  499. {
  500. prop: 'status',
  501. label: '状态',
  502. align: 'center',
  503. minWidth: 110,
  504. showOverflowTooltip: true,
  505. formatter: (row) => this.getSampleStatusLabel(row.status)
  506. },
  507. {
  508. prop: 'approvalStatus',
  509. label: '审核状态',
  510. align: 'center',
  511. minWidth: 110,
  512. showOverflowTooltip: true,
  513. formatter: (row) => reviewStatus[row.approvalStatus] || ''
  514. },
  515. {
  516. prop: 'createUserName',
  517. label: '创建人',
  518. align: 'center',
  519. minWidth: 110,
  520. showOverflowTooltip: true
  521. },
  522. {
  523. prop: 'createTime',
  524. label: '创建时间',
  525. align: 'center',
  526. minWidth: 160,
  527. showOverflowTooltip: true
  528. },
  529. {
  530. prop: 'approvalUserName',
  531. label: '审批人',
  532. align: 'center',
  533. minWidth: 110,
  534. showOverflowTooltip: true
  535. },
  536. {
  537. prop: 'approvalTime',
  538. label: '审批时间',
  539. align: 'center',
  540. minWidth: 160,
  541. showOverflowTooltip: true
  542. },
  543. {
  544. columnKey: 'action',
  545. label: '操作',
  546. align: 'center',
  547. minWidth: 110,
  548. fixed: 'right'
  549. }
  550. ];
  551. }
  552. const codeColumn = {
  553. prop: 'unqualifiedProductsCode',
  554. label: '不良品编码',
  555. align: 'center',
  556. minWidth: 150,
  557. showOverflowTooltip: true
  558. };
  559. return [
  560. {
  561. width: 45,
  562. type: 'selection',
  563. columnKey: 'selection',
  564. align: 'center',
  565. fixed: 'left'
  566. },
  567. {
  568. width: 50,
  569. type: 'index',
  570. columnKey: 'index',
  571. label: '序号',
  572. align: 'center'
  573. },
  574. codeColumn,
  575. {
  576. prop: 'sourceCode',
  577. label: '来源编码',
  578. align: 'center',
  579. minWidth: 150,
  580. showOverflowTooltip: true
  581. },
  582. {
  583. prop: 'categoryCode',
  584. label: '物品编码',
  585. align: 'center',
  586. minWidth: 150,
  587. showOverflowTooltip: true
  588. },
  589. {
  590. prop: 'categoryName',
  591. label: '物品名称',
  592. align: 'center',
  593. minWidth: 150,
  594. showOverflowTooltip: true
  595. },
  596. {
  597. prop: 'batchNo',
  598. label: '批次号',
  599. align: 'center',
  600. minWidth: 120,
  601. showOverflowTooltip: true
  602. },
  603. {
  604. prop: 'specification',
  605. label: '规格',
  606. align: 'center',
  607. minWidth: 110,
  608. showOverflowTooltip: true
  609. },
  610. {
  611. prop: 'brandNum',
  612. label: '牌号',
  613. align: 'center',
  614. minWidth: 110,
  615. showOverflowTooltip: true
  616. },
  617. {
  618. prop: 'modelType',
  619. label: '型号',
  620. align: 'center',
  621. minWidth: 130,
  622. showOverflowTooltip: true
  623. },
  624. {
  625. prop: 'quantity',
  626. label: '数量',
  627. align: 'center',
  628. minWidth: 100,
  629. showOverflowTooltip: true
  630. },
  631. {
  632. prop: 'workOrderCode',
  633. label: '工单编码',
  634. align: 'center',
  635. minWidth: 140,
  636. showOverflowTooltip: true
  637. },
  638. {
  639. prop: 'disposeTime',
  640. label: '处置时间',
  641. align: 'center',
  642. minWidth: 160,
  643. showOverflowTooltip: true
  644. },
  645. {
  646. prop: 'status',
  647. label: '状态',
  648. align: 'center',
  649. minWidth: 90,
  650. showOverflowTooltip: true,
  651. formatter: (row) => this.getDisposeStatusLabel(row.status)
  652. },
  653. {
  654. columnKey: 'action',
  655. label: '操作',
  656. align: 'center',
  657. minWidth: 110,
  658. fixed: 'right'
  659. }
  660. ];
  661. }
  662. },
  663. created() {
  664. this.requestDict('放行类型');
  665. this.requestDict('质检计划类型');
  666. this.requestDict('处置状态');
  667. this.getDisposeList('dispose_status');
  668. },
  669. methods: {
  670. reload(where = {}) {
  671. this.$refs.table.reload({
  672. where,
  673. ...this.tableQuery
  674. });
  675. },
  676. search(where) {
  677. this.reload(where);
  678. },
  679. async handlePrint(key) {
  680. if (
  681. ![
  682. 'productReleaseApproval',
  683. 'samplingForm',
  684. 'unqualifiedProductReview'
  685. ].includes(key) &&
  686. !this.selection.length
  687. ) {
  688. this.$message.warning('请先勾选要打印的数据');
  689. return;
  690. }
  691. if (key === 'unqualifiedProductReview') {
  692. await this.openUnqualifiedProductPrint();
  693. return;
  694. }
  695. if (key === 'productReleaseApproval') {
  696. await this.openReleaseOrderPrint();
  697. return;
  698. }
  699. if (key === 'samplingForm') {
  700. await this.openSamplingFormPrint();
  701. }
  702. },
  703. async openSamplingFormPrint() {
  704. try {
  705. const rows = this.selection.length ? this.selection : this.tableData;
  706. const ids = getSamplingPrintIds(rows);
  707. if (!ids.length) {
  708. this.$message.warning('未获取到可打印数据的ID');
  709. return;
  710. }
  711. const res = await querySamplingPrint(ids);
  712. const data = buildSamplingFormPrintData(res, rows);
  713. if (!data) {
  714. this.$message.warning('未查询到可打印的取样单数据');
  715. return;
  716. }
  717. this.$refs.samplingForm.open(data);
  718. } catch (error) {
  719. this.$message.error(error.message || '查询打印数据失败');
  720. }
  721. },
  722. async openReleaseOrderPrint() {
  723. try {
  724. const rows = this.selection.length ? this.selection : this.tableData;
  725. const ids = rows.map((item) => item.id).filter(Boolean);
  726. if (!ids.length) {
  727. this.$message.warning('未获取到可打印数据的ID');
  728. return;
  729. }
  730. const res = await checklistrecordQueryPrint(ids);
  731. const data = buildReleaseOrderPrintData(res, rows);
  732. if (!data) {
  733. this.$message.warning('未查询到可打印的放行单数据');
  734. return;
  735. }
  736. this.$refs.productReleaseApproval.open(data);
  737. } catch (error) {
  738. this.$message.error(error.message || '查询打印数据失败');
  739. }
  740. },
  741. async openUnqualifiedProductPrint() {
  742. try {
  743. const rows = this.selection.length ? this.selection : this.tableData;
  744. const ids = rows.map((item) => item.id).filter(Boolean);
  745. if (!ids.length) {
  746. this.$message.warning('未获取到可打印数据的ID');
  747. return;
  748. }
  749. const res = await queryUnacceptedProductPrint({ ids });
  750. const data = this.buildUnqualifiedProductPrintData(res, rows);
  751. if (!data) {
  752. this.$message.warning('未查询到可打印的不良品数据');
  753. return;
  754. }
  755. this.$refs.unqualifiedProductReviewRef.open(data);
  756. } catch (error) {
  757. this.$message.error(error.message || '查询打印数据失败');
  758. }
  759. },
  760. buildUnqualifiedProductPrintData(res, rows = this.selection) {
  761. const list = Array.isArray(res) ? res : [];
  762. if (!list.length) {
  763. return null;
  764. }
  765. return list.map((item, index) =>
  766. this.buildUnqualifiedProductPrintItem(
  767. item,
  768. this.getSelectedUnqualifiedProduct(item, index, rows)
  769. )
  770. );
  771. },
  772. getSelectedUnqualifiedProduct(item = {}, index, rows = this.selection) {
  773. return (
  774. rows.find(
  775. (row) =>
  776. (item.id && row.id == item.id) ||
  777. (item.unqualifiedProductsCode &&
  778. row.unqualifiedProductsCode == item.unqualifiedProductsCode)
  779. ) ||
  780. rows[index] ||
  781. rows[0] ||
  782. {}
  783. );
  784. },
  785. buildUnqualifiedProductPrintItem(item, selected) {
  786. const first = item || {};
  787. const specification = this.joinText([
  788. this.getValue(first.specification, selected.specification),
  789. this.getValue(first.modelType, selected.modelType)
  790. ]);
  791. return {
  792. ...selected,
  793. ...first,
  794. disposeNo: this.getValue(
  795. first.disposeNo,
  796. selected.disposeNo,
  797. first.unqualifiedProductsCode,
  798. selected.unqualifiedProductsCode
  799. ),
  800. categoryName: this.getValue(
  801. first.categoryName,
  802. selected.categoryName
  803. ),
  804. specification,
  805. modelType: this.getValue(first.modelType, selected.modelType),
  806. batchNo: this.getValue(first.batchNo, selected.batchNo),
  807. quantity: this.getValue(first.quantity, selected.quantity),
  808. measureUnit: this.getValue(first.measureUnit, selected.measureUnit),
  809. unqualifiedProductsCode: this.getValue(
  810. first.unqualifiedProductsCode,
  811. selected.unqualifiedProductsCode
  812. ),
  813. unqualifiedDescription: this.getValue(
  814. first.unqualifiedReason,
  815. selected.unqualifiedDescription,
  816. selected.unqualifiedReason
  817. ),
  818. unqualifiedReason: this.getValue(
  819. first.unqualifiedReason,
  820. selected.unqualifiedReason
  821. ),
  822. brandNum: this.getValue(first.brandNum, selected.brandNum)
  823. };
  824. },
  825. joinText(list) {
  826. return [
  827. ...new Set(
  828. (list || []).filter(
  829. (item) => item !== undefined && item !== null && item !== ''
  830. )
  831. )
  832. ].join('/');
  833. },
  834. getValue(...values) {
  835. const value = values.find(
  836. (item) => item !== undefined && item !== null && item !== ''
  837. );
  838. return value === undefined ? '' : value;
  839. },
  840. getFirstOrder(row) {
  841. return Array.isArray(row.orders) && row.orders.length
  842. ? row.orders[0]
  843. : {};
  844. },
  845. getOrderField(row, key) {
  846. if (row[key] !== undefined && row[key] !== null && row[key] !== '') {
  847. return row[key];
  848. }
  849. if (!Array.isArray(row.orders)) {
  850. return '';
  851. }
  852. return row.orders
  853. .map((item) => item[key])
  854. .filter(Boolean)
  855. .join(', ');
  856. },
  857. getApprovalStatusLabel(status) {
  858. switch (status) {
  859. case 0:
  860. return '未提交';
  861. case 1:
  862. return '审核中';
  863. case 2:
  864. return '审核通过';
  865. case 3:
  866. return '审核不通过';
  867. default:
  868. return '';
  869. }
  870. },
  871. getSampleStatusLabel(status) {
  872. switch (status) {
  873. case 1:
  874. return '审核中';
  875. case 2:
  876. return '已取样';
  877. case 3:
  878. return '已作废';
  879. case 4:
  880. return '不通过';
  881. default:
  882. return '未提交';
  883. }
  884. },
  885. getDisposeStatusLabel(status) {
  886. const data = this.disposeList.find((item) => item.value == status);
  887. return data ? data.label : '';
  888. },
  889. async getDisposeList(code) {
  890. const res = await getByCode(code);
  891. if (res?.code == 0) {
  892. this.disposeList = res.data.map((item) => {
  893. const key = Object.keys(item)[0];
  894. return { value: Number(key), label: item[key] };
  895. });
  896. }
  897. },
  898. datasource({ page, limit, where, order }) {
  899. if (this.isReleaseOrder) {
  900. const body = {
  901. ...where,
  902. ...order,
  903. pageNum: page,
  904. size: limit,
  905. ...this.tableQuery
  906. };
  907. const res = checklistrecordBatchRecordPage(body);
  908. Promise.resolve(res).then((data) => {
  909. this.tableData = data?.list || data?.records || [];
  910. });
  911. return res;
  912. }
  913. if (this.isSample) {
  914. const body = {
  915. ...where,
  916. ...order,
  917. pageNum: page,
  918. size: limit,
  919. ...this.tableQuery
  920. };
  921. const res = samplingRecordsBatchRecordPage(body);
  922. Promise.resolve(res).then((data) => {
  923. this.tableData = data?.list || data?.records || [];
  924. });
  925. return res;
  926. }
  927. if (this.isUnacceptedProduct) {
  928. const body = {
  929. ...where,
  930. ...order,
  931. pageNum: page,
  932. size: limit,
  933. ...this.tableQuery
  934. };
  935. const res = unacceptedProductPage(body);
  936. Promise.resolve(res).then((data) => {
  937. this.tableData = data?.list || data?.records || [];
  938. });
  939. return res;
  940. }
  941. return Promise.resolve({
  942. list: [],
  943. count: 0
  944. });
  945. }
  946. }
  947. };
  948. </script>