qushaowei
2023-11-18 eb48d3bada053e26def2a94d46dbe115a5a7bb2f
src/views/eam/modules/inspectionProject/InspectionProjectModel.vue
@@ -62,7 +62,7 @@
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
          <!-- <a-col :span="12">
            <a-form-item
              label="检验值类型"
              :labelCol="labelCol"
@@ -78,11 +78,9 @@
                @change="(e)=>handleChange(e)"
              />
            </a-form-item>
          </a-col>
          <a-col
            v-if="testValueType == '2'"
            :span="12"
          >
          </a-col> -->
          <a-col :span="12">
            <!-- v-if="testValueType == '2'" -->
            <a-form-item
              label="检测标准"
              :labelCol="labelCol"
@@ -116,7 +114,7 @@
            </a-form-item>
          </a-col> -->
          <a-col
          <!-- <a-col
            v-if="testValueType == '1'"
            :span="12"
          >
@@ -133,9 +131,9 @@
                v-decorator="['surfaceValue', validatorRules.surfaceValue ]"
              />
            </a-form-item>
          </a-col>
          </a-col> -->
        </a-row>
        <a-row
        <!-- <a-row
          v-if="testValueType == '1'"
          :gutter="24"
        >
@@ -169,8 +167,8 @@
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
        </a-row> -->
        <!-- <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item
              label="点检方法"
@@ -202,8 +200,8 @@
                v-decorator="['unitId', validatorRules.unitId]"
              />
            </a-form-item>
          </a-col>
          <!-- <a-col :span="12">
          </a-col> -->
        <!-- <a-col :span="12">
            <a-form-item
              label="点检工具"
              :labelCol="labelCol"
@@ -217,7 +215,7 @@
              />
            </a-form-item>
          </a-col> -->
        </a-row>
        <!-- </a-row> -->
        <a-row :gutter="24">
          <a-col :span="24">
@@ -246,13 +244,13 @@
      >
        关闭
      </a-button>
      <a-button
      <!-- <a-button
        v-if="!this.model.id"
        :disabled="disableSubmit || confirmLoading"
        :loading="confirmLoading"
        @click="handleOkAndAdd"
        type="primary"
      >保存并继续新增</a-button>
      >保存并继续新增</a-button> -->
      <a-button
        :disabled="disableSubmit || confirmLoading"
        :loading="confirmLoading"
@@ -361,25 +359,24 @@
      this.model = Object.assign({}, record);
      this.visible = true;
      this.disableSubmit = false;
      this.testValueType = record.testValueType
      // this.testValueType = record.testValueType
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'inspectionProjectCategoryNumName',
          'num', 'name', 'unitId', 'detectionStandard', 'testValueType', 'inspectionMethod', 'inspectionTool', 'remark'))
          'name', 'detectionStandard', 'remark'))
      });
      if (record.testValueType == '1') {
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'surfaceValue', 'upValue', 'downValue'))
        });
      }
      // if (record.testValueType == '1') {
      //   this.$nextTick(() => {
      //     this.form.setFieldsValue(pick(this.model, 'surfaceValue', 'upValue', 'downValue'))
      //   });
      // }
      if (record.id) {
        this.codeDisable = true;
      } else {
        debugger
        this.codeDisable = false;
        this.$nextTick(() => {
          this.form.setFieldsValue({ "testValueType": '2' })
          this.testValueType = '2'
        });
        // this.$nextTick(() => {
        //   this.form.setFieldsValue({ "testValueType": '2' })
        //   this.testValueType = '2'
        // });
      }
    },
