zhouwenxuan
2024-01-03 44813af86c1ba3203dc606c8bf7690405e084cfc
src/views/basicDataManage/gasManage/component/gasDialog.vue
@@ -5,7 +5,7 @@
            v-model="state.isShowUserDialog"
            width="500px"
        >
            <el-form :model="state.gasForm" size="default" ref="gasRef" :rules="state.title == '新增气体' ? state.gasFormRules : ''" label-width="110px">
            <el-form :model="state.gasForm" size="default" ref="gasRef" :rules="state.title == '新增气体'  || state.title == '编辑气体'? state.gasFormRules : ''" label-width="110px">
                <el-form-item label="气体名称:" prop="gasName">
                    <el-input v-model.trim="state.gasForm.gasName" :disabled="state.disabled" ></el-input>
                </el-form-item>
@@ -42,6 +42,7 @@
    title: '',
    isShowUserDialog: false,
    gasForm: {
        id: '',
        gasName: '',
        gasMolecularFormula: '',
        gasThreshold: '',
@@ -60,11 +61,16 @@
        state.disabled = false;
        state.title = '新增气体';
        state.gasForm = {
            id: '',
            gasName: '',
            gasMolecularFormula: '',
            gasThreshold: '',
            gasUnit: ''
        };
    } else if (type === '编辑'){
        state.disabled = false;
        state.title = '编辑气体';
        state.gasForm = JSON.parse(JSON.stringify(value));
    } else {
        state.disabled = true;
        state.title = '查看气体';
@@ -97,7 +103,33 @@
                    });
                }
            }
        }else {
        }else if(state.title == '编辑气体') {
          const valid = await gasRef.value.validate();
          if(valid) {
            const param = {
              id: state.gasForm.id,
              molecularFormula: state.gasForm.gasMolecularFormula,
              name: state.gasForm.gasName,
              unit: state.gasForm.gasUnit,
              threshold: state.gasForm.gasThreshold
            }
            let res = await gasManageApi().editGas(param);
            if (res.data.code === 100) {
              ElMessage({
                type: 'success',
                message: '编辑成功'
              });
              gasRef.value.clearValidate();
              state.isShowUserDialog = false;
              emit('getGasData');
            } else {
              ElMessage({
                type: 'warning',
                message: res.data.msg
              });
            }
          }
        } else {
            gasRef.value.clearValidate();
            state.isShowUserDialog = false;
            emit('getGasData');
@@ -116,4 +148,4 @@
</script>
<style scoped lang="scss">
</style>
</style>