2213980799@qq.com 1 anno fa
parent
commit
0bc13a017a
1 ha cambiato i file con 120 aggiunte e 111 eliminazioni
  1. 120 111
      src/views/unacceptedProduct/components/salesToProduction.vue

+ 120 - 111
src/views/unacceptedProduct/components/salesToProduction.vue

@@ -57,21 +57,26 @@
 
             <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
               <el-form-item label="余量系数:" prop="marginCoefficient">
-              <!-- <DictSelection
+                <!-- <DictSelection
                 @itemChange="itemChange"
                 style="width: 200px"
                 dictName="余量系数"
                 v-model="form.marginCoefficient"
               ></DictSelection> -->
-              <el-select filterable allow-create @change="itemChange" v-model="form.marginCoefficient">
-                <el-option
-                  v-for="(item, index) in marginList"
-                  :key="index"
-                  :label="item.name"
-                  :value="item.value"
-                />
-              </el-select>
-            </el-form-item>
+                <el-select
+                  filterable
+                  allow-create
+                  @change="itemChange"
+                  v-model="form.marginCoefficient"
+                >
+                  <el-option
+                    v-for="(item, index) in marginList"
+                    :key="index"
+                    :label="item.name"
+                    :value="item.value"
+                  />
+                </el-select>
+              </el-form-item>
             </el-col>
             <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
               <el-form-item label="原批号:">{{ form.oldBatchNo }}</el-form-item>
@@ -152,11 +157,7 @@
             </el-table-column> -->
             <!-- <el-table-column label="行号" align="center" prop="lineNumber">
             </el-table-column> -->
-            <el-table-column
-              label="产品名称"
-              align="center"
-              prop="productNameNew"
-            >
+            <el-table-column label="产品名称" align="center" prop="productName">
             </el-table-column>
             <el-table-column label="合同数量" align="center" prop="contractNum">
             </el-table-column>
@@ -170,11 +171,7 @@
                 {{ scope.row.productSumWeight }} {{ form.weightUnit }}
               </template>
             </el-table-column>
-            <el-table-column
-              label="规格"
-              align="center"
-              prop="specificationNew"
-            >
+            <el-table-column label="规格" align="center" prop="specification">
             </el-table-column>
             <el-table-column label="欠交数量" align="center" prop="lackNum">
             </el-table-column>
@@ -298,20 +295,25 @@
                 </el-form-item>
               </template>
             </el-table-column>
-            <el-table-column label="权重等级" align="center" width="120"   v-if="isMoCount">
-            <template slot-scope="scope">
-              <div>
-                <el-select v-model="scope.row.weight" style="width: 100%">
-                  <el-option
-                    v-for="item of weightList"
-                    :key="item.code"
-                    :label="item.name"
-                    :value="item.code"
-                  ></el-option>
-                </el-select>
-              </div>
-            </template>
-          </el-table-column>
+            <el-table-column
+              label="权重等级"
+              align="center"
+              width="120"
+              v-if="isMoCount"
+            >
+              <template slot-scope="scope">
+                <div>
+                  <el-select v-model="scope.row.weight" style="width: 100%">
+                    <el-option
+                      v-for="item of weightList"
+                      :key="item.code"
+                      :label="item.name"
+                      :value="item.code"
+                    ></el-option>
+                  </el-select>
+                </div>
+              </template>
+            </el-table-column>
             <el-table-column
               align="center"
               width="120"
@@ -435,35 +437,38 @@
               </template>
             </el-table-column>
             <el-table-column