@@ -391,32 +388,32 @@
    //保存并新增按钮触发
    handleOkAndAdd() {
      const that = this
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let formData = Object.assign(this.model, values);
          formData.inspectionProjectCategoryId = this.inspectionProjectCategoryId
          postAction(this.url.add, formData).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
              that.alterFlag = new Date();
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            this.confirmLoading = false
            this.form.setFieldsValue(pick(this.model, 'inspectionProjectCategoryNumName'))
            this.form.setFieldsValue({ "inspectionContent": null, "inspectionRequire": null, "inspectionMethod": null, "inspectionTool": null, "num": null, "name": null, "remark": null })
          })
        } else {
          return false
        }
      })
    },
    // handleOkAndAdd() {
    //   const that = this
    //   // 触发表单验证
    //   this.form.validateFields((err, values) => {
    //     if (!err) {
    //       that.confirmLoading = true;
    //       let formData = Object.assign(this.model, values);
    //       formData.inspectionProjectCategoryId = this.inspectionProjectCategoryId
    //       postAction(this.url.add, formData).then((res) => {
    //         if (res.success) {
    //           that.$message.success(res.message);
    //           that.$emit('ok');
    //           that.alterFlag = new Date();
    //         } else {
    //           that.$message.warning(res.message);
    //         }
    //       }).finally(() => {
    //         this.confirmLoading = false
    //         this.form.setFieldsValue(pick(this.model, 'inspectionProjectCategoryNumName'))
    //         this.form.setFieldsValue({ "inspectionContent": null, "inspectionRequire": null, "inspectionMethod": null, "inspectionTool": null, "num": null, "name": null, "remark": null })
    //       })
    //     } else {
    //       return false
    //     }
    //   })
    // },
    handleOk() {
      const that = this;
@@ -452,79 +449,79 @@
      this.close()
    },
    handleChange(val) {
      this.testValueType = val
    },
    // handleChange(val) {
    //   this.testValueType = val
    // },
    validateDownValue(rule, value, callback) {
      let data = this.form.getFieldsValue(['surfaceValue']);
      if (data.surfaceValue == null || data.surfaceValue == "") {
        callback('名义值不能为空!')
      } else {
        if (value > data.surfaceValue) {
          callback('下偏差值不能大于名义值!')
        } else {
          callback()
        }
      }
    },
    // validateDownValue(rule, value, callback) {
    //   let data = this.form.getFieldsValue(['surfaceValue']);
    //   if (data.surfaceValue == null || data.surfaceValue == "") {
    //     callback('名义值不能为空!')
    //   } else {
    //     if (value > data.surfaceValue) {
    //       callback('下偏差值不能大于名义值!')
    //     } else {
    //       callback()
    //     }
    //   }
    // },
    validateSurfaceValue(rule, value, callback) {
      this.form.setFieldsValue({ "upValue": null, "downValue": null })
      // let data = this.form.getFieldsValue(['surfaceValue']);
      // if (value > data.surfaceValue) {
      //   callback('不合格数量应小于检验数量!')
      // } else {
      //   callback()
      // }
    },
    // validateSurfaceValue(rule, value, callback) {
    //   this.form.setFieldsValue({ "upValue": null, "downValue": null })
    //   // let data = this.form.getFieldsValue(['surfaceValue']);
    //   // if (value > data.surfaceValue) {
    //   //   callback('不合格数量应小于检验数量!')
    //   // } else {
    //   //   callback()
    //   // }
    // },
    validateAnalysisMethod(rule, value, callback) {
      let data = this.form.getFieldsValue(['surfaceValue']);
      if (value > data.surfaceValue) {
        callback('不合格数量应小于检验数量!')
      } else {
        callback()
      }
    },
    // validateAnalysisMethod(rule, value, callback) {
    //   let data = this.form.getFieldsValue(['surfaceValue']);
    //   if (value > data.surfaceValue) {
    //     callback('不合格数量应小于检验数量!')
    //   } else {
    //     callback()
    //   }
    // },
    //验证 编号
    validateNum(rule, value, callback) {
      var params = {
        tableName: 'mom_eam_inspection_project',
        fieldName: 'num',
        fieldVal: value,
        dataId: this.model.id,
        //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
        delFlag: '0',
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback();
        } else {
          callback("编号已存在!");
        }
      })
    },
    // validateNum(rule, value, callback) {
    //   var params = {
    //     tableName: 'mom_eam_inspection_project',
    //     fieldName: 'num',
    //     fieldVal: value,
    //     dataId: this.model.id,
    //     //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
    //     delFlag: '0',
    //   };
    //   duplicateCheck(params).then((res) => {
    //     if (res.success) {
    //       callback();
    //     } else {
    //       callback("编号已存在!");
    //     }
    //   })
    // },
    //验证 名称
    validateName(rule, value, callback) {
      var params = {
        tableName: 'mom_eam_inspection_project',
        fieldName: 'name',
        fieldVal: value,
        dataId: this.model.id,
        //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
        delFlag: '0',
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback();
        } else {
          callback("名称已存在!");
        }
      })
    },
    // //验证 名称
    // validateName(rule, value, callback) {
    //   var params = {
    //     tableName: 'mom_eam_inspection_project',
    //     fieldName: 'name',
    //     fieldVal: value,
    //     dataId: this.model.id,
    //     //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
    //     delFlag: '0',
    //   };
    //   duplicateCheck(params).then((res) => {
    //     if (res.success) {
    //       callback();
    //     } else {
    //       callback("名称已存在!");
    //     }
    //   })
    // },
  },
  watch: {