695593266@qq.com 6 mesi fa
parent
commit
744f2cee1c

+ 11 - 3
src/api/outsourcing/index.js

@@ -3,7 +3,7 @@ import request from '@/utils/request';
 /**
 /**
  * 列表
  * 列表
  */
  */
-export async function getList (data) {
+export async function getList(data) {
   const res = await request.get('/mes/applyoutsource/page', {
   const res = await request.get('/mes/applyoutsource/page', {
     params: data
     params: data
   });
   });
@@ -13,15 +13,23 @@ export async function getList (data) {
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
 }
 }
 
 
-
 /**
 /**
  * 发布
  * 发布
  */
  */
 
 
- export async function release (params) {
+export async function release(params) {
   const res = await request.post('/mes/applyoutsource/release', params);
   const res = await request.post('/mes/applyoutsource/release', params);
   if (res.data.code == 0) {
   if (res.data.code == 0) {
     return res.data.data;
     return res.data.data;
   }
   }
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
 }
 }
+
+/**批量分批报工 */
+export async function batchOutsourcing(params) {
+  const res = await request.post('/mes/applyoutsource/splitBatchList', params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 148 - 17
src/views/produce/components/outsourcing/new_outsourceList.vue

@@ -138,6 +138,7 @@
               <el-select
               <el-select
                 v-model="attributeData.deliveryMethod"
                 v-model="attributeData.deliveryMethod"
                 placeholder="请选择"
                 placeholder="请选择"
+                @change="changeMethod"
               >
               >
                 <el-option
                 <el-option
                   v-for="item in deliveryMethodTypeList"
                   v-for="item in deliveryMethodTypeList"
@@ -388,13 +389,19 @@
                     v-if="item.isDemandQuantity && clientEnvironmentId != 2"
                     v-if="item.isDemandQuantity && clientEnvironmentId != 2"
                     style="width: 15%"
                     style="width: 15%"
                   >
                   >
-                    <span>数量</span
+                    <!-- <span>数量</span
                     >{{
                     >{{
                       checkListLen == 0
                       checkListLen == 0
                         ? item.demandQuantity
                         ? item.demandQuantity
                         : item.count * (checkListLen || 1)
                         : item.count * (checkListLen || 1)
                     }}
                     }}
-                    {{ item.unit }}
+                    {{ item.unit }} -->
+                    <span>数量</span>
+                    <input
+                      style="width: 90% !important"
+                      v-model="item.demandQuantity"
+                    />
+                    {{ item.measuringUnit }}
                   </div>
                   </div>
                   <div
                   <div
                     class="items content_num"
                     class="items content_num"
@@ -537,7 +544,7 @@
                 ref="pickOutRefs"
                 ref="pickOutRefs"
                 class="table_content"
                 class="table_content"
                 :max-height="600"
                 :max-height="600"
-                :data="it.pickoutInList"
+                :data="it.pickOutInList"
                 tooltip-effect="dark"
                 tooltip-effect="dark"
                 style="width: 100%; margin-top: 10px"
                 style="width: 100%; margin-top: 10px"
                 stripe
                 stripe
@@ -878,6 +885,7 @@
   } from '@/api/produce/index.js';
   } from '@/api/produce/index.js';
   import { contactList } from '@/api/produce/bom.js';
   import { contactList } from '@/api/produce/bom.js';
   import { tableHeader } from '@/utils/dict/common.js';
   import { tableHeader } from '@/utils/dict/common.js';
+  import { batchOutsourcing } from '@/api/outsourcing';
 
 
   import pickingList from './pickingList.vue';
   import pickingList from './pickingList.vue';
   import timeDialog from './timeDialog.vue';
   import timeDialog from './timeDialog.vue';
@@ -1349,24 +1357,23 @@
 
 
         const batchList = this.timeList
         const batchList = this.timeList
           .filter(
           .filter(
-            (b) => b.batchNo != '一次性到货' && Array.isArray(b.pickoutInList)
+            (b) => b.batchNo != '一次性到货' && Array.isArray(b.pickOutInList)
           )
           )
-          .flatMap((b) => b.pickoutInList);
+          .flatMap((b) => b.pickOutInList);
 
 
         const checkedList = [...this.pickOutInListSelect, ...batchList];
         const checkedList = [...this.pickOutInListSelect, ...batchList];
         const batchTimeList = this.timeList.filter(
         const batchTimeList = this.timeList.filter(
           (b) => b.batchNo != '一次性到货'
           (b) => b.batchNo != '一次性到货'
         );
         );
 
 
-        console.log(checkedList, 'checkedListcheckedList');
-
         this.$refs.timeDialogRef.open(
         this.$refs.timeDialogRef.open(
           this.attributeData,
           this.attributeData,
           null,
           null,
           false,
           false,
           checkedList,
           checkedList,
           this.workData.list[0],
           this.workData.list[0],
-          batchTimeList
+          batchTimeList,
+          this.pickOutInList
         );
         );
       },
       },
 
 
