Browse Source

2023 修改wsurl,增加控制接口

develop
zhousq 1 year ago
parent
commit
33bd4d2de1
  1. 4
      .env.development
  2. 7
      .env.production
  3. 8
      src/api/table/list.ts
  4. 4
      src/types/auto-imports.d.ts
  5. 53
      src/views/monitoring/screen/components/main.vue

4
.env.development

@ -2,5 +2,5 @@
VITE_APP_ENV = 'development' VITE_APP_ENV = 'development'
VITE_APP_TITLE = 'vue-vite-project-admin' VITE_APP_TITLE = 'vue-vite-project-admin'
VITE_APP_PORT = 8089 VITE_APP_PORT = 8089
VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 ##VITE_APP_WS_API = 'ws://localhost:9010' ## websocket地址
VITE_APP_BASE_API = '/dev-api' ## '/dev-api'线上接口 '/mock'本地模拟数据 VITE_APP_BASE_API = 'http://10.10.10.56:9010/' ## '/dev-api'线上接口 '/mock'本地模拟数据

7
.env.production

@ -2,5 +2,8 @@
VITE_APP_ENV = 'production' VITE_APP_ENV = 'production'
VITE_APP_TITLE = 'vue-vite-project-admin' VITE_APP_TITLE = 'vue-vite-project-admin'
VITE_APP_PORT = 8089 VITE_APP_PORT = 8089
VITE_APP_WS_API = 'ws://board.heatiot.cn:8001/prod-api' ## websocket地址 #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_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'本地模拟数据

8
src/api/table/list.ts

@ -66,3 +66,11 @@ export function getTableFooter(): AxiosPromise<[]> {
method: 'get' method: 'get'
}); });
} }
/** 发送控制参数 */
export function sendCtrl(data: any) {
return request({
url: '/bi/opt/device/ctrl',
method: 'post',
data: data
});
}

4
src/types/auto-imports.d.ts

@ -5,6 +5,8 @@ declare global {
const ElForm: typeof import('element-plus/es')['ElForm'] const ElForm: typeof import('element-plus/es')['ElForm']
const ElMessage: typeof import('element-plus/es')['ElMessage'] const ElMessage: typeof import('element-plus/es')['ElMessage']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] 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 asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
const computed: typeof import('vue')['computed'] const computed: typeof import('vue')['computed']
@ -274,6 +276,8 @@ declare module 'vue' {
readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']> readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']>
readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']> readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']> readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
readonly NEllipsis: UnwrapRef<typeof import('naive-ui')['NEllipsis']>
readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']> readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']> readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
readonly computed: UnwrapRef<typeof import('vue')['computed']> readonly computed: UnwrapRef<typeof import('vue')['computed']>

53
src/views/monitoring/screen/components/main.vue

