From 4185ad0d10966f02a7ae681639d284abe61b8252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=9B=8A?= Date: Wed, 30 Jul 2025 23:44:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devicemanagement/deviceinfo/index.vue | 121 ++++++++++-------- .../devicemanagement/deviceinfo/schema.ts | 80 +++++++----- 2 files changed, 114 insertions(+), 87 deletions(-) diff --git a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue index 7111984..183c67d 100644 --- a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue +++ b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue @@ -12,11 +12,10 @@ import { message as Message, Modal, Tag } from 'ant-design-vue'; import { useVbenForm } from '#/adapter/form'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { - postDeviceInfoArchivesDown, postAggregationDeviceCreateAsync, postAggregationDeviceDeleteAsync, + postDeviceInfoArchivesDown, postDeviceInfoPage, - postAggregationDeviceFindByIdAsync, } from '#/api-client'; import { TableAction } from '#/components/table-action'; import { $t } from '#/locales'; @@ -123,11 +122,11 @@ async function submit() { if (!valid) return; const formValues = await formApi.getValues(); - + // 根据平台类型处理数据 - let processedFormValues = { ...formValues }; - - if (formValues.ioTPlatform === '2') { + const processedFormValues = { ...formValues }; + + if (formValues.ioTPlatform === 2 || formValues.ioTPlatform === '2') { // OneNET平台 processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId; processedFormValues.ioTPlatformProductId = formValues.oneNETProductId; @@ -136,7 +135,7 @@ async function submit() { delete processedFormValues.oneNETProductId; delete processedFormValues.ctWingAccountId; delete processedFormValues.ctWingProductId; - } else if (formValues.ioTPlatform === '1') { + } else if (formValues.ioTPlatform === 1 || formValues.ioTPlatform === '1') { // CTWing平台 processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId; processedFormValues.ioTPlatformProductId = formValues.ctWingProductId; @@ -184,10 +183,10 @@ async function submit() { async function onEdit(record: any) { editRow.value = record; userModalApi.open(); - + // 根据平台类型设置表单值 const formValues = { ...record }; - + if (record.ioTPlatform === 2 || record.ioTPlatform === '2') { // OneNET平台 formValues.oneNETAccountId = record.ioTPlatformAccountId; @@ -197,7 +196,7 @@ async function onEdit(record: any) { formValues.ctWingAccountId = record.ioTPlatformAccountId; formValues.ctWingProductId = record.ioTPlatformProductId; } - + editFormApi.setValues(formValues); } @@ -206,7 +205,9 @@ function onDel(row: any) { title: `${$t('common.confirmDelete')}${row.deviceName || row.deviceAddress} ?`, onOk: async () => { try { - const result = await postAggregationDeviceDeleteAsync({ body: { id: row.id } }); + const result = await postAggregationDeviceDeleteAsync({ + body: { id: row.id }, + }); if (result.data) { gridApi.reload(); Message.success($t('common.deleteSuccess')); @@ -262,23 +263,19 @@ const openAddModal = async () => { - - - + diff --git a/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts b/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts index e52bd3d..7fe081e 100644 --- a/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts +++ b/apps/web-antd/src/views/devicemanagement/deviceinfo/schema.ts @@ -21,20 +21,6 @@ export const querySchema = computed(() => [ }, ]); -export const ioTPlatformOptions = [ - { - label: 'OneNET', - value: 1, - }, - { - label: 'CTWing', - value: 2, - }, - { - label: 'Other', - value: 0, - }, -]; export const tableSchema: any = computed((): VxeGridProps['columns'] => [ { title: $t('common.seq'), type: 'seq', width: 50 }, { @@ -134,10 +120,10 @@ export const addDeviceFormSchema: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformAccountName'), dependencies: { show(values: any) { - return values.ioTPlatform === '2'; // OneNET平台 + return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台 }, rules(values: any) { - if (values.ioTPlatform === '2') { + if (values.ioTPlatform === 2 || values.ioTPlatform === '2') { return 'required'; } return null; @@ -187,15 +173,15 @@ export const addDeviceFormSchema: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformAccountName'), dependencies: { show(values: any) { - return values.ioTPlatform === '1'; // CTWing平台 + return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台 }, rules(values: any) { - if (values.ioTPlatform === '1') { + if (values.ioTPlatform === 1 || values.ioTPlatform === '1') { return 'required'; } return null; }, - triggerFields: ['ioTPlatform'], + triggerFields: ['ioTPlatform'], // 添加这一行,使其能够响应平台切换 }, componentProps: { api: postCtWingAccountListAsync, @@ -206,7 +192,7 @@ export const addDeviceFormSchema: any = computed(() => [ }, }, labelField: 'accountName', - valueField: 'ctWingAccountId', + valueField: 'accountId', immediate: true, afterFetch: (res: any) => { // 如果是 Axios 响应对象,提取 data @@ -240,10 +226,16 @@ export const addDeviceFormSchema: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformProductName'), dependencies: { show(values: any) { - return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号 + return ( + (values.ioTPlatform === 2 || values.ioTPlatform === '2') && + values.oneNETAccountId + ); // OneNET平台且已选择账号 }, rules(values: any) { - if (values.ioTPlatform === '2' && values.oneNETAccountId) { + if ( + (values.ioTPlatform === 2 || values.ioTPlatform === '2') && + values.oneNETAccountId + ) { return 'required'; } return null; @@ -297,10 +289,16 @@ export const addDeviceFormSchema: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformProductName'), dependencies: { show(values: any) { - return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号 + return ( + (values.ioTPlatform === 1 || values.ioTPlatform === '1') && + values.ctWingAccountId + ); // CTWing平台且已选择账号 }, rules(values: any) { - if (values.ioTPlatform === '1' && values.ctWingAccountId) { + if ( + (values.ioTPlatform === 1 || values.ioTPlatform === '1') && + values.ctWingAccountId + ) { return 'required'; } return null; @@ -334,9 +332,10 @@ export const addDeviceFormSchema: any = computed(() => [ items = data.data; } - // 为每个产品项添加组合标签 + // 为每个产品项添加组合标签,并确保产品ID是字符串类型 return items.map((item: any) => ({ ...item, + ioTPlatformProductId: String(item.ioTPlatformProductId || ''), label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`, })); } @@ -401,10 +400,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformAccountName'), dependencies: { show(values: any) { - return values.ioTPlatform === '2'; // OneNET平台 + return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台 }, rules(values: any) { - if (values.ioTPlatform === '2') { + if (values.ioTPlatform === 2 || values.ioTPlatform === '2') { return 'required'; } return null; @@ -454,10 +453,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformAccountName'), dependencies: { show(values: any) { - return values.ioTPlatform === '1'; // CTWing平台 + return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台 }, rules(values: any) { - if (values.ioTPlatform === '1') { + if (values.ioTPlatform === 1 || values.ioTPlatform === '1') { return 'required'; } return null; @@ -507,10 +506,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformProductName'), dependencies: { show(values: any) { - return values.ioTPlatform === '2' && values.oneNETAccountId; // OneNET平台且已选择账号 + return ( + (values.ioTPlatform === 2 || values.ioTPlatform === '2') && + values.oneNETAccountId + ); // OneNET平台且已选择账号 }, rules(values: any) { - if (values.ioTPlatform === '2' && values.oneNETAccountId) { + if ( + (values.ioTPlatform === 2 || values.ioTPlatform === '2') && + values.oneNETAccountId + ) { return 'required'; } return null; @@ -564,10 +569,16 @@ export const editDeviceFormSchemaEdit: any = computed(() => [ label: $t('abp.deviceInfos.ioTPlatformProductName'), dependencies: { show(values: any) { - return values.ioTPlatform === '1' && values.ctWingAccountId; // CTWing平台且已选择账号 + return ( + (values.ioTPlatform === 1 || values.ioTPlatform === '1') && + values.ctWingAccountId + ); // CTWing平台且已选择账号 }, rules(values: any) { - if (values.ioTPlatform === '1' && values.ctWingAccountId) { + if ( + (values.ioTPlatform === 1 || values.ioTPlatform === '1') && + values.ctWingAccountId + ) { return 'required'; } return null; @@ -601,9 +612,10 @@ export const editDeviceFormSchemaEdit: any = computed(() => [ items = data.data; } - // 为每个产品项添加组合标签 + // 为每个产品项添加组合标签,并确保产品ID是字符串类型 return items.map((item: any) => ({ ...item, + ioTPlatformProductId: String(item.ioTPlatformProductId || ''), label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`, })); }