From 44813af86c1ba3203dc606c8bf7690405e084cfc Mon Sep 17 00:00:00 2001 From: zhouwenxuan <1175765986@qq.com> Date: 星期三, 03 一月 2024 13:48:48 +0800 Subject: [PATCH] 设备预警,修改气体 --- src/views/basicDataManage/gasManage/component/gasDialog.vue | 38 +++++++++++++++++++++++++++++++++++--- 1 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/views/basicDataManage/gasManage/component/gasDialog.vue b/src/views/basicDataManage/gasManage/component/gasDialog.vue index d4b57cc..b392507 100644 --- a/src/views/basicDataManage/gasManage/component/gasDialog.vue +++ b/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> \ No newline at end of file +</style> -- Gitblit v1.9.2