-            prop="priority"
-            label="优先级"
-            width="100"
-            align="center"
-            :min="0"
-            :max="10"
-          >
-            <template slot-scope="{ row, $index }">
-              <el-input
-                v-if="$index == 0"
-                v-model="row.priority"
-                type="number"
-                size="mini"
-                @change="priorityChange(row)"
-              ></el-input>
-              <el-popover
-                v-if="$index == 0"
-                placement="right"
-                width="200"
-                trigger="hover"
-                content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
-              >
-                <div class="sort-wrap" slot="reference">
-                  <i class="el-icon-caret-top" @click="sortTop(row)"></i>
-                  <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
-                </div>
-              </el-popover>
-            </template>
-          </el-table-column>
+              prop="priority"
+              label="优先级"
+              width="100"
+              align="center"
+              :min="0"
+              :max="10"
+            >
+              <template slot-scope="{ row, $index }">
+                <el-input
+                  v-if="$index == 0"
+                  v-model="row.priority"
+                  type="number"
+                  size="mini"
+                  @change="priorityChange(row)"
+                ></el-input>
+                <el-popover
+                  v-if="$index == 0"
+                  placement="right"
+                  width="200"
+                  trigger="hover"
+                  content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
+                >
+                  <div class="sort-wrap" slot="reference">
+                    <i class="el-icon-caret-top" @click="sortTop(row)"></i>
+                    <i
+                      class="el-icon-caret-bottom"
+                      @click="sortBottom(row)"
+                    ></i>
+                  </div>
+                </el-popover>
+              </template>
+            </el-table-column>
           </el-table>
 
           <el-row :gutter="24" style="margin-top: 15px">
@@ -537,7 +542,8 @@ export default {
         produceRoutingName: '',
         marginCoefficient: '1.0',
         oldBatchNo: '',
-        batchNo: ''
+        batchNo: '',
+        teamId:''
       },
 
       // 表单验证规则
@@ -571,7 +577,7 @@ export default {
         size: -1
       });
 
