Bläddra i källkod

禅道需求141 开发完成

jingshuyong 10 månader sedan
förälder
incheckning
484b52d429

+ 9 - 0
src/api/saleOrder/index.js

@@ -319,3 +319,12 @@ export async function getFactoryarea(params) {
   }
   }
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
 }
 }
+
+// 根据产品ID列表查询BOM分类
+export async function findBomCategoryByCategoryIds(data) {
+  const res = await request.post(`/aps/salesorder/findBomCategoryByCategoryIds`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 80 - 19
src/views/productionPlan/components/factoryAdd/index.vue

@@ -170,7 +170,7 @@
                 :key="$index"
                 :key="$index"
               >
               >
                 <el-option
                 <el-option
-                  v-for="item of producedList"
+                  v-for="item of row.producedList"
                   :key="$index + item.code"
                   :key="$index + item.code"
                   :label="item.name"
                   :label="item.name"
                   :value="item.code"
                   :value="item.code"
@@ -408,6 +408,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+  import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
   import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
   import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
   import { getCode } from '@/api/codeManagement';
   import { getCode } from '@/api/codeManagement';
   import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
   import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
@@ -770,7 +771,7 @@
       parameterGetByCode({
       parameterGetByCode({
         code: 'production_plan_code'
         code: 'production_plan_code'
       }).then((res) => {
       }).then((res) => {
-        console.log(res,'res 1')
+        console.log(res, 'res 1');
         if (res) {
         if (res) {
           this.processingRequired = res.value;
           this.processingRequired = res.value;
         }
         }
@@ -808,7 +809,7 @@
         await this.getFactoryList();
         await this.getFactoryList();
 
 
         if (val) {
         if (val) {
-          if(val.planType == null || val.planType == 'null'){
+          if (val.planType == null || val.planType == 'null') {
             val.planType = '';
             val.planType = '';
           }
           }
           this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
           this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
@@ -843,6 +844,29 @@
                 }
                 }
               });
               });
             }
             }
+            let categoryId = this.form.productInfoList[0].categoryId;
+            const res = await findBomCategoryByCategoryId(categoryId);
+            if (res && res.length > 0) {
+              let list = [];
+              let listMap = {};
+              res.map((el) => {
+                if (el.bomType == '2' || el.bomType == '3') {
+                  console.log(listMap, 'listMap');
+                  if (listMap[el.bomType]) {
+                    listMap[el.bomType].push(el);
+                  } else {
+                    listMap[el.bomType] = [el];
+                  }
+                }
+              });
+              if (listMap[2]) {
+                list.push({ code: 2, name: '加工(MBOM)' });
+              }
+              if (listMap[3]) {
+                list.push({ code: 3, name: '装配(ABOM)' });
+              }
+               this.form.productInfoList[0].producedList = list;
+            }
           }
           }
           this.$forceUpdate();
           this.$forceUpdate();
         }
         }
@@ -867,7 +891,7 @@
         this.$refs.equipmentRefs.open();
         this.$refs.equipmentRefs.open();
       },
       },
 
 