@@ -1374,7 +1381,21 @@
         this.$emit('outScucc');
         this.$emit('outScucc');
       },
       },
 
 
-      removeTab() {},
+      changeMethod(e) {
+        if (e == 1) {
+          this.timeList = [];
+          this.attributeData.formedNumLast = 0;
+          this.pickOutInListSelect = [];
+
+          this.$nextTick(() => {
+            if (this.$refs.pickOutRef) {
+              this.$refs.pickOutRef.clearSelection();
+            }
+          });
+
+          return;
+        }
+      },
 
 
       async save() {
       async save() {
         const valid = await this.$refs.form.validate().catch(() => false);
         const valid = await this.$refs.form.validate().catch(() => false);
@@ -1468,12 +1489,14 @@
           return;
           return;
         }
         }
 
 
-        this.timeList = clonedTimeList.map((item) => item);
-
-        if (this.workData.list[0].singleReport == 1) {
+        if (
+          this.workData.list[0].singleReport == 1 ||
+          this.pickOutInList.length > 1
+        ) {
+          this.timeList = clonedTimeList.map((item) => item);
           const selectedIds = new Set();
           const selectedIds = new Set();
           for (let item of this.timeList) {
           for (let item of this.timeList) {
-            for (let it of item.pickoutInList) {
+            for (let it of item.pickOutInList) {
               selectedIds.add(it.id);
               selectedIds.add(it.id);
             }
             }
           }
           }
@@ -1496,13 +1519,19 @@
           );
           );
 
 
           if (unassignedList.length > 0) {
           if (unassignedList.length > 0) {
+            const number = unassignedList.reduce(
+              (sum, item) => sum + Number(item.feedQuantity || 0),
+              0
+            );
+
             const data = {
             const data = {
               batchNo: '一次性到货',
               batchNo: '一次性到货',
               requireDeliveryTime: null,
               requireDeliveryTime: null,
-              purchaseQuantity: unassignedList.length,
-              pickoutInList: unassignedList,
+              purchaseQuantity: number,
+              pickOutInList: unassignedList,
               bomMaterialList: [],
               bomMaterialList: [],
-              standardOutputList: []
+              standardOutputList: [],
+              isParent: 1
             };
             };
 
 
             const exists = this.timeList.some((t) => t.batchNo == '一次性到货');
             const exists = this.timeList.some((t) => t.batchNo == '一次性到货');
@@ -1558,8 +1587,110 @@
           this.timeList[0].innerActive = '0';
           this.timeList[0].innerActive = '0';
           this.activeBatch = this.timeList[0].batchNo;
           this.activeBatch = this.timeList[0].batchNo;
           this.pickOutInListSelect = [];
           this.pickOutInListSelect = [];
+        } else {
+          if (this.pickOutInList.length == 1) {
+            this.timeList = clonedTimeList.map((item) => {
+              item.pickOutInList = [this.deepCopy(this.pickOutInListSelect[0])];
 
 
-          console.log(this.timeList, '8285');
+              return item;
+            });
+
+            this.attributeData.formedNumLast = this.timeList.reduce(
+              (acc, pro) => {
+                const num = parseFloat(pro.purchaseQuantity);
+                return acc + (isNaN(num) ? 0 : num);
+              },
+              0
+            );
+            const totalNum = this.pickOutInList.reduce(
+              (sum, item) => sum + Number(item.feedQuantity || 0),
+              0
+            );
+            const batchNum = this.timeList.reduce(
+              (sum, item) => sum + Number(item.purchaseQuantity || 0),
+              0
+            );
+
+            let singleWeight = 0;
+
+            if (
+              this.pickOutInList[0].newWeight ||
+              this.pickOutInList[0].newWeight == 0
+            ) {
+              singleWeight = this.div(
+                this.pickOutInList[0].newWeight,
+                totalNum
+              );
+            }
+            const remainderNum = this.sub(totalNum, batchNum);
+            if (remainderNum != 0) {
+              const data = {
+                batchNo: '一次性到货',
+                requireDeliveryTime: null,
+                purchaseQuantity: remainderNum,
+                pickOutInList: [this.deepCopy(this.pickOutInListSelect[0])],
+                bomMaterialList: [],
+                standardOutputList: [],
+                isParent: 1
+              };
+              const exists = this.timeList.some(
+                (t) => t.batchNo == '一次性到货'
+              );
+              if (!exists) {
+                this.timeList.unshift(data);
+              } else {
+                const index = this.timeList.findIndex(
+                  (t) => t.batchNo == '一次性到货'
+                );
+                this.timeList.splice(index, 1, data);
+              }
+            }
+            if (this.bomMaterialList.length != 0) {
+              for (let item of this.bomMaterialList) {
+                for (let it of this.timeList) {
+                  const proportion = this.div(it.purchaseQuantity, totalNum);
+                  const allocatedQuantity = this.mul(
+                    proportion,
+                    item.demandQuantity
+                  );
+                  const materialItem = {
+                    ...item,
+                    demandQuantity: allocatedQuantity
+                  };
+                  it.bomMaterialList.push(materialItem);
+                }
+              }
+            }
+            if (this.standardOutputList.length != 0) {
+              for (let item of this.standardOutputList) {
+                for (let it of this.timeList) {
+                  const proportion = this.div(it.purchaseQuantity, totalNum);
+                  const allocatedQuantity = this.mul(
+                    proportion,
+                    item.demandQuantity
+                  );
+                  const materialItem = {
+                    ...item,
+                    demandQuantity: allocatedQuantity
+                  };
+                  it.standardOutputList.push(materialItem);
+                }
+              }
+            }
+
+            this.timeList = this.timeList.map((it) => {
+              it.pickOutInList.forEach((item) => {
+                item.feedQuantity = it.purchaseQuantity;
+                item.newWeight = this.mul(singleWeight, it.purchaseQuantity);
+              });
+
+              return it;
+            });
+
+            this.timeList[0].innerActive = '0';
+            this.activeBatch = this.timeList[0].batchNo;
+            this.pickOutInListSelect = [];
+          }
         }
         }
       },
       },
 
 

