设备添加优化

This commit is contained in:
ChenYi 2025-07-30 15:05:32 +08:00
parent e65883bb5a
commit f4532070ae
9 changed files with 539 additions and 143 deletions

View File

@ -264,7 +264,6 @@
"OneNETManagement": { "OneNETManagement": {
"AccountName": "AccountName", "AccountName": "AccountName",
"PhoneNumber": "PhoneNumber", "PhoneNumber": "PhoneNumber",
"BelongingAccountName": "BelongingAccountName",
"AccountAccesskey": "AccountAccesskey", "AccountAccesskey": "AccountAccesskey",
"ProductCount": "ProductCount", "ProductCount": "ProductCount",
"OneNETAccountId": "OneNETAccountId", "OneNETAccountId": "OneNETAccountId",
@ -273,7 +272,6 @@
"ProductName": "ProductName", "ProductName": "ProductName",
"ProductAccesskey": "ProductAccesskey", "ProductAccesskey": "ProductAccesskey",
"IsEncrypted": "IsEncrypted", "IsEncrypted": "IsEncrypted",
"BelongingProductName": "Belonging ProductName",
"CommunicationAddress": "Communication Address", "CommunicationAddress": "Communication Address",
"CommunicationAddressTLS": "TLS Communication Address", "CommunicationAddressTLS": "TLS Communication Address",
"DeviceThingModelFileName": "DeviceThingModelFileName", "DeviceThingModelFileName": "DeviceThingModelFileName",
@ -285,16 +283,15 @@
"CTWingManagement": { "CTWingManagement": {
"AccountName": "AccountName", "AccountName": "AccountName",
"PhoneNumber": "PhoneNumber", "PhoneNumber": "PhoneNumber",
"BelongingAccountName": "BelongingAccountName",
"AccountAccesskey": "AccountAccesskey", "AccountAccesskey": "AccountAccesskey",
"ProductCount": "ProductCount", "ProductCount": "ProductCount",
"CTWingAccountId": "CTWingAccountId", "CTWingAccountId": "CTWingAccountId",
"CTWingProductId": "CTWingProductId", "CTWingProductId": "CTWingProductId",
"IoTPlatformProductId": "IoTPlatformProductId", "IoTPlatformProductId": "IoTPlatformProductId",
"ProductName": "ProductName", "ProductName": "ProductName",
"ProductAccesskey": "ProductAccesskey", "FeatureAccesskey": "FeatureAccesskey",
"MasterKey": "MasterKey",
"IsEncrypted": "IsEncrypted", "IsEncrypted": "IsEncrypted",
"BelongingProductName": "Belonging ProductName",
"CommunicationAddress": "Communication Address", "CommunicationAddress": "Communication Address",
"CommunicationAddressTLS": "TLS Communication Address", "CommunicationAddressTLS": "TLS Communication Address",
"DeviceThingModelFileName": "DeviceThingModelFileName", "DeviceThingModelFileName": "DeviceThingModelFileName",

View File

@ -57,5 +57,10 @@
"IoTPlatform": "IoTPlatform", "IoTPlatform": "IoTPlatform",
"note": "note", "note": "note",
"creationTime": "CreationTime", "creationTime": "CreationTime",
"lastModificationTime": "LastModificationTime" "lastModificationTime": "LastModificationTime",
"BelongingProductName": "Belonging ProductName",
"BelongingAccountName": "BelongingAccountName",
"AppId": "AppId",
"AppKey": "AppKey",
"AppSecret": "AppSecret"
} }

View File

@ -265,7 +265,6 @@
}, },
"OneNETManagement": { "OneNETManagement": {
"AccountName": "账号名称", "AccountName": "账号名称",
"BelongingAccountName": "所属账号",
"PhoneNumber": "手机号码", "PhoneNumber": "手机号码",
"AccountAccesskey": "账户通信密钥", "AccountAccesskey": "账户通信密钥",
"ProductCount": "产品数量", "ProductCount": "产品数量",
@ -275,7 +274,6 @@
"ProductName": "产品名称", "ProductName": "产品名称",
"ProductAccesskey": "产品密钥", "ProductAccesskey": "产品密钥",
"IsEncrypted": "是否加密", "IsEncrypted": "是否加密",
"BelongingProductName": "所属产品",
"CommunicationAddress": "通讯地址", "CommunicationAddress": "通讯地址",
"CommunicationAddressTLS": "TLS通讯地址", "CommunicationAddressTLS": "TLS通讯地址",
"DeviceThingModelFileName": "物模型文件", "DeviceThingModelFileName": "物模型文件",
@ -286,7 +284,6 @@
}, },
"CTWingManagement": { "CTWingManagement": {
"AccountName": "账号名称", "AccountName": "账号名称",
"BelongingAccountName": "所属账号",
"PhoneNumber": "手机号码", "PhoneNumber": "手机号码",
"AccountAccesskey": "账户通信密钥", "AccountAccesskey": "账户通信密钥",
"ProductCount": "产品数量", "ProductCount": "产品数量",
@ -294,9 +291,9 @@
"CTWingProductId": "CTWing产品Id", "CTWingProductId": "CTWing产品Id",
"IoTPlatformProductId": "物联网平台对应的产品Id", "IoTPlatformProductId": "物联网平台对应的产品Id",
"ProductName": "产品名称", "ProductName": "产品名称",
"ProductAccesskey": "产品密钥", "FeatureAccesskey": "设备访问密钥",
"MasterKey": "通信主密钥",
"IsEncrypted": "是否加密", "IsEncrypted": "是否加密",
"BelongingProductName": "所属产品",
"CommunicationAddress": "通讯地址", "CommunicationAddress": "通讯地址",
"CommunicationAddressTLS": "TLS通讯地址", "CommunicationAddressTLS": "TLS通讯地址",
"DeviceThingModelFileName": "物模型文件", "DeviceThingModelFileName": "物模型文件",

View File

@ -58,5 +58,10 @@
"IoTPlatform": "物联网平台", "IoTPlatform": "物联网平台",
"note": "备注", "note": "备注",
"creationTime": "创建时间", "creationTime": "创建时间",
"lastModificationTime": "最后更新时间" "lastModificationTime": "最后更新时间",
"BelongingProductName": "所属产品",
"BelongingAccountName": "所属账号",
"AppId": "应用Id",
"AppKey": "应用Key",
"AppSecret": "应用Secret"
} }

