From 48bf364762e643732f3bfee5793d06cbcef30661 Mon Sep 17 00:00:00 2001 From: fuguobin Date: Wed, 13 Sep 2023 13:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=95=B0=E6=8D=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/baoxue-rijian.svg | 2 +- src/assets/icons/baoyu-rijian.svg | 2 +- src/assets/icons/dabaoyu-rijian.svg | 2 +- src/assets/icons/daxue-rijian.svg | 2 +- src/assets/icons/dayu-rijian.svg | 2 +- src/assets/icons/dongyu-rijian.svg | 2 +- src/assets/icons/duoyun-rijian.svg | 2 +- src/assets/icons/duoyun-wanjian.svg | 2 +- src/assets/icons/fuchen-rijian.svg | 2 +- src/assets/icons/leizhenyu-rijian.svg | 2 +- src/assets/icons/leizhenyujiabingbao.svg | 2 +- src/assets/icons/qiangshachenbao.svg | 2 +- src/assets/icons/qing-rijian.svg | 2 +- src/assets/icons/qing-wanjian.svg | 2 +- src/assets/icons/shachenbao-rijian.svg | 2 +- src/assets/icons/tedabaoyu.svg | 2 +- src/assets/icons/wu-rijian.svg | 2 +- src/assets/icons/xiaoxue-rijian.svg | 2 +- src/assets/icons/xiaoyu-rijian.svg | 2 +- src/assets/icons/yangsha-rijian.svg | 2 +- src/assets/icons/yin-rijian.svg | 2 +- src/assets/icons/yujiaxue-rijian.svg | 2 +- src/assets/icons/zhenxue-rijian.svg | 2 +- src/assets/icons/zhenxue-wanjian.svg | 2 +- src/assets/icons/zhenyu-rijian.svg | 2 +- src/assets/icons/zhenyu-wanjian.svg | 2 +- src/assets/icons/zhongxue-rijian.svg | 2 +- src/assets/icons/zhongyu-rijian.svg | 2 +- src/utils/index.ts | 31 +++++++++ src/utils/socket.ts | 2 +- src/views/login/index.scss | 2 +- src/views/monitoring/components/header.vue | 13 ++-- .../monitoring/screen/components/main.vue | 63 +++++++++++++++---- src/views/monitoring/screen/index.scss | 8 ++- vite.config.ts | 2 +- 35 files changed, 125 insertions(+), 52 deletions(-) diff --git a/src/assets/icons/baoxue-rijian.svg b/src/assets/icons/baoxue-rijian.svg index 29bab77..f4b8d48 100644 --- a/src/assets/icons/baoxue-rijian.svg +++ b/src/assets/icons/baoxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/baoyu-rijian.svg b/src/assets/icons/baoyu-rijian.svg index 4702c77..3dae155 100644 --- a/src/assets/icons/baoyu-rijian.svg +++ b/src/assets/icons/baoyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/dabaoyu-rijian.svg b/src/assets/icons/dabaoyu-rijian.svg index 1279ec6..d1d41e6 100644 --- a/src/assets/icons/dabaoyu-rijian.svg +++ b/src/assets/icons/dabaoyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/daxue-rijian.svg b/src/assets/icons/daxue-rijian.svg index 5e1e75a..dc29cc0 100644 --- a/src/assets/icons/daxue-rijian.svg +++ b/src/assets/icons/daxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/dayu-rijian.svg b/src/assets/icons/dayu-rijian.svg index 03fa565..848044e 100644 --- a/src/assets/icons/dayu-rijian.svg +++ b/src/assets/icons/dayu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/dongyu-rijian.svg b/src/assets/icons/dongyu-rijian.svg index e09cafa..494dfb4 100644 --- a/src/assets/icons/dongyu-rijian.svg +++ b/src/assets/icons/dongyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/duoyun-rijian.svg b/src/assets/icons/duoyun-rijian.svg index 3c829b4..e124b37 100644 --- a/src/assets/icons/duoyun-rijian.svg +++ b/src/assets/icons/duoyun-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/duoyun-wanjian.svg b/src/assets/icons/duoyun-wanjian.svg index 91b6584..5ef7278 100644 --- a/src/assets/icons/duoyun-wanjian.svg +++ b/src/assets/icons/duoyun-wanjian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/fuchen-rijian.svg b/src/assets/icons/fuchen-rijian.svg index 0479673..e935c50 100644 --- a/src/assets/icons/fuchen-rijian.svg +++ b/src/assets/icons/fuchen-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/leizhenyu-rijian.svg b/src/assets/icons/leizhenyu-rijian.svg index d962ed9..671fdd7 100644 --- a/src/assets/icons/leizhenyu-rijian.svg +++ b/src/assets/icons/leizhenyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/leizhenyujiabingbao.svg b/src/assets/icons/leizhenyujiabingbao.svg index 08a80c4..b5520c7 100644 --- a/src/assets/icons/leizhenyujiabingbao.svg +++ b/src/assets/icons/leizhenyujiabingbao.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/qiangshachenbao.svg b/src/assets/icons/qiangshachenbao.svg index b8f60f3..bfb84ab 100644 --- a/src/assets/icons/qiangshachenbao.svg +++ b/src/assets/icons/qiangshachenbao.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/qing-rijian.svg b/src/assets/icons/qing-rijian.svg index 4bb1a1a..5c931e5 100644 --- a/src/assets/icons/qing-rijian.svg +++ b/src/assets/icons/qing-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/qing-wanjian.svg b/src/assets/icons/qing-wanjian.svg index 06432bc..3f63689 100644 --- a/src/assets/icons/qing-wanjian.svg +++ b/src/assets/icons/qing-wanjian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/shachenbao-rijian.svg b/src/assets/icons/shachenbao-rijian.svg index 497f129..8bb8f8b 100644 --- a/src/assets/icons/shachenbao-rijian.svg +++ b/src/assets/icons/shachenbao-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/tedabaoyu.svg b/src/assets/icons/tedabaoyu.svg index a6d57be..212908e 100644 --- a/src/assets/icons/tedabaoyu.svg +++ b/src/assets/icons/tedabaoyu.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/wu-rijian.svg b/src/assets/icons/wu-rijian.svg index 1a05285..2f930ee 100644 --- a/src/assets/icons/wu-rijian.svg +++ b/src/assets/icons/wu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/xiaoxue-rijian.svg b/src/assets/icons/xiaoxue-rijian.svg index 88ac796..21e4e3c 100644 --- a/src/assets/icons/xiaoxue-rijian.svg +++ b/src/assets/icons/xiaoxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/xiaoyu-rijian.svg b/src/assets/icons/xiaoyu-rijian.svg index 32a3035..36b9046 100644 --- a/src/assets/icons/xiaoyu-rijian.svg +++ b/src/assets/icons/xiaoyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/yangsha-rijian.svg b/src/assets/icons/yangsha-rijian.svg index a7dfa3f..8723fa8 100644 --- a/src/assets/icons/yangsha-rijian.svg +++ b/src/assets/icons/yangsha-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/yin-rijian.svg b/src/assets/icons/yin-rijian.svg index 88eb148..0e2fa38 100644 --- a/src/assets/icons/yin-rijian.svg +++ b/src/assets/icons/yin-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/yujiaxue-rijian.svg b/src/assets/icons/yujiaxue-rijian.svg index 7c7205a..12fb413 100644 --- a/src/assets/icons/yujiaxue-rijian.svg +++ b/src/assets/icons/yujiaxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhenxue-rijian.svg b/src/assets/icons/zhenxue-rijian.svg index b445b29..8495765 100644 --- a/src/assets/icons/zhenxue-rijian.svg +++ b/src/assets/icons/zhenxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhenxue-wanjian.svg b/src/assets/icons/zhenxue-wanjian.svg index 879a2b2..000747d 100644 --- a/src/assets/icons/zhenxue-wanjian.svg +++ b/src/assets/icons/zhenxue-wanjian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhenyu-rijian.svg b/src/assets/icons/zhenyu-rijian.svg index 3d2eceb..07caf8e 100644 --- a/src/assets/icons/zhenyu-rijian.svg +++ b/src/assets/icons/zhenyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhenyu-wanjian.svg b/src/assets/icons/zhenyu-wanjian.svg index 6249ff3..15c9622 100644 --- a/src/assets/icons/zhenyu-wanjian.svg +++ b/src/assets/icons/zhenyu-wanjian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhongxue-rijian.svg b/src/assets/icons/zhongxue-rijian.svg index eb391ce..a3b882b 100644 --- a/src/assets/icons/zhongxue-rijian.svg +++ b/src/assets/icons/zhongxue-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/zhongyu-rijian.svg b/src/assets/icons/zhongyu-rijian.svg index 8cb1609..af8b553 100644 --- a/src/assets/icons/zhongyu-rijian.svg +++ b/src/assets/icons/zhongyu-rijian.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index 0312193..40c2fd1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -195,6 +195,37 @@ export function getFirstNodeLastLevel(data: any) { return firstNode; // 返回第一个节点的最后一个层级的数据 } +/** + * 获取数组对象第一个节点最后一个层级的数据 + * @param {array} obj1 数组1 + * @param {array} obj2 数组2 + */ +export function isEqual(obj1: any, obj2: any) { + // 判断两个对象的类型是否相同 + if (typeof obj1 !== typeof obj2) { + return false; + } + // 如果是基本类型数据,则直接比较它们的值 + if (typeof obj1 !== 'object') { + return obj1 === obj2; + } + // 获取obj1和obj2的属性名称 + const obj1Keys = Object.keys(obj1); + const obj2Keys = Object.keys(obj2); + // 如果两个对象的属性数量不同,则它们不相等 + if (obj1Keys.length !== obj2Keys.length) { + return false; + } + // 递归比较obj1和obj2的属性和值 + for (let key of obj1Keys) { + if (!isEqual(obj1[key], obj2[key])) { + return false; + } + } + // 如果所有属性和值都相等,则两个对象相等 + return true; +} + /** * 数字补位 */ diff --git a/src/utils/socket.ts b/src/utils/socket.ts index 9786fb9..c6c9470 100644 --- a/src/utils/socket.ts +++ b/src/utils/socket.ts @@ -51,7 +51,7 @@ class WebSocketService { onMessage(event: MessageEvent): void { if (event.data != '连接成功') { const response = JSON.parse(event.data); - // console.log(response); + console.log("response:",response); this.data = response; // 处理返回的数据 if (response.code === 'datareal') { diff --git a/src/views/login/index.scss b/src/views/login/index.scss index 873c4b8..b260539 100644 --- a/src/views/login/index.scss +++ b/src/views/login/index.scss @@ -69,7 +69,7 @@ &:-webkit-autofill { box-shadow: 0 0 0 1000px transparent inset !important; - -webkit-text-fill-color: #fff !important; + -webkit-text-fill-color: #606266 !important; } // 设置输入框自动填充的延迟属性 diff --git a/src/views/monitoring/components/header.vue b/src/views/monitoring/components/header.vue index 8645bdb..fa4a0b7 100644 --- a/src/views/monitoring/components/header.vue +++ b/src/views/monitoring/components/header.vue @@ -153,11 +153,12 @@ onMounted(() => { mitt.on('waringMessage', (res: any) => { //监听报警信息 - console.log(res.data); - waringData.value.push(res.data) - console.log("waringData--", waringData.value); - waringData.value = uniqueArrayObject(waringData.value, "id") - console.log("waringData--", waringData.value); + console.log("waringMessage--", res.data); + waringData.value = res.data + // waringData.value.push(res.data) + // console.log("waringData--", waringData.value); + // waringData.value = uniqueArrayObject(waringData.value, "id") + // console.log("waringData--", waringData.value); }); function showClick() { @@ -168,7 +169,7 @@ function showClick() { function returnBack() { //返回首页 // emit('returnClick', ''); - if (routerType.value === '1'&&route.path!="/screen") { + if (routerType.value === '1' && route.path != "/screen") { router.push({ path: "/screen", query: { id: sessionStorage.getItem('id') } diff --git a/src/views/monitoring/screen/components/main.vue b/src/views/monitoring/screen/components/main.vue index b9f4e42..b595dc7 100644 --- a/src/views/monitoring/screen/components/main.vue +++ b/src/views/monitoring/screen/components/main.vue @@ -61,6 +61,7 @@ import { VxeFormInstance, VxeFormPropTypes, VxeFormEvents, + VxeTablePropTypes } from 'vxe-table'; import { getTableHeader, getStationInfo, getTableData, editConfig } from '@/api/table/list'; import { TableVo } from '@/api/table/types'; @@ -69,7 +70,6 @@ import mitt from '@/plugins/bus'; import socket from '@/utils/socket'; import useStorage from '@/utils/useStorage' const sessionStorageIns = useStorage('sessionStorage'); -// import { uniqueArrayObject } from '@/utils/index'; const tableStoreCounter = tableStore(); // import type { MenuOption } from 'naive-ui' @@ -81,8 +81,9 @@ const editModal = ref(false); const modalTitle = ref(''); const menuKey = ref(0); const tableColumn = ref([]); -const tableData = ref(); +const tableData = ref([]); const tableRef = ref>(); +const fields = ref(['deviceuuid']) //需要合并的列数据字段 // const waringArrow = ref([]) interface FormDataVO { @@ -117,7 +118,7 @@ const userStorageInfo = sessionStorage.getItem('userInfo') const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); // const loginIp = userInfo.loginIp.split('.').join(''); // const baseApi = "http://172.1.2.106:9000"//websocket链接地址,与项目接口地址一致。 -const baseApi = "http://10.10.10.56:9000"//websocket链接地址,与项目接口地址一致。 +const baseApi = "http://board.heatiot.cn:8001/prod-api"//websocket链接地址,与项目接口地址一致。 // const baseApi = import.meta.env.VITE_APP_BASE_API const apiUrl = baseApi.replace(/https?:/, ''); const wsUrl = `ws:${apiUrl}/websocket/${userInfo.userName}`; //websocket地址 @@ -166,13 +167,14 @@ const headerData = ref(); onMounted(() => { // stationInfo(); - tableHeader(); + // tableHeader(); socket.initialize(wsUrl); //初始化websocket }); mitt.on('menuKey', (res: any) => { //监听左侧菜单点击 menuKey.value = res; + tableHeader(); tableDatas(); }); @@ -194,16 +196,33 @@ mitt.on('treeData', (res: any) => { mitt.on('tableMessage', (res: any) => { //监听表格数据变化 - console.log(res.data); + console.log("tableMessage--", res.data); const $table = tableRef.value; + const tableArray = tableData.value if ($table) { console.log("tableRef--", tableRef.value) + res.data.map((item: any) => { + const index = tableArray.findIndex((obj) => obj.id === item.id); + if (index !== -1) { + tableArray.splice(index, 1, item); + } + }) + console.log("tableData--", tableArray) + $table.loadData(tableArray); // if (res.code === 'datareal') { - const index = tableData.value.findIndex((obj) => obj.id === res.data.id); - if (index !== -1) { - tableData.value.splice(index, 1, res.data); - } - $table.loadData(tableData.value); + // const index = tableData.value.findIndex((obj) => obj.id === res.data.id); + // if (index !== -1) { + // tableData.value.splice(index, 1, res.data); + // } + // res.data.map((item: any) => { + // console.log(item) + // debugger + // const index = tableData.value.findIndex((obj) => obj.id === item.id); + // if (index !== -1) { + // tableData.value.splice(index, 1, res.data); + // } + // }) + // $table.loadData(mergedArray); } // } else if (res.code === 'alertDev') { // waringArrow.value.push(res.data) @@ -240,7 +259,7 @@ function tableHeader() { if (item.formatter != undefined || item.children != undefined) { item.formatter = eval(item.formatter); if (item.children && item.children.length) { - item.children.map((res) => { + item.children.map((res: any) => { res.formatter = eval(res.formatter); }); } @@ -312,10 +331,30 @@ const formatRole: VxeColumnPropTypes.Formatter = ({ cellValue }) => { //表单参数为object时处理 // const iconFont=cellValue.changeProp===-1?'':(cellValue.changeProp===1?'':'') // const cellData = `${cellValue.val}${iconFont}`; - const cellData = `${cellValue.val}${cellValue.canBeControl === '1'?'':''}`; + const cellData = `${cellValue.val}${cellValue.canBeControl === '1' ? '' : ''}`; return cellData; }; +// 通用行合并函数(将相同多列数据合并为一行) +// const mergeRowMethod: VxeTablePropTypes.SpanMethod = ({ row, _rowIndex, column, visibleData }) => { +// const cellValue = row[column.field] +// if (cellValue && fields.value.includes(column.field)) { +// const prevRow = visibleData[_rowIndex - 1] +// let nextRow = visibleData[_rowIndex + 1] +// if (prevRow && prevRow[column.field] === cellValue) { +// return { rowspan: 0, colspan: 0 } +// } else { +// let countRowspan = 1 +// while (nextRow && nextRow[column.field] === cellValue) { +// nextRow = visibleData[++countRowspan + _rowIndex] +// } +// if (countRowspan > 1) { +// return { rowspan: countRowspan, colspan: 1 } +// } +// } +// } +// } + const submitEvent: VxeFormEvents.Submit = () => { //修改数据之后通过websocket传给后端 formLoading.value = true; diff --git a/src/views/monitoring/screen/index.scss b/src/views/monitoring/screen/index.scss index b0298a5..a3ca302 100644 --- a/src/views/monitoring/screen/index.scss +++ b/src/views/monitoring/screen/index.scss @@ -7,8 +7,8 @@ background: url(@/assets/images/screen.png) no-repeat; // background-color: var(--tableBg); background-size: 100% 100%; - background-color: rgba(0, 0, 0, 0.3); - background-blend-mode: multiply; + // background-color: rgba(0, 0, 0, 0.5); + // background-blend-mode: multiply; padding: 0 25px; overflow: hidden; @@ -170,6 +170,7 @@ position: relative; overflow: auto; transition: width 0.28s; + background-color: rgba(2, 8, 46, 0.8); // .menu { // text-align: center; @@ -267,6 +268,7 @@ .main { position: relative; width: 87%; + background-color: rgba(2, 8, 46, 0.8); .headerInfo { border: 1px solid #0D55B0; @@ -498,7 +500,7 @@ border-radius: 5px; color: #fff; padding: 15px; - background: rgba(2, 7, 46, 0.77); + background-color: rgba(2, 8, 46, 0.5); .icon { width: 40%; diff --git a/vite.config.ts b/vite.config.ts index a0ebd46..7d27a61 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -47,7 +47,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { [env.VITE_APP_BASE_API]: { // target: 'http://172.1.2.106:9000/',//本地接口地址 // target: 'http://172.1.2.48:9000/',//本地接口地址 - target: 'http://10.10.10.56:9000/',//线上接口地址 + target: 'http://board.heatiot.cn:8001/prod-api/',//线上接口地址 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')