+ 14 - 9
src/views/produce/components/outsourcing/timeDialog.vue

@@ -51,7 +51,10 @@
         <el-table-column
         <el-table-column
           label="数量"
           label="数量"
           prop="purchaseQuantity"
           prop="purchaseQuantity"
-          v-if="pickOutInList.length > 1 && workOrderData.singleReport == 1"
+          v-if="
+            (allList.length > 1 && workOrderData.singleReport == 1) ||
+            (allList.length > 1 && workOrderData.singleReport == 0)
+          "
         >
         >
           <template slot-scope="{ row, $index }">
           <template slot-scope="{ row, $index }">
             <el-form-item
             <el-form-item
@@ -149,7 +152,7 @@
               requireDeliveryTime: null,
               requireDeliveryTime: null,
               purchaseQuantity: null,
               purchaseQuantity: null,
               batchNo: null,
               batchNo: null,
-              pickoutInList: [],
+              pickOutInList: [],
               bomMaterialList: [],
               bomMaterialList: [],
               standardOutputList: []
               standardOutputList: []
             }
             }
@@ -176,7 +179,8 @@
         currentIndex: '',
         currentIndex: '',
         count: 0,
         count: 0,
         pickOutInList: [],
         pickOutInList: [],
-        workOrderData: {}
+        workOrderData: {},
+        allList: []
       };
       };
     },
     },
 
 
