ysy hai 1 ano
pai
achega
4229f257b1
Modificáronse 2 ficheiros con 86 adicións e 25 borrados
  1. 12 0
      src/api/saleOrder/index.js
  2. 74 25
      src/views/saleOrder/salesToProduction.vue

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

@@ -212,4 +212,16 @@ export async function fieldModel(params) {
     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);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }

+ 74 - 25
src/views/saleOrder/salesToProduction.vue

@@ -29,14 +29,32 @@
               </DictSelection>
             </el-form-item>
           </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-option
+                    @click.native="changeProduceType"
+                    v-for="item of producedList"
+                    :key="item.code"
+                    :label="item.name"
+                    :value="item.code"
+                  ></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="produceRoutingName">
-              <el-input
-                @click.native="openVersion"
-                placeholder="请选择工艺路线"
-                readonly
-                v-model="form.produceRoutingName"
-              ></el-input>
+            <el-form-item label="工艺路线:" prop="produceRoutingId">
+              <!--  @click.native="openVersion"   -->
+              <el-select v-model="form.produceRoutingId" style="width: 100%" @change="changeRoute">
+                  <el-option
+                    v-for="item of routingList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
+                  ></el-option>
+                </el-select>
             </el-form-item>
           </el-col>
 
@@ -77,18 +95,7 @@
           </el-col>
 
 
-          <el-col v-bind="styleResponsive ? { lg: 4, md: 8 } : { span: 4 }">
-            <el-form-item label="生产方式:" prop="produced">
-              <el-select v-model="form.produceType" style="width: 100%">
-                  <el-option
-                    v-for="item of producedList"
-                    :key="item.code"
-                    :label="item.name"
-                    :value="item.code"
-                  ></el-option>
-                </el-select>
-            </el-form-item>
-          </el-col>
+   
 
         </el-row>
         <el-row :gutter="24" class="row-intro">
@@ -503,7 +510,8 @@ import {
   releaseSave,
   getInventory,
   getUpdateInfoById,
-  getProductVersion
+  getProductVersion,
+  productionPlanRouting
 } from '@/api/saleOrder';
 
 import { getByCode } from '@/api/system/dictionary-data';
@@ -550,19 +558,22 @@ export default {
         produceRoutingName: '',
         marginCoefficient: '1.0',
         batchNo: null,
-        produceType: 2
+        produceType: ''
       },
 
       marginList: [],
 
+      routingList: [],
+
       // 表单验证规则
       rules: {
-        produceRoutingName: [
-          { required: true, message: '请选择生产版本', trigger: 'change' }
+
+        produceRoutingId: [
+          { required: true, message: '请选择工艺路线', trigger: 'blur' }
         ],
 
         produceType: [
-        { required: true, message: '请选择生产类型', trigger: 'change' }
+        { required: true, message: '请选择生产类型', trigger: 'blur' }
         ]
       },
       // selection: [],
@@ -587,12 +598,12 @@ export default {
       this.getPlanInfo(this.$route.query.id);
     } else {
       this.getSaleInfo();
+      this.getPlanRouting();
     }
   },
   methods: {
     async getPlanInfo(id) {
       const data = await getUpdateInfoById(id);
-
       this.form = data;
     },
     async _getInventory() {
@@ -613,9 +624,47 @@ export default {
         this.marginList = _arr;
       });
     },
+
+    getPlanRouting() {
+    let params = {
+      ids: JSON.parse(this.$route.query.selection),
+      produceType: this.form.produceType
+    }
+    productionPlanRouting(params).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);
+        }
+      })
+
+    },
+
+
+    changeProduceType() {
+
+      this.form.produceRoutingId = ''
+     this.form.produceRoutingName = ''
+        this.form.produceVersionName = ''
+        this.getPlanRouting()
+    },
+
+    changeRoute() {
+      this.routingList.forEach((f) => {
+        if(f.id == this.form.produceRoutingId) {
+          this.$set(this.form, 'produceRoutingName', f.name);
+          this.$set(this.form, 'produceVersionName', f.version);
+        }
+
+      })
+    },
+
     getSaleInfo() {
       let params = JSON.parse(this.$route.query.selection);
       productionToPlan(params).then((res) => {
+        console.log(res);
         this.form = deepClone(res);
         this.form.produceRoutingName =
           res.produceRoutingName || this.$route.query.produceRoutingName;