Przeglądaj źródła

修改宝盛的bug

695593266@qq.com 4 miesięcy temu
rodzic
commit
3fd2cbe029

+ 130 - 33
src/views/pick/pickApply/components/addPick.vue

@@ -284,7 +284,7 @@
 </template>
 
 <script>
-  import pickingList from '@/views/produce/components/picking/pickingList.vue';
+  import pickingList from '@/views/produce/components/picking/newPickingList.vue';
   import { workorderList, getCode } from '@/api/produce/workOrder';
   import produceOrder from './produceOrder.vue';
 
@@ -339,6 +339,7 @@
         const param = { ids, taskId };
 
         workorderList(param).then((res) => {
+          console.log(res, 'resres');
           this.workList = res.map((item) => {
             // 处理 pickList 并统一 warehouse 字段
             const pickList = item.bomDetailDTOS.map((it) => {
@@ -381,14 +382,54 @@
       },
 
       allSelection(id, list) {
+        // this.workList.forEach((e) => {
+        //   if (e.id == id) {
+        //     e.pickList = list;
+        //     this.$forceUpdate();
+        //   }
+        // });
+        console.log(id, list);
+        list.forEach((item) => {
+          item.code = item.categoryCode;
+          item.name = item.categoryName;
+          item.modelType = item.modelType ? item.modelType : item.categoryModel;
+          item.measuringUnit = item.measuringUnit
+            ? item.measuringUnit
+            : item.measureUnit;
+          item.unit = item.unit ? item.unit : item.measureUnit;
+        });
+
         this.workList.forEach((e) => {
           if (e.id == id) {
-            e.pickList = list;
+            const newData = [];
+            if (list.length != 0) {
+              list.forEach((it) => {
+                newData.push(this.deepCopy(it));
+              });
+            }
+            // e.pickList = list;
+            e.pickList = newData;
             this.$forceUpdate();
           }
         });
       },
 
+      deepCopy(obj, hash = new WeakMap()) {
+        if (obj === null) return null;
+        if (obj instanceof Date) return new Date(obj);
+        if (obj instanceof RegExp) return new RegExp(obj);
+        if (typeof obj !== 'object' && typeof obj !== 'function') return obj;
+        if (hash.has(obj)) return hash.get(obj);
+
+        const result = Array.isArray(obj) ? [] : {};
+        hash.set(obj, result);
+
+        return Object.keys(obj).reduce((acc, key) => {
+          acc[key] = this.deepCopy(obj[key], hash);
+          return acc;
+        }, result);
+      },
+
       save() {
         if (this.workList.length > 0) {
           let bol;
@@ -473,48 +514,104 @@
       },
 
       workSelect(ids, taskId) {
+        console.log(ids, taskId, 'ids, taskId');
         this.getList(ids, taskId);
 
         this.orderShow = false;
       },
       changeWarehouse(item, index) {},
+
       changeInput(item, index, idx) {
-        if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
-          this.$set(
-            this.workList[idx].pickList[index],
-            'demandQuantity',
-            Number(item.availableCountBase)
-          );
-          const idsList = [];
-          item.warehouseList.forEach((it) => {
-            idsList.push(it.id);
-          });
-          this.$set(
-            this.workList[idx].pickList[index],
-            'warehouseIdList',
-            idsList
-          );
-        } else if (!Number(item.demandQuantity)) {
-          this.$set(this.workList[idx].pickList[index], 'warehouseIdList', []);
-        } else {
-          const idsList = [];
-          let totalNum = 0;
-          for (let i = 0; i < item.warehouseList.length; i++) {
-            totalNum += Number(item.warehouseList[i].availableCountBase);
-            if (Number(item.demandQuantity) > totalNum) {
-              idsList.push(item.warehouseList[i].id);
-            } else {
-              idsList.push(item.warehouseList[i].id);
-              break;
-            }
-          }
+        const pickItem = this.workList[idx].pickList[index];
+
+        let value = String(item.demandQuantity ?? '');
+
+        value = value.replace(/[^\d.]/g, '');
+
+        value = value
+          .replace(/\.{2,}/g, '.')
+          .replace('.', '$#$')
+          .replace(/\./g, '')
+          .replace('$#$', '.');
+
+        if (value.includes('.')) {
+          const [intPart, decPart] = value.split('.');
+          value = `${intPart}.${decPart.slice(0, 4)}`;
+        }
+
+        this.$set(pickItem, 'demandQuantity', value);
+
+        const demandQty = Number(value);
+        const maxQty = item.warehouseList.reduce((sum, cur) => {
+          return sum + Number(cur.availableCountBase || 0);
+        }, 0);
+
+        if (!demandQty) {
+          this.$set(pickItem, 'warehouseIdList', []);
+          return;
+        }
+
+        if (demandQty >= maxQty) {
+          this.$set(pickItem, 'demandQuantity', maxQty);
+
           this.$set(
-            this.workList[0].pickList[index],
+            pickItem,
             'warehouseIdList',
-            idsList
+            item.warehouseList.map((w) => w.warehouse_id)
           );
+          return;
+        }
+
+        let total = 0;
+        const idsList = [];
+
+        for (const w of item.warehouseList) {
+          total += Number(w.availableCountBase) || 0;
+          idsList.push(w.warehouse_id);
+
+          if (total >= demandQty) break;
         }
+
+        this.$set(pickItem, 'warehouseIdList', idsList);
       }
+
+      // changeInput(item, index, idx) {
+      //   if (Number(item.demandQuantity) >= Number(item.availableCountBase)) {
+      //     this.$set(
+      //       this.workList[idx].pickList[index],
+      //       'demandQuantity',
+      //       Number(item.availableCountBase)
+      //     );
+      //     const idsList = [];
+      //     item.warehouseList.forEach((it) => {
+      //       idsList.push(it.id);
+      //     });
+      //     this.$set(
+      //       this.workList[idx].pickList[index],
+      //       'warehouseIdList',
+      //       idsList
+      //     );
+      //   } else if (!Number(item.demandQuantity)) {
+      //     this.$set(this.workList[idx].pickList[index], 'warehouseIdList', []);
+      //   } else {
+      //     const idsList = [];
+      //     let totalNum = 0;
+      //     for (let i = 0; i < item.warehouseList.length; i++) {
+      //       totalNum += Number(item.warehouseList[i].availableCountBase);
+      //       if (Number(item.demandQuantity) > totalNum) {
+      //         idsList.push(item.warehouseList[i].id);
+      //       } else {
+      //         idsList.push(item.warehouseList[i].id);
+      //         break;
+      //       }
+      //     }
+      //     this.$set(
+      //       this.workList[0].pickList[index],
+      //       'warehouseIdList',
+      //       idsList
+      //     );
+      //   }
+      // }
     },
 
     created() {

+ 57 - 7
src/views/pick/pickApply/components/produceOrder.vue

@@ -52,7 +52,7 @@
 
 <script>
   import { pickTaskReportPage } from '@/api/produce/workOrder.js';
-
+  import { checkRepeatPick } from '@/api/produce/index';
   import produceOrderSearch from './produceOrder-search.vue';
 
   export default {
@@ -246,16 +246,66 @@
           this.$refs.table.reload({ page: 1, where });
         });
       },
-      handleSelect() {
-        let ids = [];
-        ids = this.selection.map((item) => {
-          return item.id;
-        });
+      // handleSelect() {
+      //   let ids = [];
+      //   ids = this.selection.map((item) => {
+      //     return item.id;
+      //   });
+      //   if (!this.taskId) {
+      //     return this.$message.warning('请选择工序');
+      //   }
+
+      //   this.$emit('workSelect', ids, this.taskId);
+      // },
+
+      async handleSelect() {
         if (!this.taskId) {
           return this.$message.warning('请选择工序');
         }
 
-        this.$emit('workSelect', ids, this.taskId);
+        if (!this.selection.length) {
+          return this.$message.warning('请选择工单');
+        }
+
+        try {
+          const results = await Promise.all(
+            this.selection.map((row) =>
+              checkRepeatPick({ workOrderId: row.id }).then((res) => ({
+                id: row.id,
+                code: row.code,
+                repeatCount: res?.data || 0
+              }))
+            )
+          );
+
+          const repeatList = results.filter((item) => item.repeatCount > 0);
+
+          if (repeatList.length > 0) {
+            const repeatCodes = repeatList.map((item) => item.code).join('、');
+
+            this.$confirm(
+              `工单【${repeatCodes}】已存在领料记录,是否继续重复领料?`,
+              '提示',
+              {
+                confirmButtonText: '继续',
+                cancelButtonText: '取消',
+                type: 'warning'
+              }
+            )
+              .then(() => {
+                const ids = this.selection.map((item) => item.id);
+                this.$emit('workSelect', ids, this.taskId);
+              })
+              .catch(() => {});
+            return;
+          }
+
+          const ids = this.selection.map((item) => item.id);
+          this.$emit('workSelect', ids, this.taskId);
+        } catch (e) {
+          console.error(e);
+          // this.$message.error('校验是否重复领料失败');
+        }
       },
 
       handleClose() {

+ 25 - 2
src/views/produceOrder/workReport.vue

@@ -350,7 +350,8 @@
     listTask,
     factoryworkstationPage,
     nextTask,
-    checkPleaseEntrust
+    checkPleaseEntrust,
+    checkRepeatPick
   } from '@/api/produce/index';
   import { getTaskInstanceList } from '@/api/produce/job';
   import { workorderInfo } from '@/api/produceOrder/index.js';
@@ -1115,7 +1116,29 @@
       },
 
       pickAdd() {
-        this.pickingShow = true;
+        this.checkPick();
+
+        // this.pickingShow = true;
+      },
+
+      async checkPick() {
+        await checkRepeatPick({
+          workOrderId: this.workListIds[0]
+        }).then((res) => {
+          if (res.data == 0) {
+            this.pickingShow = true;
+          } else {
+            this.$confirm('已经有领料是否继续重复领料?', '提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            })
+              .then(() => {
+                this.pickingShow = true;
+              })
+              .catch(() => {});
+          }
+        });
       },
 
       // 关闭领料弹窗

+ 1 - 1
src/views/requirementListOrder/components/details.vue

@@ -353,7 +353,7 @@
           },
           {
             prop: 'pickQuantity',
-            label: '领数量',
+            label: '领数量',
             width: 100,
             align: 'center',
             showOverflowTooltip: true