unqualifiedProduct.vue 29 KB

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