@@ -192,8 +196,9 @@
       }
       }
     },
     },
     methods: {
     methods: {
-      open(row, index, isAll, pickOutInList, workOrderData, timeList) {
+      open(row, index, isAll, pickOutInList, workOrderData, timeList, allList) {
         this.workOrderData = workOrderData;
         this.workOrderData = workOrderData;
+        this.allList = allList.map((item) => item);
         this.pickOutInList = pickOutInList.map((item) => item);
         this.pickOutInList = pickOutInList.map((item) => item);
         this.isAll = isAll;
         this.isAll = isAll;
         if (row) {
         if (row) {
@@ -222,14 +227,14 @@
           requireDeliveryTime: null,
           requireDeliveryTime: null,
           purchaseQuantity: null,
           purchaseQuantity: null,
           batchNo: await getCode('lot_number_code'),
           batchNo: await getCode('lot_number_code'),
-          pickoutInList: [],
+          pickOutInList: [],
           bomMaterialList: [],
           bomMaterialList: [],
           standardOutputList: []
           standardOutputList: []
         });
         });
       },
       },
 
 
       handleDel(index) {
       handleDel(index) {
-        this.form.timeList[index].pickoutInList.forEach((item) => {
+        this.form.timeList[index].pickOutInList.forEach((item) => {
           item.selected = false;
           item.selected = false;
         });
         });
         this.form.timeList.splice(index, 1);
         this.form.timeList.splice(index, 1);
@@ -239,7 +244,7 @@
         this.$refs.batchChooseGoodsRef.open(
         this.$refs.batchChooseGoodsRef.open(
           this.workOrderData,
           this.workOrderData,
           this.pickOutInList,
           this.pickOutInList,
-          this.form.timeList[index].pickoutInList,
+          this.form.timeList[index].pickOutInList,
           index
           index
         );
         );
       },
       },
@@ -251,7 +256,7 @@
         }, 0);
         }, 0);
 
 
         this.form.timeList[index].purchaseQuantity = totalNum;
         this.form.timeList[index].purchaseQuantity = totalNum;
-        this.form.timeList[index].pickoutInList = list;
+        this.form.timeList[index].pickOutInList = list;
       },
       },
 
 
       handleOk() {
       handleOk() {
@@ -284,7 +289,7 @@
             requireDeliveryTime: null,
             requireDeliveryTime: null,
             purchaseQuantity: null,
             purchaseQuantity: null,
             batchNo: null,
             batchNo: null,
-            pickoutInList: [],
+            pickOutInList: [],
             bomMaterialList: [],
             bomMaterialList: [],
             standardOutputList: []
             standardOutputList: []
           }
           }

+ 2 - 2
vue.config.js

@@ -32,11 +32,11 @@ module.exports = {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
       '/api': {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://124.71.68.31:50001',
-        // target: 'http://192.168.1.125:18086',
+        target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.125:18086',
-        target: 'http://192.168.1.116:18086', // 赵沙金
+        // target: 'http://192.168.1.116:18086', // 赵沙金
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.144:18086',