From 51fe5a9581f8d94070ad8d47c4184e3a853c0447 Mon Sep 17 00:00:00 2001 From: zhousq Date: Thu, 12 Oct 2023 09:24:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?2023-10-12=20=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9B=91=E6=8E=A7=E5=A4=A7=E5=B1=8F=E4=B8=AD=E7=9A=84?= =?UTF-8?q?wsurl=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8F=8D=E6=8E=A7=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E7=9A=84formdata=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=8F=8D?= =?UTF-8?q?=E6=8E=A7=E7=9A=84=E7=BB=9F=E4=B8=80=20http=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=85=BC=E5=AE=B9IOserer=EF=BC=8CThinsBoard=E7=AD=89=EF=BC=9B?= =?UTF-8?q?=E5=9C=A8=E5=8D=95=E5=85=83=E6=A0=BC=E6=95=B0=E6=8D=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8E=A7=E5=88=B6=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 7 ++- package.json | 1 + src/api/table/list.ts | 8 +++ src/types/auto-imports.d.ts | 4 ++ .../monitoring/screen/components/main.vue | 57 ++++++++++++------- 6 files changed, 57 insertions(+), 24 deletions(-) diff --git a/.env.development b/.env.development index 0aabab7..eb98de9 100644 --- a/.env.development +++ b/.env.development @@ -2,5 +2,5 @@ VITE_APP_ENV = 'development' VITE_APP_TITLE = 'vue-vite-project-admin' VITE_APP_PORT = 8089 -VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 -VITE_APP_BASE_API = '/dev-api' ## '/dev-api'线上接口 '/mock'本地模拟数据 +##VITE_APP_WS_API = 'ws://localhost:9010' ## websocket地址 +VITE_APP_BASE_API = 'http://10.10.10.56:9010/' ## '/dev-api'线上接口 '/mock'本地模拟数据 diff --git a/.env.production b/.env.production index 23cf18a..73a264b 100644 --- a/.env.production +++ b/.env.production @@ -2,5 +2,8 @@ VITE_APP_ENV = 'production' VITE_APP_TITLE = 'vue-vite-project-admin' 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://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/' ## '/dev-api'线上接口 '/mock'本地模拟数据 + diff --git a/package.json b/package.json index ea000d1..fae0ac3 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "path-browserify": "^1.0.1", "path-to-regexp": "^6.2.0", "pinia": "^2.0.12", + "pnpm": "^8.9.0", "screenfull": "^6.0.2", "swiper": "^10.2.0", "terser": "^5.17.6", diff --git a/src/api/table/list.ts b/src/api/table/list.ts index 5c82801..d73b037 100644 --- a/src/api/table/list.ts +++ b/src/api/table/list.ts @@ -66,3 +66,11 @@ export function getTableFooter(): AxiosPromise<[]> { method: 'get' }); } +/** 发送控制参数 */ +export function sendCtrl(data: any) { + return request({ + url: '/bi/opt/device/ctrl', + method: 'post', + data: data + }); +} \ No newline at end of file diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index e5c7bdb..5742656 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -5,6 +5,8 @@ declare global { 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'] + const NEllipsis: typeof import('naive-ui')['NEllipsis'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const computed: typeof import('vue')['computed'] @@ -274,6 +276,8 @@ declare module 'vue' { readonly ElForm: UnwrapRef readonly ElMessage: UnwrapRef readonly ElMessageBox: UnwrapRef + readonly ElNotification: UnwrapRef + readonly NEllipsis: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef diff --git a/src/views/monitoring/screen/components/main.vue b/src/views/monitoring/screen/components/main.vue index 0b9b890..f9ac497 100644 --- a/src/views/monitoring/screen/components/main.vue +++ b/src/views/monitoring/screen/components/main.vue @@ -63,7 +63,7 @@ import { VxeFormEvents, VxeTablePropTypes } from 'vxe-table'; -import { getTableHeader, getStationInfo, getTableData, editConfig } from '@/api/table/list'; +import { getTableHeader, getStationInfo, getTableData, editConfig,sendCtrl } from '@/api/table/list'; import { TableVo } from '@/api/table/types'; import { tableStore } from '@/store/modules/table'; import mitt from '@/plugins/bus'; @@ -91,15 +91,17 @@ const tableBorder=ref(true) // const waringArrow = ref([]) interface FormDataVO { - url: string; + //url: string; deviceName: string; + paramCode :string; value: string; } const formRef = ref(); const formLoading = ref(false); const formData = ref({ - url: '', + //url: '', deviceName: '', + paramCode: '', value: '', }); const formRules = ref({ @@ -120,15 +122,15 @@ const formRules = ref({ const userStorageInfo = sessionStorage.getItem('userInfo') const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); -const apiUrl = import.meta.env.VITE_APP_WS_API -const wsUrl = `${apiUrl}/websocket/${userInfo.userName}`; //websocket地址 +//const apiUrl = import.meta.env.VITE_APP_WS_API +//const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket地址 +//const wsUrl = `${apiUrl}${userInfo.userName}`; //websocket地址 // const loginIp = userInfo.loginIp.split('.').join(''); // const baseApi = "http://172.1.2.106: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地址 -// const wsData = ref(socket.data); +//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 emit = defineEmits(['tableHeaderData']); // const listData = ref([ @@ -174,7 +176,7 @@ const headerData = ref(); onMounted(() => { // stationInfo(); // tableHeader(); - socket.initialize(wsUrl); //初始化websocket + socket.initialize(wsUrl); //初始化websocket http:// }); mitt.on('menuKey', (res: any) => { @@ -322,17 +324,22 @@ function tableDatas() { const cellDBLClickEvent: VxeTableEvents.CellDblclick = ({ row, column }) => { //双击单元格 + //edit ty zhousq 2023-10-12 修改控制方式为接口方式,修改formdata提交的属性值 + // ctrlPro.centeruuid 设备UUID cellField.ctrlPro.paramcode 设备参数编码 cellField.val 设备值 + //ctrlPro 为新增的单元格属性,控制参数回传 console.log("cellData--", row, column); const cellField = row[column.field]; - const data = row.data; + //const data = row.data; cellRow.value = row cellColumn.value = column cellField.value = cellField if (cellField.canBeControl === '1') { modalTitle.value = column.title; - formData.value.url = data.url; - formData.value.deviceName = cellField.deviceName; + ///formData.value.url = data.url; + //formData.value.deviceName = cellField.deviceName; formData.value.value = cellField.val; + formData.value.deviceName=cellField.ctrlPro.centeruuid + formData.value.paramCode=cellField.ctrlPro.paramcode editModal.value = true; } console.log(row[column.field]); @@ -372,15 +379,25 @@ const submitEvent: VxeFormEvents.Submit = () => { formLoading.value = true; const $table = tableRef.value; const submitData = { - code: 'W01', - data: { - url: formData.value.url, - deviceName: formData.value.deviceName, - value: formData.value.value, - }, + //code: 'W01', + //data: { + //url: formData.value.url, + //deviceName: formData.value.deviceName, + //value: formData.value.value, + deviceUUID:formData.value.deviceName, + paramCode: formData.value.paramCode, + valueType: "", + value:formData.value.value + //}, }; console.log(submitData); - socket.onSend(submitData); + //Add by zhousq 2023-10-12 控制接口调用 post 方法 + sendCtrl(submitData).then((res: any) => { + if (res.code === 200) { + console.log(res.data); + } + }); + //socket.onSend(submitData); formLoading.value = false; editModal.value = false; From 46b423a2e49b5a875c88e531adfcbf29bf9f3373 Mon Sep 17 00:00:00 2001 From: zhousq Date: Thu, 12 Oct 2023 09:39:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=92=8Cwsurl=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 7 +-- package.json | 1 - src/api/table/list.ts | 8 --- src/types/auto-imports.d.ts | 4 -- .../monitoring/screen/components/main.vue | 57 +++++++------------ 6 files changed, 24 insertions(+), 57 deletions(-) diff --git a/.env.development b/.env.development index eb98de9..0aabab7 100644 --- a/.env.development +++ b/.env.development @@ -2,5 +2,5 @@ VITE_APP_ENV = 'development' VITE_APP_TITLE = 'vue-vite-project-admin' VITE_APP_PORT = 8089 -##VITE_APP_WS_API = 'ws://localhost:9010' ## websocket地址 -VITE_APP_BASE_API = 'http://10.10.10.56:9010/' ## '/dev-api'线上接口 '/mock'本地模拟数据 +VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 +VITE_APP_BASE_API = '/dev-api' ## '/dev-api'线上接口 '/mock'本地模拟数据 diff --git a/.env.production b/.env.production index 73a264b..23cf18a 100644 --- a/.env.production +++ b/.env.production @@ -2,8 +2,5 @@ VITE_APP_ENV = 'production' VITE_APP_TITLE = 'vue-vite-project-admin' 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/' ## '/dev-api'线上接口 '/mock'本地模拟数据 - +VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 +VITE_APP_BASE_API = 'http://board.heatiot.cn:8001/prod-api/' ## 线上接口 diff --git a/package.json b/package.json index fae0ac3..ea000d1 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "path-browserify": "^1.0.1", "path-to-regexp": "^6.2.0", "pinia": "^2.0.12", - "pnpm": "^8.9.0", "screenfull": "^6.0.2", "swiper": "^10.2.0", "terser": "^5.17.6", diff --git a/src/api/table/list.ts b/src/api/table/list.ts index d73b037..5c82801 100644 --- a/src/api/table/list.ts +++ b/src/api/table/list.ts @@ -66,11 +66,3 @@ export function getTableFooter(): AxiosPromise<[]> { method: 'get' }); } -/** 发送控制参数 */ -export function sendCtrl(data: any) { - return request({ - url: '/bi/opt/device/ctrl', - method: 'post', - data: data - }); -} \ No newline at end of file diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index 5742656..e5c7bdb 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -5,8 +5,6 @@ declare global { 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'] - const NEllipsis: typeof import('naive-ui')['NEllipsis'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const computed: typeof import('vue')['computed'] @@ -276,8 +274,6 @@ declare module 'vue' { readonly ElForm: UnwrapRef readonly ElMessage: UnwrapRef readonly ElMessageBox: UnwrapRef - readonly ElNotification: UnwrapRef - readonly NEllipsis: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef diff --git a/src/views/monitoring/screen/components/main.vue b/src/views/monitoring/screen/components/main.vue index f9ac497..0b9b890 100644 --- a/src/views/monitoring/screen/components/main.vue +++ b/src/views/monitoring/screen/components/main.vue @@ -63,7 +63,7 @@ import { VxeFormEvents, VxeTablePropTypes } from 'vxe-table'; -import { getTableHeader, getStationInfo, getTableData, editConfig,sendCtrl } from '@/api/table/list'; +import { getTableHeader, getStationInfo, getTableData, editConfig } from '@/api/table/list'; import { TableVo } from '@/api/table/types'; import { tableStore } from '@/store/modules/table'; import mitt from '@/plugins/bus'; @@ -91,17 +91,15 @@ const tableBorder=ref(true) // const waringArrow = ref([]) interface FormDataVO { - //url: string; + url: string; deviceName: string; - paramCode :string; value: string; } const formRef = ref(); const formLoading = ref(false); const formData = ref({ - //url: '', + url: '', deviceName: '', - paramCode: '', value: '', }); const formRules = ref({ @@ -122,15 +120,15 @@ const formRules = ref({ const userStorageInfo = sessionStorage.getItem('userInfo') const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); -//const apiUrl = import.meta.env.VITE_APP_WS_API -//const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket地址 -//const wsUrl = `${apiUrl}${userInfo.userName}`; //websocket地址 +const apiUrl = import.meta.env.VITE_APP_WS_API +const wsUrl = `${apiUrl}/websocket/${userInfo.userName}`; //websocket地址 // const loginIp = userInfo.loginIp.split('.').join(''); // const baseApi = "http://172.1.2.106: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://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket地址 +// const baseApi = import.meta.env.VITE_APP_BASE_API +// const apiUrl = baseApi.replace(/https?:/, ''); +// const wsUrl = `ws:${apiUrl}/websocket/${userInfo.userName}`; //websocket地址 +// const wsData = ref(socket.data); const emit = defineEmits(['tableHeaderData']); // const listData = ref([ @@ -176,7 +174,7 @@ const headerData = ref(); onMounted(() => { // stationInfo(); // tableHeader(); - socket.initialize(wsUrl); //初始化websocket http:// + socket.initialize(wsUrl); //初始化websocket }); mitt.on('menuKey', (res: any) => { @@ -324,22 +322,17 @@ function tableDatas() { const cellDBLClickEvent: VxeTableEvents.CellDblclick = ({ row, column }) => { //双击单元格 - //edit ty zhousq 2023-10-12 修改控制方式为接口方式,修改formdata提交的属性值 - // ctrlPro.centeruuid 设备UUID cellField.ctrlPro.paramcode 设备参数编码 cellField.val 设备值 - //ctrlPro 为新增的单元格属性,控制参数回传 console.log("cellData--", row, column); const cellField = row[column.field]; - //const data = row.data; + const data = row.data; cellRow.value = row cellColumn.value = column cellField.value = cellField if (cellField.canBeControl === '1') { modalTitle.value = column.title; - ///formData.value.url = data.url; - //formData.value.deviceName = cellField.deviceName; + formData.value.url = data.url; + formData.value.deviceName = cellField.deviceName; formData.value.value = cellField.val; - formData.value.deviceName=cellField.ctrlPro.centeruuid - formData.value.paramCode=cellField.ctrlPro.paramcode editModal.value = true; } console.log(row[column.field]); @@ -379,25 +372,15 @@ const submitEvent: VxeFormEvents.Submit = () => { formLoading.value = true; const $table = tableRef.value; const submitData = { - //code: 'W01', - //data: { - //url: formData.value.url, - //deviceName: formData.value.deviceName, - //value: formData.value.value, - deviceUUID:formData.value.deviceName, - paramCode: formData.value.paramCode, - valueType: "", - value:formData.value.value - //}, + code: 'W01', + data: { + url: formData.value.url, + deviceName: formData.value.deviceName, + value: formData.value.value, + }, }; console.log(submitData); - //Add by zhousq 2023-10-12 控制接口调用 post 方法 - sendCtrl(submitData).then((res: any) => { - if (res.code === 200) { - console.log(res.data); - } - }); - //socket.onSend(submitData); + socket.onSend(submitData); formLoading.value = false; editModal.value = false; From 33bd4d2de1857b00442200dcbd172240bc959dd0 Mon Sep 17 00:00:00 2001 From: zhousq Date: Thu, 12 Oct 2023 13:53:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?2023=20=E4=BF=AE=E6=94=B9wsurl=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A7=E5=88=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 7 ++- src/api/table/list.ts | 8 +++ src/types/auto-imports.d.ts | 4 ++ .../monitoring/screen/components/main.vue | 57 ++++++++++++------- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/.env.development b/.env.development index 0aabab7..eb98de9 100644 --- a/.env.development +++ b/.env.development @@ -2,5 +2,5 @@ VITE_APP_ENV = 'development' VITE_APP_TITLE = 'vue-vite-project-admin' VITE_APP_PORT = 8089 -VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 -VITE_APP_BASE_API = '/dev-api' ## '/dev-api'线上接口 '/mock'本地模拟数据 +##VITE_APP_WS_API = 'ws://localhost:9010' ## websocket地址 +VITE_APP_BASE_API = 'http://10.10.10.56:9010/' ## '/dev-api'线上接口 '/mock'本地模拟数据 diff --git a/.env.production b/.env.production index 23cf18a..73a264b 100644 --- a/.env.production +++ b/.env.production @@ -2,5 +2,8 @@ VITE_APP_ENV = 'production' VITE_APP_TITLE = 'vue-vite-project-admin' 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://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/' ## '/dev-api'线上接口 '/mock'本地模拟数据 + diff --git a/src/api/table/list.ts b/src/api/table/list.ts index 5c82801..d73b037 100644 --- a/src/api/table/list.ts +++ b/src/api/table/list.ts @@ -66,3 +66,11 @@ export function getTableFooter(): AxiosPromise<[]> { method: 'get' }); } +/** 发送控制参数 */ +export function sendCtrl(data: any) { + return request({ + url: '/bi/opt/device/ctrl', + method: 'post', + data: data + }); +} \ No newline at end of file diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts index e5c7bdb..5742656 100644 --- a/src/types/auto-imports.d.ts +++ b/src/types/auto-imports.d.ts @@ -5,6 +5,8 @@ declare global { 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'] + const NEllipsis: typeof import('naive-ui')['NEllipsis'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const computed: typeof import('vue')['computed'] @@ -274,6 +276,8 @@ declare module 'vue' { readonly ElForm: UnwrapRef readonly ElMessage: UnwrapRef readonly ElMessageBox: UnwrapRef + readonly ElNotification: UnwrapRef + readonly NEllipsis: UnwrapRef readonly asyncComputed: UnwrapRef readonly autoResetRef: UnwrapRef readonly computed: UnwrapRef diff --git a/src/views/monitoring/screen/components/main.vue b/src/views/monitoring/screen/components/main.vue index 0b9b890..f9ac497 100644 --- a/src/views/monitoring/screen/components/main.vue +++ b/src/views/monitoring/screen/components/main.vue @@ -63,7 +63,7 @@ import { VxeFormEvents, VxeTablePropTypes } from 'vxe-table'; -import { getTableHeader, getStationInfo, getTableData, editConfig } from '@/api/table/list'; +import { getTableHeader, getStationInfo, getTableData, editConfig,sendCtrl } from '@/api/table/list'; import { TableVo } from '@/api/table/types'; import { tableStore } from '@/store/modules/table'; import mitt from '@/plugins/bus'; @@ -91,15 +91,17 @@ const tableBorder=ref(true) // const waringArrow = ref([]) interface FormDataVO { - url: string; + //url: string; deviceName: string; + paramCode :string; value: string; } const formRef = ref(); const formLoading = ref(false); const formData = ref({ - url: '', + //url: '', deviceName: '', + paramCode: '', value: '', }); const formRules = ref({ @@ -120,15 +122,15 @@ const formRules = ref({ const userStorageInfo = sessionStorage.getItem('userInfo') const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); -const apiUrl = import.meta.env.VITE_APP_WS_API -const wsUrl = `${apiUrl}/websocket/${userInfo.userName}`; //websocket地址 +//const apiUrl = import.meta.env.VITE_APP_WS_API +//const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket地址 +//const wsUrl = `${apiUrl}${userInfo.userName}`; //websocket地址 // const loginIp = userInfo.loginIp.split('.').join(''); // const baseApi = "http://172.1.2.106: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地址 -// const wsData = ref(socket.data); +//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 emit = defineEmits(['tableHeaderData']); // const listData = ref([ @@ -174,7 +176,7 @@ const headerData = ref(); onMounted(() => { // stationInfo(); // tableHeader(); - socket.initialize(wsUrl); //初始化websocket + socket.initialize(wsUrl); //初始化websocket http:// }); mitt.on('menuKey', (res: any) => { @@ -322,17 +324,22 @@ function tableDatas() { const cellDBLClickEvent: VxeTableEvents.CellDblclick = ({ row, column }) => { //双击单元格 + //edit ty zhousq 2023-10-12 修改控制方式为接口方式,修改formdata提交的属性值 + // ctrlPro.centeruuid 设备UUID cellField.ctrlPro.paramcode 设备参数编码 cellField.val 设备值 + //ctrlPro 为新增的单元格属性,控制参数回传 console.log("cellData--", row, column); const cellField = row[column.field]; - const data = row.data; + //const data = row.data; cellRow.value = row cellColumn.value = column cellField.value = cellField if (cellField.canBeControl === '1') { modalTitle.value = column.title; - formData.value.url = data.url; - formData.value.deviceName = cellField.deviceName; + ///formData.value.url = data.url; + //formData.value.deviceName = cellField.deviceName; formData.value.value = cellField.val; + formData.value.deviceName=cellField.ctrlPro.centeruuid + formData.value.paramCode=cellField.ctrlPro.paramcode editModal.value = true; } console.log(row[column.field]); @@ -372,15 +379,25 @@ const submitEvent: VxeFormEvents.Submit = () => { formLoading.value = true; const $table = tableRef.value; const submitData = { - code: 'W01', - data: { - url: formData.value.url, - deviceName: formData.value.deviceName, - value: formData.value.value, - }, + //code: 'W01', + //data: { + //url: formData.value.url, + //deviceName: formData.value.deviceName, + //value: formData.value.value, + deviceUUID:formData.value.deviceName, + paramCode: formData.value.paramCode, + valueType: "", + value:formData.value.value + //}, }; console.log(submitData); - socket.onSend(submitData); + //Add by zhousq 2023-10-12 控制接口调用 post 方法 + sendCtrl(submitData).then((res: any) => { + if (res.code === 200) { + console.log(res.data); + } + }); + //socket.onSend(submitData); formLoading.value = false; editModal.value = false;