index.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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. // console.log(value, 'value');
  535. // this.$set(pickItem, 'demandQuantity', value);
  536. // console.log(pickItem, 'pickItem');
  537. // const demandQty = Number(value);
  538. // console.log(demandQty, 'demandQty');
  539. // const maxQty = Number(item.availableCountBase) || 0;
  540. // console.log(item, 'item');
  541. // console.log(maxQty, 'maxQty');
  542. // if (!demandQty) {
  543. // this.$set(pickItem, 'warehouseIdList', []);
  544. // return;
  545. // }
  546. // if (demandQty >= maxQty) {
  547. // this.$set(pickItem, 'demandQuantity', maxQty);
  548. // this.$set(
  549. // pickItem,
  550. // 'warehouseIdList',
  551. // item.warehouseList.map((w) => w.warehouse_id)
  552. // );
  553. // return;
  554. // }
  555. // let total = 0;
  556. // const idsList = [];
  557. // for (const w of item.warehouseList) {
  558. // total += Number(w.availableCountBase) || 0;
  559. // idsList.push(w.warehouse_id);
  560. // if (total >= demandQty) break;
  561. // }
  562. // this.$set(pickItem, 'warehouseIdList', idsList);
  563. // },
  564. detailData(data, dimension, index) {
  565. const itemData = [];
  566. data.forEach((it) => {
  567. itemData.push({
  568. batchNo: it.batchNo,
  569. demandQuantity: it.measureQuantity,
  570. warehouseId: it.warehouseId,
  571. warehouseName: it.warehouseName
  572. });
  573. });
  574. const listData = [];
  575. if (this.workList[0].pickList[index].warehousePick) {
  576. this.workList[0].pickList[index].warehousePick.forEach((it) => {
  577. listData.push(it);
  578. });
  579. }
  580. itemData.forEach((it) => {
  581. listData.push(it);
  582. });
  583. const warehouseIdList = [];
  584. listData.forEach((it) => {
  585. warehouseIdList.push(it.warehouseId);
  586. });
  587. const uniqueArr = Array.from(new Set(warehouseIdList));
  588. this.$set(this.workList[0].pickList[index], 'warehousePick', listData);
  589. this.$set(
  590. this.workList[0].pickList[index],
  591. 'warehouseIdList',
  592. uniqueArr
  593. );
  594. const total = this.workList[0].pickList[index].warehousePick.reduce(
  595. (acc, pro) => {
  596. return pro.demandQuantity ? acc + Number(pro.demandQuantity) : acc;
  597. },
  598. 0
  599. );
  600. this.$set(this.workList[0].pickList[index], 'demandQuantity', total);
  601. this.$forceUpdate();
  602. },
  603. handleSelectionChange(val) {
  604. this.selectionData = val;
  605. },
  606. batchDelete() {
  607. if (this.selectionData.length == 0) {
  608. return this.$message.warning('请选择需要删除的领料数据!');
  609. }
  610. this.$confirm('此操作将删除领料数据, 是否继续?', '提示', {
  611. confirmButtonText: '确定',
  612. cancelButtonText: '取消',
  613. type: 'warning'
  614. })
  615. .then(() => {
  616. for (let item of this.selectionData) {
  617. const findIndex = this.workList[0].pickList.findIndex(
  618. (it) => item.id == it.id
  619. );
  620. this.workList[0].pickList.splice(findIndex, 1);
  621. }
  622. })
  623. .catch(() => {});
  624. },
  625. warehouseChangeNum(item, index) {
  626. item.warehousePick.forEach((it) => {
  627. if (Number(it.demandQuantity) > Number(it.availableCountBase)) {
  628. it.demandQuantity = it.availableCountBase;
  629. }
  630. const totalNum = item.warehousePick.reduce((acc, pro) => {
  631. return pro.demandQuantity ? acc + Number(pro.demandQuantity) : acc;
  632. }, 0);
  633. this.$set(
  634. this.workList[0].pickList[index],
  635. 'demandQuantity',
  636. totalNum
  637. );
  638. });
  639. },
  640. async getInventoryTotalFn(id) {
  641. let ids = [];
  642. this.workList.map((item) => {
  643. item.pickList.map((pitem) => {
  644. ids.push(pitem.categoryCode);
  645. });
  646. });
  647. if (ids.length == 0) {
  648. return;
  649. }
  650. const res = await getInventoryTotal(ids);
  651. res.map((ritem) => {
  652. this.workList.map((item) => {
  653. item.pickList.map((pitem) => {
  654. if (pitem.categoryCode == ritem.code) {
  655. pitem.availableCountBase = ritem.availableCountBase;
  656. }
  657. });
  658. });
  659. });
  660. },
  661. async getOrderCode() {
  662. this.pickCode = await getCode('pick_order_code');
  663. },
  664. removeItem(idx, index) {
  665. this.workList[idx].pickList.splice(index, 1);
  666. },
  667. handleClose() {
  668. this.loadingBtn = false;
  669. this.$emit('close', false);
  670. },
  671. openPicking(id, item) {
  672. this.$refs.pickingListRef.open(id, item, '选择列表');
  673. },
  674. chooseInventoryData(item, warehouseItem, index) {
  675. this.treeId.push(item.rootCategoryLevelId);
  676. this.$refs.assetsRef.open(item, warehouseItem, index);
  677. },
  678. allSelection(id, list) {
  679. list.forEach((item) => {
  680. item.code = item.categoryCode;
  681. item.name = item.categoryName;
  682. item.modelType = item.modelType ? item.modelType : item.categoryModel;
  683. item.measuringUnit = item.measuringUnit
  684. ? item.measuringUnit
  685. : item.measureUnit;
  686. item.unit = item.unit ? item.unit : item.measureUnit;
  687. });
  688. this.workList.forEach((e) => {
  689. if (e.id == id) {
  690. const newData = [];
  691. if (list.length != 0) {
  692. list.forEach((it) => {
  693. newData.push(this.deepCopy(it));
  694. });
  695. }
  696. // e.pickList = list;
  697. e.pickList = newData;
  698. this.$forceUpdate();
  699. }
  700. });
  701. },
  702. deepCopy(obj, hash = new WeakMap()) {
  703. if (obj === null) return null;
  704. if (obj instanceof Date) return new Date(obj);
  705. if (obj instanceof RegExp) return new RegExp(obj);
  706. if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
  707. if (hash.has(obj)) return hash.get(obj);
  708. const result = Array.isArray(obj) ? [] : {};
  709. hash.set(obj, result);
  710. return Object.keys(obj).reduce((acc, key) => {
  711. acc[key] = this.deepCopy(obj[key], hash);
  712. return acc;
  713. }, result);
  714. },
  715. save() {
  716. if (this.workList.length > 0) {
  717. let bol;
  718. let _i;
  719. bol = this.workList.every((e, i) => {
  720. _i = i;
  721. return (
  722. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  723. e.pickList.length > 0
  724. );
  725. });
  726. if (!bol) {
  727. this.$message.warning(
  728. `生成工单${this.workList[_i].code}领料不能为空`
  729. );
  730. return false;
  731. }
  732. }
  733. if (this.workList.length > 0) {
  734. let name;
  735. let bol2;
  736. let _i;
  737. this.workList.forEach((e, i) => {
  738. _i = i;
  739. console.log(e.pickList);
  740. bol2 = e.pickList.every((y) => {
  741. name = y.name;
  742. return (
  743. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  744. Number(y.demandQuantity) > 0
  745. );
  746. });
  747. });
  748. if (!bol2) {
  749. this.$message.warning(
  750. `${this.workList[_i].code}的${name}数量不能为空`
  751. );
  752. return false;
  753. }
  754. }
  755. let _arr = [];
  756. _arr = this.workList.map((m) => {
  757. m.instanceList = [];
  758. m.bomDetailDTOSList = [];
  759. m.pickList.forEach((e) => {
  760. if (
  761. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  762. e.isBom == 1
  763. ) {
  764. m.bomDetailDTOSList.push(e);
  765. } else {
  766. m.instanceList.push(e);
  767. }
  768. });
  769. m.workOrderId = m.id;
  770. return {
  771. ...m
  772. };
  773. });
  774. this.loadingBtn = true;
  775. // _arr.forEach((item) => {
  776. // item.pickList.forEach((it) => {
  777. // const warehousePick = [];
  778. // if (it.warehouseIdList.length != 0) {
  779. // it.warehouseIdList.forEach((i) => {
  780. // const data = it.warehouseList.find((ii) => ii.id == i);
  781. // if (data) {
  782. // warehousePick.push({
  783. // availableCountBase: data.availableCountBase,
  784. // demandQuantity: data.demandQuantity,
  785. // warehouseId: data.id
  786. // });
  787. // }
  788. // });
  789. // }
  790. // it.warehousePick = warehousePick;
  791. // });
  792. // });
  793. console.log(_arr, '_arr');
  794. // return;
  795. // if (this.clientEnvironmentId == 21) {
  796. // let param = {
  797. // workOrderId: this.workListIds[0],
  798. // pickingCode: this.pickCode
  799. // };
  800. // znfindVoucherList(param).then((res) => {
  801. // this.loadingBtn = false;
  802. // this.$message.success('领料成功');
  803. // });
  804. // }
  805. let param = {
  806. allPickList: _arr,
  807. pickName: this.pickName,
  808. pickCode: this.pickCode
  809. };
  810. batchSave(param)
  811. .then((res) => {
  812. this.loadingBtn = false;
  813. this.$message.success('领料成功');
  814. this.$emit('close', true);
  815. })
  816. .catch((err) => {
  817. this.loadingBtn = false;
  818. });
  819. },
  820. fullscreen() {
  821. this.isFullscreen = !this.isFullscreen;
  822. }
  823. },
  824. created() {
  825. this.getList();
  826. }
  827. };
  828. </script>
  829. <style lang="scss" scoped>
  830. .table_content {
  831. margin-bottom: 10px;
  832. }
  833. .tableZ_box {
  834. border: 1px solid #e3e5e5;
  835. margin: 6px 0;
  836. &:last-child {
  837. border-bottom: none;
  838. }
  839. .row {
  840. width: 100%;
  841. display: flex;
  842. }
  843. .col {
  844. width: calc(100% / 5) !important;
  845. display: flex;
  846. align-items: center;
  847. // min-width: 200px;
  848. min-height: 32px;
  849. border-bottom: 1px solid #e3e5e5;
  850. border-right: 1px solid #e3e5e5;
  851. &:last-child {
  852. border-right: none;
  853. }
  854. .name {
  855. display: flex;
  856. align-items: center;
  857. padding: 4px;
  858. width: 60px;
  859. height: 100%;
  860. background-color: #d0e4d5;
  861. color: #000;
  862. }
  863. .content {
  864. padding: 4px 6px;
  865. color: #000;
  866. }
  867. }
  868. .pd6 {
  869. padding: 0 6px;
  870. }
  871. }
  872. ::v-deep .pick-input.el-input--medium .el-input__inner {
  873. height: 22px;
  874. line-height: 22px;
  875. }
  876. // ::v-deep .el-select__tags {
  877. // flex-wrap: nowrap;
  878. // overflow: auto;
  879. // }
  880. // ::v-deep .el-select__tags-text {
  881. // max-width: 90px;
  882. // }
  883. // ::v-deep .el-select__tags::-webkit-scrollbar {
  884. // height: 2px !important;
  885. // }
  886. </style>
  887. <style>
  888. /* :v-deep .el-form-item__error {
  889. bottom: -6px !important;
  890. } */
  891. </style>