diff --git a/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue b/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue index efaa82d..2d0a99c 100644 --- a/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue +++ b/apps/web-antd/src/views/device/device/detail/components/running/EventsPanel.vue @@ -94,7 +94,7 @@ const loadList = async () => { const params: any = { deviceKey: props.deviceInfo.deviceKey, productKey: props.deviceInfo.productObj.productKey, - fields: selectedEventId.value || undefined, + // fields: selectedEventId.value || undefined, orderType: 2, current: pagination.value.current, size: pagination.value.pageSize, diff --git a/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue b/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue index 02e02b8..92dfc94 100644 --- a/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue +++ b/apps/web-antd/src/views/device/device/detail/components/running/RealtimePanel.vue @@ -121,12 +121,20 @@ const unsubscribeRealtimeData = () => { }; const initRuntime = () => { - const properties = (props.metadata?.properties || []).map((prop: any) => ({ + const list = + props.metadata?.properties.filter((item) => item.show === true) || []; + const properties = list.map((prop: any) => ({ ...prop, value: null, timestamp: dayjs().format('YYYY-MM-DD HH:mm:ss'), })); runtimeProperties.value = properties; + // const properties = (props.metadata?.properties || []).map((prop: any) => ({ + // ...prop, + // value: null, + // timestamp: dayjs().format('YYYY-MM-DD HH:mm:ss'), + // })); + // runtimeProperties.value = properties; }; // 属性分组选项 diff --git a/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue index 78742a2..3827d23 100644 --- a/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue +++ b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue @@ -58,6 +58,8 @@ const selectedRowKeys = ref([]); // 表单数据 const formData = ref({}); +const submitFunctionParameters = ref({}); + // 预检查弹窗相关 const preCheckVisible = ref(false); const preCheckType = ref(''); @@ -307,7 +309,7 @@ const checkPreCheck = () => { }; // 执行实际提交 -const executeSubmit = async (checkValue?: string) => { +const submitCheckFormatParams = async () => { try { let parameters = {}; @@ -417,13 +419,68 @@ const executeSubmit = async (checkValue?: string) => { return; } } + submitFunctionParameters.value = parameters; + if (checkPreCheck()) { + return; // 显示预检查弹窗,等待用户输入 + } + submitFunction(null); + + // // 构造提交数据格式 + // const submitData: any = { + // productKey: props.deviceInfo.productObj.productKey, + // deviceKey: props.deviceInfo.deviceKey, + // funcId: selectedFunctionId.value, + // params: parameters, + // }; + + // // 如果有预检查值,添加到提交数据中 + // if (checkValue) { + // submitData.checkValue = checkValue; + // } + + // // 更新参数框内容 + // parameterContent.value = JSON.stringify(submitData, null, 2); + + // await deviceOperateFunc(submitData); + + // // 模拟API调用 + // console.log('执行功能:', submitData); + // console.log('选中的参数keys:', selectedRowKeys.value); + // console.log('提交的参数对象:', parameters); + + // // 模拟返回结果 + // const mockResult = { + // success: true, + // message: '执行成功', + // data: { + // deviceKey: props.deviceInfo.deviceKey, + // funcId: selectedFunctionId.value, + // executeTime: new Date().toISOString(), + // result: 'OK', + // }, + // }; + + // submitResult.value = JSON.stringify(mockResult, null, 2); + // message.success('执行成功'); + } catch (error) { + if (error.errorFields[0].errors[0]) { + message.error(error.errorFields[0].errors[0]); + } else { + message.error('执行失败'); + } + console.error('执行错误:', error); + } +}; + +const submitFunction = async (checkValue: any) => { + try { // 构造提交数据格式 const submitData: any = { productKey: props.deviceInfo.productObj.productKey, deviceKey: props.deviceInfo.deviceKey, funcId: selectedFunctionId.value, - params: parameters, + params: submitFunctionParameters.value, }; // 如果有预检查值,添加到提交数据中 @@ -456,24 +513,14 @@ const executeSubmit = async (checkValue?: string) => { // submitResult.value = JSON.stringify(mockResult, null, 2); // message.success('执行成功'); } catch (error) { - if (error.errorFields[0].errors[0]) { - message.error(error.errorFields[0].errors[0]); - } else { - message.error('执行失败'); - } - console.error('执行错误:', error); + console.error('提交功能时出错:', error); } }; // 主要的提交函数 const handleSubmit = async () => { - // 检查是否需要预检查 - if (checkPreCheck()) { - return; // 显示预检查弹窗,等待用户输入 - } - // 直接执行提交 - await executeSubmit(); + await submitCheckFormatParams(); }; // 预检查确认 @@ -482,7 +529,6 @@ const handlePreCheckConfirm = async () => { await preCheckFormRef.value.validate(); let checkValue = ''; - // 根据预检查类型构造checkValue switch (preCheckType.value) { case 'staticPassword': { @@ -504,7 +550,7 @@ const handlePreCheckConfirm = async () => { preCheckVisible.value = false; // 执行实际提交 - await executeSubmit(checkValue); + await submitFunction(checkValue); } catch (error) { console.error('预检查验证失败:', error); } diff --git a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue index 7c03aa7..42fba53 100644 --- a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue +++ b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue @@ -20,7 +20,7 @@ import TSLViewer from './metadata/TSLViewer.vue'; const props = defineProps<{ productId: string; - productInfo: ProductVO; + productInfo: any; }>(); const emit = defineEmits<{ @@ -102,7 +102,6 @@ const handleTSLClose = () => { // 加载物模型数据 const loadMetadata = async () => { - console.log('加载物模型数据'); const defaultMetadata = { properties: [], functions: [], @@ -113,96 +112,6 @@ const loadMetadata = async () => { currentMetadata.value = props.productInfo.metadata ? JSON.parse(props.productInfo.metadata) : JSON.parse(JSON.stringify(defaultMetadata)); - // 这里调用API加载物模型数据 - // const res = await getProductMetadata(props.productId); - // currentMetadata.value = res.data || { properties: [], functions: [], events: [] }; - - // 模拟数据 - // currentMetadata.value = { - // properties: [ - // { - // id: 'switch', - // name: '开关状态', - // sort: 1, - // description: '开关状态描述', - // required: false, - // expands: { - // source: 'device', - // type: 'R', - // }, - // valueParams: { - // dataType: 'boolean', - // formType: 'switch', - // min: 0, - // max: 1, - // length: 1, - // viewType: 'switch', - // enumConf: [], - // arrayConf: { type: 'string' }, - // objectConf: [], - // unit: '', - // scale: 2, - // format: 'YYYY-MM-DD HH:mm:ss', - // }, - // }, - // ], - // functions: [ - // { - // id: 'changeswitch', - // name: '控制开关', - // sort: 1, - // description: '开关状态描述', - // async: false, - // expands: {}, - // inputs: [ - // { - // id: 'switch', - // name: '开关', - // required: true, - // valueParams: { - // dataType: 'boolean', - // formType: 'switch', - // min: 0, - // max: 1, - // length: 1, - // viewType: 'switch', - // enumConf: [], - // objectConf: [], - // unit: '', - // scale: 2, - // format: 'YYYY-MM-DD HH:mm:ss', - // }, - // expands: {}, - // }, - // ], - // outputs: [], - // }, - // ], - // events: [ - // { - // id: 'event1', - // name: '事件1', - // sort: 1, - // description: '事件1描述', - // outputs: [ - // { - // id: 'param1', - // name: '参数1', - // expands: {}, - // valueParams: { - // type: 'string', - // expands: {}, - // enumConf: [], - // objectConf: [], - // unit: '', - // scale: 2, - // format: 'YYYY-MM-DD HH:mm:ss', - // }, - // }, - // ], - // }, - // ], - // }; // 保存原始数据用于比较 originalMetadata.value = JSON.parse(JSON.stringify(currentMetadata.value)); diff --git a/apps/web-antd/src/views/device/product/detail/components/metadata/PropertyDrawer.vue b/apps/web-antd/src/views/device/product/detail/components/metadata/PropertyDrawer.vue index 2c0d098..998cca4 100644 --- a/apps/web-antd/src/views/device/product/detail/components/metadata/PropertyDrawer.vue +++ b/apps/web-antd/src/views/device/product/detail/components/metadata/PropertyDrawer.vue @@ -37,6 +37,7 @@ interface PropertyData { sort: number; description: string; required: boolean; + show: boolean; expands: { source: string; type: string; @@ -146,6 +147,7 @@ const defaultPropertyData: PropertyData = { sort: 1, description: '', required: false, + show: true, expands: { source: 'device', type: 'R', @@ -539,6 +541,13 @@ watch( + + + + + + +