-      this.teamList = res.list;
+      this.teamList = res.list
     },
     getByCodeFn() {
       getByCode('margin_code').then((res) => {
@@ -582,34 +588,37 @@ export default {
 
           _arr.push({ name: key, value: value });
         });
-        console.log(_arr)
+        console.log(_arr);
         this.marginList = _arr;
       });
     },
     open(row, type) {
       this.type = type;
       this.dialog = true;
-      let contractNum=0
+      let contractNum = 0;
       let data = JSON.parse(JSON.stringify(row));
       data.forEach((item) => {
+        item.productName = item.productNameNew||item.productName;
+        item.productCode = item.productCodeNew||item.productCode;
+        item.specification = item.specificationNew||item.specification;
         if (
-          item.productNameNew.includes('板材') ||
-          item.productNameNew.includes('砌块')
+          item.productName.includes('板材') ||
+          item.productName.includes('砌块')
         ) {
           this.isMoCount = true;
           item.blockCount = item.sumNew;
           this.tableHandleKeyUp(item, '', item.blockCount, 'blockCount');
         } else {
-          item.contractNum = item.sumNew;
-          item.lackNum = item.sumNew;
-          item['productNum'] = item.sumNew;
-          item.requiredFormingNum = item.sumNew;
-          contractNum+=Number(item.sumNew)
+          item.contractNum = item.sumNew||item.productNumber;
+          item.lackNum = item.sumNew||item.productNumber;
+          item['productNum'] = item.sumNew||item.productNumber;
+          item.requiredFormingNum = item.sumNew||item.productNumber;
+          contractNum += Number(item.sumNew||item.productNumber);
         }
       });
       this.form.oldBatchNo = data[0].batchNo;
-      this.form.contractNum = contractNum
-      this.form.productCode = data[0].productCodeNew;
+      this.form.contractNum = contractNum;
+      this.form.productCode = data[0].productCode;
       this.form.brandNo = data[0].brandNo;
       this.form.model = data[0].model;
       this.form.salesOrders = data;
@@ -625,7 +634,7 @@ export default {
       });
     },
     teamChange(id) {
-      this.form.teamName = this.teamList.find((item) => (item.id = id)).name;
+      this.form.teamName = this.teamList.find((item) => (item.id == id)).name;
     },
     toInt(productNum) {
       return productNum * (this.form.marginCoefficient || 1);
@@ -633,8 +642,8 @@ export default {
 
     handleClose() {
       this.dialog = false;
-      this.isMoCount=false
-      this.$refs.form= {
+      this.isMoCount = false;
+      this.$refs.form = {
         planType: '',
         produceRoutingId: '',
         stockCountBase: '',
@@ -643,35 +652,35 @@ export default {
         marginCoefficient: '1.0',
         oldBatchNo: '',
         batchNo: ''
-      }
+      };
     },
 
-     toSubmit() {
+    toSubmit() {
+      console.log( this.$refs.form)
       this.$refs.form.validate(async (valid) => {
-       if(valid){
-        let data = JSON.parse(JSON.stringify(this.form.salesOrders));
-      data.forEach((item) => {
-        item.produceRoutingId = this.form.produceRoutingId;
-        item.notes = this.form.notes;
-        item.planType = this.form.planType;
-        item.produceRoutingName = this.form.produceRoutingName;
-        item.teamName = this.form.teamName;
-        item.teamId = this.form.teamId;
-        item.batchNo = this.form.batchNo;
-        item.productName = item.productNameNew;
-        item.productCode = item.productCodeNew;
-        item.specification = item.specificationNew;
-      });
-      // console.log(data)
-      // return
-      const res = await transformation(data, this.type);
-      if (res.code == 0) {
-        this.handleClose();
-        this.$emit('success');
-      }
-       }
+        if (valid) {
+          let data = JSON.parse(JSON.stringify(this.form.salesOrders));
+          data.forEach((item) => {
+            item.produceRoutingId = this.form.produceRoutingId;
+            item.notes = this.form.notes;
+            item.planType = this.form.planType;
+            item.produceRoutingName = this.form.produceRoutingName;
+            item.teamName = this.form.teamName;
+            item.teamId = this.form.teamId;
+            item.batchNo = this.form.batchNo;
+            // item.productName = item.productNameNew;
+            // item.productCode = item.productCodeNew;
+            // item.specification = item.specificationNew;
+          });
+          // console.log(data)
+          // return
+          const res = await transformation(data, this.type);
+          if (res.code == 0) {
+            this.handleClose();
+            this.$emit('success');
+          }
+        }
       });
-  
     },
 
     sortTop(row) {
@@ -713,7 +722,7 @@ export default {
         return;
       }
       // console.log(row);
-      let modelArr = row.specificationNew.split('*');
+      let modelArr = row.specification.split('*');
       let modelLong = modelArr[0]; // model规格长度
       let modeWide = modelArr[1]; // model规格宽度
       let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
@@ -724,13 +733,13 @@ export default {
         // 计算块数的公式:
         // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
         // 每一模的块数*模数moCount = 总块数
-        if (row.productNameNew.includes('板材')) {
+        if (row.productName.includes('板材')) {
           row.blockCount =
             Math.floor(600 / modelLong) *
             Math.floor(120 / modeHight) *
             Math.floor(60 / modeWide) *
             row.moCount;
-        } else if (row.productNameNew.includes('砌块')) {
+        } else if (row.productName.includes('砌块')) {
           let modelLongFixed = (600 / modelLong).toFixed(2);
           modelLongFixed = modelLongFixed.substring(
             0,
@@ -763,14 +772,14 @@ export default {
         // console.log(modeWide,'row.blockCount')
         // console.log(modeHight,'row.blockCount')
 
-        if (row.productNameNew.includes('板材')) {
+        if (row.productName.includes('板材')) {
           row.moCount = Math.ceil(
             row.blockCount /
               (Math.floor(600 / modelLong) *
                 Math.floor(120 / modeHight) *
                 Math.floor(60 / modeWide))
           );
-        } else if (row.productNameNew.includes('砌块')) {
+        } else if (row.productName.includes('砌块')) {
           row.moCount = Math.ceil(
             row.blockCount /
               Math.floor(
@@ -782,14 +791,14 @@ export default {
         //块数
         row.blockCount = e;
 
-        if (row.productNameNew.includes('板材')) {
+        if (row.productName.includes('板材')) {
           row.moCount = Math.ceil(
             row.blockCount /
               (Math.floor(600 / modelLong) *
                 Math.floor(120 / modeHight) *
                 Math.floor(60 / modeWide))
           );
-        } else if (row.productNameNew.includes('砌块')) {
+        } else if (row.productName.includes('砌块')) {
           row.moCount = Math.ceil(
             row.blockCount /
               Math.floor(