@ -63,7 +63,7 @@ import {
VxeFormEvents, VxeFormEvents,
VxeTablePropTypes VxeTablePropTypes
} from 'vxe-table'; } 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 { TableVo } from '@/api/table/types';
import { tableStore } from '@/store/modules/table'; import { tableStore } from '@/store/modules/table';
import mitt from '@/plugins/bus'; import mitt from '@/plugins/bus';
@ -91,15 +91,17 @@ const tableBorder=ref(true)
// const waringArrow = ref([]) // const waringArrow = ref([])
interface FormDataVO { interface FormDataVO {
url: string; //url: string;
deviceName: string; deviceName: string;
paramCode :string;
value: string; value: string;
} }
const formRef = ref<VxeFormInstance>(); const formRef = ref<VxeFormInstance>();
const formLoading = ref(false); const formLoading = ref(false);
const formData = ref<FormDataVO>({ const formData = ref<FormDataVO>({
url: '', //url: '',
deviceName: '', deviceName: '',
paramCode: '',
value: '', value: '',
}); });
const formRules = ref<VxeFormPropTypes.Rules>({ const formRules = ref<VxeFormPropTypes.Rules>({
@ -120,15 +122,15 @@ const formRules = ref<VxeFormPropTypes.Rules>({
const userStorageInfo = sessionStorage.getItem('userInfo') const userStorageInfo = sessionStorage.getItem('userInfo')
const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo);
const apiUrl = import.meta.env.VITE_APP_WS_API //const apiUrl = import.meta.env.VITE_APP_WS_API
const wsUrl = `${apiUrl}/websocket/${userInfo.userName}`; //websocket //const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket
//const wsUrl = `${apiUrl}${userInfo.userName}`; //websocket
// const loginIp = userInfo.loginIp.split('.').join(''); // const loginIp = userInfo.loginIp.split('.').join('');
// const baseApi = "http://172.1.2.106:9000"//websocket // const baseApi = "http://172.1.2.106:9000"//websocket
// const baseApi = "http://board.heatiot.cn:8001/prod-api"//websocket // const baseApi = "http://board.heatiot.cn:8001/prod-api"//websocket
//const baseApi = import.meta.env.VITE_APP_BASE_API //const baseApi = import.meta.env.VITE_APP_BASE_API
//const apiUrl = baseApi.replace(/https?:/, ''); //const apiUrl = baseApi.replace(/https?:/, '');
// const wsUrl = `ws:${apiUrl}/websocket/${userInfo.userName}`; //websocket const wsUrl = `ws://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket
// const wsData = ref(socket.data);
const emit = defineEmits(['tableHeaderData']); const emit = defineEmits(['tableHeaderData']);
// const listData = ref([ // const listData = ref([
@ -174,7 +176,7 @@ const headerData = ref<HeaderVo[]>();
onMounted(() => { onMounted(() => {
// stationInfo(); // stationInfo();
// tableHeader(); // tableHeader();
socket.initialize(wsUrl); //websocket socket.initialize(wsUrl); //websocket http://
}); });
mitt.on('menuKey', (res: any) => { mitt.on('menuKey', (res: any) => {
@ -322,17 +324,22 @@ function tableDatas() {
const cellDBLClickEvent: VxeTableEvents.CellDblclick<TableVo> = ({ row, column }) => { const cellDBLClickEvent: VxeTableEvents.CellDblclick<TableVo> = ({ row, column }) => {
// //
//edit ty zhousq 2023-10-12 formdata
// ctrlPro.centeruuid UUID cellField.ctrlPro.paramcode cellField.val
//ctrlPro
console.log("cellData--", row, column); console.log("cellData--", row, column);
const cellField = row[column.field]; const cellField = row[column.field];
const data = row.data; //const data = row.data;
cellRow.value = row cellRow.value = row
cellColumn.value = column cellColumn.value = column
cellField.value = cellField cellField.value = cellField
if (cellField.canBeControl === '1') { if (cellField.canBeControl === '1') {
modalTitle.value = column.title; modalTitle.value = column.title;
formData.value.url = data.url; ///formData.value.url = data.url;
formData.value.deviceName = cellField.deviceName; //formData.value.deviceName = cellField.deviceName;
formData.value.value = cellField.val; formData.value.value = cellField.val;
formData.value.deviceName=cellField.ctrlPro.centeruuid
formData.value.paramCode=cellField.ctrlPro.paramcode
editModal.value = true; editModal.value = true;
} }
console.log(row[column.field]); console.log(row[column.field]);
@ -372,15 +379,25 @@ const submitEvent: VxeFormEvents.Submit = () => {
formLoading.value = true; formLoading.value = true;
const $table = tableRef.value; const $table = tableRef.value;
const submitData = { const submitData = {
code: 'W01', //code: 'W01',
data: { //data: {
url: formData.value.url, //url: formData.value.url,
deviceName: formData.value.deviceName, //deviceName: formData.value.deviceName,
value: formData.value.value, //value: formData.value.value,
}, deviceUUID:formData.value.deviceName,
paramCode: formData.value.paramCode,
valueType: "",
value:formData.value.value
//},
}; };
console.log(submitData); 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; formLoading.value = false;
editModal.value = false; editModal.value = false;

Loading…
Cancel
Save