zhouwenxuan
2024-01-03 44813af86c1ba3203dc606c8bf7690405e084cfc
设备预警,修改气体
已修改5个文件
已添加2个文件
280 ■■■■■ 文件已修改
src/api/basicDataManage/gasManage/index.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/warningManage/warningInfo/index.ts 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/types/gasManage.d.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicDataManage/gasManage/component/gasDialog.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicDataManage/gasManage/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningDevice/component/index.vue 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warningManage/warningDevice/index.vue 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
            });
        },
    };
}
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 @@
        },
    };
}
}
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:{},
}
}
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>
</style>
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>
</style>
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>
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>