From 8fd4aba6582da5d550acd43c66ae5a7824293000 Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Fri, 17 Apr 2026 16:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B9=B3=E5=8F=B0=E7=AB=AF?= =?UTF-8?q?=E7=89=A9=E6=A8=A1=E5=9E=8B=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devicemanagement/deviceinfo/index.vue | 63 ++++++++++++++++--- .../ioTPlatformThingModelInfo/index.vue | 63 +++++++++++++++---- 2 files changed, 104 insertions(+), 22 deletions(-) diff --git a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue index df7a1ac..81b4b76 100644 --- a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue +++ b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue @@ -736,6 +736,29 @@ const serviceCallOptions = ref< const selectedServiceIndex = ref(undefined); const serviceCallFormValues = ref>({}); +/** 服务调用接口返回,展示在弹窗内;不自动关闭弹窗 */ +const serviceCallResultText = ref(''); +const serviceCallResultOk = ref(true); + +function formatServiceCallResultPayload(data: unknown): string { + if (data === undefined || data === null) { + return '(接口无返回体)'; + } + if (typeof data === 'string') { + return data.trim() === '' ? '(空字符串)' : data; + } + try { + return JSON.stringify(data, null, 2); + } catch { + return String(data); + } +} + +function clearServiceCallResult() { + serviceCallResultText.value = ''; + serviceCallResultOk.value = true; +} + /** 需用日期时间选择「起始时标」的冻结/补抄类服务(与物模型服务标识 key 一致) */ const FREEZE_START_TIME_MARKER_SERVICES = new Set([ 'DayFreezeService', @@ -1183,12 +1206,14 @@ const [ServiceCallModal, serviceCallModalApi] = useVbenModal({ serviceCallFormValues.value = {}; valveCommandTypeOptions.value = []; valveCommandTypeLoading.value = false; + clearServiceCallResult(); return true; }, onOpenChange: async (isOpen: boolean) => { if (!isOpen) { return; } + clearServiceCallResult(); const pid = serviceCallRow.value?.ioTPlatformProductId; if (!pid) { Message.warning('设备缺少平台产品信息,无法获取服务列表'); @@ -1256,15 +1281,21 @@ async function submitDeviceServiceCall() { serviceParams, }, } as any); - if (typeof data === 'string' && data.trim() !== '') { - Message.success(data); - } else { - Message.success('服务调用成功'); - } - serviceCallModalApi.close(); - } catch (error) { + serviceCallResultOk.value = true; + serviceCallResultText.value = formatServiceCallResultPayload(data); + Message.success('服务调用成功'); + } catch (error: any) { console.error('调用设备服务失败:', error); - Message.error('调用设备服务失败'); + const backendMessage = + error?.response?.data?.error?.message ?? + error?.data?.error?.message ?? + error?.error?.message; + const msg = + backendMessage && typeof backendMessage === 'string' + ? backendMessage + : (error as Error)?.message || '调用设备服务失败'; + serviceCallResultOk.value = false; + serviceCallResultText.value = msg; } finally { serviceCallModalApi.setState({ loading: false, confirmLoading: false }); } @@ -1275,6 +1306,7 @@ function openServiceCallModal(row: Record) { Message.warning('设备缺少平台产品信息,无法获取服务列表'); return; } + clearServiceCallResult(); serviceCallRow.value = row; serviceCallModalApi.open(); } @@ -2904,7 +2936,7 @@ const toolbarActions = computed(() => [
@@ -2988,6 +3020,19 @@ const toolbarActions = computed(() => [ > 当前服务无参数(thirdValue / secondValue 为空或无法解析)
+
+
调用结果
+
+
{{ serviceCallResultText }}
+
+