-      confirmChoose(list) {
+      async confirmChoose(list) {
         list.map((el) => (el.selectionRowShow = false));
         list.map((el) => (el.selectionRowShow = false));
         if (this.clientEnvironmentId == 4) {
         if (this.clientEnvironmentId == 4) {
           list.map((v) => {
           list.map((v) => {
@@ -937,20 +961,56 @@
             }
             }
           }
           }
         }
         }
-        // bomVersionList
-
-        this.form.productInfoList = this.form.productInfoList.concat(result);
 
 
-        this.$refs.tableRef.setData(this.form.productInfoList);
-
-        this.changeLineNumber();
-
-        //重置
-        this.$set(this.form, 'produceType', '');
-        this.$set(this.form, 'bomCategoryId', '');
-        this.$set(this.form, 'produceRoutingId', '');
+        try {
+          let categoryId = result[0].categoryId;
+          const res = await findBomCategoryByCategoryId(categoryId);
+          if (res) {
+            let listMap = {};
+            let list = [];
+            let arr = [];
+            res.map((el) => {
+              if (el.bomType == '2' || el.bomType == '3') {
+                console.log(listMap, 'listMap');
+                if (listMap[el.bomType]) {
+                  listMap[el.bomType].push(el);
+                } else {
+                  listMap[el.bomType] = [el];
+                }
+              }
+            });
+            if (listMap[2]) {
+              list.push({ code: 2, name: '加工(MBOM)' });
+              arr = listMap[2];
+              result[0].productType = 2;
+            }
+            if (listMap[3]) {
+              list.push({ code: 3, name: '装配(ABOM)' });
+              if (!listMap[2]) {
+                arr = listMap[3];
+                result[0].productType = 3;
+              }
+            }
+            if (arr.length > 0) {
+              arr.map((el) => (el.bomCategoryId = el.id));
+              result[0].bomCategoryId = arr[0].id;
+              this.changeBomId(arr[0], 0);
+            }
+            result[0].producedList = list;
+            result[0].bomVersionList = arr;
+            // bomVersionList
+            this.form.productInfoList =
+              this.form.productInfoList.concat(result);
+            this.$refs.tableRef.setData(this.form.productInfoList);
+            this.changeLineNumber();
+            //重置
+            this.$set(this.form, 'produceType', '');
+            this.$set(this.form, 'bomCategoryId', '');
+            this.$set(this.form, 'produceRoutingId', '');
+          }
+        } catch (err) {}
 
 
-        this.bomListVersion();
+        // this.bomListVersion();
       },
       },
 
 
       changeLineNumber() {
       changeLineNumber() {
@@ -1145,9 +1205,9 @@
                   let total =
                   let total =
                     ((item.requiredFormingNum - 0) * item.productUnitWeight) /
                     ((item.requiredFormingNum - 0) * item.productUnitWeight) /
                     1000;
                     1000;
-                    item.newSumOrderWeight = total.toFixed(2);
-                    item.newWeightUnit = 'KG'
-                }else{
+                  item.newSumOrderWeight = total.toFixed(2);
+                  item.newWeightUnit = 'KG';
+                } else {
                   item.newWeightUnit = item.weightUnit;
                   item.newWeightUnit = item.weightUnit;
                   item.newSumOrderWeight = item.requiredFormingNum;
                   item.newSumOrderWeight = item.requiredFormingNum;
                 }
                 }
@@ -1212,6 +1272,7 @@
         bomListByPlan(param).then((res) => {
         bomListByPlan(param).then((res) => {
           this.$nextTick(() => {
           this.$nextTick(() => {
             this.bomVersionList = res || [];
             this.bomVersionList = res || [];
+            console.log(res, 'res 000');
           });
           });
         });
         });
       },
       },

+ 106 - 33
src/views/saleOrder/components/create-order.vue

@@ -147,15 +147,15 @@
           </el-table-column>
           </el-table-column>
           <el-table-column label="行号" align="center" prop="lineNumber">
           <el-table-column label="行号" align="center" prop="lineNumber">
           </el-table-column>
           </el-table-column>
-          <el-table-column label="名称" align="center" prop="productName">
+          <el-table-column label="名称" align="center" prop="productName"  width="150" show-overflow-tooltip>
           </el-table-column>
           </el-table-column>
-          <el-table-column label="编码" align="center" prop="productCode">
+          <el-table-column label="编码" align="center" prop="productCode" width="150" show-overflow-tooltip>
           </el-table-column>
           </el-table-column>
           <el-table-column label="牌号" align="center" prop="brandNo">
           <el-table-column label="牌号" align="center" prop="brandNo">
           </el-table-column>
           </el-table-column>
           <el-table-column label="型号" align="center" prop="model">
           <el-table-column label="型号" align="center" prop="model">
           </el-table-column>
           </el-table-column>
