Jelajahi Sumber

修改工步bug

695593266@qq.com 1 bulan lalu
induk
melakukan
1e635d31c1

+ 35 - 26
src/views/material/BOMmanage/components/workmanship.vue

@@ -565,36 +565,45 @@
         this.reload();
       },
       async getCreatedStep(stepData, formData) {
-        if (stepData && stepData.id) {
-          return stepData;
+        let stepId = null;
+        if (stepData && typeof stepData === 'object' && stepData.id) {
+          stepId = stepData.id;
+        } else if (
+          stepData &&
+          (typeof stepData === 'number' || typeof stepData === 'string')
+        ) {
+          stepId = stepData;
         }
-        if (!formData || (!formData.name && !formData.code)) {
-          return null;
+        if (!stepId && formData && formData.name) {
+          const res = await stepManagement.list({
+            pageNum: 1,
+            size: 50,
+            name: formData.name
+          });
+          const stepList = Array.isArray(res)
+            ? res
+            : Array.isArray(res?.list)
+            ? res.list
+            : [];
+          const matched = stepList
+            .filter((item) => item.name === formData.name)
+            .sort((a, b) => Number(b.id || 0) - Number(a.id || 0));
+          if (matched.length) {
+            stepId = matched[0].id;
+          }
         }
-        const res = await stepManagement.list({
-          pageNum: 1,
-          size: 50,
-          name: formData.name,
-          code: formData.code,
-          status: formData.status
-        });
-        const stepList = Array.isArray(res)
-          ? res
-          : Array.isArray(res?.list)
-          ? res.list
-          : [];
-        if (!stepList.length) {
+        if (!stepId) {
           return null;
         }
-        return (
-          stepList.find((item) => {
-            return (
-              item.name === formData.name &&
-              (!formData.code || item.code === formData.code)
-            );
-          }) ||
-          stepList.sort((a, b) => Number(b.id || 0) - Number(a.id || 0))[0]
-        );
+        try {
+          const detail = await stepManagement.getById(stepId);
+          if (detail && detail.id) {
+            return detail;
+          }
+        } catch (e) {
+          console.log(e, 'getById err');
+        }
+        return null;
       },
       async refreshStepList(current) {
         const data = await getStepListById({

+ 85 - 57
src/views/material/BOMmanage/qualityTesting/term.vue

@@ -312,11 +312,7 @@
 
       <div slot="footer" class="dialog-footer">
         <el-button @click="handleSchemeDialogClose">取消</el-button>
-        <el-button
-          type="primary"
-          :loading="schemeSaving"
-          @click="saveScheme"
-        >
+        <el-button type="primary" :loading="schemeSaving" @click="saveScheme">
           保存
         </el-button>
       </div>
@@ -432,7 +428,9 @@
                 ></DictSelection>
                 <el-input
                   v-model="itemForm.defaultValue"
-                  :placeholder="itemForm.textType == 1 ? '请输入数字' : '请输入'"
+                  :placeholder="
+                    itemForm.textType == 1 ? '请输入数字' : '请输入'
+                  "
                   @input="defaultInput"
                 ></el-input>
               </div>
@@ -457,10 +455,7 @@
                   clearable
                   v-model="itemForm.symbol"
                 ></DictSelection>
-                <el-select
-                  v-model="itemForm.defaultValue"
-                  placeholder="请选择"
-                >
+                <el-select v-model="itemForm.defaultValue" placeholder="请选择">
                   <el-option label="TRUE" :value="'TRUE'"></el-option>
                   <el-option label="FALSE" :value="'FALSE'"></el-option>
                 </el-select>
@@ -503,7 +498,10 @@
         </el-row>
 
         <el-row :gutter="16">
-          <el-col :span="12" v-if="itemForm.textType != 2 && itemForm.textType != 5">
+          <el-col
+            :span="12"
+            v-if="itemForm.textType != 2 && itemForm.textType != 5"
+          >
             <el-form-item
               label="参数单位"
               prop="unitName"
@@ -539,7 +537,7 @@
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="质检阶段" prop="qualityStage">
+            <el-form-item label="质检阶段">
               <el-select
                 v-model="itemForm.qualityStage"
                 placeholder="请选择"
@@ -699,10 +697,10 @@
           textType: [
             { required: true, message: '请选择参数类型', trigger: 'change' }
           ],
-          status: [{ required: true, message: '请选择状态', trigger: 'change' }],
-          qualityStage: [
-            { required: true, message: '请选择质检阶段', trigger: 'change' }
-          ]
+          status: [{ required: true, message: '请选择状态', trigger: 'change' }]
+          // qualityStage: [
+          //   { required: true, message: '请选择质检阶段', trigger: 'change' }
+          // ]
         },
         columns: [
           {
@@ -799,7 +797,8 @@
         return (list || []).map((item) => ({
           ...item,
           unitName: item.unitName || item.unit || '',
-          _localKey: item._localKey || this.getRowKey(item) || this.createLocalKey()
+          _localKey:
+            item._localKey || this.getRowKey(item) || this.createLocalKey()
         }));
       },
       normalizeToNumber(value) {
@@ -819,17 +818,25 @@
         if (!this.isQualityInspection) {
           return '';
         }
-        const row = this.schemeTypeList.find((item) => item.label == '首件两检');
+        const row = this.schemeTypeList.find(
+          (item) => item.label == '首件两检'
+        );
         return row ? row.value : '';
       },
       getParameterSummary(row) {
         if (row.textType == 3) {
           const rangeValue = [row.minValue, row.maxValue]
-            .filter((item) => item !== '' && item !== null && item !== undefined)
+            .filter(
+              (item) => item !== '' && item !== null && item !== undefined
+            )
             .join(' - ');
-          return `${row.symbol || ''}${rangeValue}${row.unitName || row.unit || ''}`;
+          return `${row.symbol || ''}${rangeValue}${
+            row.unitName || row.unit || ''
+          }`;
         }
-        return `${row.symbol || ''}${row.defaultValue || ''}${row.unitName || row.unit || ''}`;
+        return `${row.symbol || ''}${row.defaultValue || ''}${
+          row.unitName || row.unit || ''
+        }`;
       },
       resetSchemeForm() {
         this.schemeForm = createSchemeForm(this.getDefaultSchemeType());
@@ -859,7 +866,9 @@
         }
       },
       async assignSchemeCode() {
-        this.schemeForm.qualitySchemeTemplateCode = await getCode('template_code');
+        this.schemeForm.qualitySchemeTemplateCode = await getCode(
+          'template_code'
+        );
       },
       async openItemDialog(row, index = -1) {
         this.currentItemIndex = index;
@@ -973,13 +982,19 @@
             return false;
           }
         }
-        if (this.itemForm.defaultValue !== '' && this.itemForm.maxValue !== '') {
+        if (
+          this.itemForm.defaultValue !== '' &&
+          this.itemForm.maxValue !== ''
+        ) {
           if (defaultValue >= maxValue) {
             this.$message.warning('默认值应小于参数上限');
             return false;
           }
         }
-        if (this.itemForm.defaultValue !== '' && this.itemForm.minValue !== '') {
+        if (
+          this.itemForm.defaultValue !== '' &&
+          this.itemForm.minValue !== ''
+        ) {
           if (defaultValue <= minValue) {
             this.$message.warning('默认值应大于参数下限');
             return false;
@@ -1004,7 +1019,8 @@
               this.itemForm.sort === '' || this.itemForm.sort === null
                 ? this.schemeForm.inspectionItemVOList.length + 1
                 : Number(this.itemForm.sort),
-            unitName: this.itemForm.textType == 5 ? 'h' : this.itemForm.unitName,
+            unitName:
+              this.itemForm.textType == 5 ? 'h' : this.itemForm.unitName,
             unit: this.itemForm.textType == 5 ? 'h' : this.itemForm.unitName,
             executionMethod: 1,
             procedureJson: this.itemForm.procedureJson || {},
@@ -1018,7 +1034,11 @@
           if (this.currentItemIndex === -1) {
             this.schemeForm.inspectionItemVOList.push(itemData);
           } else {
-            this.$set(this.schemeForm.inspectionItemVOList, this.currentItemIndex, itemData);
+            this.$set(
+              this.schemeForm.inspectionItemVOList,
+              this.currentItemIndex,
+              itemData
+            );
           }
           this.schemeForm.inspectionItemVOList.sort((a, b) => {
             return Number(a.sort || 0) - Number(b.sort || 0);
@@ -1036,21 +1056,24 @@
           type: this.normalizeToNumber(this.schemeForm.type),
           status: 1,
           qualityMode: this.normalizeToNumber(this.schemeForm.qualityMode),
-          inspectionItemVOList: this.schemeForm.inspectionItemVOList.map((item) => {
-            const { _localKey, ...rest } = item;
-            return {
-              ...rest,
-              id: '',
-              textType: this.normalizeToNumber(rest.textType),
-              status: this.normalizeToNumber(rest.status),
-              qualityStage: this.normalizeToNumber(rest.qualityStage),
-              qualityStandardType: this.normalizeToNumber(
-                rest.qualityStandardType
-              ),
-              executionMethod: this.normalizeToNumber(rest.executionMethod) || 1,
-              unit: rest.unitName || rest.unit || ''
-            };
-          }),
+          inspectionItemVOList: this.schemeForm.inspectionItemVOList.map(
+            (item) => {
+              const { _localKey, ...rest } = item;
+              return {
+                ...rest,
+                id: '',
+                textType: this.normalizeToNumber(rest.textType),
+                status: this.normalizeToNumber(rest.status),
+                qualityStage: this.normalizeToNumber(rest.qualityStage),
+                qualityStandardType: this.normalizeToNumber(
+                  rest.qualityStandardType
+                ),
+                executionMethod:
+                  this.normalizeToNumber(rest.executionMethod) || 1,
+                unit: rest.unitName || rest.unit || ''
+              };
+            }
+          ),
           templateCategoryList: []
         };
       },
@@ -1144,22 +1167,27 @@
       async changeSel(row) {
         const { data } = await getTemplateById(row.id);
         const typeLabel = this.getSchemeTypeLabel(data.type);
-        const inspectionItemVOList = (data.inspectionItemVOList || []).map((item) => ({
-          ...item,
-          type: data.type,
-          qualityMode: data.qualityMode,
-          categoryLevelClassName: item.categoryLevelClassName || typeLabel,
-          qualitySchemeTemplateCode: data.qualitySchemeTemplateCode,
-          qualitySchemeTemplateName: data.qualitySchemeTemplateName,
-          templateRemark: data.templateRemark,
-          sampleProportion: data.sampleProportion,
-          sampleProportionUnit: data.sampleProportionUnit,
-          validityPeriod: data.validityPeriod,
-          validityPeriodUnit: data.validityPeriodUnit,
-          unitName: item.unitName || item.unit || '',
-          unit: item.unitName || item.unit || ''
-        }));
-        this.list = [...this.list, ...this.attachLocalKeys(inspectionItemVOList)];
+        const inspectionItemVOList = (data.inspectionItemVOList || []).map(
+          (item) => ({
+            ...item,
+            type: data.type,
+            qualityMode: data.qualityMode,
+            categoryLevelClassName: item.categoryLevelClassName || typeLabel,
+            qualitySchemeTemplateCode: data.qualitySchemeTemplateCode,
+            qualitySchemeTemplateName: data.qualitySchemeTemplateName,
+            templateRemark: data.templateRemark,
+            sampleProportion: data.sampleProportion,
+            sampleProportionUnit: data.sampleProportionUnit,
+            validityPeriod: data.validityPeriod,
+            validityPeriodUnit: data.validityPeriodUnit,
+            unitName: item.unitName || item.unit || '',
+            unit: item.unitName || item.unit || ''
+          })
+        );
+        this.list = [
+          ...this.list,
+          ...this.attachLocalKeys(inspectionItemVOList)
+        ];
       }
     }
   };