Kaynağa Gözat

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-aps into dev

ysy 1 yıl önce
ebeveyn
işleme
2258dbc2d6
1 değiştirilmiş dosya ile 148 ekleme ve 8 silme
  1. 148 8
      src/views/saleOrder/components/create-order.vue

+ 148 - 8
src/views/saleOrder/components/create-order.vue

@@ -127,14 +127,14 @@
         </el-table-column>
         <el-table-column label="重量单位" align="center" prop="weightUnit">
         </el-table-column>
-        <el-table-column label="交付数量" align="center" prop="contractNum">
+        <el-table-column label="订单数量" align="center" prop="contractNum">
           <template slot-scope="scope">
             <el-form-item
               label-width="0px"
               :prop="'productInfoList.' + scope.$index + '.contractNum'"
               :rules="{
                 required: true,
-                message: '请输入交付数量',
+                message: '请输入订单数量',
                 trigger: 'blur'
               }"
             >
@@ -149,12 +149,56 @@
             </el-form-item>
           </template>
         </el-table-column>
-        <el-table-column label="单位" align="center" prop="productName">
-          <template slot-scope="{ row }">
-            <span v-if="clientEnvironmentId == 4">
-              {{ row.productName.includes('板材') ? '块' : '模' }}
-            </span>
+        <el-table-column label="计量单位" align="center" prop="measuringUnit">
+          
+        </el-table-column>
+        <el-table-column
+          label="模数"
+          align="center"
+          width="100"
+          v-if="clientEnvironmentId == '4'"
+        >
+          <template slot-scope="scope">
+            <div>
+              <el-input
+                style="width: 100%"
+                size="small"
+                v-model="scope.row.moCount"
+                oninput="value=value.replace(/[^0-9.]/g,'')"
+                @input="
+                  tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
+                "
+                placeholder="请输入"
+              >
+              </el-input>
+            </div>
+          </template>
+        </el-table-column>
 
+        <el-table-column
+          align="center"
+          width="100"
+          label="块数"
+          v-if="clientEnvironmentId == '4'"
+        >
+          <template slot-scope="scope">
+            <div>
+              <el-input
+                size="small"
+                style="width: 100%"
+               
+                @input="
+                  tableHandleKeyUp(
+                    scope.row,
+                    scope.$index,
+                    $event,
+                    'blockCount'
+                  )
+                "
+                v-model="scope.row.blockCount"
+                placeholder="请输入"
+              ></el-input>
+            </div>
           </template>
         </el-table-column>
         <el-table-column label="交付重量" align="center" prop="productWeight">
@@ -290,6 +334,96 @@ export default {
       this.$refs.form.clearValidate();
       this.visible = false;
     },
+
+    // 表格:模数、数量(方)、块数输入框 输入事件
+    tableHandleKeyUp(row, index, e, name) {
+      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规格高度
+      modeHight = Number(modeHight);
+      if (name === 'moCount') {
+        // 模数
+        row.moCount = e;
+        // 计算块数的公式:
+        // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
+        // 每一模的块数*模数moCount = 总块数
+        if (row.productName.includes('板材')) {
+          row.blockCount =
+            Math.floor(600 / modelLong) *
+            Math.floor(120 / modeHight) *
+            Math.floor(60 / modeWide) *
+            row.moCount;
+        } else if (row.productName.includes('砌块')) {
+          let modelLongFixed = (600 / modelLong).toFixed(2);
+          modelLongFixed = modelLongFixed.substring(
+            0,
+            modelLongFixed.length - 1
+          );
+          let modeWideFixed = (120 / modeWide).toFixed(2);
+          modeWideFixed = modeWideFixed.substring(0, modeWideFixed.length - 1);
+          let modeHightFixed = (60 / modeHight).toFixed(2);
+          modeHightFixed = modeHightFixed.substring(
+            0,
+            modeHightFixed.length - 1
+          );
+          row.blockCount =
+            Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
+            row.moCount;
+        }
+
+        row.contractNum =
+          ((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
+          row.blockCount;
+      } else if (name === 'sum') {
+        //方数
+        row.contractNum = e;
+
+        row.blockCount = Math.floor(
+          e / ((modelLong * modeWide * modeHight) / 1000000)
+        );
+        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.productName.includes('砌块')) {
+          row.moCount = Math.ceil(
+            row.blockCount /
+              Math.floor(
+                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+              )
+          );
+        }
+      } else if (name === 'blockCount') {
+        //块数
+        row.blockCount = e;
+
+        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.productName.includes('砌块')) {
+          row.moCount = Math.ceil(
+            row.blockCount /
+              Math.floor(
+                (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
+              )
+          );
+        }
+        row.contractNum =
+          (Number(e) * modelLong * modeWide * modeHight) / 1000000;
+
+      }
+      row.contractNum = Number(row.contractNum.toFixed(5))
+
+    },
+
     // 删除产品
     handleDeleteItem(index) {
       this.form.productInfoList.splice(index, 1);
@@ -363,7 +497,8 @@ export default {
               weightUnit: item.weightUnit,
               model: item.modelType,
               specification: item.specification,
-              brandNo: item.brandNum
+              brandNo: item.brandNum,
+              measuringUnit:item.measuringUnit
             };
           }
         })
@@ -412,6 +547,11 @@ export default {
 
         this.$set(pos[index], 'productWeight', number);
       }
+      if(this.clientEnvironmentId==4){
+        this.tableHandleKeyUp(row, '', row.contractNum, 'sum');
+
+      }
+
     }
   }
 };