ysy hace 1 año
padre
commit
f1895d2d7c

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

@@ -0,0 +1,24 @@
+import request from '@/utils/request';
+
+
+
+// 投料保存
+export async function batchSave(data) {
+    const res = await request.post(`/pda/mes/feed/batchSave`, data);
+    if (res.data.code == 0) {
+        return res.data.data;
+      }
+    return Promise.reject(new Error(res.data.message));
+  }
+  
+ 
+// pda投料保存缓存
+  export async function feedSaveCache(data) {
+    const res = await request.post(`/pda/mes/feed/saveCache`, data);
+    if (res.data.code == 0) {
+        return res.data.data;
+      }
+    return Promise.reject(new Error(res.data.message));
+  }
+  
+ 

+ 1 - 1
src/views/produce/components/feeding/components/packingBom.vue

@@ -39,7 +39,7 @@
                 placeholder="数量"
               >
               </el-input>
-              /{{item.unit}}
+              /{{ item.unit }}
             </div>
           </div>
 

+ 43 - 3
src/views/produce/components/feeding/index.vue

@@ -1,9 +1,13 @@
 <template>
   <div>
     <div class="top_fixed">
-      <el-button type="primary" size="mini">一键投料(报工)</el-button>
-      <el-button type="primary" size="mini">清空缓存</el-button>
-      <el-button type="primary" size="mini">缓存</el-button>
+      <el-button type="primary" size="mini" @click="save(2)"
+        >一键投料(报工)</el-button
+      >
+      <el-button type="primary" size="mini" 
+        >清空缓存</el-button
+      >
+      <el-button type="primary" size="mini" @click="save(1)">缓存</el-button>
     </div>
 
     <div class="feed_box">
@@ -95,6 +99,7 @@
 
 <script>
   import { workorderList } from '@/api/produce/workOrder';
+  import { batchSave, feedSaveCache } from '@/api/produce/feeding';
 
   import pickingList from '../picking/pickingList.vue';
 
@@ -272,6 +277,41 @@
             this.$forceUpdate();
           }
         });
+      },
+
+      async save(type) {
+        this.List.forEach((f) => {
+          f.instanceList.forEach((e) => {
+            if (Object.prototype.hasOwnProperty.call(e, 'type')) {
+              e.extInfo['type'] = e.type;
+            }
+            e.extInfo['isConsumable'] = e.isConsumable;
+          });
+        });
+
+        const isCache = await this.checkCache(type);
+
+        if (!isCache) {
+          return false;
+        }
+
+        batchSave(this.List).then((res) => {
+          this.$message.success('投料成功');
+        });
+      },
+
+      checkCache(type) {
+       
+        return new Promise((resolve) => {
+          if (type == 1) {
+            feedSaveCache(this.List).then((rr) => {
+              this.$message.success('已经缓存');
+            });
+            resolve(false);
+          } else if (type == 2) {
+            resolve(true);
+          }
+        });
       }
     }
   };