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/warningManage/warningDevice/index.vue | 153 ++++++++++++++++++++++++++++++
src/api/basicDataManage/gasManage/index.ts | 9 +
src/api/warningManage/warningInfo/index.ts | 13 ++
src/types/gasManage.d.ts | 3
src/views/basicDataManage/gasManage/component/gasDialog.vue | 38 +++++++
src/views/warningManage/warningDevice/component/index.vue | 61 ++++++++++++
src/views/basicDataManage/gasManage/index.vue | 3
7 files changed, 273 insertions(+), 7 deletions(-)
diff --git a/src/api/basicDataManage/gasManage/index.ts b/src/api/basicDataManage/gasManage/index.ts
index 4062b55..60fbab1 100644
--- a/src/api/basicDataManage/gasManage/index.ts
+++ b/src/api/basicDataManage/gasManage/index.ts
@@ -29,5 +29,14 @@
data: data
});
},
+
+ //气体编辑
+ editGas: (data: object) => {
+ return request({
+ url: import.meta.env.VITE_API_URL + `/gasCategory/update`,
+ method: 'post',
+ data: data
+ });
+ },
};
}
diff --git a/src/api/warningManage/warningInfo/index.ts b/src/api/warningManage/warningInfo/index.ts
index 0be772f..56955b0 100644
--- a/src/api/warningManage/warningInfo/index.ts
+++ b/src/api/warningManage/warningInfo/index.ts
@@ -3,10 +3,19 @@
export function warningInfoApi() {
return {
- //预警信息分页
+ //气体预警信息分页
getWarnLogPage: (data: object) => {
return request({
url: import.meta.env.VITE_API_URL + `/gasWarnLog/page`,
+ method: 'post',
+ data: data
+ });
+ },
+
+ //设备预警信息分页
+ getWarnDeviceLogPage: (data: object) => {
+ return request({
+ url: import.meta.env.VITE_API_URL + `/deviceExcLog/page`,
method: 'post',
data: data
});
@@ -22,4 +31,4 @@
},
};
-}
\ No newline at end of file
+}
diff --git a/src/types/gasManage.d.ts b/src/types/gasManage.d.ts
index 5f4fe45..fc2a73c 100644
--- a/src/types/gasManage.d.ts
+++ b/src/types/gasManage.d.ts
@@ -25,10 +25,11 @@
title: string;
isShowUserDialog: boolean;
gasForm: {
+ id: string;
gasName: string;
gasMolecularFormula: string;
gasThreshold: string;
gasUnit: string;
};
gasFormRules:{},
-}
\ No newline at end of file
+}
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>
diff --git a/src/views/basicDataManage/gasManage/index.vue b/src/views/basicDataManage/gasManage/index.vue
index b803281..5c63e6a 100644
--- a/src/views/basicDataManage/gasManage/index.vue
+++ b/src/views/basicDataManage/gasManage/index.vue
@@ -36,6 +36,7 @@
<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>
@@ -137,4 +138,4 @@
</script>
<style scoped lang="scss">
-</style>
\ No newline at end of file
+</style>
diff --git a/src/views/warningManage/warningDevice/component/index.vue b/src/views/warningManage/warningDevice/component/index.vue
new file mode 100644
index 0000000..bc1afd7
--- /dev/null
+++ b/src/views/warningManage/warningDevice/component/index.vue
@@ -0,0 +1,61 @@
+<template>
+ <div class="system-add-gas-container">
+ <el-dialog
+ title="查看"
+ v-model="state.isShowUserDialog"
+ width="550px"
+ @close="handleClose"
+ >
+ <el-form :model="state.infoForm" size="default" ref="gasRef" style="padding: 10px 20px ">
+ <el-form-item label="预警内容:" prop="name">
+ <span>{{state.infoForm.content}}</span>
+ </el-form-item>
+ <el-form-item label="预警时间:" prop="points">
+ <span>{{state.infoForm.time}}</span>
+ </el-form-item>
+ <el-form-item label="信息详情:" prop="points">
+ <span>{{state.infoForm.execDesc}}</span>
+ </el-form-item>
+ </el-form>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup lang="ts">
+import {reactive, ref} from "vue";
+import {InfoState} from "/@/types/warning";
+import {userApi} from "/@/api/systemManage/user";
+import {ElMessage} from "element-plus";
+import {warningInfoApi} from "/@/api/warningManage/warningInfo";
+
+const gasRef = ref();
+const emit = defineEmits(["getInfoData"]);
+const state = reactive({
+ title: '',
+ isShowUserDialog: false,
+ disabled: false,
+ infoForm: {
+ id: '',
+ content: '',
+ time: '',
+ execDesc: ''
+ },
+});
+const openDialog = (type: string, value: any) => {
+ state.isShowUserDialog = true;
+ if (type === '查看') {
+ state.disabled = true;
+ let data = JSON.parse(JSON.stringify(value));
+ state.infoForm = data;
+ }
+ state.title = type;
+};
+
+const handleClose = () => {
+ state.isShowUserDialog = false;
+ emit('getInfoData');
+}
+defineExpose({
+ openDialog
+});
+</script>
diff --git a/src/views/warningManage/warningDevice/index.vue b/src/views/warningManage/warningDevice/index.vue
new file mode 100644
index 0000000..7219d58
--- /dev/null
+++ b/src/views/warningManage/warningDevice/index.vue
@@ -0,0 +1,153 @@
+<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"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ range-separator="~"
+ start-placeholder="开始时间"
+ end-placeholder="结束时间"
+ />
+ </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-table :data="state.tableData.data" style="width: 100%">
+ <el-table-column align="center" prop="content" label="预警内容"/>
+ <el-table-column align="center" prop="time" 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>
+ </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>
+ <info-dialog ref="infoRef" @getInfoData="initInfoData"></info-dialog>
+ </div>
+</template>
+
+<script setup lang="ts">
+import {reactive, ref, onMounted} from "vue";
+import { ElMessage, ElMessageBox } from 'element-plus';
+import infoDialog from "./component/index.vue";
+import {warningInfoApi} from "/@/api/warningManage/warningInfo";
+
+const infoRef = ref();
+const state = reactive({
+ tableData: {
+ data: [] as any,
+ total: 0,
+ loading: false,
+ listQuery: {
+ pageIndex: 1,
+ pageSize: 10,
+ searchParams: {
+ time: []
+ }
+ },
+ }
+});
+
+//页面加载
+onMounted(() => {
+ initInfoData();
+});
+
+
+//预警信息列表
+const initInfoData = async () => {
+ const param = {
+ pageIndex: state.tableData.listQuery.pageIndex,
+ pageSize: state.tableData.listQuery.pageSize,
+ searchParams: {
+ startTime: state.tableData.listQuery.searchParams.time ? state.tableData.listQuery.searchParams.time[0] : '',
+ endTime: state.tableData.listQuery.searchParams.time ? state.tableData.listQuery.searchParams.time[1]: ''
+ }
+ };
+ let res = await warningInfoApi().getWarnDeviceLogPage(param);
+ if(res.data.code == 100) {
+ state.tableData.data = res.data.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;
+ initInfoData();
+};
+// 分页改变
+const onHandleCurrentChange = (val: number) => {
+ state.tableData.listQuery.pageIndex = val;
+ initInfoData();
+};
+const openDialog = (type: string, value: any) => {
+ infoRef.value.openDialog(type, value);
+};
+
+const search = () => {
+ state.tableData.listQuery.pageIndex = 1;
+ initInfoData();
+}
+const reset = () => {
+ state.tableData.listQuery.pageIndex = 1;
+ state.tableData.listQuery.searchParams.time = [];
+ initInfoData();
+}
+</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
+}
+.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
+}
+</style>
--
Gitblit v1.9.2