Files
emsfront/src/views/ems/site/sblb/PointTable.vue

296 lines
7.7 KiB
Vue
Raw Normal View History

2025-09-13 22:41:41 +08:00
<!--电位展示图表-->
<template>
<div>
<el-dialog
2025-09-13 22:41:41 +08:00
v-loading="loading"
:close-on-click-modal="false"
2025-09-18 10:07:41 +08:00
:visible.sync="show"
append-to-body
class="ems-dialog"
2025-09-13 22:41:41 +08:00
destroy-on-close
lock-scroll
2025-09-18 10:07:41 +08:00
show-close
2025-09-25 17:30:16 +08:00
title="点位清单"
2025-11-05 18:00:05 +08:00
width="950px"
>
2025-11-05 18:00:05 +08:00
<el-form :inline="true" label-width="100px">
<el-form-item label="点位名称">
<el-input
v-model="form.dataPointName"
clearable
placeholder="请输入点位名称"
style="width: 150px"
></el-input>
</el-form-item>
<el-form-item label="点位">
<el-input
v-model="form.dataPoint"
clearable
placeholder="请输入点位"
style="width: 150px"
></el-input>
</el-form-item>
2025-11-05 18:00:05 +08:00
<el-form-item label="modbus ip">
<el-input
2025-11-25 17:56:12 +08:00
v-model="form.ipAddress"
clearable
placeholder="请输入ip"
style="width: 150px"
2025-11-05 18:00:05 +08:00
></el-input>
</el-form-item>
<el-form-item label="最小值">
<el-input
v-model="form.lower"
clearable
placeholder="请输入最小值"
style="width: 150px"
></el-input>
</el-form-item>
<el-form-item label="最大值">
<el-input
v-model="form.upper"
clearable
placeholder="请输入最大值"
style="width: 150px"
></el-input>
</el-form-item>
2025-11-05 18:00:05 +08:00
<el-form-item label="modbus 端口">
<el-input
2025-11-25 17:56:12 +08:00
v-model="form.ipPort"
clearable
placeholder="请输入端口"
style="width: 150px"
2025-11-05 18:00:05 +08:00
></el-input>
</el-form-item>
<el-form-item style="margin-left: 20px">
<el-button type="primary" @click="search">搜索</el-button>
</el-form-item>
</el-form>
2025-09-25 17:30:16 +08:00
<el-table
2025-09-13 22:41:41 +08:00
:data="tableData"
2025-09-18 10:07:41 +08:00
class="common-table"
2025-09-17 17:53:21 +08:00
max-height="400px"
2025-09-18 10:07:41 +08:00
stripe
style="width: 100%"
:default-sort="defaultSort"
@sort-change="handleSortChange"
>
<el-table-column label="数据点位" prop="dataPoint"> </el-table-column>
2025-11-05 18:00:05 +08:00
<el-table-column
2025-11-25 17:56:12 +08:00
label="数据点位名称"
prop="pointName"
></el-table-column>
<el-table-column label="modbus地址">
2025-11-05 18:00:05 +08:00
<template slot-scope="scope">
2025-11-25 17:56:12 +08:00
<span>{{
`${scope.row.ipAddress || ""} ${scope.row.ipPort || ""}`
}}</span>
2025-11-05 18:00:05 +08:00
</template>
</el-table-column>
<el-table-column
2025-09-18 10:07:41 +08:00
label="最新值"
prop="pointValue"
align="right"
2025-09-25 17:30:16 +08:00
sortable="custom"
>
<template slot-scope="scope">
2025-11-25 17:56:12 +08:00
<span class="pointer" @click="showChart(scope.row)">{{
scope.row.pointValue
}}</span>
</template>
</el-table-column>
<el-table-column label="单位" prop="dataUnit"></el-table-column>
2025-11-25 17:56:12 +08:00
<el-table-column
label="更新时间"
min-width="160px"
prop="updateTime"
sortable="custom"
>
</el-table-column>
</el-table>
<el-pagination
v-show="tableData.length > 0"
2025-09-13 22:41:41 +08:00
:current-page="pageNum"
:page-size="pageSize"
:page-sizes="[10, 20, 30, 40]"
2025-09-18 10:07:41 +08:00
:pager-count="5"
2025-09-13 22:41:41 +08:00
:total="totalSize"
2025-09-18 10:07:41 +08:00
background
layout="total, sizes, prev, pager, next, jumper"
small
style="margin-top: 15px; text-align: center"
2025-09-18 10:07:41 +08:00
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
</el-pagination>
</el-dialog>
<point-chart ref="pointChart" :site-id="siteId" />
</div>
2025-09-13 22:41:41 +08:00
</template>
<script>
import { getDevicePointList } from "@/api/ems/site";
import pointChart from "@/views/ems/dzjk/sbjk/PointChart.vue";
2025-09-13 22:41:41 +08:00
export default {
components: { pointChart },
2025-09-25 17:30:16 +08:00
watch: {
2025-09-13 22:41:41 +08:00
show(val) {
2025-09-25 17:30:16 +08:00
if (!val) {
this.tableData = [];
this.deviceId = "";
2025-11-25 17:56:12 +08:00
this.parentId = "";
this.siteId = "";
this.pageSize = 10;
this.pageNum = 1;
this.totalSize = 0;
2025-09-25 17:30:16 +08:00
this.form = {
sortMethod: "desc", //升序不传或者asc、降序desc
2025-11-25 17:56:12 +08:00
sortData: this.defaultSort.prop,
dataPointName: "", //点位名称
dataPoint: "", //点位名称
lower: "", //
upper: "", //
2025-11-25 17:56:12 +08:00
ipAddress: "",
ipPort: "",
};
this.loading = false;
2025-09-13 22:41:41 +08:00
}
},
},
2025-11-25 17:56:12 +08:00
computed: {
isDtdc() {
return this.deviceCategory === "BATTERY";
},
},
2025-09-25 17:30:16 +08:00
data() {
return {
// 默认排序
defaultSort: { prop: "updateTime", order: "descending" },
2025-09-25 17:30:16 +08:00
show: false,
loading: false,
form: {
sortData: "updateTime", //最新值升序不传或者asc、降序desc
sortMethod: "desc", //升序不传或者asc、降序desc
dataPointName: "", //点位名称
dataPoint: "", //点位名称
lower: "", //
upper: "", //
2025-11-25 17:56:12 +08:00
ipAddress: "",
ipPort: "",
2025-09-25 17:30:16 +08:00
},
deviceCategory: "",
deviceId: "",
2025-11-25 17:56:12 +08:00
parentId: "",
siteId: "",
2025-09-25 17:30:16 +08:00
tableData: [],
pageSize: 10, //分页栏当前每个数据总数
pageNum: 1, //分页栏当前页数
totalSize: 0, //table表格数据总数
};
2025-09-13 22:41:41 +08:00
},
2025-09-25 17:30:16 +08:00
methods: {
2025-11-25 17:56:12 +08:00
showChart({ pointName }) {
if (pointName) {
const { deviceCategory, deviceId } = this;
if (this.isDtdc)
this.$refs.pointChart.showChart({
pointName,
deviceCategory,
deviceId: this.parentId,
child: [deviceId],
});
else
this.$refs.pointChart.showChart({
pointName,
deviceCategory,
deviceId,
});
}
},
handleSortChange(column) {
2025-11-25 17:56:12 +08:00
this.form.sortData = column.prop;
this.form.sortMethod = column.order === "descending" ? "desc" : "asc";
console.log("切换排序方式", column, this.form);
this.getData();
2025-09-25 17:30:16 +08:00
},
search() {
this.pageNum = 1;
this.getData();
2025-09-22 10:16:21 +08:00
},
2025-11-25 17:56:12 +08:00
showTable({ deviceCategory, siteId, deviceId, parentId = "" }) {
this.deviceCategory = deviceCategory;
this.siteId = siteId;
this.deviceId = deviceId;
2025-11-25 17:56:12 +08:00
this.parentId = deviceCategory === "BATTERY" ? parentId : ""; //只有单体电池需要这个值
this.show = true;
this.getData();
2025-09-13 22:41:41 +08:00
},
2025-09-25 17:30:16 +08:00
getData() {
this.loading = true;
2025-09-25 17:30:16 +08:00
const {
siteId,
deviceId,
deviceCategory,
parentId,
2025-09-25 17:30:16 +08:00
pageNum,
pageSize,
form: {
sortData,
sortMethod,
dataPointName,
dataPoint,
lower,
upper,
2025-11-05 18:00:05 +08:00
ipAddress,
2025-11-25 17:56:12 +08:00
ipPort,
},
} = this;
2025-09-25 17:30:16 +08:00
getDevicePointList({
siteId,
deviceId,
deviceCategory,
2025-10-16 16:34:32 +08:00
parentId,
2025-09-25 17:30:16 +08:00
pageNum,
pageSize,
sortData,
sortMethod,
dataPointName,
dataPoint,
lower,
upper,
2025-11-05 18:00:05 +08:00
ipAddress,
2025-11-25 17:56:12 +08:00
ipPort,
2025-09-25 17:30:16 +08:00
})
.then((response) => {
this.tableData = response?.rows || [];
this.totalSize = response?.total || 0;
})
.finally(() => {
this.loading = false;
});
2025-09-13 22:41:41 +08:00
},
// 分页
handleSizeChange(val) {
this.pageSize = val;
2025-09-25 17:30:16 +08:00
this.$nextTick(() => {
this.getData();
});
2025-09-13 22:41:41 +08:00
},
handleCurrentChange(val) {
this.pageNum = val;
2025-09-25 17:30:16 +08:00
this.$nextTick(() => {
this.getData();
});
2025-09-13 22:41:41 +08:00
},
},
};
2025-09-13 22:41:41 +08:00
</script>
2025-09-18 10:07:41 +08:00
<style lang="scss" scoped>
2025-09-13 22:41:41 +08:00
::v-deep {
2025-09-25 17:30:16 +08:00
.card-title .el-radio {
2025-09-13 22:41:41 +08:00
line-height: 40px;
}
}
</style>