chencc 1 год назад
Родитель
Сommit
9f0ca31640

+ 113 - 41
src/views/productionPlan/components/factoryAdd/index.vue

@@ -69,8 +69,8 @@
         <headerTitle title="产品信息"> </headerTitle>
 
         <el-row :gutter="24">
-          <ele-pro-table ref="tableRef"  :columns="columns" row-key="code" :cache-key="`ProductionPlanTable`" :datasource="form.productInfoList"
-            border height="40vh" key="id">
+          <ele-pro-table ref="tableRef" :columns="columns" row-key="code" :cache-key="`ProductionPlanTable`"
+            :datasource="form.productInfoList" border height="40vh" key="id">
 
 
             <template v-slot:requiredFormingNum="{ row, $index }">
@@ -261,32 +261,25 @@ export default {
     }
   },
   watch: {
-    factoryObj: {
-      immediate: true,
-      deep: true,
-      handler(val) {
+    // factoryObj: {
+    //   immediate: true,
+    //   deep: true,
+    //   handler(val) {
 
 
-        // this.type = val;
-        this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
-        // this.form = this.factoryObj;
+    //     // 修改
+    //     // this.$nextTick(() => {
+    //     //   if (val.id) {
+    //     //     this.bomListVersion();
+    //     //     if (val.bomCategoryId) {
+    //     //       this.getPlanRouting();
+    //     //     }
 
-        this.getFactoryList();
+    //     //   }
+    //     // });
 
-        this.form = val;
-        // 修改
-        this.$nextTick(() => {
-          if (val.id) {
-            this.bomListVersion();
-            if (val.bomCategoryId) {
-              this.getPlanRouting();
-            }
-
-          }
-        });
-
-      }
-    }
+    //   }
+    // }
   },
   computed: {
     clientEnvironmentId() {
@@ -576,17 +569,52 @@ export default {
     async getFactoryList() {
       this.factoryList = await getFactoryList();
     },
-    open() {
+    open(val) {
+      if (val) {
+        this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
+
+        this.getFactoryList();
+        this.form = val;
+        // 修改
+        if (val.id) {
 
+          if (Array.isArray(val.productInfoList) && val.productInfoList.length) {
+
+            this.form.productInfoList.map(async (v, index) => {
+              if (v.productType) {
+                this.$set(this.form.productInfoList[index], 'bomVersionList', await this.bomListVersionFn(v.productType, v.categoryId))
+
+              }
+              if (v.bomCategoryId) {
+                this.$set(this.form.productInfoList[index], 'routingList', await this.changeBomIdFn(v.bomCategoryId))
+
+              }
+            })
+          }
+
+        }
+
+        this.$forceUpdate()
+      }
       this.visible = true;
-      this.initForm();
-      console.log('this.form123', this.form);
 
-     
+
+      // this.$nextTick(async () => {
+      //   console.log(val.productInfoList);
+      //   this.$set(this.form, 'productInfoList', val.productInfoList);
+      //   this.$set(this.form, 'routingList', val.routingList);
+
+
+      // });
+
+
+
+
+
       //this.clientEnvironmentId 环境判断 宝悦环境
-      if (this.clientEnvironmentId == 4) {
-        this.getPlanRoutingNew();
-      }
+      // if (this.clientEnvironmentId == 4) {
+      //   this.getPlanRoutingNew();
+      // }
 
       // this.getPlanRoutingNew();
     },
@@ -688,6 +716,7 @@ export default {
       this.bomListVersion();
 
     },
+
     changeLineNumber() {
       this.form.productInfoList.map((item, index) => {
         item.lineNumber = 10 * (index + 1);
@@ -697,7 +726,7 @@ export default {
       this.$confirm('确定删除当前数据?', '提示')
         .then(() => {
           const newArray = this.form.productInfoList.filter((item, i) => i !== index)
-          this.form.productInfoList =newArray
+          this.form.productInfoList = newArray
           this.$refs.tableRef.setData(newArray);
         })
         .catch(() => { });
@@ -735,8 +764,23 @@ export default {
       // console.log(this.$refs);
       // this.$refs.tableRef.setData([]);
     },
+    changeBomIdFn(bomCategoryId) {
+      return new Promise((resolve, reject) => {
+        bomRoutingList(bomCategoryId).then((res) => {
+          let arr = res || [];
+          if (arr.length == 0) {
+            row.produceRoutingId = '';
+          }
+          resolve(arr)
+        })
+      })
+    },
+
+
     changeBomId(row, index) {
 
+      row.routingList = []
+
       bomRoutingList(row.bomCategoryId).then((res) => {
         let arr = res || [];
         if (arr.length == 0) {
@@ -747,24 +791,29 @@ export default {
         this.$forceUpdate()
       })
     },
+
     changeProductType(row, index) {
       let param = {
         bomType: row.productType,
         categoryId: row.categoryId
       }
       bomListByPlan(param).then(res => {
-        let arr = res || [];
 
+        let arr = res || [];
+        console.log(arr, 'arr');
         if (arr.length == 0) {
           row.bomCategoryId = '';
         }
 
         this.$nextTick(() => {
-          row.bomVersionList = arr;
-          this.form.productInfoList[index].bomVersionList = arr;
-          let arrAll = JSON.parse(JSON.stringify(this.form));
-          this.$set(this, 'form', arrAll);
-
+          if (arr.length) {
+            row.bomVersionList = arr;
+            this.form.productInfoList[index].bomVersionList = arr;
+            let arrAll = JSON.parse(JSON.stringify(this.form));
+            this.$set(this, 'form', arrAll);
+          } else {
+            this.form.productInfoList[index].bomVersionList = [];
+          }
         })
 
 
@@ -783,9 +832,14 @@ export default {
           return false;
         }
 
+        console.log(this.form);
+        this.form.productInfoList.forEach(v => {
+          if (!v.produceRoutingId) {
+            return this.$message.error('请选择工艺路线');
+          }
+        })
 
         if (!this.form.id) {
-
           if (this.form.productInfoList.length) {
             this.form.productInfoList.map((item, index) => {
               if (item.bomVersionList && item.bomVersionList.length) {
@@ -793,7 +847,6 @@ export default {
                 item.bomCategoryVersions = item.bomVersionList[0].versions;
                 item.produceRoutingName = item.routingList[0].name;
               }
-
             });
           }
 
@@ -828,6 +881,21 @@ export default {
         }
       });
     },
+    bomListVersionFn(produceType, categoryId) {
+      return new Promise((resolve, reject) => {
+        let param = {
+          bomType: produceType,
+          categoryId: categoryId
+        };
+        bomListByPlan(param).then((res) => {
+
+          this.bomVersionList = res || [];
+          resolve(res || [])
+
+        });
+      })
+    },
+
 
     bomListVersion() {
       let param = {
@@ -835,7 +903,11 @@ export default {
         categoryId: this.form.categoryId
       };
       bomListByPlan(param).then((res) => {
-        this.bomVersionList = res || [];
+        this.$nextTick(() => {
+          this.bomVersionList = res || [];
+
+          console.log(this.bomVersionList);
+        })
       });
     },
 

+ 4 - 3
src/views/productionPlan/index.vue

@@ -286,11 +286,11 @@
       ref="disassemblePlanRef"
       @close="reload"
     ></disassemblePlanPop>
-    <!-- v-if="factoryShow" -->
+    <!-- v-if="factoryShow" :factoryObj="factoryObj" -->
     <factoryAdd
       ref="factoryAddRef"
       :factoryType="factoryType"
-      :factoryObj="factoryObj"
+      
       @close="factoryClose"
     ></factoryAdd>
   </div>
@@ -807,10 +807,11 @@
       planEdit(row) {
 
         if (row.timeDimensionPlanType == 3) {
+          console.log(row,'1111');
           this.factoryObj = row;
           // this.factoryType = ;
           // this.factoryShow = true;
-          this.$refs.factoryAddRef.open();
+          this.$refs.factoryAddRef.open(row );
         } else {
           this.$router.push({
             path: '/saleOrder/salesToProduction',

+ 10 - 1
src/views/saleOrder/components/EquipmentDialog.vue

@@ -29,8 +29,15 @@
                   size="small"
                 ></el-input>
               </el-col>
-
               <el-col :span="6" style="margin-left: 10px">
+                <el-input
+                  v-model="searchKey"
+                  placeholder="请输入关键字"
+                  size="small"
+                ></el-input>
+              </el-col>
+              
+              <el-col :span="4" style="margin-left: 10px">
                 <el-button type="primary" size="small" @click="reload"
                   >搜索</el-button
                 >
@@ -137,6 +144,7 @@
         ],
         tableList: [],
         categoryLevelId: null,
+        searchKey: null,
         code: null,
         name: null,
         selection: []
@@ -149,6 +157,7 @@
         const params = {
           code: this.code,
           name: this.name,
+          searchKey: this.searchKey,
           pageNum: page,
           size: limit,
           categoryLevelId: this.categoryLevelId,

+ 13 - 0
src/views/saleOrder/salesToProductionNewTwo.vue

@@ -804,6 +804,19 @@ export default {
         toSubmit() {
             if (!this.form.factoriesId) return this.$message.warning('请选择所属工厂');
 
+            console.log(this.form.salesOrders);
+            this.form.salesOrders.map(v=>{
+                let arrTime = v.deliveryTime&&v.deliveryTime.split(' ');
+                let arrTimeTow = v.produceDeliveryDeadline&&v.produceDeliveryDeadline.split(' ');
+                
+                v.deliveryTime = arrTime&&arrTime[0];
+                v.produceDeliveryDeadline =arrTimeTow&&arrTimeTow[0];
+                
+
+                // if(v.salesOrders)
+            })
+            console.log(this.form.salesOrders,'123666');
+
             this.$refs.form.validate((valid) => {
 
                 if (valid) {