ysy пре 1 година
родитељ
комит
cb2eb66c6b
2 измењених фајлова са 97 додато и 28 уклоњено
  1. 18 4
      src/api/saleOrder/index.js
  2. 79 24
      src/views/saleOrder/salesToProduction.vue

+ 18 - 4
src/api/saleOrder/index.js

@@ -215,13 +215,27 @@ export async function fieldModel(params) {
 }
 
 
+// aps生产计划获取产品的多个bom版本
+export async function bomListByPlan(params) {
+  const res = await request.get(
+    `/main/bomCategory/bomListByPlan`, { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+
 
-// 销售订单转生产计划获取工艺路线
 
-export async function productionPlanRouting(data) {
-  const res = await request.post(`/aps/salesorder/productionPlanRouting`,  data);
+// 根据bom 获取工艺路线
+
+export async function bomRoutingList(id) {
+  const res = await request.get(`/main/bomCategory/bomRoutingList/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+

+ 79 - 24
src/views/saleOrder/salesToProduction.vue

@@ -31,10 +31,9 @@
           </el-col>
 
           <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
-            <el-form-item label="生产方式:" prop="produceType">
-              <el-select v-model="form.produceType" style="width: 100%"  >
+            <el-form-item label="加工方式:" prop="produceType">
+              <el-select v-model="form.produceType" style="width: 100%"   @change="changeProduceType" >
                   <el-option
-                    @click.native="changeProduceType"
                     v-for="item of producedList"
                     :key="item.code"
                     :label="item.name"
@@ -44,6 +43,19 @@
             </el-form-item>
           </el-col>
 
+          <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
+            <el-form-item label="BOM版本:" prop="bomCategoryId">
+              <el-select v-model="form.bomCategoryId" style="width: 100%"  @change="changeBomId" >
+                  <el-option
+                    v-for="item of bomVersionList"
+                    :key="item.id"
+                    :label="item.name + '(V' + item.versions + '.0)'"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
+            </el-form-item>
+          </el-col>
+
           <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
             <el-form-item label="工艺路线:" prop="produceRoutingId">
               <!--  @click.native="openVersion"   -->
@@ -67,6 +79,13 @@
               ></el-checkbox>
             </el-form-item>
           </el-col> -->
+
+
+   
+
+        </el-row>
+        <el-row :gutter="24">
+
           <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
             <el-form-item label="余量系数:" prop="marginCoefficient">
               <el-select
@@ -94,9 +113,6 @@
             </el-form-item>
           </el-col>
 
-
-   
-
         </el-row>
         <el-row :gutter="24" class="row-intro">
           <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
@@ -510,8 +526,8 @@ import {
   releaseSave,
   getInventory,
   getUpdateInfoById,
-  getProductVersion,
-  productionPlanRouting
+  bomRoutingList,
+  bomListByPlan
 } from '@/api/saleOrder';
 
 import { getByCode } from '@/api/system/dictionary-data';
@@ -558,11 +574,13 @@ export default {
         produceRoutingName: '',
         marginCoefficient: '1.0',
         batchNo: null,
-        produceType: 2
+        produceType: 2,
+        bomCategoryId: '',
       },
 
       marginList: [],
 
+      bomVersionList: [],
       routingList: [],
 
       // 表单验证规则
@@ -573,8 +591,12 @@ export default {
         ],
 
         produceType: [
-        { required: true, message: '请选择生产类型', trigger: 'blur' }
-        ]
+        { required: true, message: '请选择加工方式', trigger: 'blur' }
+        ],
+        bomCategoryId: [
+          { required: true, message: '请选择BOM版本', trigger: 'blur' }
+        ],
+
       },
       // selection: [],
       loading: false
@@ -597,15 +619,19 @@ export default {
     this.getByCodeFn();
     if (this.type == 'edit') {
       this.getPlanInfo(this.$route.query.id);
+
     } else {
       this.getSaleInfo();
-      this.getPlanRouting();
+
     }
   },
   methods: {
     async getPlanInfo(id) {
       const data = await getUpdateInfoById(id);
       this.form = data;
+      this.bomListVersion()
+      this.getPlanRouting()
+      this.bomListVersion()
 
     
     },
@@ -628,32 +654,60 @@ export default {
       });
     },
 
+ 
     getPlanRouting() {
-    let params = {
-      ids: JSON.parse(this.$route.query.selection),
-      produceType: this.form.produceType
-    }
-    productionPlanRouting(params).then((res) => {
+      bomRoutingList(this.form.bomCategoryId).then((res) => {
         this.routingList = res || []
-
-        if( this.routingList.length == 1) {
-          this.$set(this.form, 'produceRoutingId',  this.routingList[0].id);
-          this.$set(this.form, 'produceRoutingName', this.routingList[0].name);
-          this.$set(this.form, 'produceVersionName',this.routingList[0].version);
-        }
       })
 
     },
 
+    bomListVersion() {
+      let param = {
+        bomType:  this.form.produceType,
+        categoryId: this.form.salesOrders[0].categoryId
+      }
+      bomListByPlan(param).then(res => {
+        this.bomVersionList = res || []
+      })
+    },
+
 
     changeProduceType() {
+      this.form.bomCategoryId = ''
+      this.form['bomCategoryName'] = ''
+      this.form['bomCategoryVersions'] = ''
 
+
+      this.bomVersionList  = []
+
+      this.routingList  = []
        this.form.produceRoutingId = ''
        this.form.produceRoutingName = ''
         this.form.produceVersionName = ''
-        this.getPlanRouting()
+        this.bomListVersion()
+
     },
 
+    changeBomId() {
+      this.routingList  = []
+      this.form.produceRoutingId = ''
+       this.form.produceRoutingName = ''
+        this.form.produceVersionName = ''
+
+        this.bomVersionList.forEach((f) => {
+        if(f.id == this.form.bomCategoryId) {
+          this.$set(this.form, 'bomCategoryName', f.name);
+          this.$set(this.form, 'bomCategoryVersions', f.versions);
+        }
+
+      })
+
+       this.getPlanRouting()
+    },
+
+
+
     changeRoute() {
       this.routingList.forEach((f) => {
         if(f.id == this.form.produceRoutingId) {
@@ -671,6 +725,7 @@ export default {
         this.form = deepClone(res);
         if(!this.form.produceType) {
           this.form.produceType = 2;
+          this.bomListVersion()
          }
         this.form.produceRoutingName =
           res.produceRoutingName || this.$route.query.produceRoutingName;