-          <el-table-column label="规格" align="center" prop="specification">
+          <el-table-column label="规格" align="center" prop="specification" width="150" show-overflow-tooltip>
           </el-table-column>
           </el-table-column>
           <el-table-column label="单重" align="center" prop="productUnitWeight">
           <el-table-column label="单重" align="center" prop="productUnitWeight">
           </el-table-column>
           </el-table-column>
@@ -262,7 +262,7 @@
                   :key="scope.$index"
                   :key="scope.$index"
                 >
                 >
                   <el-option
                   <el-option
-                    v-for="item of producedList"
+                    v-for="item of scope.row.producedList"
                     :key="scope.$index + item.code"
                     :key="scope.$index + item.code"
                     :label="item.name"
                     :label="item.name"
                     :value="item.code"
                     :value="item.code"
@@ -393,7 +393,7 @@
                 <el-select
                 <el-select
                   v-model="scope.row.factoriesId"
                   v-model="scope.row.factoriesId"
                   :key="scope.row.factoriesId"
                   :key="scope.row.factoriesId"
-                  @change="(e)=>factorChange(e,scope.row)"
+                  @change="(e) => factorChange(e, scope.row)"
                 >
                 >
                   <el-option
                   <el-option
                     v-for="item of factoryList"
                     v-for="item of factoryList"
@@ -524,7 +524,8 @@
     getOrderDetail,
     getOrderDetail,
     bomListByPlan,
     bomListByPlan,
     bomRoutingList,
     bomRoutingList,
-    getFactoryList
+    getFactoryList,
+    findBomCategoryByCategoryIds
   } from '@/api/saleOrder';
   } from '@/api/saleOrder';
   import { parameterGetByCode } from '@/api/mainData/index';
   import { parameterGetByCode } from '@/api/mainData/index';
   import dayjs from 'dayjs';
   import dayjs from 'dayjs';
@@ -676,11 +677,9 @@
         });
         });
       },
       },
 
 
-      
-      factorChange(e,row){
-        let obj = this.factoryList.find(el=>el.id === e);
-        if(obj){
-          console.log(obj,'obj 1234')
+      factorChange(e, row) {
+        let obj = this.factoryList.find((el) => el.id === e);
+        if (obj) {
           row.factoriesIdName = obj.name;
           row.factoriesIdName = obj.name;
         }
         }
         // factoriesIdName
         // factoriesIdName
@@ -711,7 +710,7 @@
         }
         }
       },
       },
       getDetail(code) {
       getDetail(code) {
-        getOrderDetail(code).then((res) => {
+        getOrderDetail(code).then(async (res) => {
           if (res.productInfoList) {
           if (res.productInfoList) {
             for (let item of res.productInfoList) {
             for (let item of res.productInfoList) {
               if (!item.bomCategoryId) {
               if (!item.bomCategoryId) {
@@ -730,6 +729,11 @@
               item.lackNum = null;
               item.lackNum = null;
             });
             });
           }
           }
+          if (res.productInfoList.length > 0) {
+            let ids = res.productInfoList.map((item) => item.categoryId);
+            const data = await findBomCategoryByCategoryIds(ids);
+            this.handleResult(res.productInfoList, data, 'init');
+          }
           this.disabledList = res.productInfoList;
           this.disabledList = res.productInfoList;
           this.form = res;
           this.form = res;
         });
         });
@@ -957,7 +961,7 @@
         }
         }
       },
       },
       // 确定选择
       // 确定选择
-      confirmChoose(list) {
+      async confirmChoose(list) {
         list.map((el) => (el.selectionRowShow = false));
         list.map((el) => (el.selectionRowShow = false));
         list = list
         list = list
           .filter(
           .filter(
@@ -1006,10 +1010,79 @@
           }
           }
         }
         }
 
 
