zhouwenxuan
2024-01-03 44813af86c1ba3203dc606c8bf7690405e084cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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>