| | |
| | | v-model="state.isShowUserDialog" |
| | | width="500px" |
| | | > |
| | | <el-form :model="state.gasForm" size="default" ref="gasRef" :rules="state.gasFormRules" label-width="110px"> |
| | | <el-form :model="state.gasForm" size="default" ref="gasRef" :rules="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> |
| | |
| | | <script setup lang="ts"> |
| | | import {reactive, ref} from "vue"; |
| | | import { GasState } from "/@/types/gasManage"; |
| | | import {gasManageApi} from "/@/api/basicDataManage/gasManage"; |
| | | import {ElMessage} from "element-plus"; |
| | | |
| | | const gasRef = ref(); |
| | | const emit = defineEmits(["getGasData"]); |
| | |
| | | state.gasForm = JSON.parse(JSON.stringify(value)); |
| | | } |
| | | }; |
| | | const onSubmit = () => { |
| | | const onSubmit = async () => { |
| | | if(state.title == '新增气体'){ |
| | | const valid = await gasRef.value.validate(); |
| | | if(valid) { |
| | | const param = { |
| | | molecularFormula: state.gasForm.gasMolecularFormula, |
| | | name: state.gasForm.gasName, |
| | | unit: state.gasForm.gasUnit, |
| | | threshold: state.gasForm.gasThreshold |
| | | } |
| | | let res = await gasManageApi().addGas(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'); |
| | | } |
| | | }; |
| | | |
| | | const handleClose = () => { |