| | |
| | | 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 |
| | | }); |
| | | }, |
| | | }; |
| | | } |
| | |
| | | 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>; |
| | | } |
对比新文件 |
| | |
| | | <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> |
| | | |
| | |
| | | <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.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> |
| | | <el-form-item label="气体分子式:" prop="gasMolecularFormula"> |
| | | <el-input v-model.trim="state.gasForm.gasMolecularFormula" :disabled="state.disabled"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="气体阈值:" prop="gasThreshold"> |
| | | <el-input v-model.trim="state.gasForm.gasThreshold" :disabled="state.disabled"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="气体单位:" prop="gasUnit"> |
| | | <el-input v-model.trim="state.gasForm.gasUnit" :disabled="state.disabled"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <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.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> |
| | | <el-form-item label="气体分子式:" prop="gasMolecularFormula"> |
| | | <el-input v-model.trim="state.gasForm.gasMolecularFormula" :disabled="state.disabled"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="气体阈值:" prop="gasThreshold"> |
| | | <el-input v-model.trim="state.gasForm.gasThreshold" :disabled="state.disabled"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="气体单位:" prop="gasUnit"> |
| | | <el-input v-model.trim="state.gasForm.gasUnit" :disabled="state.disabled"></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> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | |
| | | const gasRef = ref(); |
| | | const emit = defineEmits(["getGasData"]); |
| | | const state = reactive<GasState>({ |
| | | disabled: false, |
| | | title: '', |
| | | isShowUserDialog: false, |
| | | gasForm: { |
| | | id: '', |
| | | gasName: '', |
| | | gasMolecularFormula: '', |
| | | gasThreshold: '', |
| | | gasUnit: '' |
| | | }, |
| | | gasFormRules:{ |
| | | gasName: [{ required: true, message: '请填写气体名称', trigger: 'blur' }], |
| | | gasMolecularFormula: [{ required: true, message: '请填写气体分子式', trigger: 'blur' }], |
| | | gasThreshold: [{ required: true, message: '请填写阈值', trigger: 'blur' }], |
| | | gasUnit: [{ required: true, message: '请选择气体单位', trigger: 'blur' }], |
| | | }, |
| | | disabled: false, |
| | | title: '', |
| | | isShowUserDialog: false, |
| | | gasForm: { |
| | | id: '', |
| | | gasName: '', |
| | | gasMolecularFormula: '', |
| | | gasThreshold: '', |
| | | gasUnit: '' |
| | | }, |
| | | gasFormRules:{ |
| | | gasName: [{ required: true, message: '请填写气体名称', trigger: 'blur' }], |
| | | gasMolecularFormula: [{ required: true, message: '请填写气体分子式', trigger: 'blur' }], |
| | | gasThreshold: [{ required: true, message: '请填写阈值', trigger: 'blur' }], |
| | | gasUnit: [{ required: true, message: '请选择气体单位', trigger: 'blur' }], |
| | | }, |
| | | }); |
| | | const openDialog = (type: string, value: any) => { |
| | | state.isShowUserDialog = true; |
| | | if (type === '新增') { |
| | | 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 = '查看气体'; |
| | | state.gasForm = JSON.parse(JSON.stringify(value)); |
| | | } |
| | | state.isShowUserDialog = true; |
| | | if (type === '新增') { |
| | | 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 = '查看气体'; |
| | | state.gasForm = JSON.parse(JSON.stringify(value)); |
| | | } |
| | | }; |
| | | 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 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'); |
| | | } |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | 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 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'); |
| | | } |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | gasRef.value.clearValidate(); |
| | | state.isShowUserDialog = false; |
| | | emit('getGasData'); |
| | | } |
| | | |
| | | defineExpose({ |
| | | openDialog |
| | | openDialog |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | |
| | | <template> |
| | | <div class="system-gas-container"> |
| | | <el-card shadow="hover"> |
| | | <div class="system-menu-search mb15"> |
| | | <el-form :inline="true" > |
| | | <el-form-item label="气体名称:"> |
| | | <el-input v-model="state.tableData.listQuery.searchParams.name" placeholder="气体名称" ></el-input> |
| | | </el-form-item> |
| | | <el-button size="default" type="primary" class="ml10" @click="search()"> |
| | | <el-icon> |
| | | <ele-Search /> |
| | | </el-icon> |
| | | 查询 |
| | | </el-button> |
| | | <el-button size="default" class="ml10" @click="reset()"> |
| | | <el-icon> |
| | | <RefreshLeft /> |
| | | </el-icon> |
| | | 重置 |
| | | </el-button> |
| | | </el-form> |
| | | </div> |
| | | <el-button size="default" class="mb10" type="success" @click="openDialog('新增',{})"> |
| | | <el-icon> |
| | | <ele-FolderAdd /> |
| | | </el-icon> |
| | | 新增气体 |
| | | </el-button> |
| | | <div class="system-gas-container"> |
| | | <el-card shadow="hover"> |
| | | <div class="system-menu-search mb15"> |
| | | <el-form :inline="true" > |
| | | <el-form-item label="气体名称:"> |
| | | <el-input v-model="state.tableData.listQuery.searchParams.name" placeholder="气体名称" ></el-input> |
| | | </el-form-item> |
| | | <el-button size="default" type="primary" class="ml10" @click="search()"> |
| | | <el-icon> |
| | | <ele-Search /> |
| | | </el-icon> |
| | | 查询 |
| | | </el-button> |
| | | <el-button size="default" class="ml10" @click="reset()"> |
| | | <el-icon> |
| | | <RefreshLeft /> |
| | | </el-icon> |
| | | 重置 |
| | | </el-button> |
| | | </el-form> |
| | | </div> |
| | | <el-button size="default" class="mb10" type="success" @click="openDialog('新增',{})"> |
| | | <el-icon> |
| | | <ele-FolderAdd /> |
| | | </el-icon> |
| | | 新增气体 |
| | | </el-button> |
| | | |
| | | <el-table :data="state.tableData.data" style="width: 100%"> |
| | | <el-table-column align="center" type="index" label="序号" width="60" /> |
| | | <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"> |
| | | <template #default="scope"> |
| | | <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> |
| | | </el-table-column> |
| | | <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> |
| | | <br /> |
| | | <el-pagination |
| | | @size-change="onHandleSizeChange" |
| | | @current-change="onHandleCurrentChange" |
| | | class="page-position" |
| | | :pager-count="5" |
| | | :page-sizes="[10, 20, 30]" |
| | | v-model:current-page="state.tableData.listQuery.pageIndex" |
| | | background |
| | | v-model:page-size="state.tableData.listQuery.pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="state.tableData.total"> |
| | | </el-pagination> |
| | | <br /> |
| | | <br /> |
| | | </el-card> |
| | | <gas-dialog ref="gasRef" @getGasData="initGasData"></gas-dialog> |
| | | </div> |
| | | </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="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> |
| | | </el-table-column> |
| | | </el-table> |
| | | <br /> |
| | | <el-pagination |
| | | @size-change="onHandleSizeChange" |
| | | @current-change="onHandleCurrentChange" |
| | | class="page-position" |
| | | :pager-count="5" |
| | | :page-sizes="[10, 20, 30]" |
| | | v-model:current-page="state.tableData.listQuery.pageIndex" |
| | | background |
| | | v-model:page-size="state.tableData.listQuery.pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="state.tableData.total"> |
| | | </el-pagination> |
| | | <br /> |
| | | <br /> |
| | | </el-card> |
| | | <gas-dialog ref="gasRef" @getGasData="initGasData"></gas-dialog> |
| | | <config-dialog ref="configRef" @getGasData="initGasData"></config-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | 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: [], |
| | | total: 0, |
| | | loading: false, |
| | | listQuery: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | searchParams:{ |
| | | name :'' |
| | | } |
| | | } |
| | | tableData: { |
| | | data: [], |
| | | total: 0, |
| | | loading: false, |
| | | listQuery: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | searchParams:{ |
| | | name :'' |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //页面加载 |
| | | onMounted(() => { |
| | | initGasData(); |
| | | initGasData(); |
| | | }); |
| | | |
| | | const expandRowKeys = ref([]) |
| | | const initGasData = async () => { |
| | | let res = await gasManageApi().getGasPage(state.tableData.listQuery); |
| | | console.log("res",res) |
| | | if (res.data.code === 100) { |
| | | if(res.data.data && res.data.data.length > 0){ |
| | | state.tableData.data = res.data.data.map((item: any) => { |
| | | return { |
| | | id: item.id, |
| | | gasName: item.name, |
| | | gasMolecularFormula: item.molecularFormula, |
| | | gasThreshold: item.threshold, |
| | | gasUnit: item.unit |
| | | } |
| | | }); |
| | | }else { |
| | | state.tableData.data = []; |
| | | let res = await gasManageApi().getGasPage(state.tableData.listQuery); |
| | | console.log("res",res) |
| | | if (res.data.code === 100) { |
| | | 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, |
| | | } |
| | | state.tableData.total = res.data.total; |
| | | state.tableData.listQuery.pageIndex = res.data.pageIndex; |
| | | state.tableData.listQuery.pageSize = res.data.pageSize; |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | }); |
| | | }else { |
| | | state.tableData.data = []; |
| | | } |
| | | state.tableData.total = res.data.total; |
| | | state.tableData.listQuery.pageIndex = res.data.pageIndex; |
| | | state.tableData.listQuery.pageSize = res.data.pageSize; |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }; |
| | | const onHandleSizeChange = (val: number) => { |
| | | state.tableData.listQuery.pageSize = val; |
| | | initGasData(); |
| | | state.tableData.listQuery.pageSize = val; |
| | | initGasData(); |
| | | }; |
| | | // 分页改变 |
| | | const onHandleCurrentChange = (val: number) => { |
| | | state.tableData.listQuery.pageIndex = val; |
| | | initGasData(); |
| | | state.tableData.listQuery.pageIndex = val; |
| | | initGasData(); |
| | | }; |
| | | const openDialog = (type: string, value: any) => { |
| | | gasRef.value.openDialog(type, value); |
| | | gasRef.value.openDialog(type, value); |
| | | }; |
| | | const search = () => { |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | initGasData(); |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | initGasData(); |
| | | } |
| | | const reset = () => { |
| | | state.tableData.listQuery.searchParams.name = ''; |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | initGasData(); |
| | | state.tableData.listQuery.searchParams.name = ''; |
| | | 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"> |
| | |
| | | <template> |
| | | <div class="system-gas-container"> |
| | | <el-card shadow="hover"> |
| | | <div class="system-menu-search mb15"> |
| | | <el-form :inline="true" style="display: flex;align-items: flex-start;flex-wrap: wrap" > |
| | | <el-form-item label="日期:" > |
| | | <el-date-picker |
| | | v-model="state.tableData.listQuery.searchParams.time" |
| | | type="datetimerange" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | range-separator="~" |
| | | start-placeholder="开始时间" |
| | | end-placeholder="结束时间" |
| | | @change = "chooseTime" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="气体:"> |
| | | <el-select |
| | | v-model="state.tableData.listQuery.searchParams.gas" |
| | | class="w100" |
| | | style="max-width: 180px" |
| | | size="default" |
| | | > |
| | | <el-option v-for="item in state.tableData.gasList" :key="item.id" :label="item.name" :value="item.id"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="方位:"> |
| | | <el-select |
| | | v-model="state.tableData.listQuery.searchParams.position" |
| | | class="w100" |
| | | style="max-width: 180px" |
| | | size="default" |
| | | > |
| | | <el-option v-for="item in state.tableData.positionList" :key="item.label" :label="item.value" :value="item.label"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <div class="system-gas-container"> |
| | | <el-card shadow="hover"> |
| | | <div class="system-menu-search mb15"> |
| | | <el-form :inline="true" style="display: flex;align-items: flex-start;flex-wrap: wrap" > |
| | | <el-form-item label="日期:" > |
| | | <el-date-picker |
| | | v-model="state.tableData.listQuery.searchParams.time" |
| | | type="datetimerange" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | range-separator="~" |
| | | start-placeholder="开始时间" |
| | | end-placeholder="结束时间" |
| | | @change = "chooseTime" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="气体:"> |
| | | <el-select |
| | | v-model="state.tableData.listQuery.searchParams.gas" |
| | | class="w100" |
| | | style="max-width: 180px" |
| | | size="default" |
| | | > |
| | | <el-option v-for="item in state.tableData.gasList" :key="item.id" :label="item.name" :value="item.id"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="方位:"> |
| | | <el-select |
| | | v-model="state.tableData.listQuery.searchParams.position" |
| | | class="w100" |
| | | style="max-width: 180px" |
| | | size="default" |
| | | > |
| | | <el-option v-for="item in state.tableData.positionList" :key="item.label" :label="item.value" :value="item.label"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-button size="default" type="primary" class="ml10" @click="search()"> |
| | | <el-icon> |
| | | <ele-Search /> |
| | | </el-icon> |
| | | 查询 |
| | | </el-button> |
| | | <el-button size="default" class="ml10" @click="reset()"> |
| | | <el-icon> |
| | | <RefreshLeft /> |
| | | </el-icon> |
| | | 重置 |
| | | </el-button> |
| | | <vue3-json-excel |
| | | class="ml10" |
| | | :json-data="state.tableData.excelData" |
| | | :fields="fields" |
| | | name="气体数据.xls" |
| | | > |
| | | <el-button type="primary" :icon="Download" size="default">导出</el-button> |
| | | </vue3-json-excel> |
| | | </el-form> |
| | | </div> |
| | | <div :id="gasChart" style="height: 500px;width: auto"></div> |
| | | <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px" v-loading="loading"> |
| | | <el-table-column type="index" label="序号" width="80" /> |
| | | <el-table-column align="center" prop="time" label="采集时间"/> |
| | | <el-table-column align="center" prop="windSpeed" label="风速"/> |
| | | <el-table-column align="center" prop="windDirection" label="风向"/> |
| | | <el-table-column align="center" prop="name" label="气体名称"/> |
| | | <el-table-column align="center" prop="gasValue" label="气体浓度"/> |
| | | <el-table-column align="center" prop="position" label="方位"/> |
| | | </el-table> |
| | | <br /> |
| | | <el-pagination |
| | | @size-change="onHandleSizeChange" |
| | | @current-change="onHandleCurrentChange" |
| | | class="page-position" |
| | | :pager-count="5" |
| | | :page-sizes="[10, 20, 30]" |
| | | v-model:current-page="state.tableData.listQuery.pageIndex" |
| | | background |
| | | v-model:page-size="state.tableData.listQuery.pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="state.tableData.total"> |
| | | </el-pagination> |
| | | <br /> |
| | | <br /> |
| | | </el-card> |
| | | </div> |
| | | <el-button size="default" type="primary" class="ml10" @click="search()"> |
| | | <el-icon> |
| | | <ele-Search /> |
| | | </el-icon> |
| | | 查询 |
| | | </el-button> |
| | | <el-button size="default" class="ml10" @click="reset()"> |
| | | <el-icon> |
| | | <RefreshLeft /> |
| | | </el-icon> |
| | | 重置 |
| | | </el-button> |
| | | <vue3-json-excel |
| | | class="ml10" |
| | | :json-data="state.tableData.excelData" |
| | | :fields="fields" |
| | | name="气体数据.xls" |
| | | > |
| | | <el-button type="primary" :icon="Download" size="default">导出</el-button> |
| | | </vue3-json-excel> |
| | | </el-form> |
| | | </div> |
| | | <div :id="gasChart" style="height: 500px;width: auto"></div> |
| | | <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px" v-loading="loading"> |
| | | <el-table-column type="index" label="序号" width="80" /> |
| | | <el-table-column align="center" prop="time" label="采集时间"/> |
| | | <el-table-column align="center" prop="windSpeed" label="风速"/> |
| | | <el-table-column align="center" prop="windDirection" label="风向"/> |
| | | <el-table-column align="center" prop="name" label="气体名称"/> |
| | | <el-table-column align="center" prop="gasValue" label="气体浓度"/> |
| | | <el-table-column align="center" prop="position" label="方位"/> |
| | | </el-table> |
| | | <br /> |
| | | <el-pagination |
| | | @size-change="onHandleSizeChange" |
| | | @current-change="onHandleCurrentChange" |
| | | class="page-position" |
| | | :pager-count="5" |
| | | :page-sizes="[10, 20, 30]" |
| | | v-model:current-page="state.tableData.listQuery.pageIndex" |
| | | background |
| | | v-model:page-size="state.tableData.listQuery.pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="state.tableData.total"> |
| | | </el-pagination> |
| | | <br /> |
| | | <br /> |
| | | </el-card> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | |
| | | import {Download} from "@element-plus/icons-vue"; |
| | | |
| | | const state = reactive<TableGasState>({ |
| | | tableData: { |
| | | data: [], |
| | | total: 0, |
| | | loading: false, |
| | | listQuery: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | searchParams:{ |
| | | startTime: '', |
| | | endTime: '', |
| | | time: [], |
| | | gas: '', |
| | | position: null |
| | | } |
| | | }, |
| | | gasList: [], |
| | | positionList: [ |
| | | { |
| | | value: '方位1', |
| | | label: 1 |
| | | }, |
| | | { |
| | | value: '方位2', |
| | | label: 2 |
| | | }, |
| | | { |
| | | value: '方位3', |
| | | label: 3 |
| | | }, |
| | | ], |
| | | excelData: [] |
| | | } |
| | | tableData: { |
| | | data: [], |
| | | total: 0, |
| | | loading: false, |
| | | listQuery: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | searchParams:{ |
| | | startTime: '', |
| | | endTime: '', |
| | | time: [], |
| | | gas: '', |
| | | position: null |
| | | } |
| | | }, |
| | | gasList: [], |
| | | positionList: [ |
| | | { |
| | | value: '方位1', |
| | | label: 1 |
| | | }, |
| | | { |
| | | value: '方位2', |
| | | label: 2 |
| | | }, |
| | | { |
| | | value: '方位3', |
| | | label: 3 |
| | | }, |
| | | ], |
| | | excelData: [] |
| | | } |
| | | }); |
| | | const fields = ref({ |
| | | 'time':'dataReceivingTime', |
| | |
| | | const gasChart = ref("eChartgasN" + Date .now() + Math .random()) |
| | | |
| | | const chooseTime = (val: any) => { |
| | | let sTime = Date.parse(new Date(val[0])); |
| | | let eTime = Date.parse(new Date(val[1])); |
| | | const datadiff = eTime - sTime + 86400000; |
| | | const time = 7 * 24 * 60 * 60 * 1000; |
| | | if (sTime > eTime) { |
| | | return false; |
| | | } else { |
| | | if (datadiff > time) { |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: '查询时间范围7天内', |
| | | }) |
| | | getNowTime(); |
| | | return false; |
| | | } |
| | | let sTime = Date.parse(new Date(val[0])); |
| | | let eTime = Date.parse(new Date(val[1])); |
| | | const datadiff = eTime - sTime + 86400000; |
| | | const time = 7 * 24 * 60 * 60 * 1000; |
| | | if (sTime > eTime) { |
| | | return false; |
| | | } else { |
| | | if (datadiff > time) { |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: '查询时间范围7天内', |
| | | }) |
| | | getNowTime(); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | const loading = ref(false); |
| | | const dataZoomEnd = ref(); |
| | |
| | | const myChart = shallowRef(null) |
| | | onMounted( |
| | | () => { |
| | | getNowTime(); |
| | | getAllGas(); |
| | | getNowTime(); |
| | | getAllGas(); |
| | | } |
| | | ); |
| | | const getNowTime = () => { |
| | | let isDate = new Date() |
| | | let sTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}` |
| | | let eTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}` |
| | | sTime = `${sTime} 00:00:00` |
| | | eTime = `${eTime} ` + moment().format('HH:mm:ss') |
| | | state.tableData.listQuery.searchParams.time = [sTime,eTime]; |
| | | let isDate = new Date() |
| | | let sTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}` |
| | | let eTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}` |
| | | sTime = `${sTime} 00:00:00` |
| | | eTime = `${eTime} ` + moment().format('HH:mm:ss') |
| | | state.tableData.listQuery.searchParams.time = [sTime,eTime]; |
| | | } |
| | | const initInfoData = async () => { |
| | | await exportGasData(); |
| | | //折线图 |
| | | const chartParam = { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'), |
| | | gasName: state.tableData.listQuery.searchParams.gas, |
| | | position: state.tableData.listQuery.searchParams.position |
| | | } |
| | | let resChart = await gasDataApi().getGasLineChart(chartParam); |
| | | if(resChart.data.code == 100) { |
| | | if (resChart.data.data) { |
| | | xData.value = resChart.data.data.map((item: any) => { |
| | | return item.time; |
| | | }) |
| | | yData.value = resChart.data.data.map((item: any) => { |
| | | return item.gasValue; |
| | | }) |
| | | dataZoomEnd.value = xData.value.length > 25 ? 30 : 100; |
| | | }else { |
| | | xData.value = []; |
| | | yData.value = []; |
| | | markLines.value = 0; |
| | | dataZoomEnd.value = 100; |
| | | await exportGasData(); |
| | | //折线图 |
| | | const chartParam = { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'), |
| | | gasName: state.tableData.listQuery.searchParams.gas, |
| | | position: state.tableData.listQuery.searchParams.position |
| | | } |
| | | let resChart = await gasDataApi().getGasLineChart(chartParam); |
| | | if(resChart.data.code == 100) { |
| | | if (resChart.data.data) { |
| | | 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) |
| | | }) |
| | | } |
| | | initCharts(); |
| | | } |
| | | yData.value = resChart.data.data.map((item: any) => { |
| | | return item.gasValue; |
| | | }) |
| | | dataZoomEnd.value = xData.value.length > 25 ? 30 : 100; |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: resChart.data.msg |
| | | }); |
| | | xData.value = []; |
| | | yData.value = []; |
| | | markLines.value = 0; |
| | | dataZoomEnd.value = 100; |
| | | } |
| | | initCharts(); |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: resChart.data.msg |
| | | }); |
| | | } |
| | | |
| | | loading.value = true; |
| | | //表格 |
| | | const pageParam = { |
| | | pageIndex: state.tableData.listQuery.pageIndex, |
| | | pageSize: state.tableData.listQuery.pageSize, |
| | | searchParams: { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'), |
| | | gasName: state.tableData.listQuery.searchParams.gas, |
| | | position: state.tableData.listQuery.searchParams.position |
| | | } |
| | | loading.value = true; |
| | | //表格 |
| | | const pageParam = { |
| | | pageIndex: state.tableData.listQuery.pageIndex, |
| | | pageSize: state.tableData.listQuery.pageSize, |
| | | searchParams: { |
| | | startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'), |
| | | endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'), |
| | | gasName: state.tableData.listQuery.searchParams.gas, |
| | | position: state.tableData.listQuery.searchParams.position |
| | | } |
| | | let res = await gasDataApi().getGasLinePage(pageParam); |
| | | if(res.data.code == 100) { |
| | | state.tableData.data = res.data.data; |
| | | 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; |
| | | loading.value = false; |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | 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; |
| | | loading.value = false; |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | const getAllGas = async () => { |
| | | let res = await gasManageApi().getGas({}); |
| | | if(res.data.code == 100) { |
| | | state.tableData.gasList = res.data.data; |
| | | console.log("气体",state.tableData.gasList) |
| | | //默认选择第一个气体 |
| | | state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id; |
| | | markLines.value = state.tableData.gasList[0].threshold; |
| | | await initInfoData(); |
| | | let res = await gasManageApi().getGas({}); |
| | | if(res.data.code == 100) { |
| | | state.tableData.gasList = res.data.data; |
| | | console.log("气体",state.tableData.gasList) |
| | | //默认选择第一个气体 |
| | | state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id; |
| | | markLines.value = state.tableData.gasList[0].threshold; |
| | | await initInfoData(); |
| | | |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | } |
| | | }; |
| | | const exportGasData = async () => { |
| | | const pageParam = { |
| | |
| | | } |
| | | |
| | | const onHandleSizeChange = (val: number) => { |
| | | state.tableData.listQuery.pageSize = val; |
| | | initInfoData(); |
| | | state.tableData.listQuery.pageSize = val; |
| | | initInfoData(); |
| | | }; |
| | | // 分页改变 |
| | | const onHandleCurrentChange = (val: number) => { |
| | | state.tableData.listQuery.pageIndex = val; |
| | | initInfoData(); |
| | | state.tableData.listQuery.pageIndex = val; |
| | | initInfoData(); |
| | | }; |
| | | const search = () => { |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | const gasObj = state.tableData.gasList.filter(item => { |
| | | return item.id == state.tableData.listQuery.searchParams.gas |
| | | }); |
| | | markLines.value = gasObj[0].threshold; |
| | | initInfoData(); |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | const gasObj = state.tableData.gasList.filter(item => { |
| | | return item.id == state.tableData.listQuery.searchParams.gas |
| | | }); |
| | | markLines.value = gasObj[0].threshold; |
| | | initInfoData(); |
| | | } |
| | | const reset = () => { |
| | | getNowTime(); |
| | | state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id; |
| | | markLines.value = state.tableData.gasList[0].threshold; |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | state.tableData.listQuery.searchParams.position = null; |
| | | initInfoData(); |
| | | getNowTime(); |
| | | state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id; |
| | | markLines.value = state.tableData.gasList[0].threshold; |
| | | state.tableData.listQuery.pageIndex = 1; |
| | | state.tableData.listQuery.searchParams.position = null; |
| | | initInfoData(); |
| | | } |
| | | |
| | | const initCharts = () => { |
| | | if (myChart.value != null && myChart.value != "" && myChart.value != undefined) { |
| | | myChart.value.dispose(); |
| | | } |
| | | myChart.value = echarts.init(document.getElementById(gasChart.value)); |
| | | // 指定图表的配置项和数据 |
| | | const option = { |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | if (myChart.value != null && myChart.value != "" && myChart.value != undefined) { |
| | | myChart.value.dispose(); |
| | | } |
| | | myChart.value = echarts.init(document.getElementById(gasChart.value)); |
| | | // 指定图表的配置项和数据 |
| | | const option = { |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: 'shadow' |
| | | }, |
| | | }, |
| | | xAxis: { |
| | | show: true, |
| | | type: 'category', |
| | | data: xData.value |
| | | }, |
| | | yAxis: { |
| | | show: true, |
| | | type: 'value', |
| | | max: Math.max(markLines.value,...yData.value), |
| | | min: Math.min(markLines.value,...yData.value) |
| | | }, |
| | | graphic: { |
| | | type: 'text', // 类型:文本 |
| | | left: 'center', |
| | | top: 'middle', |
| | | silent: true, // 不响应事件 |
| | | invisible: yData.value.length > 0, // 有数据就隐藏 |
| | | style: { |
| | | fill: '#9d9d9d', |
| | | fontWeight: 'bold', |
| | | text: '暂无数据', |
| | | fontFamily: 'Microsoft YaHei', |
| | | fontSize: '25px' |
| | | } |
| | | }, |
| | | series: [ |
| | | { |
| | | // name : '总计', |
| | | data: yData.value, |
| | | type: 'line', |
| | | markLine: {//图表标线 |
| | | symbol: "none", |
| | | data: [{ |
| | | label: { |
| | | position: 'end', // 表现内容展示的位置 |
| | | color: 'red' // 展示内容颜色 |
| | | }, |
| | | }, |
| | | xAxis: { |
| | | show: true, |
| | | type: 'category', |
| | | data: xData.value |
| | | }, |
| | | yAxis: { |
| | | show: true, |
| | | type: 'value', |
| | | max: Math.max(markLines.value,...yData.value), |
| | | min: Math.min(markLines.value,...yData.value) |
| | | }, |
| | | graphic: { |
| | | type: 'text', // 类型:文本 |
| | | left: 'center', |
| | | top: 'middle', |
| | | silent: true, // 不响应事件 |
| | | invisible: yData.value.length > 0, // 有数据就隐藏 |
| | | style: { |
| | | fill: '#9d9d9d', |
| | | fontWeight: 'bold', |
| | | text: '暂无数据', |
| | | fontFamily: 'Microsoft YaHei', |
| | | fontSize: '25px' |
| | | yAxis: markLines.value == 0 ? '':markLines.value , |
| | | lineStyle: { |
| | | color: "red", |
| | | width: markLines.value == 0 ? 0: 1, // 0 的时候可以隐藏线 |
| | | type: "solid" // 实线,不写默认虚线 |
| | | } |
| | | },],//type: 'average', 平均值, min最小值, max 最大值, median中位数 |
| | | }, |
| | | series: [ |
| | | { |
| | | // name : '总计', |
| | | data: yData.value, |
| | | type: 'line', |
| | | markLine: {//图表标线 |
| | | symbol: "none", |
| | | data: [{ |
| | | label: { |
| | | position: 'end', // 表现内容展示的位置 |
| | | color: 'red' // 展示内容颜色 |
| | | }, |
| | | yAxis: markLines.value == 0 ? '':markLines.value , |
| | | lineStyle: { |
| | | color: "red", |
| | | width: markLines.value == 0 ? 0: 1, // 0 的时候可以隐藏线 |
| | | type: "solid" // 实线,不写默认虚线 |
| | | } |
| | | },],//type: 'average', 平均值, min最小值, max 最大值, median中位数 |
| | | }, |
| | | }, |
| | | ], |
| | | dataZoom: [ |
| | | { |
| | | type: 'slider', |
| | | show: dataZoomEnd.value == 100 ? false : true, |
| | | realtime: true, |
| | | start: 0, |
| | | end: dataZoomEnd.value |
| | | }, |
| | | { |
| | | type: 'inside', |
| | | realtime: true, |
| | | start: 0, |
| | | end: dataZoomEnd.value |
| | | }, |
| | | ] |
| | | }; |
| | | // 使用刚指定的配置项和数据显示图表。 |
| | | myChart.value.setOption(option,true); |
| | | //自适应宽度 |
| | | window.addEventListener('resize',function () { |
| | | myChart.value.resize(); |
| | | }) |
| | | }, |
| | | ], |
| | | dataZoom: [ |
| | | { |
| | | type: 'slider', |
| | | show: dataZoomEnd.value == 100 ? false : true, |
| | | realtime: true, |
| | | start: 0, |
| | | end: dataZoomEnd.value |
| | | }, |
| | | { |
| | | type: 'inside', |
| | | realtime: true, |
| | | start: 0, |
| | | end: dataZoomEnd.value |
| | | }, |
| | | ] |
| | | }; |
| | | // 使用刚指定的配置项和数据显示图表。 |
| | | myChart.value.setOption(option,true); |
| | | //自适应宽度 |
| | | window.addEventListener('resize',function () { |
| | | myChart.value.resize(); |
| | | }) |
| | | } |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .yellow{ |
| | | width: 80px; |
| | | height: 30px; |
| | | background-color: rgb(255,223,37); |
| | | line-height: 30px; |
| | | color: white; |
| | | box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2); |
| | | padding: 3px |
| | | width: 80px; |
| | | height: 30px; |
| | | background-color: rgb(255,223,37); |
| | | line-height: 30px; |
| | | color: white; |
| | | box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2); |
| | | padding: 3px |
| | | } |
| | | .red{ |
| | | width: 80px; |
| | | height: 30px; |
| | | background-color: rgb(239,90,161); |
| | | line-height: 30px; |
| | | color: white; |
| | | box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2); |
| | | padding: 3px |
| | | width: 80px; |
| | | height: 30px; |
| | | background-color: rgb(239,90,161); |
| | | line-height: 30px; |
| | | color: white; |
| | | box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2); |
| | | padding: 3px |
| | | } |
| | | </style> |