-        this.form.productInfoList = this.form.productInfoList.concat(result);
+        if (result.length > 0) {
+          let ids = result.map((item) => item.categoryId);
+          const res = await findBomCategoryByCategoryIds(ids);
+          let datas = JSON.parse(JSON.stringify(result));
+          datas = await this.handleResult(datas, res);
+          this.form.productInfoList = this.form.productInfoList.concat(datas);
+        } else {
+          this.form.productInfoList = this.form.productInfoList.concat(result);
+        }
         this.changeLineNumber();
         this.changeLineNumber();
       },
       },
 
 
+      // 计算生产类型数据
+      calculationType(data) {
+        let list = [];
+        let listMap = {
+          1: { code: 1, name: 'PBOM' },
+          2: { code: 2, name: '加工(MBOM)' },
+          3: { code: 3, name: '装配(ABOM)' }
+        };
+        data.forEach((el) => {
+          if (listMap[el.bomType]) {
+            list.push(listMap[el.bomType]);
+            delete listMap[el.bomType];
+          }
+        });
+        return list;
+      },
+      //
+      async handleResult(result, res, type) {
+        result.forEach((item) => {
+          if (!res[item.categoryId]) {
+            return;
+          }
+          let val = res[item.categoryId];
+          if (!val || val.length == 0) {
+            return;
+          }
+          let arr = [];
+          let first = val[0];
+          arr = val.filter((item) => item.bomType == first.bomType);
+          item.productType = first.bomType - 0;
+          let list = this.calculationType(val);
+          item.producedList = list;
+          if (!type) {
+            item.bomVersionList = arr;
+            // arr.map((el) => (el.bomCategoryId = el.id));
+            item.bomCategoryId = arr[0].id;
+          }
+        });
+        result.forEach(async (ele) => {
+          ele = await this.getFindRoutingListByBomId(ele);
+          console.log(ele, 'ele');
+        });
+        return result;
+      },
+      // 获取工艺路线
+      async getFindRoutingListByBomId(ele) {
+        let proArr = ele.bomVersionList;
+        if (!proArr || proArr.length == 0) {
+          return ele;
+        }
+        console.log(proArr, 'proArr');
+        const res = await bomRoutingList(proArr[0].id);
+        let arr = res || [];
+        if (arr.length > 0) {
+          this.$set(ele, 'routingList', arr);
+          ele.produceRoutingName = arr[0].name;
+          this.$set(ele, 'produceRoutingId', arr[0].id);
+        }
+        return ele;
+      },
+      // // await this.changeBomId(arr[0], 0);
       changeLineNumber() {
       changeLineNumber() {
         this.form.productInfoList.map((item, index) => {
         this.form.productInfoList.map((item, index) => {
           item.lineNumber = 10 * (index + 1);
           item.lineNumber = 10 * (index + 1);
@@ -1073,23 +1146,23 @@
       },
       },
 
 
       // 选择BOM
       // 选择BOM
-      changeBomId(row, index) {
-        bomRoutingList(row.bomCategoryId).then((res) => {
-          let arr = res || [];
-          // if (arr.length == 0) {
-          //   row.produceRoutingId = '';
-          // }
-          if (arr.length > 0) {
-            this.$set(this.form.productInfoList[index], 'routingList', arr);
-            row.produceRoutingName = arr[0].name;
-            this.$set(
-              this.form.productInfoList[index],
-              'produceRoutingId',
-              arr[0].id
-            );
-          }
-          this.$forceUpdate();
-        });
+      async changeBomId(row, index) {
+        const res = await bomRoutingList(row.bomCategoryId);
+        let arr = res || [];
+        // if (arr.length == 0) {
+        //   row.produceRoutingId = '';
+        // }
+        console.log(arr, 'arr');
+        if (arr.length > 0) {
+          this.$set(this.form.productInfoList[index], 'routingList', arr);
+          row.produceRoutingName = arr[0].name;
+          this.$set(
+            this.form.productInfoList[index],
+            'produceRoutingId',
+            arr[0].id
+          );
+        }
+        this.$forceUpdate();
       },
       },
 
 
       homogeneityInspect(row) {
       homogeneityInspect(row) {
@@ -1105,8 +1178,8 @@
           this.$message.warning('请输入订单数量且订单数量不能为0');
           this.$message.warning('请输入订单数量且订单数量不能为0');
           return;
           return;
         }
         }
-        console.log(row,'row');
-        console.log(this.form,'form +++');
+        console.log(row, 'row');
+        console.log(this.form, 'form +++');
         this.$refs.orderHomogeneityInspectDialog.open([row], this.form, 'new');
         this.$refs.orderHomogeneityInspectDialog.open([row], this.form, 'new');
         // if (row.productType == 2) {
         // if (row.productType == 2) {
         //   let data = [];
         //   let data = [];

+ 9 - 5
src/views/saleOrder/index.vue

@@ -235,14 +235,16 @@
             prop: 'productName',
             prop: 'productName',
             label: '名称',
             label: '名称',
             align: 'center',
             align: 'center',
-            minWidth: 120
+            minWidth: 120,
+            showOverflowTooltip: true
           },
           },
 
 
           {
           {
             prop: 'produceRoutingName',
             prop: 'produceRoutingName',
             label: '工艺路线',
             label: '工艺路线',
             align: 'center',
             align: 'center',
-            minWidth: 120
+            minWidth: 120,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'specification',
             prop: 'specification',
@@ -261,14 +263,16 @@
           {
           {
             prop: 'brandNo',
             prop: 'brandNo',
             label: '牌号',
             label: '牌号',
-            align: 'center'
+            align: 'center',
+            showOverflowTooltip: true
           },
           },
 
 
           {
           {
             prop: 'model',
             prop: 'model',
             label: '型号',
             label: '型号',
             align: 'center',
             align: 'center',
-            minWidth: 120
+            minWidth: 120,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'priority',
             prop: 'priority',
@@ -560,7 +564,7 @@
           ...this.sort
           ...this.sort
         };
         };
         const data = await getPageList(params);
         const data = await getPageList(params);
-        console.log(data,'data')
+        console.log(data, 'data');
         return data;
         return data;
       },
       },
 
 

+ 13 - 6
src/views/workOrder/index.vue

@@ -399,7 +399,8 @@
             label: '生产订单号',
             label: '生产订单号',
             align: 'center',
             align: 'center',
             minWidth: 220,
             minWidth: 220,
-            sortable: true
+            sortable: true,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'taskName',
             prop: 'taskName',
@@ -418,7 +419,8 @@
             prop: 'productionPlanCode',
             prop: 'productionPlanCode',
             label: '计划编号',
             label: '计划编号',
             align: 'center',
             align: 'center',
-            minWidth: 150
+            minWidth: 150,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'productType',
             prop: 'productType',
@@ -452,19 +454,22 @@
             prop: 'produceRoutingName',
             prop: 'produceRoutingName',
             label: '工艺路线',
             label: '工艺路线',
             align: 'center',
             align: 'center',
-            minWidth: 170
+            minWidth: 170,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'productCode',
             prop: 'productCode',
             label: '编码',
             label: '编码',
             align: 'center',
             align: 'center',
-            minWidth: 120
+            minWidth: 120,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'productName',
             prop: 'productName',
             label: '名称',
             label: '名称',
             align: 'center',
             align: 'center',
-            minWidth: 170
+            minWidth: 170,
+            showOverflowTooltip: true
           },
           },
           {
           {
             prop: 'productionCodes',
             prop: 'productionCodes',
@@ -476,7 +481,8 @@
           {
           {
             prop: 'brandNo',
             prop: 'brandNo',
             label: '牌号',
             label: '牌号',
-            align: 'center'
+            align: 'center',
+            showOverflowTooltip: true,
           },
           },
 
 
           {
           {
@@ -704,6 +710,7 @@
         if (where.status) {
         if (where.status) {
           where.statusList = [];
           where.statusList = [];
           where.statusList.push(where.status);
           where.statusList.push(where.status);
+          delete where.status;
         }
         }
         return getList({
         return getList({
           pageNum: page,
           pageNum: page,