|
|
@@ -47,7 +47,7 @@
|
|
|
|
|
|
|
|
|
</div>
|
|
|
- <el-button v-if="tableData.length > 0 && tableData.length < 4" type="primary"
|
|
|
+ <el-button v-if="tableData.length < 4" type="primary"
|
|
|
style="position: absolute;right: 20px;" @click="goAdd">添加设备</el-button>
|
|
|
</div>
|
|
|
<div style="margin-top: 20px">
|
|
|
@@ -153,311 +153,308 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="CarInfo" lang="ts">
|
|
|
- import { TreeNode } from "element-plus";
|
|
|
- import { useRoute, useRouter } from "vue-router";
|
|
|
- import EZUIKit from 'ezuikit-js';
|
|
|
- import { getCameraPlayerConfig } from '@/api/gpsData';
|
|
|
- import { listCarPath, getCarPath, delCarPath, addCarPath, updateCarPath } from '@/api/carPath';
|
|
|
- import { updateData, listData } from "@/api/system/dict/data";
|
|
|
- import imgulock from "@/assets/images/unlock@2x.png";
|
|
|
+import { TreeNode } from "element-plus";
|
|
|
+import { useRoute, useRouter } from "vue-router";
|
|
|
+import EZUIKit from 'ezuikit-js';
|
|
|
+import { getCameraPlayerConfig } from '@/api/gpsData';
|
|
|
+import { listCarPath, getCarPath, delCarPath, addCarPath, updateCarPath } from '@/api/carPath';
|
|
|
+import { updateData, listData } from "@/api/system/dict/data";
|
|
|
+import imgulock from "@/assets/images/unlock@2x.png";
|
|
|
|
|
|
- const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
|
- const sites = ref([]);
|
|
|
+const sites = ref([]);
|
|
|
|
|
|
- const showTree = ref(true)
|
|
|
+const showTree = ref(true)
|
|
|
|
|
|
|
|
|
- const formdata = ref({
|
|
|
- name: "",
|
|
|
- type: "",
|
|
|
- code: "",
|
|
|
- cabinetType: ''
|
|
|
- })
|
|
|
+const formdata = ref({
|
|
|
+ name: "",
|
|
|
+ type: "",
|
|
|
+ code: "",
|
|
|
+ cabinetType: ''
|
|
|
+})
|
|
|
|
|
|
|
|
|
- const route = useRoute();
|
|
|
- const router = useRouter();
|
|
|
+const route = useRoute();
|
|
|
+const router = useRouter();
|
|
|
|
|
|
- const tableData = ref([]);
|
|
|
- const carPathList = ref([]);
|
|
|
- const line = ref([]);
|
|
|
+const tableData = ref([]);
|
|
|
+const carPathList = ref([]);
|
|
|
+const line = ref([]);
|
|
|
|
|
|
- const activeName = ref("camera")
|
|
|
+const activeName = ref("camera")
|
|
|
|
|
|
- const filterText = ref("");
|
|
|
- const treeRef = ref(null);
|
|
|
- const dialogVisible = ref(false);
|
|
|
+const filterText = ref("");
|
|
|
+const treeRef = ref(null);
|
|
|
+const dialogVisible = ref(false);
|
|
|
|
|
|
- const gettreeheight = () => {
|
|
|
- return document.body.clientHeight - 100;
|
|
|
- }
|
|
|
+const gettreeheight = () => {
|
|
|
+ return document.body.clientHeight - 100;
|
|
|
+}
|
|
|
|
|
|
- const goAdd = () => {
|
|
|
- dialogVisible.value = true
|
|
|
- formdata.value = {
|
|
|
- name: "",
|
|
|
- type: "",
|
|
|
- code: ""
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const getTypeName = (data) => {
|
|
|
- var type = data.cabinetType
|
|
|
- if (type == 1) {
|
|
|
- return '一主'
|
|
|
- } else if (type == 2) {
|
|
|
- return '一主一副'
|
|
|
- } else {
|
|
|
- return '一主二副'
|
|
|
- }
|
|
|
+const goAdd = () => {
|
|
|
+ dialogVisible.value = true
|
|
|
+ formdata.value = {
|
|
|
+ name: "",
|
|
|
+ type: "",
|
|
|
+ code: ""
|
|
|
}
|
|
|
-
|
|
|
- const initData = async () => {
|
|
|
- const res = await listCarPath({ pageSize: 1000 });
|
|
|
- carPathList.value = res.rows;
|
|
|
+}
|
|
|
+
|
|
|
+const getTypeName = (data) => {
|
|
|
+ var type = data.cabinetType
|
|
|
+ if (type == 1) {
|
|
|
+ return '一主'
|
|
|
+ } else if (type == 2) {
|
|
|
+ return '一主一副'
|
|
|
+ } else {
|
|
|
+ return '一主二副'
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
+const initData = async () => {
|
|
|
+ const res = await listCarPath({ pageSize: 1000 });
|
|
|
+ carPathList.value = res.rows;
|
|
|
+}
|
|
|
|
|
|
- const defaultProps = {
|
|
|
- children: "children",
|
|
|
- label: "label",
|
|
|
- value: 'id',
|
|
|
- };
|
|
|
- const treeIndent = ref(40);
|
|
|
-
|
|
|
- watch(filterText, (val) => {
|
|
|
- if (treeRef.value) {
|
|
|
- treeRef.value.filter(val);
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
- const savedata = () => {
|
|
|
- //保存数据
|
|
|
- var data = {
|
|
|
- dictCode: currentdata.value.dictCode,
|
|
|
- dictValue: currentdata.value.dictValue,
|
|
|
- dictLabel: currentdata.value.dictLabel,
|
|
|
- dictType: "tbl_sites",
|
|
|
- remark: JSON.stringify(tableData.value)
|
|
|
- }
|
|
|
- updateData(data).then(res => {
|
|
|
- ElMessage.success("成功!");
|
|
|
- getLineSites();
|
|
|
+const defaultProps = {
|
|
|
+ children: "children",
|
|
|
+ label: "label",
|
|
|
+ value: 'id',
|
|
|
+};
|
|
|
+const treeIndent = ref(40);
|
|
|
|
|
|
- })
|
|
|
+watch(filterText, (val) => {
|
|
|
+ if (treeRef.value) {
|
|
|
+ treeRef.value.filter(val);
|
|
|
}
|
|
|
+});
|
|
|
+
|
|
|
+const savedata = () => {
|
|
|
+ //保存数据
|
|
|
+ var data = {
|
|
|
+ dictCode: currentdata.value.dictCode,
|
|
|
+ dictValue: currentdata.value.dictValue,
|
|
|
+ dictLabel: currentdata.value.dictLabel,
|
|
|
+ dictType: "tbl_sites",
|
|
|
+ remark: JSON.stringify(tableData.value)
|
|
|
+ }
|
|
|
+ updateData(data).then(res => {
|
|
|
+ ElMessage.success("成功!");
|
|
|
+ getLineSites();
|
|
|
|
|
|
- const getLineSites = () => {
|
|
|
- console.log(line.value)
|
|
|
- var sitesList = []
|
|
|
- for (var index in carPathList.value) {
|
|
|
- if (carPathList.value[index].id == line.value) {
|
|
|
- sitesList = JSON.parse(carPathList.value[index].stationList)
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(sitesList)
|
|
|
- var sites = []
|
|
|
- for (var i in sitesList) {
|
|
|
- sites.push({ id: i, label: sitesList[i].data.dictLabel })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const getLineSites = () => {
|
|
|
+ console.log(line.value)
|
|
|
+ var sitesList = []
|
|
|
+ for (var index in carPathList.value) {
|
|
|
+ if (carPathList.value[index].id == line.value) {
|
|
|
+ sitesList = JSON.parse(carPathList.value[index].stationList)
|
|
|
}
|
|
|
- console.log(sites)
|
|
|
+ }
|
|
|
+ console.log(sitesList)
|
|
|
+ var sites = []
|
|
|
+ for (var i in sitesList) {
|
|
|
+ sites.push({ id: i, label: sitesList[i].data.dictLabel })
|
|
|
+ }
|
|
|
+ console.log(sites)
|
|
|
+ data.value = [{
|
|
|
+ id: 1,
|
|
|
+ label: "站点",
|
|
|
+ },];
|
|
|
+ data.value[0].children = sites
|
|
|
+ console.log(data.value)
|
|
|
+ showTree.value = false;
|
|
|
+ setTimeout(() => {
|
|
|
+ showTree.value = true
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const getSites = () => {
|
|
|
+ listData({ dictType: "tbl_sites" }).then(res2 => {
|
|
|
+ sites.value = res2.rows;
|
|
|
+ var index = 1;
|
|
|
data.value = [{
|
|
|
id: 1,
|
|
|
label: "站点",
|
|
|
+ children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
|
|
|
},];
|
|
|
- data.value[0].children = sites
|
|
|
- console.log(data.value)
|
|
|
- showTree.value = false;
|
|
|
- setTimeout(() => {
|
|
|
- showTree.value = true
|
|
|
- }, 100);
|
|
|
-
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const deleteDevice = (datac) => {
|
|
|
+ tableData.value = tableData.value.filter(i => i.type != datac.type);
|
|
|
+ var data = {
|
|
|
+ dictCode: currentdata.value.dictCode,
|
|
|
+ dictValue: currentdata.value.dictValue,
|
|
|
+ dictLabel: currentdata.value.dictLabel,
|
|
|
+ dictType: "tbl_sites",
|
|
|
+ remark: JSON.stringify(tableData.value)
|
|
|
}
|
|
|
+ updateData(data).then(res => {
|
|
|
+ ElMessage.success("成功!");
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
- const getSites = () => {
|
|
|
- listData({ dictType: "tbl_sites" }).then(res2 => {
|
|
|
- sites.value = res2.rows;
|
|
|
- var index = 1;
|
|
|
- data.value = [{
|
|
|
- id: 1,
|
|
|
- label: "站点",
|
|
|
- children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
|
|
|
- },];
|
|
|
- });
|
|
|
- }
|
|
|
+const handleTabClick = () => {
|
|
|
|
|
|
- const deleteDevice = (datac) => {
|
|
|
- tableData.value = tableData.value.filter(i => i.type != datac.type);
|
|
|
- var data = {
|
|
|
- dictCode: currentdata.value.dictCode,
|
|
|
- dictValue: currentdata.value.dictValue,
|
|
|
- dictLabel: currentdata.value.dictLabel,
|
|
|
- dictType: "tbl_sites",
|
|
|
- remark: JSON.stringify(tableData.value)
|
|
|
- }
|
|
|
- updateData(data).then(res => {
|
|
|
- ElMessage.success("成功!");
|
|
|
- })
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
- const handleTabClick = () => {
|
|
|
+const filterNode = (value: string, node: TreeNode) => {
|
|
|
+ if (node.id == 1) return true;
|
|
|
+ console.log(node.label.indexOf(value) != -1)
|
|
|
+ return node.label.indexOf(value) != -1;
|
|
|
+};
|
|
|
|
|
|
- }
|
|
|
+const currentdata = ref(null)
|
|
|
|
|
|
- const filterNode = (value: string, node: TreeNode) => {
|
|
|
- if (node.id == 1) return true;
|
|
|
- console.log(node.label.indexOf(value) != -1)
|
|
|
- return node.label.indexOf(value) != -1;
|
|
|
- };
|
|
|
-
|
|
|
- const currentdata = ref(null)
|
|
|
-
|
|
|
- const isJSON = (str) => {
|
|
|
- if (typeof str == 'string') {
|
|
|
- try {
|
|
|
- var obj = JSON.parse(str);
|
|
|
- if (typeof obj == 'object' && obj) {
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- } catch (e) {
|
|
|
+const isJSON = (str) => {
|
|
|
+ if (typeof str == 'string') {
|
|
|
+ try {
|
|
|
+ var obj = JSON.parse(str);
|
|
|
+ if (typeof obj == 'object' && obj) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ } catch (e) {
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- const treeclick = (data: TreeNodeData, node: TreeNode) => {
|
|
|
-
|
|
|
- currentdata.value = sites.value.filter(i => {
|
|
|
- return i.dictLabel == data.label
|
|
|
- })[0];
|
|
|
- tableData.value = [];
|
|
|
- if (currentdata.value) {
|
|
|
- if (isJSON(currentdata.value.remark)) {
|
|
|
- tableData.value = JSON.parse(currentdata.value.remark);
|
|
|
- var cameras = tableData.value.filter(i => i.type == 'camera');
|
|
|
- if (cameras.length > 0) {
|
|
|
- var cameracode = cameras[0].code;
|
|
|
- //存在视频播放视频
|
|
|
- // getCameraPlayerConfig(cameracode).then(res => {
|
|
|
- // console.log(res.data);
|
|
|
- // var player = new EZUIKit.EZUIKitPlayer({
|
|
|
- // template: "pcLive",
|
|
|
- // id: 'video-container', // 视频容器ID
|
|
|
- // ...res.data
|
|
|
- // })
|
|
|
- // })
|
|
|
- }
|
|
|
-
|
|
|
- var cabinets = tableData.value.filter(i => i.type == 'cabinet');
|
|
|
- if (cabinets.length > 0) {
|
|
|
- var cabinetcode = cameras[0].code;
|
|
|
- SycCabinet(cabinetcode);
|
|
|
- }
|
|
|
- }else{
|
|
|
- ElMessage.warning("站点设备配置错误");
|
|
|
+}
|
|
|
+
|
|
|
+const treeclick = (data: TreeNodeData, node: TreeNode) => {
|
|
|
+
|
|
|
+ currentdata.value = sites.value.filter(i => {
|
|
|
+ return i.dictLabel == data.label
|
|
|
+ })[0];
|
|
|
+ tableData.value = [];
|
|
|
+ if (currentdata.value) {
|
|
|
+ // if (isJSON(currentdata.value.remark)) {
|
|
|
+ tableData.value = JSON.parse(currentdata.value.remark??"{}");
|
|
|
+ var cameras = tableData.value.filter(i => i.type == 'camera');
|
|
|
+ if (cameras.length > 0) {
|
|
|
+ var cameracode = cameras[0].code;
|
|
|
+ //存在视频播放视频
|
|
|
+ // getCameraPlayerConfig(cameracode).then(res => {
|
|
|
+ // console.log(res.data);
|
|
|
+ // var player = new EZUIKit.EZUIKitPlayer({
|
|
|
+ // template: "pcLive",
|
|
|
+ // id: 'video-container', // 视频容器ID
|
|
|
+ // ...res.data
|
|
|
+ // })
|
|
|
+ // })
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ var cabinets = tableData.value.filter(i => i.type == 'cabinet');
|
|
|
+ if (cabinets.length > 0) {
|
|
|
+ var cabinetcode = cameras[0].code;
|
|
|
+ SycCabinet(cabinetcode);
|
|
|
+ }
|
|
|
+ // }else{
|
|
|
+ // ElMessage.warning("站点设备配置错误");
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- const addDevice = () => {
|
|
|
- dialogVisible.value = false;
|
|
|
- if (formdata.value.name == "") {
|
|
|
- ElMessage.warning("设备名称未填写");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (formdata.value.type == "") {
|
|
|
- ElMessage.warning("设备类型未填写");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (formdata.value.code == "") {
|
|
|
- ElMessage.warning("设备序列号未填写");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (tableData.value.filter(i => i.type == formdata.value.type).length > 0) {
|
|
|
- ElMessage.warning("存在相同类型的设备");
|
|
|
- return;
|
|
|
- }
|
|
|
- tableData.value.push(formdata.value);
|
|
|
- var data = {
|
|
|
- dictCode: currentdata.value.dictCode,
|
|
|
- dictValue: currentdata.value.dictValue,
|
|
|
- dictLabel: currentdata.value.dictLabel,
|
|
|
- dictType: "tbl_sites",
|
|
|
- remark: JSON.stringify(tableData.value)
|
|
|
- }
|
|
|
- updateData(data).then(res => {
|
|
|
- ElMessage.success("成功!");
|
|
|
- })
|
|
|
+}
|
|
|
|
|
|
|
|
|
+const addDevice = () => {
|
|
|
+ dialogVisible.value = false;
|
|
|
+ if (formdata.value.name == "") {
|
|
|
+ ElMessage.warning("设备名称未填写");
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- const currentCabinet = ref({
|
|
|
- total: 40,
|
|
|
- unused: 10,
|
|
|
- boxlist: []
|
|
|
- })
|
|
|
- const SycCabinet = (code) => {
|
|
|
- //TODO 获取格数
|
|
|
- // var toalnum
|
|
|
- currentCabinet.value.boxlist = [];
|
|
|
- for (var i = 0; i < currentCabinet.value.total; i++) {
|
|
|
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
- //@ts-ignore
|
|
|
- currentCabinet.value.boxlist.push({
|
|
|
- box_id: 1,
|
|
|
- box_name: (i + 1) + "",
|
|
|
- box_status: i % 2
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
+ if (formdata.value.type == "") {
|
|
|
+ ElMessage.warning("设备类型未填写");
|
|
|
+ return;
|
|
|
}
|
|
|
- const openbox = (code) => {
|
|
|
- setTimeout(() => {
|
|
|
- ElMessage.success("指令已发送!");
|
|
|
- }, 1000);
|
|
|
+ if (formdata.value.code == "") {
|
|
|
+ ElMessage.warning("设备序列号未填写");
|
|
|
+ return;
|
|
|
}
|
|
|
+ if (tableData.value.filter(i => i.type == formdata.value.type).length > 0) {
|
|
|
+ ElMessage.warning("存在相同类型的设备");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ tableData.value.push(formdata.value);
|
|
|
+ var data = {
|
|
|
+ dictCode: currentdata.value.dictCode,
|
|
|
+ dictValue: currentdata.value.dictValue,
|
|
|
+ dictLabel: currentdata.value.dictLabel,
|
|
|
+ dictType: "tbl_sites",
|
|
|
+ remark: JSON.stringify(tableData.value)
|
|
|
+ }
|
|
|
+ updateData(data).then(res => {
|
|
|
+ ElMessage.success("成功!");
|
|
|
+ })
|
|
|
|
|
|
|
|
|
- const data = computed(() => {
|
|
|
-
|
|
|
- var index = 1;
|
|
|
-
|
|
|
- return [{
|
|
|
- id: 1,
|
|
|
- label: "站点",
|
|
|
- children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
|
|
|
- },]
|
|
|
- });
|
|
|
- onMounted(() => {
|
|
|
- if (treeRef.value) {
|
|
|
- setTimeout(() => {
|
|
|
- treeRef.value.expandNode(treeRef.value.getNode(1))
|
|
|
- }, 100);
|
|
|
- getSites();
|
|
|
- initData();
|
|
|
- // treeRef.value.expandNode(treeRef.value.getNode(1))
|
|
|
+}
|
|
|
+
|
|
|
+const currentCabinet = ref({
|
|
|
+ total: 40,
|
|
|
+ unused: 10,
|
|
|
+ boxlist: []
|
|
|
+})
|
|
|
+const SycCabinet = (code) => {
|
|
|
+ //TODO 获取格数
|
|
|
+ // var toalnum
|
|
|
+ currentCabinet.value.boxlist = [];
|
|
|
+ for (var i = 0; i < currentCabinet.value.total; i++) {
|
|
|
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
+ //@ts-ignore
|
|
|
+ currentCabinet.value.boxlist.push({
|
|
|
+ box_id: 1,
|
|
|
+ box_name: (i + 1) + "",
|
|
|
+ box_status: i % 2
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+const openbox = (code) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ ElMessage.success("指令已发送!");
|
|
|
+ }, 1000);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const data = computed(() => {
|
|
|
+
|
|
|
+ var index = 1;
|
|
|
+
|
|
|
+ return [{
|
|
|
+ id: 1,
|
|
|
+ label: "站点",
|
|
|
+ children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
|
|
|
+ },]
|
|
|
+});
|
|
|
+onMounted(() => {
|
|
|
+ if (treeRef.value) {
|
|
|
+ setTimeout(() => {
|
|
|
+ treeRef.value.expandNode(treeRef.value.getNode(1))
|
|
|
+ }, 100);
|
|
|
+ getSites();
|
|
|
+ initData();
|
|
|
+ // treeRef.value.expandNode(treeRef.value.getNode(1))
|
|
|
+ }
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
- .card-header {
|
|
|
- display: flex;
|
|
|
- flex-direction: row;
|
|
|
- justify-content: space-between;
|
|
|
- }
|
|
|
-
|
|
|
- .boxunused {
|
|
|
- background: #3333332d;
|
|
|
- }
|
|
|
-</style>
|
|
|
+.card-header {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ justify-content: space-between;
|
|
|
+}
|
|
|
+
|
|
|
+.boxunused {
|
|
|
+ background: #3333332d;
|
|
|
+}
|
|
|
+</style>
|