| | |
| | | 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> |
| | |
| | | title: '', |
| | | isShowUserDialog: false, |
| | | gasForm: { |
| | | id: '', |
| | | gasName: '', |
| | | gasMolecularFormula: '', |
| | | gasThreshold: '', |
| | |
| | | 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 = '查看气体'; |
| | |
| | | }); |
| | | } |
| | | } |
| | | }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'); |
| | |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | |
| | | </style> |
| | | </style> |