|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<el-card>
|
|
|
- <el-space wrap :size="30">
|
|
|
+ <el-space wrap>
|
|
|
<div class="search-input">
|
|
|
<span class="lable">类型:</span>
|
|
|
<el-select
|
|
@@ -22,15 +22,16 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="search-input" v-if="!isStation">
|
|
|
- <span class="lable">场站:</span>
|
|
|
+ <span class="lable">{{
|
|
|
+ state.isshowwindturbineName ? "场站:" : "升压站:"
|
|
|
+ }}</span>
|
|
|
<el-select
|
|
|
v-model="state.stationId"
|
|
|
clearable
|
|
|
- style="width: 150px"
|
|
|
size="mini"
|
|
|
placeholder="全部"
|
|
|
popper-class="select"
|
|
|
- @change="getWindturbineList()"
|
|
|
+ @change="getWindturbineList"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in stationList"
|
|
@@ -40,12 +41,11 @@
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
- <div class="search-input" v-show="state.isshowwindturbineName">
|
|
|
+ <div class="search-input" v-if="state.isshowwindturbineName">
|
|
|
<span class="lable">机组:</span>
|
|
|
<el-select
|
|
|
v-model="state.windturbineId"
|
|
|
clearable
|
|
|
- style="width: 150px"
|
|
|
size="mini"
|
|
|
placeholder="全部"
|
|
|
popper-class="select"
|
|
@@ -54,15 +54,51 @@
|
|
|
v-for="item in state.windturbineList"
|
|
|
:key="item.id"
|
|
|
:value="item.id"
|
|
|
- :label="item.windturbineCode"
|
|
|
+ :label="item.name"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div class="search-input" v-if="state.isshowwindturbineName">
|
|
|
+ <span class="lable">型号:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="state.modelId"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="全部"
|
|
|
+ popper-class="select"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in modelList"
|
|
|
+ :key="item.id"
|
|
|
+ :value="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div class="search-input" v-if="state.isshowwindturbineName">
|
|
|
+ <span class="lable">部件:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="state.components"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="全部"
|
|
|
+ popper-class="select"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in componentList"
|
|
|
+ :key="item.id"
|
|
|
+ :value="item.id"
|
|
|
+ :label="item.name"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div class="search-input">
|
|
|
- <span class="lable">关键字:</span>
|
|
|
+ <span class="lable">描述:</span>
|
|
|
<el-input
|
|
|
- v-model="state.keywords"
|
|
|
+ v-model="state.description"
|
|
|
style="width: 100px"
|
|
|
size="mini"
|
|
|
></el-input>
|
|
@@ -85,187 +121,282 @@
|
|
|
<el-button type="primary" size="mini" @click="getAlarmHistoryt"
|
|
|
>查询</el-button
|
|
|
>
|
|
|
- <el-button size="mini" type="primary" @click="export2Excel"
|
|
|
- :disabled="state.tableData?.length == 0 ? true : false">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="primary"
|
|
|
+ @click="export2Excel"
|
|
|
+ :disabled="state.tableData?.length == 0 ? true : false"
|
|
|
+ >
|
|
|
导出</el-button
|
|
|
>
|
|
|
</el-space>
|
|
|
</el-card>
|
|
|
- <el-table
|
|
|
- :data="state.tableData"
|
|
|
- height="70vh"
|
|
|
- style="width: 100%; margin-top: 10px"
|
|
|
- >
|
|
|
- <el-table-column prop="alertTime" label="时间" width="180px">
|
|
|
- <template #default="scope">
|
|
|
- {{ formatTime(scope.row.alertTime) }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
-
|
|
|
- <el-table-column prop="stationName" label="场站" width="180px" />
|
|
|
- <el-table-column
|
|
|
- label="机组"
|
|
|
- prop="windturbineName"
|
|
|
- v-if="state.isshowwindturbineName"
|
|
|
- width="180px"
|
|
|
- />
|
|
|
- <el-table-column prop="alertText" label="报警信息" />
|
|
|
- <el-table-column prop="rank" label="级别" width="80px">
|
|
|
- <template #default="scope">
|
|
|
- {{ tableFilter(scope.row.rank) }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="messageType" label="类型" width="80px">
|
|
|
- <template #default="scope">
|
|
|
- {{ messageTypeFilter(scope.row.messageType) }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <div class="pagination">
|
|
|
- <el-pagination
|
|
|
- background
|
|
|
- layout="total, prev, pager, next"
|
|
|
- hide-on-single-page
|
|
|
- :current-page="query.page"
|
|
|
- :page-size="query.limit"
|
|
|
- :total="query.pageTotal"
|
|
|
- @current-change="handlePageChange"
|
|
|
- ></el-pagination>
|
|
|
+ <div class="table-wrapper">
|
|
|
+ <el-table
|
|
|
+ :data="state.tableData"
|
|
|
+ height="calc(100% - 35px - 10px)"
|
|
|
+ style="width: 100%"
|
|
|
+ border
|
|
|
+ stripe
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ v-for="item in state.isshowwindturbineName
|
|
|
+ ? state.tableHeader
|
|
|
+ : state.tableHeader1"
|
|
|
+ :label="item.title"
|
|
|
+ :prop="item.code"
|
|
|
+ :key="item.code"
|
|
|
+ :width="item.width ? item.width : 0"
|
|
|
+ show-overflow-tooltip
|
|
|
+ header-align="center"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <span v-if="item.code == 'rank'">
|
|
|
+ {{ tableFilter(scope.row.rank) }}
|
|
|
+ </span>
|
|
|
+ <span v-else-if="item.code == 'alarmtype'">
|
|
|
+ {{ tableFilter(scope.row.alarmtype) }}
|
|
|
+ </span>
|
|
|
+ <span v-else-if="item.code == 'ts'">
|
|
|
+ {{ formatTime(scope.row.ts) }}
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ {{ scope.row[item.code] }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div class="pagination-wrapper">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="total, prev, pager, next"
|
|
|
+ hide-on-single-page
|
|
|
+ :current-page="query.page"
|
|
|
+ :page-size="query.limit"
|
|
|
+ :total="query.pageTotal"
|
|
|
+ @current-change="handlePageChange"
|
|
|
+ ></el-pagination>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { watch, reactive, nextTick, computed, onMounted } from "vue";
|
|
|
import dayjs from "dayjs";
|
|
|
-import { alarm_history,new_alarm_history, fetchWindturbineList } from "/@/api/api.js";
|
|
|
+import {
|
|
|
+ alarm_history,
|
|
|
+ new_alarm_history,
|
|
|
+ fetchWindturbineList,
|
|
|
+ fetchModel,
|
|
|
+ fetchRelatePartAndAlarmType,
|
|
|
+} from "/@/api/api.js";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { initWebSocket } from "/@/websocket/indextest";
|
|
|
import { outExportExcel } from "/@/utils/exportExcel"; //引入文件
|
|
|
import { useStore } from "vuex";
|
|
|
|
|
|
const store = useStore();
|
|
|
-const endtime = new Date();
|
|
|
-const starttime = new Date(endtime - 1 * 24 * 60 * 60 * 1000);
|
|
|
-const stationList = computed(() => store.state.stationList);
|
|
|
const isStation = computed(() => store.getters.isStation);
|
|
|
|
|
|
-onMounted(() => {});
|
|
|
-
|
|
|
-watch(
|
|
|
- () => stationList,
|
|
|
- (val, old) => {
|
|
|
- val.value[0] &&
|
|
|
- nextTick(async () => {
|
|
|
- state.stationId = val.value[0]?.id;
|
|
|
- state.dateTime[0] = formatTime(starttime);
|
|
|
- state.dateTime[1] = formatTime(endtime);
|
|
|
- await getWindturbineList();
|
|
|
- await getAlarmHistoryt();
|
|
|
- });
|
|
|
- },
|
|
|
- {
|
|
|
- deep: true,
|
|
|
- immediate: true,
|
|
|
- }
|
|
|
-);
|
|
|
+onMounted(() => {
|
|
|
+ getequipmentmodel_list();
|
|
|
+ getfetchRelatePart();
|
|
|
+ state.dateTime = [
|
|
|
+ dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
|
+ dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
|
|
+ ];
|
|
|
+});
|
|
|
+// 机型
|
|
|
+const getequipmentmodel_list = async () => {
|
|
|
+ const { data } = await fetchModel();
|
|
|
+ state.modelListAll = data;
|
|
|
+};
|
|
|
+//所属部件
|
|
|
+const getfetchRelatePart = async () => {
|
|
|
+ const { data } = await fetchRelatePartAndAlarmType();
|
|
|
+ state.fetchListAll = data;
|
|
|
+};
|
|
|
const state = reactive({
|
|
|
typeList: [
|
|
|
- // {
|
|
|
- // label: "升压站",
|
|
|
- // value: "SYZ",
|
|
|
- // },
|
|
|
{
|
|
|
- label: "自定义",
|
|
|
- value: "custom",
|
|
|
+ label: "升压站",
|
|
|
+ value: "booststation",
|
|
|
},
|
|
|
+ // {
|
|
|
+ // label: "自定义",
|
|
|
+ // value: "custom",
|
|
|
+ // },
|
|
|
{
|
|
|
label: "风机",
|
|
|
value: "windturbine",
|
|
|
},
|
|
|
],
|
|
|
- typeVal: "",
|
|
|
+ typeVal: "windturbine",
|
|
|
stationId: "",
|
|
|
windturbineList: [],
|
|
|
windturbineId: "",
|
|
|
- keywords: "",
|
|
|
+ modelListAll: {},
|
|
|
+ fetchListAll: {},
|
|
|
+ modelId: "", //型号
|
|
|
+ components: "", //部件
|
|
|
+ description: "", //描述
|
|
|
dateTime: [],
|
|
|
startDate: null,
|
|
|
endDate: null,
|
|
|
tableData: [],
|
|
|
isshowwindturbineName: true,
|
|
|
+ tableHeader: [
|
|
|
+ { title: "时间", code: "ts", width: "180" },
|
|
|
+ { title: "场站", code: "stationname", width: "180" },
|
|
|
+ { title: "机组", code: "devicename", width: "180" },
|
|
|
+ { title: "报警信息", code: "description" },
|
|
|
+ { title: "级别", code: "rank", width: "80" },
|
|
|
+ { title: "类型", code: "alarmtype", width: "80" },
|
|
|
+ ],
|
|
|
+ tableHeader1: [
|
|
|
+ { title: "时间", code: "ts", width: "180" },
|
|
|
+ { title: "升压站", code: "stationname", width: "180" },
|
|
|
+ { title: "报警信息", code: "description" },
|
|
|
+ { title: "级别", code: "rank", width: "80" },
|
|
|
+ { title: "类型", code: "alarmtype", width: "80" },
|
|
|
+ ],
|
|
|
});
|
|
|
+// 场站列表/升压站列表
|
|
|
+const stationList = computed(() => {
|
|
|
+ if (state.typeVal == "windturbine") {
|
|
|
+ return store.state.stationListAll;
|
|
|
+ } else if (state.typeVal == "booststation") {
|
|
|
+ return store.state.booststationList;
|
|
|
+ }
|
|
|
+});
|
|
|
+watch(
|
|
|
+ () => stationList,
|
|
|
+ (val, old) => {
|
|
|
+ val.value.length &&
|
|
|
+ nextTick(async () => {
|
|
|
+ state.stationId = val.value[0]?.id;
|
|
|
+ await getWindturbineList();
|
|
|
+ await getAlarmHistoryt();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ {
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ }
|
|
|
+);
|
|
|
+//型号列表
|
|
|
+const modelList = computed(() => {
|
|
|
+ if (state.typeVal == "windturbine") {
|
|
|
+ if (state.stationId == "") {
|
|
|
+ return [];
|
|
|
+ } else {
|
|
|
+ return state.modelListAll[state.stationId];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+});
|
|
|
+//部件列表
|
|
|
+const componentList = computed(() => {
|
|
|
+ if (state.typeVal == "windturbine") {
|
|
|
+ if (state.stationId == "") {
|
|
|
+ return [];
|
|
|
+ } else {
|
|
|
+ if (state.stationId.includes("FDC")) {
|
|
|
+ return state.fetchListAll?.fjbj;
|
|
|
+ } else {
|
|
|
+ return state.fetchListAll?.gfbj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+});
|
|
|
+//get 风机
|
|
|
+const getWindturbineList = async () => {
|
|
|
+ state.windturbineList = [];
|
|
|
+ state.windturbineId = "";
|
|
|
+ const { data } = await fetchWindturbineList(state.stationId);
|
|
|
+ state.windturbineList = data;
|
|
|
+};
|
|
|
const query = reactive({
|
|
|
page: 1,
|
|
|
- limit: 15,
|
|
|
+ limit: 17,
|
|
|
pageTotal: null,
|
|
|
});
|
|
|
|
|
|
// 获取历史记录表
|
|
|
const getAlarmHistoryt = async () => {
|
|
|
let params = {
|
|
|
- pagenum: query.page,
|
|
|
- pagesize: query.limit,
|
|
|
+ pageNum: query.page,
|
|
|
+ pageSize: query.limit,
|
|
|
+ alarmType: state.typeVal,
|
|
|
stationid: state.stationId,
|
|
|
- windturbineid: state.typeVal == "SYZ" ? "" : state.windturbineId,
|
|
|
- category1: state.typeVal,
|
|
|
- category2: "",
|
|
|
- rank: null,
|
|
|
- keyword: state.keywords,
|
|
|
- starttime: state.dateTime[0],
|
|
|
- endtime: state.dateTime[1],
|
|
|
+ deviceid: state.typeVal == "booststation" ? "" : state.windturbineId,
|
|
|
+ modelId: state.modelId,
|
|
|
+ components: state.components,
|
|
|
+ description: state.description,
|
|
|
+ begin: state.dateTime[0],
|
|
|
+ end: state.dateTime[1],
|
|
|
};
|
|
|
const { data } = await alarm_history(params);
|
|
|
query.pageTotal = data?.total;
|
|
|
- state.tableData = data?.records;
|
|
|
+ state.tableData = data?.ls;
|
|
|
};
|
|
|
+//报警类型变化
|
|
|
const typechange = () => {
|
|
|
- state.isshowwindturbineName = state.typeVal == "SYZ" ? false : true;
|
|
|
-};
|
|
|
-//get 风机
|
|
|
-const getWindturbineList = async () => {
|
|
|
- state.windturbineList = [];
|
|
|
- state.windturbineId = "";
|
|
|
- const res = await fetchWindturbineList(state.stationId);
|
|
|
- state.windturbineList = res;
|
|
|
+ state.isshowwindturbineName = state.typeVal == "booststation" ? false : true;
|
|
|
};
|
|
|
|
|
|
// 批量导出
|
|
|
const export2Excel = async () => {
|
|
|
let params = {
|
|
|
- pagenum: 1,
|
|
|
- pagesize: 999999,
|
|
|
+ pageNum: query.page,
|
|
|
+ pageSize: query.pageTotal,
|
|
|
+ alarmType: state.typeVal,
|
|
|
stationid: state.stationId,
|
|
|
- windturbineid: state.typeVal == "SYZ" ? "" : state.windturbineId,
|
|
|
- category1: state.typeVal,
|
|
|
- category2: "",
|
|
|
- rank: null,
|
|
|
- keyword: state.keywords,
|
|
|
- starttime: state.dateTime[0],
|
|
|
- endtime: state.dateTime[1],
|
|
|
+ deviceid: state.typeVal == "booststation" ? "" : state.windturbineId,
|
|
|
+ modelId: state.modelId,
|
|
|
+ components: state.components,
|
|
|
+ description: state.description,
|
|
|
+ begin: state.dateTime[0],
|
|
|
+ end: state.dateTime[1],
|
|
|
};
|
|
|
|
|
|
- if (endtime - starttime > 6 * 24 * 60 * 60 * 1000) {
|
|
|
+ if (state.dateTime[1] - state.dateTime[0] > 6 * 24 * 60 * 60 * 1000) {
|
|
|
this.$message({
|
|
|
message: "导出时间范围不能大于7天",
|
|
|
type: "warning",
|
|
|
});
|
|
|
} else {
|
|
|
- const file = await new_alarm_history(params);
|
|
|
- let blob = new Blob([file], {
|
|
|
- type: "application/zip", // 这边的类型需要改
|
|
|
- });
|
|
|
+ let tableHeader = [];
|
|
|
+ let tableKey = [];
|
|
|
+ const { data } = await alarm_history(params);
|
|
|
+ if (state.isshowwindturbineName) {
|
|
|
+ tableHeader = state.tableHeader.map((item) => item.title);
|
|
|
+ tableKey = state.tableHeader.map((item) => item.code);
|
|
|
+ } else {
|
|
|
+ tableHeader = state.tableHeader1.map((item) => item.title);
|
|
|
+ tableKey = state.tableHeader1.map((item) => item.code);
|
|
|
+ }
|
|
|
const stationName = stationList.value.find((ele) => {
|
|
|
return ele.id === state.stationId;
|
|
|
}).name;
|
|
|
- const fileName = `${stationName} ${state.dateTime[0].replace(/_/g,':')} ~ ${state.dateTime[1].replace(/_/g,':')} 数据表`;
|
|
|
+ const fileName = `${stationName} ${state.dateTime[0]} ~ ${state.dateTime[1]} 数据表`;
|
|
|
|
|
|
- let url = window.URL.createObjectURL(blob);
|
|
|
- let link = document.createElement("a");
|
|
|
- link.style.display = "none";
|
|
|
- link.download = fileName;
|
|
|
- link.href = url;
|
|
|
- document.body.appendChild(link);
|
|
|
- link.click();
|
|
|
+ outExportExcel(
|
|
|
+ tableHeader,
|
|
|
+ tableKey,
|
|
|
+ data.ls.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ ts: formatTime(item.ts),
|
|
|
+ rank: tableFilter(item.rank),
|
|
|
+ alarmtype: tableFilter(item.alarmtype),
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ fileName
|
|
|
+ );
|
|
|
ElMessage.success(`导出成功!`);
|
|
|
}
|
|
|
};
|
|
@@ -285,7 +416,7 @@ const obj = {
|
|
|
3: "中级",
|
|
|
4: "中高级",
|
|
|
5: "高级",
|
|
|
- SYZ: "升压站",
|
|
|
+ booststation: "升压站",
|
|
|
custom: "自定义",
|
|
|
windturbine: "风机",
|
|
|
};
|
|
@@ -301,5 +432,18 @@ const messageTypeFilter = (val) => {
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
-</style>
|
|
|
+<style scoped lang="scss">
|
|
|
+.table-wrapper {
|
|
|
+ height: calc(100% - 70px - 50px);
|
|
|
+ background-color: #fff;
|
|
|
+ margin-top: 10px;
|
|
|
+ padding: 20px;
|
|
|
+ .pagination-wrapper :deep {
|
|
|
+ text-align: right;
|
|
|
+ margin-top: 10px;
|
|
|
+ .el-icon {
|
|
|
+ width: unset;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|