unqualifiedProduct.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="poList.filter((item) => item.disposalStatus != 2)"
  8. :selection.sync="selection"
  9. :needPage="false"
  10. row-key="id"
  11. max-height="500px"
  12. >
  13. <!-- 操作列 -->
  14. <template v-slot:toolbar v-if="showBtn">
  15. <el-button type="primary" slot="reference" @click="add"
  16. >新增</el-button
  17. >
  18. <el-button
  19. type="primary"
  20. slot="reference"
  21. :disabled="selection.length == 0"
  22. @click="disposeFn(1)"
  23. >批量处置</el-button
  24. >
  25. <el-popconfirm
  26. class="ele-action"
  27. title="确定要删除吗?"
  28. @confirm="remove"
  29. style="margin-left: 10px"
  30. >
  31. <template v-slot:reference>
  32. <el-button :disabled="selection.length == 0" type="danger"
  33. >批量删除</el-button
  34. >
  35. </template>
  36. </el-popconfirm>
  37. </template>
  38. <template v-slot:badTypeName="{ row, $index }">
  39. <el-select
  40. v-model="row.badTypeId"
  41. placeholder="请选择不良类型"
  42. size="small"
  43. style="width: 100%"
  44. remote
  45. filterable
  46. clearable
  47. >
  48. <el-option
  49. v-for="item in badTypeList"
  50. :key="item.id"
  51. :label="item.name"
  52. :value="item.id"
  53. @click="row.badTypeName = item.name"
  54. >
  55. </el-option>
  56. </el-select>
  57. </template>
  58. <template v-slot:badNameName="{ row, $index }">
  59. <el-select
  60. v-model="row.badNameId"
  61. placeholder="请选择不良名称"
  62. size="small"
  63. style="width: 100%"
  64. remote
  65. filterable
  66. clearable
  67. >
  68. <el-option
  69. v-for="item in badNameList"
  70. :key="item.id"
  71. :label="item.name"
  72. :value="item.id"
  73. @click="row.badNameName = item.name"
  74. >
  75. </el-option>
  76. </el-select>
  77. </template>
  78. <template v-slot:reasonTypeName="{ row, $index }">
  79. <el-select
  80. v-model="row.reasonTypeId"
  81. placeholder="请选择原因类型"
  82. size="small"
  83. style="width: 100%"
  84. remote
  85. filterable
  86. clearable
  87. >
  88. <el-option
  89. v-for="item in reasonTypeList"
  90. :key="item.id"
  91. :label="item.name"
  92. :value="item.id"
  93. @click="row.reasonTypeName = item.name"
  94. >
  95. </el-option>
  96. </el-select>
  97. </template>
  98. <template v-slot:unqualifiedReason="{ row, $index }">
  99. <el-input v-model="row.unqualifiedReason"></el-input>
  100. </template>
  101. </ele-pro-table>
  102. </el-card>
  103. <ele-modal
  104. :visible.sync="dialogVisible"
  105. width="35%"
  106. @close="close"
  107. append-to-body
  108. title="处置"
  109. >
  110. <el-form
  111. ref="disposeForm"
  112. :model="disposeForm"
  113. label-width="150px"
  114. :rules="rules"
  115. >
  116. <el-form-item label="处置方式:" prop="disposeType">
  117. <el-select
  118. v-model="disposeForm.disposeType"
  119. placeholder="请选择"
  120. style="width: 100%"
  121. @change="disposeTypeChange"
  122. >
  123. <el-option
  124. v-for="item in disposeList"
  125. :key="item.value"
  126. :label="item.label"
  127. :value="item.value"
  128. >
  129. </el-option>
  130. </el-select>
  131. </el-form-item>
  132. <template
  133. v-if="disposeForm.disposeType == 1 || disposeForm.disposeType == 2"
  134. >
  135. <el-form-item label="回流工序" prop="taskId" align="center">
  136. <el-select
  137. style="width: 100%"
  138. v-model="disposeForm.taskId"
  139. clearable
  140. >
  141. <el-option
  142. v-for="item in refluxTaskList"
  143. :key="item.taskId"
  144. :value="item.taskId"
  145. :label="item.taskTypeName"
  146. ></el-option>
  147. </el-select>
  148. </el-form-item>
  149. </template>
  150. <template v-if="disposeForm.disposeType == 6">
  151. <el-row>
  152. <el-col :span="24">
  153. <el-form-item
  154. label="留样数量:"
  155. prop="keepSampleQuantity"
  156. align="center"
  157. >
  158. <el-input
  159. v-model="disposeForm.keepSampleQuantity"
  160. placeholder="请输入"
  161. style="width: 100%"
  162. >
  163. <template slot="append">{{
  164. current?.measureUnit
  165. }}</template></el-input
  166. >
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="6"> </el-col>
  170. </el-row>
  171. <el-row style="margin-top: 12px">
  172. <el-col :span="24">
  173. <el-form-item label="留样日期:" prop="sampleDate" align="center">
  174. <el-date-picker
  175. class="w100"
  176. v-model="disposeForm.sampleDate"
  177. type="date"
  178. value-format="yyyy-MM-dd"
  179. placeholder="请输入"
  180. ></el-date-picker>
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="6"> </el-col>
  184. </el-row>
  185. <el-row style="margin-top: 12px">
  186. <el-col :span="24">
  187. <el-form-item
  188. label="留样条件:"
  189. prop="sampleCondition"
  190. align="center"
  191. >
  192. <el-input
  193. v-model="disposeForm.sampleCondition"
  194. placeholder="请输入"
  195. style="width: 100%"
  196. ></el-input>
  197. </el-form-item>
  198. </el-col>
  199. </el-row>
  200. <el-row style="margin-top: 12px">
  201. <el-col :span="24">
  202. <el-form-item
  203. label="生产商/受托生产:"
  204. prop="producerManufacturer"
  205. align="center"
  206. >
  207. <el-input
  208. v-model="disposeForm.producerManufacturer"
  209. placeholder="请输入"
  210. style="width: 100%"
  211. ></el-input>
  212. </el-form-item>
  213. </el-col>
  214. </el-row>
  215. <el-row style="margin-top: 12px">
  216. <el-col :span="24">
  217. <el-form-item
  218. label="留样地点:"
  219. prop="samplePlace"
  220. align="center"
  221. >
  222. <el-input
  223. type="textarea"
  224. v-model="disposeForm.samplePlace"
  225. placeholder="请输入"
  226. style="width: 100%"
  227. ></el-input>
  228. </el-form-item>
  229. </el-col>
  230. </el-row>
  231. <el-row style="margin-top: 12px">
  232. <el-col :span="24">
  233. <el-form-item
  234. label="留样备注:"
  235. prop="sampleRemark"
  236. align="center"
  237. >
  238. <el-input
  239. type="textarea"
  240. v-model="disposeForm.sampleRemark"
  241. placeholder="请输入"
  242. style="width: 100%"
  243. ></el-input>
  244. </el-form-item>
  245. </el-col>
  246. </el-row>
  247. <el-row style="margin-top: 12px">
  248. <el-col :span="24"> </el-col>
  249. </el-row>
  250. </template>
  251. <template
  252. v-if="
  253. disposeForm.disposeType == 3 ||
  254. disposeForm.disposeType == 6 ||
  255. disposeForm.disposeType == 9
  256. "
  257. >
  258. <el-form-item label="入库仓库:" prop="depotId" align="center">
  259. <el-select style="width: 100%" v-model="disposeForm.depotId">
  260. <el-option
  261. v-for="item in warehouseList"
  262. :key="item.id"
  263. :value="item.id"
  264. :label="item.name"
  265. @click.native="chooseWarehouse(item)"
  266. ></el-option>
  267. </el-select>
  268. </el-form-item>
  269. </template>
  270. </el-form>
  271. <!-- <DictSelection
  272. dictName="不良品处理类型"
  273. :filterArr="all ? ['返工返修'] : []"
  274. v-model="current.disposalStatus"
  275. /> -->
  276. <div slot="footer" class="dialog-footer">
  277. <el-button @click="dialogVisible = false">取 消 </el-button>
  278. <el-button type="primary" @click="handleDispose">确 定</el-button>
  279. </div>
  280. </ele-modal>
  281. <!-- <Edit ref="edit" @success="save" /> -->
  282. <ele-modal
  283. :visible.sync="addDialogVisible"
  284. width="60%"
  285. append-to-body
  286. title="选择"
  287. >
  288. <el-table
  289. :data="inventoryList"
  290. @selection-change="handleAddSelectionChange"
  291. row-key="id"
  292. >
  293. <el-table-column
  294. type="selection"
  295. width="55"
  296. align="center"
  297. :selectable="
  298. (row, index) => {
  299. return (
  300. !poList.map((item) => item.sourceId).includes(row.sourceId) ||
  301. inventoryList.length == 1
  302. );
  303. }
  304. "
  305. ></el-table-column>
  306. <el-table-column
  307. type="index"
  308. label="序号"
  309. width="55"
  310. align="center"
  311. ></el-table-column>
  312. <el-table-column
  313. prop="sampleCode"
  314. label="样品编码"
  315. width="150"
  316. align="center"
  317. ></el-table-column>
  318. <el-table-column
  319. prop="categoryCode"
  320. label="物品编码"
  321. width="150"
  322. align="center"
  323. ></el-table-column>
  324. <el-table-column
  325. prop="categoryName"
  326. label="物品名称"
  327. width="150"
  328. align="center"
  329. show-overflow-tooltip
  330. ></el-table-column>
  331. <el-table-column
  332. prop="specification"
  333. label="规格"
  334. width="120"
  335. align="center"
  336. ></el-table-column>
  337. <el-table-column prop="measureQuantity" label="计量数量" align="center">
  338. <template slot-scope="scope">
  339. <template v-if="inventoryList.length === 1">
  340. <el-input-number
  341. v-model="singleQuantity"
  342. :min="0"
  343. :max="availableTotal"
  344. style="width: 120px"
  345. ></el-input-number>
  346. </template>
  347. <template v-else>
  348. {{ scope.row.measureQuantity }}
  349. </template>
  350. </template>
  351. </el-table-column>
  352. <el-table-column
  353. prop="measureUnit"
  354. label="计量单位"
  355. align="center"
  356. ></el-table-column>
  357. </el-table>
  358. <div slot="footer" class="dialog-footer">
  359. <el-button @click="addDialogVisible = false">取 消</el-button>
  360. <el-button type="primary" @click="handleAddSave">确 定</el-button>
  361. </div>
  362. </ele-modal>
  363. </div>
  364. </template>
  365. <script>
  366. import Edit from './edit.vue';
  367. import { getWarehouseList } from '@/api/bpm/components/saleManage/saleorder.js';
  368. import dictMixins from '@/mixins/dictMixins';
  369. import {
  370. queryQualitySamplContent,
  371. queryQualityInventory,
  372. getById,
  373. getBadnameList,
  374. getBadtypeList,
  375. getReasontypeList
  376. } from '@/api/bpm/components/qualityReportApproval/qualityReportApproval';
  377. export default {
  378. components: {
  379. Edit
  380. },
  381. props: {
  382. total: {
  383. type: Number,
  384. default: 0
  385. },
  386. businessType: {
  387. type: String,
  388. default: ''
  389. }
  390. },
  391. mixins: [dictMixins],
  392. data() {
  393. return {
  394. cacheKeyUrl: 'qsm-c2e9664a-unqualifiedList-detailList',
  395. key: '',
  396. warehouseList: [],
  397. activeComp: 'main',
  398. addDialogVisible: false,
  399. rules: {
  400. disposeType: [
  401. { required: true, message: '请选择处置方式', trigger: 'change' }
  402. ],
  403. depotId: [
  404. { required: true, message: '请选择仓库', trigger: 'change' }
  405. ],
  406. keepSampleQuantity: [
  407. {
  408. validator: (rule, value, callback) => {
  409. if (
  410. this.disposeForm.disposeType === 6 &&
  411. this.current &&
  412. this.current.measureQuantity !== undefined
  413. ) {
  414. const inputVal = Number(value);
  415. const maxVal = Number(this.current.measureQuantity);
  416. if (inputVal > maxVal) {
  417. return callback(new Error(`不能超过原计量数量${maxVal}`));
  418. }
  419. }
  420. callback();
  421. },
  422. trigger: 'blur'
  423. }
  424. ]
  425. },
  426. disposeType: '',
  427. disposeForm: {
  428. disposeType: '',
  429. sampleCondition: '',
  430. sampleDate: '',
  431. samplePlace: '',
  432. sampleRemark: '',
  433. producerManufacturer: '',
  434. depotId: '',
  435. depotName: '',
  436. taskId: '',
  437. keepSampleQuantity: ''
  438. },
  439. loading: false,
  440. selection: [],
  441. poList: [],
  442. id: '',
  443. dialogVisible: false,
  444. current: {},
  445. formData: {},
  446. all: false,
  447. qualityType: null,
  448. allList: [
  449. { value: 1, label: '返工' },
  450. { value: 2, label: '返修' },
  451. { value: 3, label: '报废' },
  452. { value: 4, label: '降级使用' },
  453. { value: 5, label: '让步接收' },
  454. // { value: 6, label: '留样' },
  455. // { value: 7, label: '消耗' },
  456. // { value: 8, label: '回用/归批' },
  457. { value: 9, label: '转试销' },
  458. { value: 10, label: '退货' }
  459. ],
  460. //来料
  461. disposalStatusListType: [
  462. {
  463. value: 5,
  464. label: '让步接收'
  465. },
  466. {
  467. value: 9,
  468. label: '退货'
  469. }
  470. ],
  471. //生产
  472. disposalStatusList: [
  473. {
  474. value: 1,
  475. label: '返工'
  476. },
  477. {
  478. value: 2,
  479. label: '返修'
  480. },
  481. {
  482. value: 3,
  483. label: '报废'
  484. },
  485. {
  486. value: 4,
  487. label: '降级使用'
  488. },
  489. {
  490. value: 5,
  491. label: '让步接收'
  492. },
  493. {
  494. value: 6,
  495. label: '留样'
  496. },
  497. {
  498. value: 7,
  499. label: '消耗'
  500. },
  501. {
  502. value: 8,
  503. label: '回用'
  504. }
  505. ],
  506. workOrderCode: '',
  507. qualityWorkerId: '',
  508. qualityResults: '',
  509. refluxTaskList: [],
  510. sampleList: [],
  511. inventoryList: [],
  512. oldList: [],
  513. addSelection: [],
  514. retainedSampleQuantity: 0,
  515. retainedSampleUnqualified: 0,
  516. lossNumber: 0,
  517. lossNumberUnqualified: 0,
  518. badTypeList: [],
  519. badNameList: [],
  520. reasonTypeList: []
  521. };
  522. },
  523. computed: {
  524. showBtn() {
  525. return true;
  526. },
  527. disposeList() {
  528. if (this.qualityType == 1) {
  529. return this.allList.filter((item) => [5, 10].includes(item.value));
  530. }
  531. if (this.qualityType == 2) {
  532. return this.allList.filter((item) => item.value !== 8);
  533. }
  534. if (this.qualityType == 2 || this.qualityType == 3) {
  535. return this.allList.filter(
  536. (item) => item.value !== 8 && item.value !== 10
  537. );
  538. } else {
  539. return this.allList;
  540. }
  541. },
  542. // 可用总数 = 总数 - 留样数 - 消耗数
  543. availableTotal() {
  544. if (!this.sampleList.length) return this.total;
  545. const usedQuantity = this.sampleList
  546. .filter((item) => item.disposeType == 6 || item.disposeType == 7)
  547. .reduce((sum, item) => sum + (item.measureQuantity || 0), 0);
  548. return this.total - usedQuantity;
  549. },
  550. // 表格列配置
  551. columns() {
  552. const arr = [
  553. {
  554. width: 45,
  555. type: 'selection',
  556. columnKey: 'selection',
  557. reserveSelection: true,
  558. align: 'center'
  559. },
  560. {
  561. columnKey: 'index',
  562. label: '序号',
  563. type: 'index',
  564. width: 55,
  565. align: 'center',
  566. showOverflowTooltip: true,
  567. fixed: 'left'
  568. },
  569. {
  570. label: '样品编码',
  571. prop: 'sampleCode',
  572. width: '150',
  573. align: 'center',
  574. showOverflowTooltip: true
  575. },
  576. {
  577. prop: 'categoryCode',
  578. label: '物品编码',
  579. width: '150',
  580. align: 'center',
  581. showOverflowTooltip: true
  582. },
  583. {
  584. prop: 'categoryName',
  585. label: '物品名称',
  586. width: '150',
  587. align: 'center',
  588. showOverflowTooltip: true
  589. },
  590. {
  591. label: '规格',
  592. prop: 'specification',
  593. width: '120',
  594. align: 'center',
  595. showOverflowTooltip: true
  596. },
  597. {
  598. prop: 'brandNum',
  599. label: '牌号',
  600. align: 'center'
  601. },
  602. {
  603. prop: 'modelType',
  604. label: '型号',
  605. align: 'center',
  606. width: '120',
  607. showOverflowTooltip: true
  608. },
  609. {
  610. label: '机型',
  611. prop: 'modelKey',
  612. align: 'center',
  613. showOverflowTooltip: true
  614. },
  615. {
  616. label: '颜色',
  617. prop: 'colorKey',
  618. align: 'center',
  619. showOverflowTooltip: true
  620. },
  621. {
  622. prop: 'batchNo',
  623. label: '批次号',
  624. align: 'center',
  625. width: '120',
  626. showOverflowTooltip: true
  627. },
  628. {
  629. prop: 'weight',
  630. label: '重量',
  631. align: 'center',
  632. width: '120',
  633. showOverflowTooltip: true
  634. },
  635. {
  636. prop: 'weightUnit',
  637. label: '重量单位',
  638. align: 'center',
  639. width: '120',
  640. showOverflowTooltip: true
  641. },
  642. {
  643. prop: 'engrave',
  644. label: '刻码',
  645. align: 'center'
  646. },
  647. { label: '计量数量', prop: 'measureQuantity', align: 'center' },
  648. { label: '计量单位', prop: 'measureUnit', align: 'center' },
  649. {
  650. prop: 'produceRoutingName',
  651. label: '工艺路线',
  652. align: 'center'
  653. },
  654. {
  655. prop: 'produceTaskName',
  656. label: '工序',
  657. align: 'center'
  658. },
  659. {
  660. prop: 'badTypeName',
  661. label: '不良类型',
  662. slot: 'badTypeName',
  663. width: '180',
  664. align: 'center'
  665. },
  666. {
  667. prop: 'badNameName',
  668. slot: 'badNameName',
  669. label: '不良名称',
  670. width: '180',
  671. align: 'center'
  672. },
  673. {
  674. slot: 'reasonTypeName',
  675. prop: 'reasonTypeName',
  676. label: '原因类型',
  677. width: '180',
  678. align: 'center'
  679. },
  680. {
  681. slot: 'unqualifiedReason',
  682. prop: 'unqualifiedReason',
  683. label: '原因',
  684. width: '180',
  685. align: 'center'
  686. },
  687. {
  688. prop: 'disposeTime',
  689. label: '处置时间',
  690. align: 'center',
  691. width: '180',
  692. showOverflowTooltip: true
  693. },
  694. {
  695. prop: 'disposalStatus',
  696. label: '处置状态',
  697. align: 'center',
  698. fixed: 'right',
  699. width: '120',
  700. showOverflowTooltip: true,
  701. filters: [
  702. { value: 0, text: '待处置' },
  703. { value: 1, text: '处置中' }
  704. ],
  705. filterMethod: this.disposalStatusFilter,
  706. formatter: (row, column, cellValue) => {
  707. return this.disposalStatustList[cellValue ? cellValue : 0];
  708. }
  709. },
  710. {
  711. prop: 'disposeType',
  712. label: '处置类型',
  713. align: 'center',
  714. fixed: 'right',
  715. width: '120',
  716. showOverflowTooltip: true,
  717. formatter: (row, column, cellValue) => {
  718. console.log(this.allList.find((item) => item.value == cellValue));
  719. return this.allList.find((item) => item.value == cellValue)
  720. ?.label;
  721. }
  722. }
  723. ];
  724. return arr;
  725. },
  726. disposalStatustList() {
  727. return { 0: '待处置', 1: '处置中', 2: '处置完成' };
  728. }
  729. },
  730. created() {
  731. this.getBadTypeList();
  732. this.getBadNameList();
  733. this.getReasonTypeList();
  734. },
  735. methods: {
  736. disposalStatusFilter(value, row, column) {
  737. if (value == row.disposalStatus) {
  738. return row;
  739. }
  740. },
  741. // 查询不良类型
  742. async getBadTypeList() {
  743. const res = await getBadtypeList({
  744. pageNum: 1,
  745. size: 999
  746. });
  747. this.badTypeList = res.list;
  748. },
  749. // 查询不良名称
  750. async getBadNameList() {
  751. const res = await getBadnameList({
  752. pageNum: 1,
  753. size: 999
  754. });
  755. this.badNameList = res.list;
  756. },
  757. // 查询原因类型
  758. async getReasonTypeList() {
  759. const res = await getReasontypeList({
  760. pageNum: 1,
  761. size: 999
  762. });
  763. this.reasonTypeList = res.list;
  764. },
  765. async init(row) {
  766. this.qualityType = row.qualityType;
  767. this.id = row.id;
  768. console.log(row, 'row');
  769. this.workOrderCode = row.workOrderCode;
  770. this.qualityWorkerId = row.qualityWorkerId;
  771. this.qualityResults = row.qualityResults;
  772. this.warehouseList = await getWarehouseList();
  773. await this.getQueryQualityInventory();
  774. await this.queryQualitySamplContent();
  775. if (this.id) {
  776. await this.datasource();
  777. }
  778. },
  779. setQualifiedNumber() {
  780. let isQualifiedNumber = true;
  781. let noQualifiedNumber = this.poList
  782. .filter((item) => ![5, 6, 7].includes(item.disposeType))
  783. .reduce((acc, cur) => acc + cur.measureQuantity, 0);
  784. if (
  785. this.poList
  786. .filter((item) => item.disposeType == 5)
  787. .reduce((acc, cur) => acc + cur.measureQuantity, 0) ==
  788. this.availableTotal
  789. ) {
  790. isQualifiedNumber = false;
  791. }
  792. this.$emit('setQualifiedNumber', {
  793. noQualifiedNumber,
  794. qualifiedNumber: this.availableTotal - noQualifiedNumber,
  795. isQualifiedNumber
  796. });
  797. },
  798. selectResult(qualityResults) {
  799. if (qualityResults == 1) {
  800. this.poList = JSON.parse(JSON.stringify(this.oldList));
  801. this.poList = this.poList.map((item) => {
  802. if (item.disposalStatus != 2) {
  803. item.disposalStatus = 1;
  804. item.disposeType = 5;
  805. }
  806. return item;
  807. });
  808. }
  809. if (qualityResults == 4) {
  810. this.poList = [
  811. ...JSON.parse(JSON.stringify(this.inventoryList)),
  812. ...JSON.parse(
  813. JSON.stringify(
  814. this.oldList.filter((item) => item.disposalStatus == 2)
  815. )
  816. )
  817. ];
  818. this.poList = this.poList.map((item) => {
  819. if (item.disposalStatus != 2) {
  820. item.disposalStatus = 1;
  821. item.disposeType = 5;
  822. }
  823. return item;
  824. });
  825. }
  826. if (qualityResults == 2) {
  827. this.poList = [
  828. ...JSON.parse(JSON.stringify(this.inventoryList)),
  829. ...JSON.parse(
  830. JSON.stringify(
  831. this.oldList.filter((item) => item.disposalStatus == 2)
  832. )
  833. )
  834. ];
  835. }
  836. if (qualityResults == 3) {
  837. this.poList = JSON.parse(JSON.stringify(this.oldList));
  838. }
  839. this.qualityResults = qualityResults;
  840. this.setQualifiedNumber();
  841. },
  842. disposeTypeChange() {
  843. if (this.disposeForm.disposeType == 6) {
  844. this.disposeForm.keepSampleQuantity =
  845. this.current?.measureQuantity || '';
  846. }
  847. },
  848. handleAddSelectionChange(selection) {
  849. this.addSelection = selection;
  850. },
  851. handleAddSave() {
  852. if (this.addSelection.length === 0) {
  853. this.$message.warning('请选择数据');
  854. return;
  855. }
  856. const poListTotal = this.poList.reduce(
  857. (sum, item) => sum + Number(item.measureQuantity || 0),
  858. 0
  859. );
  860. let selectedTotal = 0;
  861. if (this.inventoryList.length === 1) {
  862. selectedTotal =
  863. this.addSelection.length * Number(this.singleQuantity || 0);
  864. } else {
  865. selectedTotal = this.addSelection.reduce(
  866. (sum, item) => sum + Number(item.measureQuantity || 0),
  867. 0
  868. );
  869. }
  870. if (poListTotal + selectedTotal > this.availableTotal) {
  871. this.$message.error('选中的计量数量之和加上已有数量不能超过总数');
  872. return;
  873. }
  874. this.addSelection.forEach((item) => {
  875. const newItem = JSON.parse(JSON.stringify(item));
  876. if (this.inventoryList.length === 1) {
  877. newItem.measureQuantity = Number(this.singleQuantity);
  878. }
  879. this.poList.push(newItem);
  880. });
  881. this.addDialogVisible = false;
  882. this.setQualifiedNumber();
  883. },
  884. add() {
  885. this.addDialogVisible = true;
  886. this.addSelection = [];
  887. if (this.inventoryList.length === 1) {
  888. this.singleQuantity = this.inventoryList[0].measureQuantity || 0;
  889. }
  890. },
  891. // /* 表格数据源 */
  892. async datasource() {
  893. const arr = await getById(this.id);
  894. this.oldList = JSON.parse(JSON.stringify(arr.poList));
  895. this.poList = arr.poList;
  896. this.setQualifiedNumber();
  897. },
  898. // async getRefluxTask() {
  899. // await refluxTask({
  900. // workOrderCode: this.workOrderCode
  901. // }).then((res) => {
  902. // this.refluxTaskList = res;
  903. // });
  904. // },
  905. remove() {
  906. let ids = this.selection.map((item) => item.id);
  907. console.log(ids, 'ids');
  908. this.poList = this.poList.filter((item) => !ids.includes(item.id));
  909. this.setQualifiedNumber();
  910. },
  911. close() {
  912. this.dialogVisible = false;
  913. this.disposeType = '';
  914. this.all = false;
  915. this.formData.disposalStatus = '';
  916. },
  917. // // 处置
  918. disposeFn(type, row) {
  919. if (type == 1) {
  920. this.all = true;
  921. } else {
  922. this.current = row;
  923. }
  924. this.formData = { ...row };
  925. this.dialogVisible = true;
  926. // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
  927. },
  928. async getQueryQualityInventory() {
  929. const res = await queryQualityInventory({
  930. qualityWorkerId: this.qualityWorkerId,
  931. size: -1
  932. });
  933. if (res.list.length > 0) {
  934. this.inventoryList = res.list;
  935. }
  936. return;
  937. },
  938. async queryQualitySamplContent() {
  939. const res = await queryQualitySamplContent({
  940. qualityWorkerId: this.qualityWorkerId,
  941. size: 1000
  942. });
  943. this.sampleList = res.list;
  944. [
  945. 'retainedSampleQuantity',
  946. 'retainedSampleUnqualified',
  947. 'lossNumber',
  948. 'lossNumberUnqualified'
  949. ].forEach((key) => {
  950. this[key] = 0;
  951. });
  952. if (this.sampleList.length > 0 && this.inventoryList.length > 0) {
  953. const processedList = this.sampleList.filter(
  954. (item) => item.disposeType == 6 || item.disposeType == 7
  955. );
  956. console.log(
  957. processedList.filter((item) => item.disposeType == 6),
  958. 'qwewqe'
  959. );
  960. console.log(
  961. processedList.filter((item) => item.disposeType == 7),
  962. '123123'
  963. );
  964. processedList.forEach((sampleItem) => {
  965. if (sampleItem.disposeType == 6) {
  966. sampleItem.qualityResults == 2
  967. ? (this.retainedSampleUnqualified += sampleItem.measureQuantity)
  968. : (this.retainedSampleQuantity += sampleItem.measureQuantity);
  969. } else {
  970. sampleItem.qualityResults == 2
  971. ? (this.lossNumberUnqualified += sampleItem.measureQuantity)
  972. : (this.lossNumber += sampleItem.measureQuantity);
  973. }
  974. const inventoryItem = this.inventoryList.find(
  975. (item) => item.sourceId === sampleItem.sourceId
  976. );
  977. if (inventoryItem) {
  978. inventoryItem.measureQuantity = Math.max(
  979. 0,
  980. (inventoryItem.measureQuantity || 0) -
  981. (sampleItem.measureQuantity || 0)
  982. );
  983. }
  984. });
  985. }
  986. this.$emit('setLossNumber', {
  987. lossNumber: this.lossNumber,
  988. lossNumberUnqualified: this.lossNumberUnqualified,
  989. retainedSampleQuantity: this.retainedSampleQuantity,
  990. retainedSampleUnqualified: this.retainedSampleUnqualified
  991. });
  992. if (this.inventoryList.length == 1 && !this.inventoryList[0].sourceId) {
  993. this.inventoryList[0].measureQuantity =
  994. this.inventoryList[0].measureQuantity -
  995. this.lossNumber -
  996. this.lossNumberUnqualified -
  997. this.retainedSampleQuantity -
  998. this.retainedSampleUnqualified;
  999. }
  1000. },
  1001. async handleDispose() {
  1002. this.$refs['disposeForm'].validate(async (valid) => {
  1003. let ids = this.selection.map((item) => item.id);
  1004. this.poList.forEach((item, index) => {
  1005. if (ids.includes(item.id)) {
  1006. this.$set(this.poList[index], 'disposalStatus', 1);
  1007. for (const key in this.disposeForm) {
  1008. this.$set(this.poList[index], key, this.disposeForm[key]);
  1009. }
  1010. }
  1011. });
  1012. this.dialogVisible = false;
  1013. this.$refs.table.clearSelection();
  1014. this.setQualifiedNumber();
  1015. });
  1016. },
  1017. validate() {},
  1018. getValue() {
  1019. let unqualifiedProducts = { id: this.id };
  1020. let isNodisposeType = false;
  1021. if (this.poList.length > 0) {
  1022. unqualifiedProducts.poList = this.poList.map((item) => {
  1023. if (!item.disposeType && this.businessType.includes('不良品处置')) {
  1024. isNodisposeType = true;
  1025. }
  1026. item.qualityResults = 1;
  1027. item.qualityStatus = 1;
  1028. item.qualityWorkOrderId = this.qualityWorkerId;
  1029. return item;
  1030. });
  1031. [
  1032. 'batchNo',
  1033. 'brandNum',
  1034. 'categoryCode',
  1035. 'categoryId',
  1036. 'categoryName',
  1037. 'factoriesId',
  1038. 'measureUnit',
  1039. 'modelType',
  1040. 'produceRoutingId',
  1041. 'produceRoutingName',
  1042. 'productCategory'
  1043. ].forEach((item) => {
  1044. unqualifiedProducts[item] = this.poList[0][item];
  1045. });
  1046. unqualifiedProducts.qualityType = this.qualityType;
  1047. unqualifiedProducts.qualityWorkOrderId = this.qualityWorkerId;
  1048. unqualifiedProducts.sourceCode = this.workOrderCode;
  1049. unqualifiedProducts.quantity = this.poList.reduce(
  1050. (total, item) => total + item.measureQuantity,
  1051. 0
  1052. );
  1053. unqualifiedProducts.sourceType = this.workOrderId ? 1 : 0;
  1054. return isNodisposeType ? 'isNodisposeType' : unqualifiedProducts;
  1055. }
  1056. return null;
  1057. },
  1058. chooseWarehouse(item) {
  1059. // console.log(item);
  1060. this.disposeForm.depotId = item.id;
  1061. this.disposeForm.depotName = item.name;
  1062. }
  1063. },
  1064. watch: {
  1065. 'disposeForm.disposeType': {
  1066. handler(newVal, oldVal) {
  1067. if (newVal == 6) {
  1068. this.rules.depotId = [];
  1069. } else {
  1070. this.rules.depotId = [
  1071. { required: true, message: '请选择仓库', trigger: 'change' }
  1072. ];
  1073. }
  1074. this.disposeForm.sampleCondition = '';
  1075. this.disposeForm.sampleDate = '';
  1076. this.disposeForm.samplePlace = '';
  1077. this.disposeForm.sampleRemark = '';
  1078. this.disposeForm.producerManufacturer = '';
  1079. this.disposeForm.depotId = '';
  1080. this.disposeForm.depotName = '';
  1081. this.disposeForm.taskId = '';
  1082. }
  1083. }
  1084. }
  1085. };
  1086. </script>
  1087. <style lang="scss" scoped>
  1088. .unacceptedProductSelect {
  1089. display: flex;
  1090. flex-direction: column;
  1091. align-items: center;
  1092. }
  1093. </style>