ysy пре 1 година
родитељ
комит
2e0438eae5
1 измењених фајлова са 35 додато и 11 уклоњено
  1. 35 11
      src/views/material/BOMmanage/components/workingProcedure.vue

+ 35 - 11
src/views/material/BOMmanage/components/workingProcedure.vue

@@ -440,14 +440,14 @@
             :immediate="true"
           >
             <!-- 表头工具栏 -->
-            <template v-if="!isView" v-slot:toolbar>
-              <el-button type="primary" @click="add">添加</el-button>
+            <template  v-slot:toolbar>
+              <el-button type="primary" v-if="!isView" @click="add">添加</el-button>
               <div class="toolbar_box">
                 <div
                   ><span>基本数量</span>
-                  <el-input placeholder="请输入" v-model.number="baseCount">
+                  <el-input placeholder="请输入" :disabled="isView" v-model.number="baseCount">
                   </el-input>
-                  <DictSelection dictName="计量单位" v-model="baseCountUnit"
+                  <DictSelection dictName="计量单位" :disabled="isView" v-model="baseCountUnit"
                 /></div>
               </div>
             </template>
@@ -661,12 +661,12 @@
             :immediate="true"
           >
             <!-- 表头工具栏 -->
-            <template v-if="!isView" v-slot:toolbar>
-              <el-button type="primary" @click="add">添加</el-button>
+            <template v-slot:toolbar>
+              <el-button type="primary"  v-if="!isView" @click="add">添加</el-button>
               <div class="toolbar_box">
                 <div
                   ><span>基本数量</span>
-                  <el-input placeholder="请输入" v-model.number="baseCount2">
+                  <el-input placeholder="请输入" :disabled="isView" v-model.number="baseCount2">
                   </el-input>
                   <DictSelection dictName="计量单位" v-model="baseCountUnit2"
                 /></div>
@@ -1362,7 +1362,7 @@
         this.tableData.taskParam[this.currentIndex][type].splice(index, 1);
       },
       addProductList(list) {
-        console.log(list, 8888);
+      
         let subCode = 0;
         let array = [];
         list.map((item, index) => {
@@ -1380,7 +1380,7 @@
               ) +
               10 * ++index +
               '';
-            console.log(max);
+        
             if (max.length < 4) {
               max = new Array(4 - max.length).fill('0').join('') + max;
             }
@@ -1391,7 +1391,12 @@
             }
           }
 
-
+            
+          if(item.categoryLevelPathIdParent == 8 && this.isValueANumber(this.baseCount) && this.isValueANumber(item.specification)  ) {
+             let num = this.baseCount / item.specification;
+             item.count = num.toFixed(3)
+          } 
+        
 
 
           subCode = max.substring(0, max.length - 1) + '0';
@@ -1402,7 +1407,7 @@
             categoryCode: item.categoryCode,
             isReworkBom: 0,
             brandNum: item.brandNum,
-            count: '',
+            count:  item.count  || '',
             modelType: item.modelType,
             unit: item.measuringUnit,
             bomArtFiles: [],
@@ -1424,6 +1429,25 @@
           this.tableData.taskParam[this.currentIndex].materialQuota
         );
       },
+
+
+        isValueANumber(variable) {
+    if (variable === undefined || variable === null) {
+        return false; // 变量没有值
+    }
+    if (typeof variable === 'number') {
+        return true; // 基本类型的数字
+    }
+    if (typeof variable === 'string' && !isNaN(variable) && !variable.includes('.') || (variable.includes('.') && !variable.endsWith('.'))) {
+        // 字符串类型的数字(注意:这个正则表达式判断较为简单,可能需要根据实际情况调整)
+        // 或者使用 Number.isFinite(parseFloat(variable)) 来代替这部分逻辑,但要注意性能开销和边缘情况
+        const num = Number(variable);
+        return !isNaN(num) && isFinite(num);
+    }
+    return false; // 其他类型
+},
+
+
       add() {
         let subCode = '0010';
         let type = '';