index.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <ele-modal
  3. title="新建领料单"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :maxable="true"
  9. :close-on-press-escape="false"
  10. id="formId"
  11. append-to-body
  12. width="90%"
  13. @update:fullscreen="fullscreen"
  14. :fullscreen="isFullscreen"
  15. :height="dialogDynamicHeight"
  16. >
  17. <el-form>
  18. <el-row :gutter="24">
  19. <el-col :span="6">
  20. <el-form-item label="领料单编号" prop="pickCode" label-width="90px">
  21. <el-input v-model="pickCode" disabled=""></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="领料单名称" prop="pickName" label-width="90px">
  26. <el-input v-model="pickName" style="width: 260px"></el-input>
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. <div v-for="(item, idx) in workList" :key="idx">
  32. <el-form
  33. :ref="`formRef${idx}`"
  34. :model="{ pickList: item }"
  35. :rules="tableRules"
  36. size="mini"
  37. label-position="left"
  38. >
  39. <div class="tableZ_box">
  40. <div class="row">
  41. <div class="col">
  42. <div class="name">生产工单号</div>
  43. <div class="content">{{ item.code }}</div>
  44. </div>
  45. <div class="col">
  46. <div class="name">产品编码</div>
  47. <div class="content">{{ item.productCode }}</div>
  48. </div>
  49. <div class="col">
  50. <div class="name">产品名称</div>
  51. <div class="content">{{ item.productName }}</div>
  52. </div>
  53. <div class="col">
  54. <div class="name">型号</div>
  55. <div class="content">{{ item.model }}</div>
  56. </div>
  57. <div class="col">
  58. <div class="name">规格</div>
  59. <div class="content">{{ item.specification }}</div>
  60. </div>
  61. <div class="col">
  62. <div class="name">颜色</div>
  63. <div class="content">{{ item.colorKey }}</div>
  64. </div>
  65. <div class="col">
  66. <div class="name">要求生产数量</div>
  67. <div class="content">{{ item.formingNum }}{{ item.unit }}</div>
  68. </div>
  69. <!-- <div class="col">
  70. <div class="name">批次号</div>
  71. <div class="content">{{ item.batchNo }}</div>
  72. </div> -->
  73. <div class="col pd6" v-if="clientEnvironmentId != 21">
  74. <el-button
  75. type="primary"
  76. size="mini"
  77. @click="openPicking(item.id, item)"
  78. >新增</el-button
  79. >
  80. <el-button type="primary" size="mini" @click="batchDelete"
  81. >批量删除</el-button
  82. >
  83. </div>
  84. </div>
  85. </div>
  86. <div>
  87. <el-table
  88. :ref="`tableRef${idx}`"
  89. class="table_content"
  90. :max-height="tabalHeight"
  91. :data="item.pickList"
  92. tooltip-effect="dark"
  93. style="width: 100%"
  94. stripe
  95. border
  96. @selection-change="handleSelectionChange"
  97. >
  98. <el-table-column type="selection" width="55" align="center">
  99. </el-table-column>
  100. <el-table-column label="序号" type="index" width="60">
  101. <template slot-scope="{ row, $index }">
  102. {{ $index + 1 }}
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="类型" prop="rootCategoryLevelId" width="80">
  106. <template slot-scope="{ row, $index }">
  107. <el-tag size="mini">{{
  108. typeName[Number(row.rootCategoryLevelId)]
  109. }}</el-tag>
  110. </template>
  111. </el-table-column>
  112. <el-table-column
  113. label="编码"
  114. prop="assetCode"
  115. show-overflow-tooltip
  116. >
  117. <template slot-scope="{ row, $index }">
  118. <span
  119. v-if="
  120. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  121. row.isBom == 1
  122. "
  123. style="color: #faad14"
  124. >
  125. {{ row.categoryCode }}
  126. </span>
  127. <span v-else>
  128. {{
  129. row.rootCategoryLevelId == 4 ? row.codeNumber : row.code
  130. }}</span
  131. >
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="批次号" prop="batchNo"> </el-table-column>
  135. <el-table-column label="名称" prop="name" show-overflow-tooltip>
  136. <template slot-scope="{ row, $index }">
  137. <span
  138. v-if="
  139. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  140. row.isBom == 1
  141. "
  142. >
  143. {{ row.categoryName }}
  144. </span>
  145. <span v-else> {{ row.name }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column
  149. label="型号"
  150. prop="modelType"
  151. show-overflow-tooltip
  152. >
  153. </el-table-column>
  154. <el-table-column
  155. label="规格"
  156. prop="specification"
  157. show-overflow-tooltip
  158. >
  159. </el-table-column>
  160. <el-table-column label="数量" prop="demandQuantity" width="140">
  161. <template slot-scope="{ row, $index }">
  162. <el-form-item>
  163. <el-input
  164. v-model="row.demandQuantity"
  165. @input="changeInput(row, $index)"
  166. size="mini"
  167. style="width: 120px"
  168. >
  169. <template slot="append">{{ row.measuringUnit }}</template>
  170. </el-input>
  171. </el-form-item>
  172. </template>
  173. </el-table-column>
  174. <!-- <el-table-column label="计量库存数量" prop="availableCountBase">
  175. <template slot-scope="{ row, $index }">
  176. {{ row.availableCountBase }} {{ row.measuringUnit }}
  177. </template>
  178. </el-table-column> -->
  179. <el-table-column
  180. label="计量库存数量"
  181. prop="availableCountBase"
  182. width="220"
  183. show-overflow-tooltip
  184. >
  185. <template slot-scope="{ row, $index }">
  186. <div v-for="it of row.warehouseList">
  187. <span
  188. v-if="it.availableCountBase != '0'"
  189. @click="chooseInventoryData(row, it, $index)"
  190. style="cursor: pointer"
  191. >{{ it.name ? it.name : it.warehouse_name }}库存数:<span
  192. style="color: green"
  193. >{{ it.availableCountBase }}</span
  194. >{{ row.measuringUnit }}</span
  195. >
  196. </div>
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="领料仓库" prop="warehouseId" width="180">
  200. <template slot-scope="{ row, $index }">
  201. <div
  202. v-if="
  203. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  204. row.isBom == 1
  205. "
  206. >
  207. <el-select
  208. v-model="row.warehouseIdList"
  209. placeholder="请选择"
  210. filterable
  211. multiple
  212. @change="changeWarehouse(row, $index)"
  213. >
  214. <el-option
  215. v-for="item in row.warehouseList"
  216. :label="item.name"
  217. :value="item.id"
  218. :key="item.id"
  219. >
  220. </el-option>
  221. </el-select>
  222. </div>
  223. <div v-else-if="clientEnvironmentId == 21">
  224. <el-select
  225. v-model="row.warehouseId"
  226. placeholder="请选择"
  227. filterable
  228. >
  229. <el-option
  230. v-for="item in row.warehouseList"
  231. :label="item.name"
  232. :value="item.id"
  233. :key="item.id"
  234. >
  235. </el-option>
  236. </el-select>
  237. </div>
  238. <div v-else>
  239. <el-select
  240. v-model="row.warehouseIdList"
  241. placeholder="请选择"
  242. filterable
  243. multiple
  244. @change="changeWarehouse(row, $index)"
  245. >
  246. <el-option
  247. v-for="item in row.warehouseList"
  248. :label="item.warehouse_name"
  249. :value="item.warehouse_id"
  250. :key="item.warehouse_id"
  251. >
  252. </el-option>
  253. </el-select>
  254. </div>
  255. </template>
  256. </el-table-column>
  257. <el-table-column
  258. label="领料信息"
  259. prop="warehousePick"
  260. width="340"
  261. show-overflow-tooltip
  262. >
  263. <template slot-scope="{ $index, row }">
  264. <div
  265. v-for="it of row.warehousePick"
  266. :key="it.id"
  267. style="display: flex; flex-direction: row"
  268. >
  269. <span>{{ it.warehouseName }}</span
  270. >,批次号:{{ it.batchNo }},出库数:<span
  271. style="color: green"
  272. >{{ it.demandQuantity }}</span
  273. >
  274. {{ row.measuringUnit }}
  275. </div>
  276. </template>
  277. </el-table-column>
  278. <el-table-column label="操作" width="100px">
  279. <template slot-scope="{ $index, row }">
  280. <el-link type="danger" @click="removeItem(idx, $index)"
  281. >删除</el-link
  282. >
  283. </template>
  284. </el-table-column>
  285. </el-table>
  286. </div>
  287. </el-form>
  288. </div>
  289. <template slot="footer">
  290. <el-button size="mini" @click="handleClose">取 消</el-button>
  291. <el-button
  292. size="mini"
  293. type="primary"
  294. :loading="loadingBtn"
  295. @click="save()"
  296. >确 定</el-button
  297. >
  298. </template>
  299. <pickingList
  300. isType="pick"
  301. ref="pickingListRef"
  302. @allSelection="allSelection"
  303. ></pickingList>
  304. <AssetsDialog
  305. ref="assetsRef"
  306. :treeIds="treeId"
  307. @detailData="detailData"
  308. ></AssetsDialog>
  309. </ele-modal>
  310. </template>
  311. <script>
  312. import pickingList from './newPickingList.vue';
  313. import {
  314. workorderList,
  315. getCode,
  316. getInventoryTotal,
  317. znworkorderList
  318. } from '@/api/produce/workOrder';
  319. import { typeName } from '../common.js';
  320. import { batchSave, znfindVoucherList } from '@/api/produce/picking';
  321. import AssetsDialog from './AssetsDialog.vue';
  322. export default {
  323. components: {
  324. pickingList,
  325. AssetsDialog
  326. },
  327. props: {
  328. workListIds: {
  329. type: Array,
  330. default() {
  331. return [];
  332. }
  333. }
  334. },
  335. data() {
  336. return {
  337. visible: true,
  338. workList: [],
  339. rules: {},
  340. pickCode: null,
  341. pickName: null,
  342. typeName,
  343. tableRules: {},
  344. loadingBtn: false,
  345. contentStyleObj: {
  346. height: ''
  347. },
  348. isFullscreen: false,
  349. tabalHeight: 300,
  350. treeId: [],
  351. selectionData: []
  352. // warehouseIdList: []
  353. };
  354. },
  355. computed: {
  356. taskObj() {
  357. return this.$store.state.user.taskObj;
  358. },
  359. clientEnvironmentId() {
  360. return this.$store.state.user.info.clientEnvironmentId;
  361. },
  362. dialogDynamicHeight() {
  363. if (this.isFullscreen) {
  364. // 全屏时,高度为窗口高度
  365. console.log(window.innerHeight + 'px', '全屏高度');
  366. this.tabalHeight = window.innerHeight - 200;
  367. return window.innerHeight + 'px';
  368. } else {
  369. this.tabalHeight = 300;
  370. return '500px';
  371. }
  372. }
  373. },
  374. watch: {},
  375. methods: {
  376. getList() {
  377. let param = {
  378. ids: this.workListIds,
  379. taskId: this.taskObj.id
  380. };
  381. if (this.clientEnvironmentId == 21) {
  382. znworkorderList(param).then((res) => {
  383. let arr = res.map((e) => {
  384. e.bomDetailDTOS.map((d) => {
  385. e.warehouseId =
  386. d.warehouseList.length > 0 ? d.warehouseList[0].id : '';
  387. });
  388. e.pickList = [...e.bomDetailDTOS];
  389. e.bomDetailDTOS = [];
  390. return e;
  391. });
  392. this.pickName = res[0].productName + '领料';
  393. arr[0].pickList.forEach((it) => {
  394. it.warehouseIdList = [];
  395. it.warehouseIdList.push(it.warehouseId);
  396. it.warehouseList.forEach((i) => {
  397. i.warehouse_name = i.name;
  398. i.warehouse_id = i.id;
  399. });
  400. });
  401. // arr.bomDetailDTOS.map(v=>{
  402. // this.getInventoryTotalFn(v.id)
  403. // })
  404. // getInventoryTotal
  405. // this.workList = arr;
  406. console.log(arr, '12344');
  407. this.$set(this, 'workList', arr);
  408. this.getOrderCode();
  409. this.$forceUpdate();
  410. });
  411. } else {
  412. workorderList(param).then((res) => {
  413. let arr = res.map((e) => {
  414. e.bomDetailDTOS.map((d) => {
  415. e.warehouseId =
  416. d.warehouseList.length > 0 ? d.warehouseList[0].id : '';
  417. // this.getInventoryTotalFn([d.categoryCode])
  418. });
  419. e.pickList = [...e.bomDetailDTOS];
  420. e.bomDetailDTOS = [];
  421. return e;
  422. });
  423. this.pickName = res[0].productName + '领料';
  424. arr[0].pickList.forEach((it) => {
  425. it.warehouseIdList = [];
  426. if (it.warehouseId) {
  427. it.warehouseIdList.push(it.warehouseId);
  428. } else {
  429. if (it.warehouseList.length != 0) {
  430. it.warehouseIdList.push(it.warehouseList[0].id);
  431. }
  432. }
  433. it.warehouseList.forEach((i) => {
  434. i.warehouse_name = i.name;
  435. i.warehouse_id = i.id;
  436. });
  437. });
  438. console.log(arr, 'e.pickList');
  439. // arr.bomDetailDTOS.map(v=>{
  440. // this.getInventoryTotalFn(v.id)
  441. // })
  442. // getInventoryTotal
  443. // this.workList = arr;
  444. this.$set(this, 'workList', arr);
  445. this.getOrderCode();
  446. // this.getInventoryTotalFn();
  447. this.$forceUpdate();
  448. });
  449. }
  450. },
  451. changeWarehouse(item, index) {
  452. // const data = [];
  453. // if (item.warehouseIdList.length != 0) {
  454. // item.warehouseIdList.forEach((it) => {
  455. // const chooseData = item.warehouseList.find((item) => item.id == it);
  456. // data.push(chooseData);
  457. // });
  458. // }
  459. // const pickData = [...data];
  460. // if (data.length != 0) {
  461. // const totalNum = data.reduce((acc, pro) => {
  462. // return pro.availableCountBase
  463. // ? acc + Number(pro.availableCountBase)
  464. // : acc;
  465. // }, 0);
  466. // this.$set(
  467. // this.workList[0].pickList[index],
  468. // 'availableCountBase',
  469. // totalNum
  470. // );
  471. // this.$set(
  472. // this.workList[0].pickList[index],
  473. // 'warehousePick',
  474. // pickData
  475. // );
  476. // console.log(this.workList[0], 'this.workList[0]');
  477. // this.$forceUpdate();
  478. // } else {
  479. // this.$set(this.workList[0].pickList[index], 'warehousePick', []);
  480. // this.$set(this.workList[0].pickList[index], 'availableCountBase', 0);
  481. // this.$set(this.workList[0].pickList[index], 'demandQuantity', 0);
  482. // }
  483. },
  484. // changeInput(item, index) {
  485. // if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
  486. // this.$set(
  487. // this.workList[0].pickList[index],
  488. // 'demandQuantity',
  489. // Number(item.availableCountBase)
  490. // );
  491. // const idsList = [];
  492. // item.warehouseList.forEach((it) => {
  493. // idsList.push(it.warehouse_id);
  494. // });
  495. // this.$set(
  496. // this.workList[0].pickList[index],
  497. // 'warehouseIdList',
  498. // idsList
  499. // );
  500. // } else if (!Number(item.demandQuantity)) {
  501. // this.$set(this.workList[0].pickList[index], 'warehouseIdList', []);
  502. // } else {
  503. // const idsList = [];
  504. // let totalNum = 0;
  505. // for (let i = 0; i < item.warehouseList.length; i++) {
  506. // totalNum += Number(item.warehouseList[i].availableCountBase);
  507. // if (Number(item.demandQuantity) > totalNum) {
  508. // idsList.push(item.warehouseList[i].warehouse_id);
  509. // } else {
  510. // idsList.push(item.warehouseList[i].warehouse_id);
  511. // break;
  512. // }
  513. // }
  514. // this.$set(
  515. // this.workList[0].pickList[index],
  516. // 'warehouseIdList',
  517. // idsList
  518. // );
  519. // }
  520. // },
  521. changeInput(item, index) {
  522. const pickItem = this.workList[0].pickList[index];
  523. let value = String(item.demandQuantity ?? '');
  524. value = value.replace(/[^\d.]/g, '');
  525. value = value
  526. .replace(/\.{2,}/g, '.')
  527. .replace('.', '$#$')
  528. .replace(/\./g, '')
  529. .replace('$#$', '.');
  530. if (value.includes('.')) {
  531. const [intPart, decPart] = value.split('.');
  532. value = `${intPart}.${decPart.slice(0, 4)}`;
  533. }
  534. this.$set(pickItem, 'demandQuantity', value);
  535. const demandQty = Number(value);
  536. const maxQty = item.warehouseList.reduce((sum, cur) => {
  537. return sum + Number(cur.availableCountBase || 0);
  538. }, 0);
  539. // const maxQty = Number(item.availableCountBase) || 0;
  540. if (!demandQty) {
  541. this.$set(pickItem, 'warehouseIdList', []);
  542. return;
  543. }
  544. if (demandQty >= maxQty) {
  545. this.$set(pickItem, 'demandQuantity', maxQty);
  546. this.$set(
  547. pickItem,
  548. 'warehouseIdList',
  549. item.warehouseList.map((w) => w.warehouse_id)
  550. );
  551. return;
  552. }
  553. let total = 0;
  554. const idsList = [];
  555. for (const w of item.warehouseList) {
  556. total += Number(w.availableCountBase) || 0;
  557. idsList.push(w.warehouse_id);
  558. if (total >= demandQty) break;
  559. }
  560. this.$set(pickItem, 'warehouseIdList', idsList);
  561. },
  562. detailData(data, dimension, index) {
  563. const itemData = [];
  564. data.forEach((it) => {
  565. itemData.push({
  566. batchNo: it.batchNo,
  567. demandQuantity: it.measureQuantity,
  568. warehouseId: it.warehouseId,
  569. warehouseName: it.warehouseName
  570. });
  571. });
  572. const listData = [];
  573. if (this.workList[0].pickList[index].warehousePick) {
  574. this.workList[0].pickList[index].warehousePick.forEach((it) => {
  575. listData.push(it);
  576. });
  577. }
  578. itemData.forEach((it) => {
  579. listData.push(it);
  580. });
  581. const warehouseIdList = [];
  582. listData.forEach((it) => {
  583. warehouseIdList.push(it.warehouseId);
  584. });
  585. const uniqueArr = Array.from(new Set(warehouseIdList));
  586. this.$set(this.workList[0].pickList[index], 'warehousePick', listData);
  587. this.$set(
  588. this.workList[0].pickList[index],
  589. 'warehouseIdList',
  590. uniqueArr
  591. );
  592. const total = this.workList[0].pickList[index].warehousePick.reduce(
  593. (acc, pro) => {
  594. return pro.demandQuantity ? acc + Number(pro.demandQuantity) : acc;
  595. },
  596. 0
  597. );
  598. this.$set(this.workList[0].pickList[index], 'demandQuantity', total);
  599. this.$forceUpdate();
  600. },
  601. handleSelectionChange(val) {
  602. this.selectionData = val;
  603. },
  604. batchDelete() {
  605. if (this.selectionData.length == 0) {
  606. return this.$message.warning('请选择需要删除的领料数据!');
  607. }
  608. this.$confirm('此操作将删除领料数据, 是否继续?', '提示', {
  609. confirmButtonText: '确定',
  610. cancelButtonText: '取消',
  611. type: 'warning'
  612. })
  613. .then(() => {
  614. for (let item of this.selectionData) {
  615. const findIndex = this.workList[0].pickList.findIndex(
  616. (it) => item.id == it.id
  617. );
  618. this.workList[0].pickList.splice(findIndex, 1);
  619. }
  620. })
  621. .catch(() => {});
  622. },
  623. warehouseChangeNum(item, index) {
  624. item.warehousePick.forEach((it) => {
  625. if (Number(it.demandQuantity) > Number(it.availableCountBase)) {
  626. it.demandQuantity = it.availableCountBase;
  627. }
  628. const totalNum = item.warehousePick.reduce((acc, pro) => {
  629. return pro.demandQuantity ? acc + Number(pro.demandQuantity) : acc;
  630. }, 0);
  631. this.$set(
  632. this.workList[0].pickList[index],
  633. 'demandQuantity',
  634. totalNum
  635. );
  636. });
  637. },
  638. async getInventoryTotalFn(id) {
  639. let ids = [];
  640. this.workList.map((item) => {
  641. item.pickList.map((pitem) => {
  642. ids.push(pitem.categoryCode);
  643. });
  644. });
  645. if (ids.length == 0) {
  646. return;
  647. }
  648. const res = await getInventoryTotal(ids);
  649. res.map((ritem) => {
  650. this.workList.map((item) => {
  651. item.pickList.map((pitem) => {
  652. if (pitem.categoryCode == ritem.code) {
  653. pitem.availableCountBase = ritem.availableCountBase;
  654. }
  655. });
  656. });
  657. });
  658. },
  659. async getOrderCode() {
  660. this.pickCode = await getCode('pick_order_code');
  661. },
  662. removeItem(idx, index) {
  663. this.workList[idx].pickList.splice(index, 1);
  664. },
  665. handleClose() {
  666. this.loadingBtn = false;
  667. this.$emit('close', false);
  668. },
  669. openPicking(id, item) {
  670. this.$refs.pickingListRef.open(id, item, '选择列表');
  671. },
  672. chooseInventoryData(item, warehouseItem, index) {
  673. this.treeId.push(item.rootCategoryLevelId);
  674. this.$refs.assetsRef.open(item, warehouseItem, index);
  675. },
  676. allSelection(id, list) {
  677. list.forEach((item) => {
  678. item.code = item.categoryCode;
  679. item.name = item.categoryName;
  680. item.modelType = item.modelType ? item.modelType : item.categoryModel;
  681. item.measuringUnit = item.measuringUnit
  682. ? item.measuringUnit
  683. : item.measureUnit;
  684. item.unit = item.unit ? item.unit : item.measureUnit;
  685. });
  686. this.workList.forEach((e) => {
  687. if (e.id == id) {
  688. const newData = [];
  689. if (list.length != 0) {
  690. list.forEach((it) => {
  691. newData.push(this.deepCopy(it));
  692. });
  693. }
  694. // e.pickList = list;
  695. e.pickList = newData;
  696. this.$forceUpdate();
  697. }
  698. });
  699. },
  700. deepCopy(obj, hash = new WeakMap()) {
  701. if (obj === null) return null;
  702. if (obj instanceof Date) return new Date(obj);
  703. if (obj instanceof RegExp) return new RegExp(obj);
  704. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  705. if (hash.has(obj)) return hash.get(obj);
  706. const result = Array.isArray(obj) ? [] : {};
  707. hash.set(obj, result);
  708. return Object.keys(obj).reduce((acc, key) => {
  709. acc[key] = this.deepCopy(obj[key], hash);
  710. return acc;
  711. }, result);
  712. },
  713. save() {
  714. if (this.workList.length > 0) {
  715. let bol;
  716. let _i;
  717. bol = this.workList.every((e, i) => {
  718. _i = i;
  719. return (
  720. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  721. e.pickList.length > 0
  722. );
  723. });
  724. if (!bol) {
  725. this.$message.warning(
  726. `生成工单${this.workList[_i].code}领料不能为空`
  727. );
  728. return false;
  729. }
  730. }
  731. if (this.workList.length > 0) {
  732. let name;
  733. let bol2;
  734. let _i;
  735. this.workList.forEach((e, i) => {
  736. _i = i;
  737. console.log(e.pickList);
  738. bol2 = e.pickList.every((y) => {
  739. name = y.name;
  740. return (
  741. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  742. Number(y.demandQuantity) > 0
  743. );
  744. });
  745. });
  746. if (!bol2) {
  747. this.$message.warning(
  748. `${this.workList[_i].code}的${name}数量不能为空`
  749. );
  750. return false;
  751. }
  752. }
  753. let _arr = [];
  754. _arr = this.workList.map((m) => {
  755. m.instanceList = [];
  756. m.bomDetailDTOSList = [];
  757. m.pickList.forEach((e) => {
  758. if (
  759. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  760. e.isBom == 1
  761. ) {
  762. m.bomDetailDTOSList.push(e);
  763. } else {
  764. m.instanceList.push(e);
  765. }
  766. });
  767. m.workOrderId = m.id;
  768. return {
  769. ...m
  770. };
  771. });
  772. this.loadingBtn = true;
  773. // _arr.forEach((item) => {
  774. // item.pickList.forEach((it) => {
  775. // const warehousePick = [];
  776. // if (it.warehouseIdList.length != 0) {
  777. // it.warehouseIdList.forEach((i) => {
  778. // const data = it.warehouseList.find((ii) => ii.id == i);
  779. // if (data) {
  780. // warehousePick.push({
  781. // availableCountBase: data.availableCountBase,
  782. // demandQuantity: data.demandQuantity,
  783. // warehouseId: data.id
  784. // });
  785. // }
  786. // });
  787. // }
  788. // it.warehousePick = warehousePick;
  789. // });
  790. // });
  791. console.log(_arr, '_arr');
  792. // return;
  793. // if (this.clientEnvironmentId == 21) {
  794. // let param = {
  795. // workOrderId: this.workListIds[0],
  796. // pickingCode: this.pickCode
  797. // };
  798. // znfindVoucherList(param).then((res) => {
  799. // this.loadingBtn = false;
  800. // this.$message.success('领料成功');
  801. // });
  802. // }
  803. let param = {
  804. allPickList: _arr,
  805. pickName: this.pickName,
  806. pickCode: this.pickCode
  807. };
  808. batchSave(param)
  809. .then((res) => {
  810. this.loadingBtn = false;
  811. this.$message.success('领料成功');
  812. this.$emit('close', true);
  813. })
  814. .catch((err) => {
  815. this.loadingBtn = false;
  816. });
  817. },
  818. fullscreen() {
  819. this.isFullscreen = !this.isFullscreen;
  820. }
  821. },
  822. created() {
  823. this.getList();
  824. }
  825. };
  826. </script>
  827. <style lang="scss" scoped>
  828. .table_content {
  829. margin-bottom: 10px;
  830. }
  831. .tableZ_box {
  832. border: 1px solid #e3e5e5;
  833. margin: 6px 0;
  834. &:last-child {
  835. border-bottom: none;
  836. }
  837. .row {
  838. width: 100%;
  839. display: flex;
  840. }
  841. .col {
  842. width: calc(100% / 5) !important;
  843. display: flex;
  844. align-items: center;
  845. // min-width: 200px;
  846. min-height: 32px;
  847. border-bottom: 1px solid #e3e5e5;
  848. border-right: 1px solid #e3e5e5;
  849. &:last-child {
  850. border-right: none;
  851. }
  852. .name {
  853. display: flex;
  854. align-items: center;
  855. padding: 4px;
  856. width: 60px;
  857. height: 100%;
  858. background-color: #d0e4d5;
  859. color: #000;
  860. }
  861. .content {
  862. padding: 4px 6px;
  863. color: #000;
  864. }
  865. }
  866. .pd6 {
  867. padding: 0 6px;
  868. }
  869. }
  870. ::v-deep .pick-input.el-input--medium .el-input__inner {
  871. height: 22px;
  872. line-height: 22px;
  873. }
  874. // ::v-deep .el-select__tags {
  875. // flex-wrap: nowrap;
  876. // overflow: auto;
  877. // }
  878. // ::v-deep .el-select__tags-text {
  879. // max-width: 90px;
  880. // }
  881. // ::v-deep .el-select__tags::-webkit-scrollbar {
  882. // height: 2px !important;
  883. // }
  884. </style>
  885. <style>
  886. /* :v-deep .el-form-item__error {
  887. bottom: -6px !important;
  888. } */
  889. </style>