index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. <template>
  2. <!-- 入库报工 报工列表 -->
  3. <div>
  4. <div class="top_fixed">
  5. <el-button type="primary" size="mini" @click="save">一键报工</el-button>
  6. </div>
  7. <div class="warehousing_box">
  8. <div v-for="(item, index) in List" :key="index" class="card_box">
  9. <div class="title_box rx-bc">
  10. <div class="name">工单信息</div>
  11. </div>
  12. <workOrderBom :item="item" v-if="item"></workOrderBom>
  13. <!-- 报工时间 -->
  14. <div>
  15. <div class="title_box rx-bc">
  16. <div class="name">报工时间</div>
  17. </div>
  18. <el-date-picker
  19. v-model="item.workReportInfo.executorTime"
  20. type="datetime"
  21. value-format="yyyy-MM-dd HH:mm:ss"
  22. placeholder="选择日期"
  23. >
  24. </el-date-picker>
  25. </div>
  26. <div>
  27. <jobDdBom
  28. :item="item"
  29. ref="jobRef"
  30. :notFormed="item.notFormedList"
  31. :warehouseList="warehouseList"
  32. ></jobDdBom>
  33. </div>
  34. <div
  35. v-if="
  36. clientEnvironmentId == 3 &&
  37. item.toWarehouseList &&
  38. item.toWarehouseList.length > 0
  39. "
  40. >
  41. <div class="item">
  42. <div>
  43. <div class="text">仓库</div>
  44. <div class="select-type">
  45. <el-select
  46. v-model="warehouseId"
  47. filterable
  48. clearable
  49. placeholder="请选择仓库"
  50. size="mini"
  51. class="content_num"
  52. >
  53. <el-option
  54. v-for="item in warehouseList"
  55. :key="item.id"
  56. :value="item.id"
  57. :label="item.name"
  58. ></el-option>
  59. </el-select>
  60. </div>
  61. </div>
  62. <div>
  63. <div class="text">入库规格</div>
  64. <div class="select-type">
  65. <el-select
  66. v-model="inWarehouseSpecType"
  67. filterable
  68. clearable
  69. placeholder="请选择入库规格"
  70. size="mini"
  71. class="content_num select-warehousing"
  72. >
  73. <el-option
  74. v-for="item in WarehouseSpecTypeList"
  75. :key="item.value"
  76. :label="item.text"
  77. :value="item.value"
  78. ></el-option>
  79. </el-select>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- <div style="margin-top: 6px">
  84. <el-select
  85. v-model="item.warehouseId"
  86. filterable
  87. clearable
  88. placeholder="请选择仓库"
  89. size="mini"
  90. class="content_num"
  91. >
  92. <el-option
  93. v-for="item in warehouseList"
  94. :key="item.id"
  95. :value="item.id"
  96. :label="item.name"
  97. ></el-option>
  98. </el-select>
  99. </div> -->
  100. <div v-for="(it, idx) in item.toWarehouseList" :key="idx">
  101. <packingTgBom
  102. :list="it.extInfo.pickOutInList"
  103. :isWarehousing="true"
  104. :item="it"
  105. ></packingTgBom>
  106. </div>
  107. </div>
  108. <!-- 单独报工 -->
  109. <div
  110. v-else-if="
  111. item.currentTaskDiagram.type == 4 ||
  112. (item.currentTaskDiagram.type == 5 && item.singleReport == 1)
  113. "
  114. >
  115. <div v-if="item.toWarehouseList && item.toWarehouseList.length > 0">
  116. <div class="item">
  117. <div>
  118. <div class="text">仓库</div>
  119. <div class="select-type">
  120. <el-select
  121. v-model="warehouseId"
  122. filterable
  123. clearable
  124. placeholder="请选择仓库"
  125. size="mini"
  126. class="content_num"
  127. >
  128. <el-option
  129. v-for="item in warehouseList"
  130. :key="item.id"
  131. :value="item.id"
  132. :label="item.name"
  133. ></el-option>
  134. </el-select>
  135. </div>
  136. </div>
  137. <div>
  138. <div class="text">入库规格</div>
  139. <div class="select-type">
  140. <el-select
  141. v-model="inWarehouseSpecType"
  142. filterable
  143. clearable
  144. placeholder="请选择入库规格"
  145. size="mini"
  146. class="content_num select-warehousing"
  147. >
  148. <el-option
  149. v-for="item in WarehouseSpecTypeList"
  150. :key="item.value"
  151. :label="item.text"
  152. :value="item.value"
  153. ></el-option>
  154. </el-select>
  155. </div>
  156. </div>
  157. </div>
  158. <div v-for="(it, idx) in item.toWarehouseList" :key="idx">
  159. <packingTgBom
  160. :list="it.extInfo.pickOutInList"
  161. :singleReport="item.singleReport"
  162. :item="item"
  163. :equipmentList="item.equipmentList"
  164. :isWarehousing="true"
  165. ></packingTgBom>
  166. </div>
  167. </div>
  168. </div>
  169. <!-- {{ item.currentTaskDiagram.type }} {{ item.singleReport }}
  170. {{ clientEnvironmentId != 2 && item && item.currentTaskDiagram.type == 5 && clientEnvironmentId != 3 && item.singleReport == 1 }} -->
  171. <!-- <div
  172. v-if="
  173. clientEnvironmentId != 2 &&
  174. item &&
  175. item.currentTaskDiagram.type == 5 &&
  176. clientEnvironmentId != 3 &&
  177. item.singleReport !== 1
  178. "
  179. >
  180. <div style="margin-top: 6px">
  181. <el-select
  182. v-model="item.warehouseId"
  183. filterable
  184. clearable
  185. placeholder="请选择仓库"
  186. size="mini"
  187. class="content_num"
  188. >
  189. <el-option
  190. v-for="item in warehouseList"
  191. :key="item.id"
  192. :value="item.id"
  193. :label="item.name"
  194. ></el-option>
  195. </el-select>
  196. </div> -->
  197. <div
  198. v-if="
  199. clientEnvironmentId != 2 &&
  200. item &&
  201. item.currentTaskDiagram.type == 5 &&
  202. clientEnvironmentId != 3 &&
  203. item.singleReport !== 1
  204. "
  205. >
  206. <div style="margin-top: 6px">
  207. <el-select
  208. v-model="warehouseId"
  209. filterable
  210. clearable
  211. placeholder="请选择仓库"
  212. size="mini"
  213. class="content_num"
  214. >
  215. <el-option
  216. v-for="item in warehouseList"
  217. :key="item.id"
  218. :value="item.id"
  219. :label="item.name"
  220. ></el-option>
  221. </el-select>
  222. </div>
  223. <!-- 批量报工 -->
  224. <div
  225. class="list_box"
  226. v-for="(d, index) in item.toWarehouseList"
  227. :key="index"
  228. >
  229. <div class="time" style="margin-bottom: 10rpx"
  230. >打包时间: {{ d.createTime }}</div
  231. >
  232. <packagingGroupingTwx
  233. ref="packagingGroupingRef"
  234. :objData="d.extInfo"
  235. :workOrderId="item.workOrderId"
  236. :taskId="item.currentTaskDiagram.taskId"
  237. >
  238. </packagingGroupingTwx>
  239. </div>
  240. </div>
  241. <div v-if="clientEnvironmentId == 2">
  242. <div class="item">
  243. <div>
  244. <div class="text">仓库</div>
  245. <div class="select-type">
  246. <el-select
  247. v-model="warehouseId"
  248. filterable
  249. clearable
  250. placeholder="请选择仓库"
  251. size="mini"
  252. class="content_num"
  253. >
  254. <el-option
  255. v-for="item in warehouseList"
  256. :key="item.id"
  257. :value="item.id"
  258. :label="item.name"
  259. ></el-option>
  260. </el-select>
  261. </div>
  262. </div>
  263. <div>
  264. <div class="text">入库规格</div>
  265. <div class="select-type">
  266. <el-select
  267. v-model="inWarehouseSpecType"
  268. filterable
  269. clearable
  270. placeholder="请选择入库规格"
  271. size="mini"
  272. class="content_num select-warehousing"
  273. >
  274. <el-option
  275. v-for="item in WarehouseSpecTypeList"
  276. :key="item.value"
  277. :label="item.text"
  278. :value="item.value"
  279. ></el-option>
  280. </el-select>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <!-- item.currentTaskDiagram.type == 4 ? item.pickOutInList : item.semiProductList -->
  286. <!-- <div v-else>
  287. <el-empty :image-size="30" description="暂无数据"></el-empty>
  288. </div> -->
  289. </div>
  290. </div>
  291. </div>
  292. </template>
  293. <script>
  294. import workOrderBom from '../feeding/components/workOrderBom.vue';
  295. import packingTgBom from '../jobBooking/components/packingTgBom.vue';
  296. import semiProductJobBomQT from '../jobBooking/components/semiProductJobBomQT.vue';
  297. import packagingGroupingTwx from '../jobBooking/components/packagingGroupingTwx.vue';
  298. import { getWarehouseList } from '@/api/produce/index.js';
  299. import { listByIdsReport } from '@/api/produce/job';
  300. import {
  301. listPcToWarehouseTG,
  302. listPCToWarehouse
  303. } from '@/api/produce/workOrder';
  304. import { jobSave } from '@/api/produce/workOrder';
  305. // import jobDdBom from './components/jobDdBom.vue';
  306. import jobDdBom from './components/newJobDdBom.vue';
  307. export default {
  308. components: {
  309. workOrderBom,
  310. semiProductJobBomQT,
  311. packagingGroupingTwx,
  312. packingTgBom,
  313. jobDdBom
  314. },
  315. props: {
  316. workListIds: {
  317. type: Array,
  318. default() {
  319. return [];
  320. }
  321. }
  322. },
  323. data() {
  324. return {
  325. isLoad: false,
  326. List: [],
  327. idsList: [],
  328. warehouseList: [],
  329. inWarehouseSpecType: '2',
  330. WarehouseSpecTypeList: [
  331. {
  332. text: '按计量入库',
  333. value: '1'
  334. },
  335. {
  336. text: '最小包装入库',
  337. value: '2'
  338. },
  339. {
  340. text: '内包装入库',
  341. value: '3'
  342. },
  343. {
  344. text: '外包装入库',
  345. value: '4'
  346. }
  347. ],
  348. warehouseId: null,
  349. inWarehouseType: null
  350. };
  351. },
  352. computed: {
  353. taskObj() {
  354. return this.$store.state.user.taskObj;
  355. },
  356. clientEnvironmentId() {
  357. return this.$store.state.user.info.clientEnvironmentId;
  358. }
  359. },
  360. watch: {
  361. workListIds: {
  362. handler(val) {
  363. this.getList(val);
  364. },
  365. deep: true,
  366. immediate: true
  367. }
  368. },
  369. created() {
  370. this.getWarehouseListFn();
  371. },
  372. methods: {
  373. getList(ids) {
  374. this.idsList = ids || [];
  375. let param = {
  376. ids: ids,
  377. taskId: this.taskObj.id,
  378. type: 0
  379. };
  380. this.isLoad = false;
  381. listByIdsReport(param)
  382. .then((res) => {
  383. if (res[0].workOrderType == 1) {
  384. this.inWarehouseType = 1;
  385. } else if (res[0].workOrderType == 2) {
  386. this.inWarehouseType = 8; // "1入库类型1生产入库2半成品入库"
  387. }
  388. this.List = res.map((obj) => {
  389. obj.workReportInfo = {
  390. formingNum: null,
  391. formingWeight: null,
  392. formedNum: null,
  393. formedWeight: null,
  394. taskId: this.taskObj.id,
  395. executorTime: null
  396. };
  397. obj.notFormedList = [
  398. {
  399. notFormedNum: null,
  400. notFormedWeight: null,
  401. weightUnit: res.weightUnit,
  402. unit: res.unit,
  403. warehouseId: null // 处置 仓库id
  404. }
  405. ];
  406. return {
  407. ...obj
  408. };
  409. });
  410. })
  411. .finally(() => {
  412. this.isLoad = true;
  413. if (this.clientEnvironmentId == 3) {
  414. this.getTgWarehouse();
  415. } else {
  416. this.getQtWarehouse();
  417. }
  418. });
  419. },
  420. getTgWarehouse() {
  421. const param = {
  422. workOrderIds: this.idsList,
  423. taskId: this.taskObj.id
  424. };
  425. listPcToWarehouseTG(param).then((res) => {
  426. // 创建一个映射,以便快速查找
  427. const workOrderMap = new Map(res.map((it) => [it.workOrderId, it]));
  428. // 更新List中的每个项目
  429. // this.List.forEach((item,index) => {
  430. // if (workOrderMap.has(item.workOrderId)) {
  431. // // 直接从映射中获取数据,避免嵌套循环
  432. // this.$set(item, 'toWarehouseList', [
  433. // JSON.parse(JSON.stringify(workOrderMap.get(item.workOrderId)))
  434. // ]);
  435. // } else {
  436. // this.$set(item, 'toWarehouseList', []);
  437. // }
  438. // });
  439. this.List.forEach((item, index) => {
  440. let arr = [];
  441. res.map((titem) => {
  442. if (item.workOrderId == titem.workOrderId) {
  443. arr.push(titem);
  444. }
  445. this.$set(item, 'toWarehouseList', arr);
  446. });
  447. });
  448. });
  449. },
  450. getQtWarehouse() {
  451. const param = {
  452. workOrderIds: this.idsList,
  453. taskId: this.taskObj.id
  454. };
  455. console.log(123456);
  456. listPCToWarehouse(param).then((res) => {
  457. // 创建一个映射,以便快速查找
  458. const workOrderMap = new Map(res.map((it) => [it.workOrderId, it]));
  459. console.log(workOrderMap, '99');
  460. // 更新List中的每个项目
  461. // this.List.map((item) => {
  462. // if (workOrderMap.has(item.workOrderId)) {
  463. // console.log(1);
  464. // // 直接从映射中获取数据,避免嵌套循环
  465. // this.$set(item, 'toWarehouseList', [
  466. // JSON.parse(JSON.stringify(workOrderMap.get(item.workOrderId)))
  467. // ]);
  468. // } else {
  469. // this.$set(item, 'toWarehouseList', []);
  470. // }
  471. // });
  472. this.List.forEach((item, index) => {
  473. let arr = [];
  474. res.map((titem) => {
  475. if (item.workOrderId == titem.workOrderId) {
  476. arr.push(titem);
  477. }
  478. this.$set(item, 'toWarehouseList', arr);
  479. });
  480. });
  481. console.log(this.List, '6666666666');
  482. });
  483. },
  484. getWarehouseListFn() {
  485. getWarehouseList().then((res) => {
  486. this.warehouseList = res.data;
  487. });
  488. },
  489. save() {
  490. if (this.clientEnvironmentId == 21) {
  491. console.log(this.List, 'List');
  492. if (!this.warehouseId) {
  493. return this.$message.warning('请选择仓库');
  494. }
  495. this.List.forEach((item) => {
  496. item.warehouseId = this.warehouseId;
  497. });
  498. jobSave(this.List).then((res) => {
  499. console.log(res);
  500. this.$message.success('入库成功');
  501. this.getList(this.idsList);
  502. });
  503. } else if (this.clientEnvironmentId == 2) {
  504. if (!this.warehouseId) {
  505. return this.$message.warning('请选择仓库');
  506. }
  507. const listData = this.List.map((item) => {
  508. let categoryId = '',
  509. rootCategoryLevelId = '';
  510. if (item.product.length) {
  511. categoryId = item.categoryId;
  512. rootCategoryLevelId = item.rootCategoryLevelId;
  513. }
  514. let storageInfo = {
  515. inWarehouseSpecType:
  516. this.clientEnvironmentId !== 3 || this.clientEnvironmentId !== 2
  517. ? Number(this.inWarehouseSpecType)
  518. : '',
  519. warehouseId: this.warehouseId,
  520. inWarehouseType: this.inWarehouseType,
  521. toWarehouseList: this.clientEnvironmentId == 3 ? this.tgList : []
  522. };
  523. if (this.clientEnvironmentId == 2) {
  524. let num = '';
  525. if (item.workReportInfo && item.workReportInfo?.formedNum) {
  526. num = item.workReportInfo.formedNum;
  527. }
  528. storageInfo.packingReportList = [
  529. {
  530. code: item.productCode,
  531. categoryId: categoryId,
  532. workOrderId: item.workOrderId,
  533. rootCategoryLevelId: rootCategoryLevelId,
  534. totalQuantity: num,
  535. quantity: num,
  536. unit: item.unit,
  537. packingNum: 1,
  538. taskId: -1
  539. }
  540. ];
  541. item.storageInfo = storageInfo;
  542. }
  543. return {
  544. ...item
  545. };
  546. });
  547. console.log(listData, 'listData');
  548. // const data = this.List[0];
  549. // if (!this.warehouseId) {
  550. // return this.$message.warning('请选择仓库');
  551. // }
  552. // let categoryId = '',
  553. // rootCategoryLevelId = '';
  554. // if (data.product.length) {
  555. // categoryId = data.product[0].categoryId;
  556. // rootCategoryLevelId = data.product[0].rootCategoryLevelId;
  557. // }
  558. // let storageInfo = {
  559. // inWarehouseSpecType:
  560. // this.clientEnvironmentId !== 3 || this.clientEnvironmentId !== 2
  561. // ? Number(this.inWarehouseSpecType)
  562. // : '',
  563. // warehouseId: this.warehouseId,
  564. // inWarehouseType: this.inWarehouseType,
  565. // toWarehouseList: this.clientEnvironmentId == 3 ? this.tgList : []
  566. // };
  567. // let num = '';
  568. // if (data.workReportInfo && data.workReportInfo?.formedNum) {
  569. // num = data.workReportInfo.formedNum;
  570. // }
  571. // storageInfo.packingReportList = [
  572. // {
  573. // code: data.productCode,
  574. // categoryId: categoryId,
  575. // workOrderId: data.workOrderId,
  576. // rootCategoryLevelId: rootCategoryLevelId,
  577. // totalQuantity: num,
  578. // quantity: num,
  579. // unit: data.unit,
  580. // packingNum: 1,
  581. // taskId: -1
  582. // }
  583. // ];
  584. // data.storageInfo = storageInfo;
  585. // console.log(storageInfo, 'storageInfo');
  586. // console.log(data, 'this.data');
  587. // const data = this.List[0];
  588. jobSave(listData).then((res) => {
  589. console.log(res);
  590. this.$message.success('入库成功');
  591. this.getList(this.idsList);
  592. });
  593. } else {
  594. let _arr = [];
  595. console.log(this.List, 'this.List');
  596. _arr = this.List.filter((item) => {
  597. if (item.toWarehouseList && item.toWarehouseList.length > 0) {
  598. return item.toWarehouseList.length > 0;
  599. }
  600. });
  601. _arr.forEach((item) => {
  602. item.warehouseId = this.warehouseId;
  603. });
  604. let bol = true;
  605. bol = _arr.every((e, i) => {
  606. return e.warehouseId;
  607. });
  608. if (!bol) {
  609. this.$message.warning(`仓库不能为空`);
  610. return false;
  611. }
  612. let _arr2 = JSON.parse(JSON.stringify(_arr));
  613. _arr2.map((m) => {
  614. m.storageInfo = {
  615. warehouseId: m.warehouseId,
  616. toWarehouseList: m.toWarehouseList,
  617. inWarehouseSpecType: 2
  618. };
  619. delete m.warehouseId;
  620. delete m.toWarehouseList;
  621. return {
  622. ...m
  623. };
  624. });
  625. jobSave(_arr2).then((res) => {
  626. console.log(res);
  627. this.$message.success('入库成功');
  628. this.getList(this.idsList);
  629. });
  630. }
  631. }
  632. }
  633. };
  634. </script>
  635. <style scoped lang="scss">
  636. .top_fixed {
  637. width: 100%;
  638. height: 40px;
  639. background: #fff;
  640. display: flex;
  641. align-items: center;
  642. justify-content: flex-end;
  643. }
  644. .title_box {
  645. .name {
  646. font-size: 14px;
  647. font-style: normal;
  648. font-weight: 400;
  649. color: #157a2c;
  650. padding-left: 5px;
  651. position: relative;
  652. &:before {
  653. position: absolute;
  654. content: '';
  655. left: 0px;
  656. top: 0px;
  657. bottom: 0px;
  658. width: 2px;
  659. height: 14px;
  660. background: #157a2c;
  661. margin: auto;
  662. }
  663. }
  664. }
  665. .warehousing_box {
  666. margin-top: 6px;
  667. width: 100%;
  668. height: calc(100vh - 70px - 50px - 80px - 60px);
  669. overflow-y: scroll;
  670. overflow-x: hidden;
  671. }
  672. .card_box {
  673. background: #fff;
  674. padding: 8px;
  675. border-radius: 2px;
  676. }
  677. .content_num {
  678. --input-background-color: #f0f8f2;
  679. }
  680. .item {
  681. display: flex;
  682. flex-direction: row;
  683. border: 1px solid #e3e5e5;
  684. border-top: 0 solid #e3e5e5;
  685. align-items: center;
  686. div {
  687. display: flex;
  688. flex-direction: row;
  689. align-items: center;
  690. height: 100%;
  691. .text {
  692. font-size: 12px;
  693. width: 100px;
  694. height: 32px;
  695. display: flex;
  696. justify-content: center;
  697. align-items: center;
  698. background-color: #f7f9fa;
  699. }
  700. .select-type {
  701. width: 205px;
  702. padding: 2px;
  703. box-sizing: border-box;
  704. }
  705. }
  706. }
  707. </style>