소스 검색

bug 修改

jingshuyong 10 달 전
부모
커밋
0e08e6e26e
1개의 변경된 파일95개의 추가작업 그리고 29개의 파일을 삭제
  1. 95 29
      src/views/saleOrder/components/create-order.vue

+ 95 - 29
src/views/saleOrder/components/create-order.vue

@@ -547,6 +547,7 @@
     getFactoryList,
     findBomCategoryByCategoryIds
   } from '@/api/saleOrder';
+  import { listBomType } from '@/api/productionPlan/index';
   import { parameterGetByCode } from '@/api/mainData/index';
   import dayjs from 'dayjs';
   import { multiply } from '@/utils/math';
@@ -758,13 +759,32 @@
               item.lackNum = null;
             });
           }
+          // this.disabledList = res.productInfoList;
+
           if (res.productInfoList.length > 0) {
-            let ids = res.productInfoList.map((item) => item.categoryId);
-            const data = await findBomCategoryByCategoryIds(ids);
-            this.handleResult(res.productInfoList, data, 'init');
+            const promiselist = [];
+            res.productInfoList.forEach(async (el, index) => {
+              promiselist.push(this.getBomInfo(el));
+            });
+            await Promise.all(promiselist);
+
+            console.log(this.disabledList, '3333');
+            // let ids = res.productInfoList.map((item) => item.categoryId);
+            // const data = await findBomCategoryByCategoryIds(ids);
+            // this.handleResult(res.productInfoList, data, 'init');
           }
+
           this.disabledList = res.productInfoList;
           this.form = res;
+          const promiseProduct = [];
+          this.form.productInfoList.forEach(async (el, index) => {
+            let lis = el.producedList;
+            if (!el.bomCategoryId && lis && lis.length > 0) {
+              el.productType = el.producedList[0].code;
+              promiseProduct.push(this.changeProductType(el, index));
+            }
+          });
+          await Promise.all(promiseProduct);
           // // 如果没有bom版本的选择的话
           // this.disabledList.forEach((item, index) => {
           //   if (item.bomVersionList && item.bomVersionList.length > 0) {
@@ -782,6 +802,36 @@
           // });
         });
       },
+      // 获取bom信息
+      async getBomInfo(data) {
+        let params = { categoryId: data.categoryId };
+        const res = await listBomType(params);
+        if (!res || res.length == 0) return;
+        let bomMap = {
+          1: { code: 1, name: 'PBOM' },
+          2: { code: 2, name: 'MBOM' },
+          3: { code: 3, name: 'ABOM' }
+        };
+        let arr = [];
+        res.map((item) => {
+          if (bomMap[item.bomType]) {
+            arr.push(bomMap[item.bomType]);
+            delete bomMap[item.bomType];
+          }
+        });
+        console.log('什么时候进来');
+        // this.$set(data, 'producedList', arr);
+        data.producedList = arr;
+        console.log(arr, 'arr');
+        // if (!data.productType || !data.bomCategoryId) {
+        // this.$set(data, 'productType', arr[0].code);
+        // console.log(333333);
+        // this.changeProductType(data, index);
+        // }
+        // console.log(data, 'data');
+        // data.producedList = arr;
+      },
+
       cancel() {
         this.form = {
           productInfoList: [],
@@ -1063,12 +1113,28 @@
         }
 
         if (result.length > 0) {
-          let ids = result.map((item) => item.categoryId);
-          const res = await findBomCategoryByCategoryIds(ids);
+          // let ids = result.map((item) => item.categoryId);
+          // const res = await findBomCategoryByCategoryIds(ids);
+          // let datas = JSON.parse(JSON.stringify(result));
+          // console.log(datas, 'datas 00000');
+          // datas = await this.handleResult(datas, res);
           let datas = JSON.parse(JSON.stringify(result));
-          console.log(datas,'datas 00000')
-          datas = await this.handleResult(datas, res);
+          const promiselist = [];
+          datas.forEach(async (el) => {
+            promiselist.push(this.getBomInfo(el));
+            this.getBomInfo(el);
+          });
+          await Promise.all(promiselist);
           this.form.productInfoList = this.form.productInfoList.concat(datas);
+          const promiseProduct = [];
+          this.form.productInfoList.forEach(async (el, index) => {
+            let lis = el.producedList;
+            if (!el.bomCategoryId && lis && lis.length > 0) {
+              el.productType = el.producedList[0].code;
+              promiseProduct.push(this.changeProductType(el, index));
+            }
+          });
+          await Promise.all(promiseProduct);
         } else {
           this.form.productInfoList = this.form.productInfoList.concat(result);
         }
@@ -1077,6 +1143,7 @@
 
       // 计算生产类型数据
       calculationType(data) {
+        console.log(data, 'data 99955');
         let list = [];
         let listMap = {
           1: { code: 1, name: 'PBOM' },
@@ -1107,7 +1174,7 @@
           if (!item.productType) {
             item.productType = first.bomType - 0;
           }
-          console.log(arr,'arr')
+          console.log(arr, 'arr');
           let list = this.calculationType(val);
           item.producedList = list;
           if (!type) {
@@ -1189,35 +1256,34 @@
       },
 
       // 选择生产类型
-      changeProductType(row, index) {
+      async changeProductType(row, index) {
         let param = {
           bomType: row.productType,
           categoryId: row.categoryId
         };
         this.wipeData(index);
-        bomListByPlan(param).then((res) => {
-          console.log(res, 'res 3333');
-          let arr = res || [];
-          let data = this.form.productInfoList[index];
-          if (arr.length) {
-            this.form.productInfoList[index].bomVersionList = arr;
-            row.bomCategoryId = arr[0].id;
-            this.changeBomId(row, index);
-            let arrAll = JSON.parse(JSON.stringify(this.form));
-            this.$set(this, 'form', arrAll);
-          }
-          this.$forceUpdate();
+        const res = await bomListByPlan(param);
+        console.log(res, 'res 3333');
+        let arr = res || [];
+        let data = this.form.productInfoList[index];
+        if (arr.length) {
+          this.form.productInfoList[index].bomVersionList = arr;
+          row.bomCategoryId = arr[0].id;
+          await this.changeBomId(row, index);
+          let arrAll = JSON.parse(JSON.stringify(this.form));
+          this.$set(this, 'form', arrAll);
+        }
+        this.$forceUpdate();
 
-          // let arr = res || [];
-          // if (arr.length == 0) {
-          //   row.bomCategoryId = '';
-          // }
+        // let arr = res || [];
+        // if (arr.length == 0) {
+        //   row.bomCategoryId = '';
+        // }
 
-          // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
-          // this.$forceUpdate();
+        // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
+        // this.$forceUpdate();
 
-          // console.log(this.form,'this.formthis.form')
-        });
+        // console.log(this.form,'this.formthis.form')
       },
 
       // 选择BOM