ysy преди 1 година
родител
ревизия
33bf791089
променени са 3 файла, в които са добавени 89 реда и са изтрити 15 реда
  1. 12 0
      src/api/produce/feeding.js
  2. 37 8
      src/views/produce/components/feeding/index.vue
  3. 40 7
      src/views/produce/components/picking/pickingList.vue

+ 12 - 0
src/api/produce/feeding.js

@@ -22,6 +22,7 @@ export async function batchSave(data) {
   }
 
 
+  // pda投料查缓存
   export async function feedGetCache(data) {
     const res = await request.post(`/pda/mes/feed/getCache`, data);
     if (res.data.code == 0) {
@@ -30,5 +31,16 @@ export async function batchSave(data) {
     return Promise.reject(new Error(res.data.message));
   }
   
+  // 清空缓存
+  export async function removeCache(data) {
+    const res = await request.post(`/pda/mes/workreport/removeCache`, data);
+    if (res.data.code == 0) {
+        return res.data.data;
+      }
+    return Promise.reject(new Error(res.data.message));
+  }
+  
   
  
+
+ 

+ 37 - 8
src/views/produce/components/feeding/index.vue

@@ -1,11 +1,15 @@
 <template>
   <div>
     <div class="top_fixed">
-      <el-button type="primary" size="mini" @click="save(2)"
+      <el-button type="primary" size="mini" @click="save(2, 'all')"
         >一键投料(报工)</el-button
       >
-      <el-button type="primary" size="mini">清空缓存</el-button>
-      <el-button type="primary" size="mini" @click="save(1)">缓存</el-button>
+      <el-button type="primary" size="mini" @click="removeCacheFn('all')"
+        >清空缓存</el-button
+      >
+      <el-button type="primary" size="mini" @click="save(1, 'all')"
+        >缓存</el-button
+      >
     </div>
 
     <div class="feed_box">
@@ -21,8 +25,15 @@
               @click="openPicking(item.workOrderId, item)"
               >添加物料</el-button
             >
-            <el-button type="text" size="mini">清空缓存</el-button>
-            <el-button type="text" size="mini">缓存</el-button>
+            <el-button
+              type="text"
+              size="mini"
+              @click="removeCacheFn(item.workOrderId)"
+              >清空缓存</el-button
+            >
+            <el-button type="text" size="mini" @click="save(1, index)"
+              >缓存</el-button
+            >
           </div>
         </div>
 
@@ -100,7 +111,8 @@
   import {
     batchSave,
     feedSaveCache,
-    feedGetCache
+    feedGetCache,
+    removeCache
   } from '@/api/produce/feeding';
 
   import pickingList from '../picking/pickingList.vue';
@@ -317,7 +329,7 @@
         });
       },
 
-      async save(type) {
+      async save(type, index) {
         this.List.forEach((f) => {
           f.instanceList.forEach((e) => {
             if (Object.prototype.hasOwnProperty.call(e, 'type')) {
@@ -335,12 +347,14 @@
 
         batchSave(this.List).then((res) => {
           this.$message.success('投料成功');
+          this.getList(this.idsList);
         });
       },
 
-      checkCache(type) {
+      checkCache(type, index) {
         return new Promise((resolve) => {
           if (type == 1) {
+            console.log([this.List[index]]);
             feedSaveCache(this.List).then((rr) => {
               this.$message.success('已经缓存');
             });
@@ -349,6 +363,21 @@
             resolve(true);
           }
         });
+      },
+
+      removeCacheFn(type) {
+        this.$confirm('是否清空缓存', '缓存')
+          .then(() => {
+            let parma = {
+              workOrderIds: this.type == 'all' ? this.idsList : [type],
+              taskId: this.taskObj.id,
+              type: 2
+            };
+            removeCache(parma).then((res) => {
+              this.getList(this.idsList);
+            });
+          })
+          .catch(() => {});
       }
     }
   };

+ 40 - 7
src/views/produce/components/picking/pickingList.vue

@@ -182,7 +182,8 @@
 
         selection: [],
 
-        allSelection: []
+        allSelection: [],
+        temporaryList: []
       };
     },
 
@@ -401,7 +402,7 @@
         };
         if (this.isType == 'pick') {
           param.dimension = 1;
-          console.log(888, param);
+
           URL = pageeLedgerMain;
         } else if (this.isType == 'feed') {
           if ([4, 7, 14].includes(Number(this.rootCategoryLevelId))) {
@@ -504,6 +505,7 @@
         this.id = id;
 
         if (this.isType == 'pick') {
+          this.temporaryList = item.pickList || [];
           this.allSelection = item.pickList || [];
           this.visible = true;
           this.$nextTick(() => {
@@ -523,6 +525,7 @@
             ...item.revolvingDiskList,
             ...item.semiProductList
           ];
+          this.temporaryList = feedList || [];
           this.allSelection = feedList || [];
           this.visible = true;
 
@@ -536,6 +539,7 @@
 
       handleClose() {
         this.clearChoose();
+        this.temporaryList = [];
         this.allSelection = [];
         this.visible = false;
       },
@@ -544,11 +548,40 @@
           this.$message.warning('请选择物料');
           return false;
         }
-        this.allSelection = this.allSelection.sort(
-          (a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId
-        );
-        this.$emit('allSelection', this.id, this.allSelection);
-        this.handleClose();
+
+
+        if (this.temporaryList.length > 0) {
+          // 使用Promise来“模拟”异步操作
+          new Promise((resolve) => {
+            if (this.temporaryList.length > 0) {
+              this.temporaryList.forEach((item) => {
+                this.allSelection.forEach((item2) => {
+                  if (item.id == item2.id && this.isType == 'pick') {
+                  this.$set(item2, 'demandQuantity',  item.demandQuantity || null);
+                  } else if (item.id == item2.id && this.isType == 'feed') {
+                  this.$set(item2, 'feedQuantity',  item.feedQuantity || null);
+                  }
+                });
+              });
+            }
+            this.allSelection.sort(
+              (a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId
+            );
+
+            resolve();
+          }).then(() => {
+    
+            this.$emit('allSelection', this.id, this.allSelection);
+            this.handleClose();
+          });
+        } else {
+          this.allSelection.sort(
+            (a, b) => a.rootCategoryLevelId - b.rootCategoryLevelId
+          );
+
+          this.$emit('allSelection', this.id, this.allSelection);
+          this.handleClose();
+        }
       }
     },