From 2f7c0dae65d2ecfc0baf7c79cb998caedbe653a8 Mon Sep 17 00:00:00 2001 From: fuguobin Date: Mon, 23 Oct 2023 16:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 4 +- src/api/device/types.ts | 2 + src/store/modules/user.ts | 11 +- src/types/auto-imports.d.ts | 2 - src/views/details/index - 副本 (2).vue | 202 ------ src/views/details/index - 副本.vue | 187 ------ src/views/details/index.vue | 226 ++++--- src/views/monitoring/components/header.vue | 574 +++++++++--------- .../monitoring/screen/components/main.vue | 4 +- vite.config.ts | 4 +- 10 files changed, 446 insertions(+), 770 deletions(-) delete mode 100644 src/views/details/index - 副本 (2).vue delete mode 100644 src/views/details/index - 副本.vue diff --git a/.env.production b/.env.production index 69b8686..cd5f73e 100644 --- a/.env.production +++ b/.env.production @@ -5,6 +5,6 @@ VITE_APP_PORT = 8089 #VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 #VITE_APP_BASE_API = 'http://board.heatiot.cn:8001/prod-api/' ## 线上接口 #VITE_APP_WS_API = 'ws://${window.location.host}/ws' ## websocket地址 ws://10.10.10.56:9000/websocket/ -VITE_APP_BASE_API = '/prod-api/' ## 正式环境 -# VITE_APP_BASE_API = '/biprod-api/' ## 测试环境 +# VITE_APP_BASE_API = '/prod-api/' ## 正式环境 +VITE_APP_BASE_API = '/biprod-api/' ## 测试环境 diff --git a/src/api/device/types.ts b/src/api/device/types.ts index 6bfe661..27f432e 100644 --- a/src/api/device/types.ts +++ b/src/api/device/types.ts @@ -74,10 +74,12 @@ export interface parameterVo { version: null; } export interface seriesVo { + index: number; name: string; type: string; smooth: boolean; symbol: string; paramUnit: string; + unit: string; data: Array; } diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index cbe3cd4..3b052ec 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -13,6 +13,7 @@ import { useSessionStorage } from '@vueuse/core'; export const useUserStore = defineStore('user', () => { // state const token = useSessionStorage('userToken', ''); + const userInfo = useSessionStorage('userInfo', {}); const nickname = ref(''); const avatar = ref(''); const roles = ref>([]); // 用户角色编码集合 → 判断路由权限 @@ -27,7 +28,7 @@ export const useUserStore = defineStore('user', () => { function login(loginData: LoginData) { return new Promise((resolve, reject) => { loginApi(loginData) - .then((response:any) => { + .then((response: any) => { const userToken = response.token; token.value = 'Bearer ' + userToken; // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx resolve(); @@ -42,19 +43,20 @@ export const useUserStore = defineStore('user', () => { function getInfo() { return new Promise((resolve, reject) => { getUserInfo() - .then((data:any) => { + .then((data: any) => { if (!data) { return reject('Verification failed, please Login again.'); } if (!data.roles || data.roles.length <= 0) { reject('getUserInfo: roles must be a non-null array!'); } - const user=data.user + const user = data.user; nickname.value = user.nickName; avatar.value = user.avatar; roles.value = data.roles; perms.value = data.permissions; - useSessionStorage('userInfo', user); + userInfo.value = user; + // useSessionStorage('userInfo', user); resolve(data); }) .catch(error => { @@ -81,6 +83,7 @@ export const useUserStore = defineStore('user', () => { // 重置 function resetToken() { token.value = ''; + userInfo.value = {}; nickname.value = ''; avatar.value = ''; roles.value = []; diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index 5742656..67e581d 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -2,7 +2,6 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] - const ElForm: typeof import('element-plus/es')['ElForm'] const ElMessage: typeof import('element-plus/es')['ElMessage'] const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] const ElNotification: typeof import('element-plus/es')['ElNotification'] @@ -273,7 +272,6 @@ import { UnwrapRef } from 'vue' declare module 'vue' { interface ComponentCustomProperties { readonly EffectScope: UnwrapRef - readonly ElForm: UnwrapRef readonly ElMessage: UnwrapRef readonly ElMessageBox: UnwrapRef readonly ElNotification: UnwrapRef diff --git a/src/views/details/index - 副本 (2).vue b/src/views/details/index - 副本 (2).vue deleted file mode 100644 index 30ed388..0000000 --- a/src/views/details/index - 副本 (2).vue +++ /dev/null @@ -1,202 +0,0 @@ - - - diff --git a/src/views/details/index - 副本.vue b/src/views/details/index - 副本.vue deleted file mode 100644 index d513ea8..0000000 --- a/src/views/details/index - 副本.vue +++ /dev/null @@ -1,187 +0,0 @@ - - - diff --git a/src/views/details/index.vue b/src/views/details/index.vue index ca759af..eb73d74 100644 --- a/src/views/details/index.vue +++ b/src/views/details/index.vue @@ -793,30 +793,30 @@ const options2 = { color: colors[1] } } - }, - { - type: 'value', - name: '累计热量(JG)', - position: 'right', - alignTicks: true, - offset: 100, - scale: true, //自适应 - minInterval: 1, //最小间距 - nameTextStyle: { - fontSize: 12, - padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 - }, - axisTick: { - // 轴刻度 - show: false - }, - axisLine: { - show: true, - lineStyle: { - color: colors[2] - } - } } + // { + // type: 'value', + // name: '累计热量(JG)', + // position: 'right', + // alignTicks: true, + // offset: 100, + // scale: true, //自适应 + // minInterval: 1, //最小间距 + // nameTextStyle: { + // fontSize: 12, + // padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 + // }, + // axisTick: { + // // 轴刻度 + // show: false + // }, + // axisLine: { + // show: true, + // lineStyle: { + // color: colors[2] + // } + // } + // } ], // yAxis: { // type: 'value', @@ -982,9 +982,9 @@ const options2 = { type: 'line', smooth: true, symbol: 'none', - yAxisIndex: 2, + yAxisIndex: 1, data: [ - ['2023-10-01 08:00:00', Math.round(Math.random() * 500)], + ['2023-10-01 08:00:00', Math.round(Math.random() * 600)], ['2023-10-01 09:00:00', Math.round(Math.random() * 500)], ['2023-10-01 10:00:00', Math.round(Math.random() * 500)], ['2023-10-01 11:00:00', Math.round(Math.random() * 500)], @@ -1097,76 +1097,114 @@ function init(data: any) { options.series = []; if (data.mainInfos.length === 0) { options.title.text = '暂无数据'; - } else { - options.title.text = data.additionalInfo.name; - options.title.x = 'top'; - options.title.y = 'left'; - if (multipleLimit.value === 0 && parameterLimit.value === 1) { - console.log('单设备多参数'); - data.mainInfos.map((item: seriesVo, index: number) => { - const offsetData = index === 0 ? 0 : index === 1 ? 0 : (index - 1) * 100; - console.log('offsetData--', offsetData); - options.legend.data.push(item.name); - options.yAxis.push({ - type: 'value', - name: `${item.name}(${item.paramUnit})`, - position: `${index === 0 ? 'left' : 'right'}`, - alignTicks: true, - offset: offsetData, - scale: true, //自适应 - // minInterval: 1, //最小间距 - nameTextStyle: { - fontSize: 12, - padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 - }, - axisTick: { - // 轴刻度 - show: false - }, - axisLine: { - show: true, - lineStyle: { - color: colors[index] - } - } - }); - options.series.push({ - name: item.name, - type: 'line', - smooth: true, - symbol: 'none', - yAxisIndex: index, - data: item.data - }); - }); - } else { - console.log('多设备单参数'); - options.yAxis.push({ - type: 'value', - scale: true, //自适应 - minInterval: 1, //最小间距 - name: `${data.additionalInfo.name}(${data.additionalInfo.unit})`, - nameTextStyle: { - fontSize: 12, - padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 - }, - axisTick: { - // 轴刻度 - show: false - } - }); - data.mainInfos.map((item: seriesVo) => { - options.legend.data.push(item.name); - options.series.push({ - name: item.name, - type: 'line', - smooth: true, - symbol: 'none', - data: item.data - }); - }); - } + return; } + options.title.text = data.additionalInfo.name; + options.title.x = 'top'; + options.title.y = 'left'; + data.units.map((item: seriesVo, index: number) => { + const offsetData = index === 0 ? 0 : index === 1 ? 0 : (index - 1) * 100; + console.log('offsetData--', offsetData); + options.yAxis.push({ + type: 'value', + name: `${item.name}(${item.unit})`, + position: `${index === 0 ? 'left' : 'right'}`, + alignTicks: true, + offset: offsetData, + scale: true, //自适应 + // minInterval: 1, //最小间距 + nameTextStyle: { + fontSize: 12, + padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 + }, + axisTick: { + // 轴刻度 + show: false + }, + axisLine: { + show: true, + lineStyle: { + color: colors[index] + } + } + }); + }); + data.mainInfos.map((item: seriesVo, index: number) => { + options.legend.data.push(item.name); + options.series.push({ + name: item.name, + type: 'line', + smooth: true, + symbol: 'none', + yAxisIndex: item.index, + data: item.data + }); + }); + // if (multipleLimit.value === 0 && parameterLimit.value === 1) { + // console.log('单设备多参数'); + // data.mainInfos.map((item: seriesVo, index: number) => { + // const offsetData = index === 0 ? 0 : index === 1 ? 0 : (index - 1) * 100; + // console.log('offsetData--', offsetData); + // options.legend.data.push(item.name); + // options.yAxis.push({ + // type: 'value', + // name: `${item.name}(${item.paramUnit})`, + // position: `${index === 0 ? 'left' : 'right'}`, + // alignTicks: true, + // offset: offsetData, + // scale: true, //自适应 + // // minInterval: 1, //最小间距 + // nameTextStyle: { + // fontSize: 12, + // padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 + // }, + // axisTick: { + // // 轴刻度 + // show: false + // }, + // axisLine: { + // show: true, + // lineStyle: { + // color: colors[index] + // } + // } + // }); + // options.series.push({ + // name: item.name, + // type: 'line', + // smooth: true, + // symbol: 'none', + // yAxisIndex: index, + // data: item.data + // }); + // }); + // } else { + // console.log('多设备单参数'); + // options.yAxis.push({ + // type: 'value', + // scale: true, //自适应 + // minInterval: 1, //最小间距 + // name: `${data.additionalInfo.name}(${data.additionalInfo.unit})`, + // nameTextStyle: { + // fontSize: 12, + // padding: [0, 0, 0, 0] //name文字位置 对应 上右下左 + // }, + // axisTick: { + // // 轴刻度 + // show: false + // } + // }); + // data.mainInfos.map((item: seriesVo) => { + // options.legend.data.push(item.name); + // options.series.push({ + // name: item.name, + // type: 'line', + // smooth: true, + // symbol: 'none', + // data: item.data + // }); + // }); + // } const chart = echarts.init(stackedRef.value); chart.clear(); chart.resize(); diff --git a/src/views/monitoring/components/header.vue b/src/views/monitoring/components/header.vue index cc32ccf..701d1c2 100644 --- a/src/views/monitoring/components/header.vue +++ b/src/views/monitoring/components/header.vue @@ -1,200 +1,222 @@ \ No newline at end of file + diff --git a/src/views/monitoring/screen/components/main.vue b/src/views/monitoring/screen/components/main.vue index 87e14f2..3cce580 100644 --- a/src/views/monitoring/screen/components/main.vue +++ b/src/views/monitoring/screen/components/main.vue @@ -161,8 +161,8 @@ const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); // 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://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket地址 -const wsUrl = `ws://10.10.10.56:9010/websocket/${userInfo.userName}`; //websocket地址 +const wsUrl = `ws://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket地址 +// const wsUrl = `ws://172.1.2.158:9010/websocket/${userInfo.userName}`; //websocket地址 const emit = defineEmits(['tableHeaderData']); // const listData = ref([ diff --git a/vite.config.ts b/vite.config.ts index c6d658d..66dd95b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -46,8 +46,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { proxy: { [env.VITE_APP_BASE_API]: { // target: 'http://172.1.2.196:9010/', //本地接口地址 - target: 'http://172.1.2.139:9010/', //本地接口地址 - // target: 'http://10.10.10.56:9010/', //线上测试接口地址 + // target: 'http://172.1.2.158:9010/', //本地接口地址 + target: 'http://10.10.10.56:9010/', //线上测试接口地址 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') }