From ddc85c375af71d0891708d623a94691a88847caf Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期三, 04 十二月 2024 17:00:09 +0800 Subject: [PATCH] 气体修改 --- .env.development | 2 src/views/monitorData/gasData/index.vue | 16 +++ src/views/basicDataManage/gasManage/component/config.vue | 160 ++++++++++++++++++++++++++++++++ src/api/basicDataManage/gasManage/index.ts | 26 +++++ src/types/gasManage.d.ts | 11 +- src/views/basicDataManage/gasManage/index.vue | 73 +++++++++++++ 6 files changed, 278 insertions(+), 10 deletions(-) diff --git a/.env.development b/.env.development index 23070ad..4f7259c 100644 --- a/.env.development +++ b/.env.development @@ -1,6 +1,6 @@ # 本地环境 ENV = 'development' -VITE_API_URL = 'http://192.168.2.10:17080' +VITE_API_URL = 'http://192.168.2.24:17080' #线上正式环境接口地址 #VITE_API_URL = 'http://ftir.sinanoaq.cn/api' diff --git a/src/api/basicDataManage/gasManage/index.ts b/src/api/basicDataManage/gasManage/index.ts index 60fbab1..b6afb3e 100644 --- a/src/api/basicDataManage/gasManage/index.ts +++ b/src/api/basicDataManage/gasManage/index.ts @@ -38,5 +38,31 @@ data: data }); }, + + //气体参数配置 + //删除 + delConfig: (param: object) => { + return request({ + url: import.meta.env.VITE_API_URL + `/gasCategoryConfiguration/deleted`, + method: 'get', + params: param + }); + }, + //编辑 + editGasConfig: (data: object) => { + return request({ + url: import.meta.env.VITE_API_URL + `/gasCategoryConfiguration/update`, + method: 'post', + data: data + }); + }, + //新增 + addGasConfig: (data: object) => { + return request({ + url: import.meta.env.VITE_API_URL + `/gasCategoryConfiguration/add`, + method: 'post', + data: data + }); + }, }; } diff --git a/src/types/gasManage.d.ts b/src/types/gasManage.d.ts index fc2a73c..f00cd59 100644 --- a/src/types/gasManage.d.ts +++ b/src/types/gasManage.d.ts @@ -25,11 +25,12 @@ title: string; isShowUserDialog: boolean; gasForm: { - id: string; - gasName: string; - gasMolecularFormula: string; - gasThreshold: string; - gasUnit: string; + id: string | null, + gasCategoryId: string| null, + orientation: string, + concentration: number | string, + multiplication: number | string, }; gasFormRules:{}, + positionList: Array<any>; } diff --git a/src/views/basicDataManage/gasManage/component/config.vue b/src/views/basicDataManage/gasManage/component/config.vue new file mode 100644 index 0000000..4640c7b --- /dev/null +++ b/src/views/basicDataManage/gasManage/component/config.vue @@ -0,0 +1,160 @@ +<template> + <div class="system-add-gas-container"> + <el-dialog + :title="state.title" + v-model="state.isShowUserDialog" + width="500px" + > + <el-form :model="state.gasForm" size="default" ref="gasRef" :rules="state.gasFormRules" label-width="110px"> + <el-form-item label="方位:" prop="orientation"> + <el-select + v-model="state.gasForm.orientation" + class="w100" + style="width: 100%" + size="default" + > + <el-option v-for="item in state.positionList" :key="item.label" :label="item.value" :value="item.label"></el-option> + </el-select> + </el-form-item> + <el-form-item label="本底浓度:" prop="concentration"> + <el-input v-model.trim="state.gasForm.concentration" placeholder="请输入本底浓度" :disabled="state.disabled" @input="checkTextInput($event)"></el-input> + </el-form-item> + <el-form-item label="倍增系数:" prop="multiplication"> + <el-input v-model.trim="state.gasForm.multiplication" placeholder="请输入倍增系数" :disabled="state.disabled" @input="state.gasForm.multiplication= state.gasForm.multiplication.replace(/[^0-9]/g,'')"></el-input> + </el-form-item> + </el-form> + <template #footer> + <span class="dialog-footer"> + <el-button @click="handleClose" size="default">取 消</el-button> + <el-button type="primary" @click="onSubmit" size="default">确 定</el-button> + </span> + </template> + </el-dialog> + </div> +</template> + +<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"; +import {verifyAndSpace, verifyNumberIntegerAndFloat} from "/@/utils/toolsValidate"; + +const gasRef = ref(); +const emit = defineEmits(["getGasData"]); +const state = reactive<GasState>({ + disabled: false, + title: '', + isShowUserDialog: false, + gasForm: { + id: null, + gasCategoryId: null, + orientation: '', + concentration: '', + multiplication: '', + }, + gasFormRules:{ + concentration: [{ required: true, message: '请填写本底浓度', trigger: 'blur' }], + multiplication: [{ required: true, message: '请填写倍增系数', trigger: 'blur' }], + orientation: [{ required: true, message: '请选择方位', trigger: 'blur' }], + }, + positionList: [ + { + value: '方位1', + label: 1 + }, + { + value: '方位2', + label: 2 + }, + { + value: '方位3', + label: 3 + }, + ], +}); +const openDialog = (type: string, value: any) => { + state.isShowUserDialog = true; + state.gasForm.gasCategoryId = value.id + if (type === '新增') { + state.disabled = false; + state.title = '新增参数配置'; + state.gasForm = { + id: null, + gasCategoryId: value.id, + orientation: '', + concentration: '', + multiplication: '', + }; + } else if (type === '编辑'){ + state.disabled = false; + state.title = '编辑参数配置'; + state.gasForm = JSON.parse(JSON.stringify(value)); + } +}; +const onSubmit = async () => { + if(state.title == '新增参数配置'){ + const valid = await gasRef.value.validate(); + if(valid) { + const {id,...data} = state.gasForm + let res = await gasManageApi().addGasConfig(data); + 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 if(state.title == '编辑参数配置') { + + const valid = await gasRef.value.validate(); + if(valid) { + const {...data} = state.gasForm + let res = await gasManageApi().editGasConfig(data); + 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 = () => { + gasRef.value.clearValidate(); + state.isShowUserDialog = false; + emit('getGasData'); +} + +const checkTextInput = (val:any) => { + state.gasForm.concentration = verifyNumberIntegerAndFloat(val); +} +defineExpose({ + openDialog +}); +</script> +<style scoped lang="scss"> + +</style> + diff --git a/src/views/basicDataManage/gasManage/index.vue b/src/views/basicDataManage/gasManage/index.vue index 5c63e6a..561f5ab 100644 --- a/src/views/basicDataManage/gasManage/index.vue +++ b/src/views/basicDataManage/gasManage/index.vue @@ -27,14 +27,34 @@ 新增气体 </el-button> - <el-table :data="state.tableData.data" style="width: 100%"> - <el-table-column align="center" type="index" label="序号" width="60" /> + <el-table :data="state.tableData.data" style="width: 100%" :row-key="row => row.id" :expand-row-keys="expandRowKeys" @expand-change="handleExpandChange" > + <el-table-column type="expand"> + <template #default="props"> + <el-table :data="props.row.gasCategoryConfigurations" style="width: 90%;margin-left: 5%" border> + <el-table-column label="方位" prop="orientation" align="center"> + <template #default="scope"> + <span>{{scope.row.orientation == 1 ? '方位1' : scope.row.orientation == 2 ? '方位2' :scope.row.orientation == 3? '方位3': '--'}}</span> + </template> + </el-table-column> + <el-table-column label="本底浓度" prop="concentration" align="center" /> + <el-table-column label="倍增系数" prop="multiplication" align="center" /> + <el-table-column label="操作" show-overflow-tooltip width="120" > + <template #default="scope"> + <el-button size="small" text type="primary" @click="configP('编辑',scope.row)">编辑</el-button> + <el-button size="small" text type="danger" @click="delP(scope.row)">删除</el-button> + </template> + </el-table-column> + </el-table> + </template> + </el-table-column> + <el-table-column align="center" type="index" label="序号" width="70" /> <el-table-column align="center" prop="gasName" label="气体名称"/> <el-table-column align="center" prop="gasMolecularFormula" label="气体分子式"/> <el-table-column align="center" prop="gasThreshold" label="气体阈值"/> <el-table-column align="center" prop="gasUnit" label="气体单位"/> - <el-table-column label="操作" show-overflow-tooltip width="140"> + <el-table-column label="操作" show-overflow-tooltip width="180"> <template #default="scope"> + <el-button size="small" text type="primary" @click="configP('新增', scope.row)">参数配置</el-button> <el-button size="small" text type="primary" @click="openDialog('查看', scope.row)">查看</el-button> <el-button size="small" text type="primary" @click="openDialog('编辑', scope.row)">编辑</el-button> </template> @@ -57,6 +77,7 @@ <br /> </el-card> <gas-dialog ref="gasRef" @getGasData="initGasData"></gas-dialog> + <config-dialog ref="configRef" @getGasData="initGasData"></config-dialog> </div> </template> @@ -64,10 +85,15 @@ import {onMounted, reactive, ref} from "vue"; import { TableDataState } from "/@/types/gasManage"; import gasDialog from "./component/gasDialog.vue"; +import configDialog from "./component/config.vue"; import { gasManageApi } from "/@/api/basicDataManage/gasManage"; import {ElMessage} from "element-plus"; +import {ElMessageBox} from "element-plus/es"; +import {areaManageApi} from "/@/api/basicDataManage/areaManage"; const gasRef = ref(); +const configRef = ref(); + const state = reactive<TableDataState>({ tableData: { data: [], @@ -87,6 +113,7 @@ initGasData(); }); +const expandRowKeys = ref([]) const initGasData = async () => { let res = await gasManageApi().getGasPage(state.tableData.listQuery); console.log("res",res) @@ -94,11 +121,12 @@ if(res.data.data && res.data.data.length > 0){ state.tableData.data = res.data.data.map((item: any) => { return { + ...item, id: item.id, gasName: item.name, gasMolecularFormula: item.molecularFormula, gasThreshold: item.threshold, - gasUnit: item.unit + gasUnit: item.unit, } }); }else { @@ -135,6 +163,43 @@ state.tableData.listQuery.pageIndex = 1; initGasData(); } +const configP = (type:string,value:any) => { + configRef.value.openDialog(type, value); +} + +const delP = (value:any) => { + ElMessageBox.confirm( + '确定删除此条数据?', + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then( async() => { + let res = await gasManageApi().delConfig({id: value.id}); + if(res.data.code == 100) { + ElMessage({ + type: 'success', + message: '删除成功', + }); + reset(); + }else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + } + }) +} +const handleExpandChange = (row:any, expandedRows:any) => { + const Ids = [] + expandedRows.forEach(element => { + Ids.push(element.id) + }) + expandRowKeys.value = Ids + console.log('展开的id,this.expandedRowIds', expandRowKeys.value) +} </script> <style scoped lang="scss"> diff --git a/src/views/monitorData/gasData/index.vue b/src/views/monitorData/gasData/index.vue index 1baa150..fe1c36f 100644 --- a/src/views/monitorData/gasData/index.vue +++ b/src/views/monitorData/gasData/index.vue @@ -212,6 +212,14 @@ xData.value = resChart.data.data.map((item: any) => { return item.time; }) + if(resChart.data.data && resChart.data.data.length > 0){ + const gasNewValue = resChart.data.data[0].gasCategoryConfigurationRespDTO + if(resChart.data.data && gasNewValue && gasNewValue != null ){ + resChart.data.data.forEach(item => { + item.gasValue = ((Number(item.gasValue) - Number(gasNewValue.concentration)) * Number(gasNewValue.multiplication)).toFixed(2) + }) + } + } yData.value = resChart.data.data.map((item: any) => { return item.gasValue; }) @@ -245,6 +253,14 @@ let res = await gasDataApi().getGasLinePage(pageParam); if(res.data.code == 100) { state.tableData.data = res.data.data; + if(res.data.data && res.data.data.length > 0){ + const gasNewValue = state.tableData.data[0].gasCategoryConfigurationRespDTO + if(res.data.data && gasNewValue && gasNewValue != null ){ + state.tableData.data.forEach(item => { + item.gasValue = ((Number(item.gasValue) - Number(gasNewValue.concentration)) * Number(gasNewValue.multiplication)).toFixed(2) + }) + } + } state.tableData.total = res.data.total == null ? 0 :res.data.total; state.tableData.listQuery.pageIndex = res.data.pageIndex; state.tableData.listQuery.pageSize = res.data.pageSize; -- Gitblit v1.9.2