View File

@ -17,7 +17,7 @@ export const querySchema = computed(() => [
export const tableSchema: any = computed((): VxeGridProps['columns'] => [ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 }, { title: $t('common.seq'), type: 'seq', width: 50 },
{ {
field: 'ctWingAccountId', field: 'accountId',
title: $t('abp.CTWingManagement.CTWingAccountId'), title: $t('abp.CTWingManagement.CTWingAccountId'),
minWidth: '150', minWidth: '150',
}, },
@ -32,8 +32,18 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'accountAccesskey', field: 'appId',
title: $t('abp.CTWingManagement.AccountAccesskey'), title: $t('common.AppId'),
minWidth: '150',
},
{
field: 'appKey',
title: $t('common.AppKey'),
minWidth: '150',
},
{
field: 'appSecret',
title: $t('common.AppSecret'),
minWidth: '150', minWidth: '150',
}, },
{ {

View File

@ -19,7 +19,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 }, { title: $t('common.seq'), type: 'seq', width: 50 },
{ {
field: 'ctWingAccountName', field: 'ctWingAccountName',
title: $t('abp.CTWingManagement.BelongingAccountName'), title: $t('common.BelongingAccountName'),
minWidth: '150', minWidth: '150',
}, },
{ {
@ -33,8 +33,13 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'productAccesskey', field: 'masterKey',
title: $t('abp.CTWingManagement.ProductAccesskey'), title: $t('abp.CTWingManagement.MasterKey'),
minWidth: '150',
},
{
field: 'featureAccesskey',
title: $t('abp.CTWingManagement.FeatureAccesskey'),
minWidth: '150', minWidth: '150',
}, },
{ {
@ -42,55 +47,12 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
title: $t('abp.CTWingManagement.CommunicationAddress'), title: $t('abp.CTWingManagement.CommunicationAddress'),
minWidth: '150', minWidth: '150',
}, },
{
field: 'communicationAddressTLS',
title: $t('abp.CTWingManagement.CommunicationAddressTLS'),
minWidth: '150',
},
{ {
field: 'deviceThingModelFileName', field: 'deviceThingModelFileName',
title: $t('abp.CTWingManagement.DeviceThingModelFileName'), title: $t('abp.CTWingManagement.DeviceThingModelFileName'),
minWidth: '150', minWidth: '150',
slots: { default: 'deviceThingModelFileName' }, slots: { default: 'deviceThingModelFileName' },
}, },
{
field: 'productCreateTime',
title: $t('abp.CTWingManagement.IoTPlatformProductCreateTime'),
minWidth: '150',
formatter: ({ cellValue }: any) => {
if (!cellValue) return '-';
const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
}).replace(/\//g, '-');
},
},
{
field: 'productUpdateTime',
title: $t('abp.CTWingManagement.IoTPlatformProductUpdateTime'),
minWidth: '150',
formatter: ({ cellValue }: any) => {
if (!cellValue) return '-';
const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
}).replace(/\//g, '-');
},
},
{ {
field: 'creationTime', field: 'creationTime',
title: $t('abp.CTWingManagement.CreationTime'), title: $t('abp.CTWingManagement.CreationTime'),
@ -99,15 +61,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {
@ -118,15 +82,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {

View File

@ -123,13 +123,37 @@ async function submit() {
if (!valid) return; if (!valid) return;
const formValues = await formApi.getValues(); const formValues = await formApi.getValues();
//
let processedFormValues = { ...formValues };
if (formValues.ioTPlatform === '1') {
// OneNET
processedFormValues.ioTPlatformAccountId = formValues.oneNETAccountId;
processedFormValues.ioTPlatformProductId = formValues.oneNETProductId;
//
delete processedFormValues.oneNETAccountId;
delete processedFormValues.oneNETProductId;
delete processedFormValues.ctWingAccountId;
delete processedFormValues.ctWingProductId;
} else if (formValues.ioTPlatform === '2') {
// CTWing
processedFormValues.ioTPlatformAccountId = formValues.ctWingAccountId;
processedFormValues.ioTPlatformProductId = formValues.ctWingProductId;
//
delete processedFormValues.ctWingAccountId;
delete processedFormValues.ctWingProductId;
delete processedFormValues.oneNETAccountId;
delete processedFormValues.oneNETProductId;
}
const fetchParams: any = isEdit const fetchParams: any = isEdit
? { ? {
id: editRow.value.id, id: editRow.value.id,
...formValues, ...processedFormValues,
} }
: { : {
...formValues, ...processedFormValues,
}; };
try { try {
@ -160,7 +184,21 @@ async function submit() {
async function onEdit(record: any) { async function onEdit(record: any) {
editRow.value = record; editRow.value = record;
userModalApi.open(); userModalApi.open();
editFormApi.setValues({ ...record });
//
const formValues = { ...record };
if (record.ioTPlatform === 1 || record.ioTPlatform === '1') {
// OneNET
formValues.oneNETAccountId = record.ioTPlatformAccountId;
formValues.oneNETProductId = record.ioTPlatformProductId;
} else if (record.ioTPlatform === 2 || record.ioTPlatform === '2') {
// CTWing
formValues.ctWingAccountId = record.ioTPlatformAccountId;
formValues.ctWingProductId = record.ioTPlatformProductId;
}
editFormApi.setValues(formValues);
} }
function onDel(row: any) { function onDel(row: any) {

View File

@ -6,6 +6,9 @@ import { z } from '@vben/common-ui';
import { import {
getCommonGetSelectList, getCommonGetSelectList,
postCtWingAccountListAsync,
postCtWingProductListAsync,
postOneNetAccountListAsync,
postOneNetProductListAsync, postOneNetProductListAsync,
} from '#/api-client'; } from '#/api-client';
import { $t } from '#/locales'; import { $t } from '#/locales';
@ -91,8 +94,8 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
export const addDeviceFormSchema: any = computed(() => [ export const addDeviceFormSchema: any = computed(() => [
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'IoTPlatform', fieldName: 'ioTPlatform',
label: $t('common.IoTPlatform'), label: $t('abp.deviceInfos.ioTPlatform'),
componentProps: { componentProps: {
api: getCommonGetSelectList, api: getCommonGetSelectList,
params: { params: {
@ -122,22 +125,141 @@ export const addDeviceFormSchema: any = computed(() => [
}, },
}, },
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('common.IoTPlatform')}`, message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
}), }),
}, },
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'ioTPlatformProductId', fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.BelongingProductName'), label: $t('abp.deviceInfos.ioTPlatformAccountName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '1'; // OneNET平台
},
rules(values: any) {
if (values.ioTPlatform === '1') {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform'],
},
componentProps: { componentProps: {
api: postOneNetProductListAsync, api: postOneNetAccountListAsync,
params: { params: {
body: { body: {
pageIndex: 1, pageIndex: 1,
pageSize: 1000, pageSize: 1000,
}, },
}, },
labelField: 'label', labelField: 'accountName',
valueField: 'oneNETAccountId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
return data.data;
}
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformAccountName')}`,
},
rules: z.string().optional(),
},
{
component: 'ApiSelect',
fieldName: 'ctWingAccountId',
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '2'; // CTWing平台
},
rules(values: any) {
if (values.ioTPlatform === '2') {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform'],
},
componentProps: {
api: postCtWingAccountListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
},
},
labelField: 'accountName',
valueField: 'ctWingAccountId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
return data.data;
}
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformAccountName')}`,
},
rules: z.string().optional(),
},
{
component: 'ApiSelect',
fieldName: 'oneNETProductId',
label: $t('abp.deviceInfos.ioTPlatformProductName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '1' && values.oneNETAccountId; // OneNET平台且已选择账号
},
rules(values: any) {
if (values.ioTPlatform === '1' && values.oneNETAccountId) {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform', 'oneNETAccountId'],
},
componentProps: {
api: postOneNetProductListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
oneNETAccountId: '{{oneNETAccountId}}', // 动态参数
},
},
labelField: 'productName',
valueField: 'ioTPlatformProductId', valueField: 'ioTPlatformProductId',
immediate: true, immediate: true,
afterFetch: (res: any) => { afterFetch: (res: any) => {
@ -158,17 +280,80 @@ export const addDeviceFormSchema: any = computed(() => [
// 为每个产品项添加组合标签 // 为每个产品项添加组合标签
return items.map((item: any) => ({ return items.map((item: any) => ({
...item, ...item,
label: `${item.productName || item.ProductName || ''} (${item.ioTPlatformProductId || ''})`, label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
})); }));
} }
// 如果都不是,返回空数组 // 如果都不是,返回空数组
return []; return [];
}, },
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`, placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
}, },
rules: z.string().optional(),
},
{
component: 'ApiSelect',
fieldName: 'ctWingProductId',
label: $t('abp.deviceInfos.ioTPlatformProductName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '2' && values.ctWingAccountId; // CTWing平台且已选择账号
},
rules(values: any) {
if (values.ioTPlatform === '2' && values.ctWingAccountId) {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform', 'ctWingAccountId'],
},
componentProps: {
api: postCtWingProductListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
ctWingAccountId: '{{ctWingAccountId}}', // 动态参数
},
},
labelField: 'productName',
valueField: 'ioTPlatformProductId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
let items = [];
if (Array.isArray(data)) {
items = data;
} else if (data && Array.isArray(data.items)) {
items = data.items;
} else if (data && Array.isArray(data.data)) {
items = data.data;
}
// 为每个产品项添加组合标签
return items.map((item: any) => ({
...item,
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
}));
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
},
rules: z.string().optional(),
},
{
component: 'Input',
fieldName: 'deviceName',
label: $t('abp.deviceInfos.deviceName'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`, message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceName')}`,
}), }),
}, },
{ {
@ -179,13 +364,21 @@ export const addDeviceFormSchema: any = computed(() => [
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`, message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
}), }),
}, },
{
component: 'Input',
fieldName: 'platformPassword',
label: $t('abp.deviceInfos.platformPassword'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`,
}),
},
]); ]);
export const editDeviceFormSchemaEdit: any = computed(() => [ export const editDeviceFormSchemaEdit: any = computed(() => [
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'IoTPlatform', fieldName: 'ioTPlatform',
label: $t('common.IoTPlatform'), label: $t('abp.deviceInfos.ioTPlatform'),
componentProps: { componentProps: {
api: getCommonGetSelectList, api: getCommonGetSelectList,
params: { params: {
@ -214,20 +407,142 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
return []; return [];
}, },
}, },
rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
}),
}, },
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'ioTPlatformProductId', fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.BelongingProductName'), label: $t('abp.deviceInfos.ioTPlatformAccountName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '1'; // OneNET平台
},
rules(values: any) {
if (values.ioTPlatform === '1') {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform'],
},
componentProps: { componentProps: {
api: postOneNetProductListAsync, api: postOneNetAccountListAsync,
params: { params: {
body: { body: {
pageIndex: 1, pageIndex: 1,
pageSize: 1000, pageSize: 1000,
}, },
}, },
labelField: 'label', labelField: 'accountName',
valueField: 'oneNETAccountId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
return data.data;
}
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformAccountName')}`,
},
rules: z.string().optional(),
},
{
component: 'ApiSelect',
fieldName: 'ctWingAccountId',
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '2'; // CTWing平台
},
rules(values: any) {
if (values.ioTPlatform === '2') {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform'],
},
componentProps: {
api: postCtWingAccountListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
},
},
labelField: 'accountName',
valueField: 'ctWingAccountId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
return data.data;
}
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformAccountName')}`,
},
rules: z.string().optional(),
},
{
component: 'ApiSelect',
fieldName: 'oneNETProductId',
label: $t('abp.deviceInfos.ioTPlatformProductName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '1' && values.oneNETAccountId; // OneNET平台且已选择账号
},
rules(values: any) {
if (values.ioTPlatform === '1' && values.oneNETAccountId) {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform', 'oneNETAccountId'],
},
componentProps: {
api: postOneNetProductListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
oneNETAccountId: '{{oneNETAccountId}}', // 动态参数
},
},
labelField: 'productName',
valueField: 'ioTPlatformProductId', valueField: 'ioTPlatformProductId',
immediate: true, immediate: true,
afterFetch: (res: any) => { afterFetch: (res: any) => {
@ -248,18 +563,73 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
// 为每个产品项添加组合标签 // 为每个产品项添加组合标签
return items.map((item: any) => ({ return items.map((item: any) => ({
...item, ...item,
label: `${item.productName || item.ProductName || ''} (${item.ioTPlatformProductId || ''})`, label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
})); }));
} }
// 如果都不是,返回空数组 // 如果都不是,返回空数组
return []; return [];
}, },
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`, placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
}, },
rules: z.string().min(1, { rules: z.string().optional(),
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`, },
}), {
component: 'ApiSelect',
fieldName: 'ctWingProductId',
label: $t('abp.deviceInfos.ioTPlatformProductName'),
dependencies: {
show(values: any) {
return values.ioTPlatform === '2' && values.ctWingAccountId; // CTWing平台且已选择账号
},
rules(values: any) {
if (values.ioTPlatform === '2' && values.ctWingAccountId) {
return 'required';
}
return null;
},
triggerFields: ['ioTPlatform', 'ctWingAccountId'],
},
componentProps: {
api: postCtWingProductListAsync,
params: {
body: {
pageIndex: 1,
pageSize: 1000,
ctWingAccountId: '{{ctWingAccountId}}', // 动态参数
},
},
labelField: 'productName',
valueField: 'ioTPlatformProductId',
immediate: true,
afterFetch: (res: any) => {
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
const data = res.data;
// 确保返回的是数组格式
let items = [];
if (Array.isArray(data)) {
items = data;
} else if (data && Array.isArray(data.items)) {
items = data.items;
} else if (data && Array.isArray(data.data)) {
items = data.data;
}
// 为每个产品项添加组合标签
return items.map((item: any) => ({
...item,
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
}));
}
// 如果都不是,返回空数组
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
},
rules: z.string().optional(),
}, },
{ {
component: 'Input', component: 'Input',

View File

@ -19,7 +19,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 }, { title: $t('common.seq'), type: 'seq', width: 50 },
{ {
field: 'oneNETAccountName', field: 'oneNETAccountName',
title: $t('abp.OneNETManagement.BelongingAccountName'), title: $t('common.BelongingAccountName'),
minWidth: '150', minWidth: '150',
}, },
{ {
@ -61,15 +61,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {
@ -80,15 +82,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {
@ -99,15 +103,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {
@ -118,15 +124,17 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
if (!cellValue) return '-'; if (!cellValue) return '-';
const date = new Date(cellValue); const date = new Date(cellValue);
if (isNaN(date.getTime())) return '-'; if (isNaN(date.getTime())) return '-';
return date.toLocaleString('zh-CN', { return date
year: 'numeric', .toLocaleString('zh-CN', {
month: '2-digit', year: 'numeric',
day: '2-digit', month: '2-digit',
hour: '2-digit', day: '2-digit',
minute: '2-digit', hour: '2-digit',
second: '2-digit', minute: '2-digit',
hour12: false, second: '2-digit',
}).replace(/\//g, '-'); hour12: false,
})
.replaceAll('/', '-');
}, },
}, },
{ {
@ -158,7 +166,7 @@ export const addProductFormSchema: any = computed(() => [
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'oneNETAccountId', fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.BelongingAccountName'), label: $t('common.BelongingAccountName'),
componentProps: { componentProps: {
api: postOneNetAccountListAsync, api: postOneNetAccountListAsync,
params: { params: {
@ -192,10 +200,10 @@ export const addProductFormSchema: any = computed(() => [
// 如果都不是,返回空数组 // 如果都不是,返回空数组
return []; return [];
}, },
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, placeholder: `${$t('common.pleaseSelect')}${$t('common.BelongingAccountName')}`,
}, },
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, message: `${$t('common.pleaseSelect')}${$t('common.BelongingAccountName')}`,
}), }),
}, },
{ {