|
|
@@ -6,7 +6,7 @@
|
|
|
<template #header>
|
|
|
<div class="card-header">
|
|
|
<span>设备区域</span>
|
|
|
- <div>
|
|
|
+ <div style="display: none">
|
|
|
<el-button type="primary" >
|
|
|
添加
|
|
|
</el-button>
|
|
|
@@ -21,7 +21,11 @@
|
|
|
v-model:selectedKey="selectedKey"
|
|
|
@node-click="handleClick"
|
|
|
>
|
|
|
+ <template #title="{ data }">
|
|
|
+ {{ data.name }}
|
|
|
+ </template>
|
|
|
</LayTree>
|
|
|
+
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</el-col>
|
|
|
@@ -38,9 +42,9 @@
|
|
|
align-items: center;
|
|
|
"
|
|
|
>
|
|
|
- <div style="font-size: 12px; width: 100px;">监测点编号:</div>
|
|
|
+ <div style="font-size: 12px; width: 100px;">传感器编号:</div>
|
|
|
<el-input
|
|
|
- v-model="searchform.devicename"
|
|
|
+ v-model="searchform.sn"
|
|
|
placeholder="请输入"
|
|
|
></el-input>
|
|
|
</div>
|
|
|
@@ -54,14 +58,14 @@
|
|
|
>
|
|
|
<div style="font-size: 12px; width: 80px;margin-right: 10px;text-align: right;">描述:</div>
|
|
|
<el-input
|
|
|
- v-model="searchform.devicename"
|
|
|
+ v-model="searchform.desc"
|
|
|
placeholder="请输入"
|
|
|
></el-input>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div>
|
|
|
- <el-button type="primary" plain>重置</el-button>
|
|
|
- <el-button type="primary">搜索</el-button>
|
|
|
+ <el-button type="primary" plain @click="initdata">重置</el-button>
|
|
|
+ <el-button type="primary" @click="getalldata">搜索</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
@@ -72,19 +76,16 @@
|
|
|
<span>传感器台账</span>
|
|
|
<div>
|
|
|
<el-button type="primary" @click="goadd">添加</el-button>
|
|
|
- <el-button type="danger">批量删除</el-button>
|
|
|
- <el-button type="primary" plain>显示字段</el-button>
|
|
|
+ <el-button type="danger" @click="deleteall">批量删除</el-button>
|
|
|
+ <el-button type="primary" plain @click="ziduanshow=true">显示字段</el-button>
|
|
|
</div>
|
|
|
</div></template>
|
|
|
|
|
|
<el-row>
|
|
|
<el-col :span="24" style="padding-left: 10px">
|
|
|
- <el-table :data="devicetabledata" :border="true">
|
|
|
- <el-table-column label="传感器编号"></el-table-column>
|
|
|
- <el-table-column label="传感器名称"></el-table-column>
|
|
|
- <el-table-column label="描述"></el-table-column>
|
|
|
- <el-table-column label="状态"></el-table-column>
|
|
|
- <el-table-column label="类型"></el-table-column>
|
|
|
+ <el-table :data="devicetabledata" ref="tableref" :border="true">
|
|
|
+ <el-table-column type="selection" width="55" />
|
|
|
+ <el-table-column v-for="item in cloumdata.filter(i=>i.visible)" :prop="item.prop" :label="item.label" ></el-table-column>
|
|
|
|
|
|
<el-table-column label="操作">
|
|
|
<template #default="scope">
|
|
|
@@ -108,7 +109,7 @@
|
|
|
<el-icon><VideoPlay /></el-icon>
|
|
|
</el-tooltip>
|
|
|
</el-button>
|
|
|
- <el-popconfirm title="确定删除该标签?">
|
|
|
+ <el-popconfirm title="确定删除该传感器?" @confirm="deleterow(scope.row)">
|
|
|
<template #reference>
|
|
|
<el-button link
|
|
|
><el-tooltip effect="dark" content="删除"
|
|
|
@@ -128,7 +129,10 @@
|
|
|
small
|
|
|
background
|
|
|
layout="prev, pager, next"
|
|
|
- :total="50"
|
|
|
+ :total="pagedata.total"
|
|
|
+ :page-size="pagedata.size"
|
|
|
+ :current-page="pagedata.current"
|
|
|
+ @current-change="onchangepage"
|
|
|
class="mt-4"
|
|
|
/>
|
|
|
</el-col>
|
|
|
@@ -197,80 +201,197 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <el-dialog
|
|
|
+ title="字段显示"
|
|
|
+ v-model="ziduanshow"
|
|
|
+ width="50%"
|
|
|
+ @close="ziduanshow = false"
|
|
|
+ >
|
|
|
+ <div style="display: flex;flex-wrap: wrap;align-content: center;justify-content: center;align-items: center;">
|
|
|
+ <el-checkbox v-for="item in cloumdata" v-model="item.visible" :label="item.label" size="large" />
|
|
|
+ </div>
|
|
|
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script setup lang="ts" name="Units">
|
|
|
+<script setup>
|
|
|
import {ref} from "vue";
|
|
|
-import { LayTree } from "@layui/layui-vue";
|
|
|
+import {LayTree} from "@layui/layui-vue";
|
|
|
import "@layui/layui-vue/lib/index.css";
|
|
|
import {useRoute, useRouter} from "vue-router";
|
|
|
+import {listEquipmentOrganizational} from "@/api/data/equipmentOrganizational"
|
|
|
+import {listEquipmentSbook} from "@/api/data/equipmentSbook"
|
|
|
+import {listSensor,delSensor,addSensor,updateSensor} from "@/api/data/sensor"
|
|
|
+import {delGateway} from "@/api/data/gateway";
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+
|
|
|
+const {proxy} = getCurrentInstance();
|
|
|
+const {protocal_type, sensor_type, sensor_status} = proxy.useDict("protocal_type", "sensor_type", "sensor_status");
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
+const ziduanshow = ref(false);
|
|
|
+
|
|
|
+const tableref = ref(null);
|
|
|
+
|
|
|
+const cloumdata = ref([
|
|
|
+ {label: '传感器编号', prop: 'sn', visible: true},
|
|
|
+ {label: '传感器名称', prop: 'name', visible: true},
|
|
|
+ {label: '描述', prop: 'sensorDesc', visible: true},
|
|
|
+ {label: '状态', prop: 'statusname', visible: true},
|
|
|
+ {label: '类型', prop: 'sensorType', visible: true},
|
|
|
+])
|
|
|
|
|
|
|
|
|
-const goadd = ()=>{
|
|
|
+const onchangepage = (page) => {
|
|
|
+ pagedata.value.current = page;
|
|
|
+ getalldata();
|
|
|
+}
|
|
|
+const pagedata = ref({
|
|
|
+ total:0,
|
|
|
+ size:10,
|
|
|
+ current:1
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+const deleterow =(item)=>{
|
|
|
+ delSensor(item.id).then((res)=>{
|
|
|
+ ElMessage.success("删除成功");
|
|
|
+ getalldata();
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const deleteall = ()=>{
|
|
|
+ let selected = tableref.value.getSelectionRows();
|
|
|
+ if(selected.length==0) {
|
|
|
+ ElMessage.warning("请选择要删除的行");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selected.length > 0) {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ `是否删除${selected.length}条数据`,
|
|
|
+ "警告",
|
|
|
+ {
|
|
|
+ confirmButtonText: "确认",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: 'warning',
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+
|
|
|
+ delSensor(selected.map(i => i.id).join(",")).then((res) => {
|
|
|
+ ElMessage.success("删除成功");
|
|
|
+ getalldata();
|
|
|
+ })
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const initdata = ()=>{
|
|
|
+ searchform.value.sn = '';
|
|
|
+ searchform.value.desc = '';
|
|
|
+ pagedata.value = {
|
|
|
+ total:0,
|
|
|
+ size:10,
|
|
|
+ current:1
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const goadd = () => {
|
|
|
router.push("/device/sensordash/add")
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+const currentnode = ref(null);
|
|
|
+const getalldata = () => {
|
|
|
+ const getdeviceid = (node) => {
|
|
|
+ if (node.children) {
|
|
|
+ return node.children.map(item => {
|
|
|
+ return getdeviceid(item);
|
|
|
+ }).join(",")
|
|
|
+ } else {
|
|
|
+ if ((node.id + "").indexOf("device") > -1) {
|
|
|
+ return node.id;
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let deviceids = getdeviceid(currentnode.value).split(",").filter(i => i != "").join(",");
|
|
|
+ if (deviceids != "") {
|
|
|
+ deviceids = deviceids.replaceAll("device_", "")
|
|
|
+ listSensor({...pagedata, params: {deviceids: deviceids,...searchform.value}}).then(res => {
|
|
|
+ const {rows,total,page,size} = res;
|
|
|
+ pagedata.value = {total:total,current:page, size:10};
|
|
|
+ devicetabledata.value = rows.map(item => {
|
|
|
+ try{
|
|
|
+ var statusname = sensor_status.value.find(i => i.value == item.status).label;
|
|
|
+ item["statusname"] = statusname;
|
|
|
+ }catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ pagedata.value = {total:0,current:1, size:10};
|
|
|
+ devicetabledata.value=[];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const handleClick = (node) => {
|
|
|
- console.log("Click Node:" + JSON.stringify(node));
|
|
|
+ //循环获取子的id
|
|
|
+ currentnode.value = node;
|
|
|
+ getalldata();
|
|
|
};
|
|
|
const selectedKey = ref(4);
|
|
|
-const data = ref([
|
|
|
- {
|
|
|
- title: "集团公司",
|
|
|
- id: 1,
|
|
|
- checked: true,
|
|
|
- spread: true,
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: "示范项目",
|
|
|
- id: 2,
|
|
|
- spread: true,
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: "监测站",
|
|
|
- id: 4,
|
|
|
- href: "https://www.layui.com/",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "用能区域",
|
|
|
- id: 5,
|
|
|
- href: "https://www.layui.com/",
|
|
|
- },
|
|
|
-
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "虚拟项目",
|
|
|
- id: 3,
|
|
|
- href: "https://www.layui.com/",
|
|
|
- },
|
|
|
+const data = ref([]);
|
|
|
+
|
|
|
+
|
|
|
+const getTreedata = () => {
|
|
|
+ listEquipmentOrganizational({pageSize: 10000}).then(res => {
|
|
|
+ const {rows, total, page, size} = res;
|
|
|
+ //获取设备数据
|
|
|
+ listEquipmentSbook({page: 1, pageSize: 100000}).then(res1 => {
|
|
|
+ res1.rows.forEach(item => {
|
|
|
+ item["parentId"] = item.equipmentTreeId;
|
|
|
+ item["id"] = "device_" + item.id;
|
|
|
+ rows.push(item);
|
|
|
+ data.value = proxy.handleTree(rows, "id", "parentId");
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+getTreedata();
|
|
|
|
|
|
- ],
|
|
|
- },
|
|
|
-]);
|
|
|
|
|
|
-const devicetabledata = ref([1]);
|
|
|
+const devicetabledata = ref([]);
|
|
|
const searchform = ref({
|
|
|
- devicename: "",
|
|
|
- devicesn:""
|
|
|
+ sn: "",
|
|
|
+ desc: ""
|
|
|
});
|
|
|
|
|
|
|
|
|
const cdbdshow = ref(false);
|
|
|
-const cdbd = ()=>{
|
|
|
+const cdbd = () => {
|
|
|
cdbdshow.value = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
+<style lang="scss">
|
|
|
+.layui-tree .layui-this .layui-tree-txt {
|
|
|
+ color: #038de0 !important;
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|
|
|
<style lang="scss" scoped>
|
|
|
.card-header {
|
|
|
display: flex;
|
|
|
@@ -278,6 +399,7 @@ const cdbd = ()=>{
|
|
|
justify-content: space-between;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
.tree {
|
|
|
*,
|
|
|
*:before,
|