2025-07-08 16:04:14 +08:00
|
|
|
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
|
|
|
|
|
|
|
|
|
|
import { computed } from 'vue';
|
|
|
|
|
|
|
|
|
|
|
|
import { z } from '@vben/common-ui';
|
|
|
|
|
|
|
2025-08-05 17:33:47 +08:00
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
2025-07-28 16:50:59 +08:00
|
|
|
|
import {
|
|
|
|
|
|
getCommonGetSelectList,
|
2025-07-30 15:05:32 +08:00
|
|
|
|
postCtWingAccountListAsync,
|
|
|
|
|
|
postCtWingProductListAsync,
|
|
|
|
|
|
postOneNetAccountListAsync,
|
2025-07-28 16:50:59 +08:00
|
|
|
|
postOneNetProductListAsync,
|
|
|
|
|
|
} from '#/api-client';
|
2025-07-08 16:04:14 +08:00
|
|
|
|
import { $t } from '#/locales';
|
|
|
|
|
|
|
|
|
|
|
|
export const querySchema = computed(() => [
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'Input',
|
2025-07-25 17:27:41 +08:00
|
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
2025-10-21 17:21:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ioTPlatform',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatform'),
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: getCommonGetSelectList,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
query: {
|
|
|
|
|
|
typeName: 'IoTPlatformTypeEnum',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelField: 'value',
|
|
|
|
|
|
valueField: 'key',
|
|
|
|
|
|
optionsPropName: 'options',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
allowClear: true,
|
|
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
console.log('产品选择器API调用 - 平台类型:',res);
|
|
|
|
|
|
|
|
|
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
|
if (Array.isArray(res)) {
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 items 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.items)) {
|
|
|
|
|
|
return res.items;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 data 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.data)) {
|
|
|
|
|
|
return res.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'oneNETProductId',
|
|
|
|
|
|
label: $t('common.BelongingProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
|
|
|
|
|
const shouldShow = values.ioTPlatform === 2 || values.ioTPlatform === '2';
|
|
|
|
|
|
console.log('OneNET产品选择器显示检查 - 平台类型:', values.ioTPlatform, '是否显示:', shouldShow);
|
|
|
|
|
|
return shouldShow; // OneNET平台
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetProductListAsync,
|
|
|
|
|
|
params: (formValues: any) => ({
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
labelField: 'productName',
|
|
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
console.log('OneNET产品选择器afterFetch调用 - 响应:', res);
|
|
|
|
|
|
// 如果是 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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('OneNET产品列表处理后的数据:', items);
|
|
|
|
|
|
return items;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('common.BelongingProductName')}`,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ctWingProductId',
|
|
|
|
|
|
label: $t('common.BelongingProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
|
|
|
|
|
const shouldShow = values.ioTPlatform === 1 || values.ioTPlatform === '1';
|
|
|
|
|
|
console.log('CTWing产品选择器显示检查 - 平台类型:', values.ioTPlatform, '是否显示:', shouldShow);
|
|
|
|
|
|
return shouldShow; // CTWing平台
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingProductListAsync,
|
|
|
|
|
|
params: (formValues: any) => ({
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
labelField: 'productName',
|
|
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
console.log('CTWing产品选择器afterFetch调用 - 响应:', res);
|
|
|
|
|
|
// 如果是 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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('CTWing产品列表处理后的数据:', items);
|
|
|
|
|
|
return items;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('common.BelongingProductName')}`,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
]);
|
2025-07-28 16:50:59 +08:00
|
|
|
|
|
2025-07-08 16:04:14 +08:00
|
|
|
|
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
|
|
|
|
|
{ title: $t('common.seq'), type: 'seq', width: 50 },
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'ioTPlatformName',
|
|
|
|
|
|
title: $t('common.BelongingIoTPlatform'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
2025-07-31 10:43:47 +08:00
|
|
|
|
slots: { default: 'ioTPlatformName' },
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'accountPhoneNumber',
|
|
|
|
|
|
title: $t('common.BelongingAccountName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'ioTPlatformProductName',
|
|
|
|
|
|
title: $t('common.BelongingProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'deviceName',
|
|
|
|
|
|
title: $t('abp.deviceInfos.deviceName'),
|
|
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'deviceAddress',
|
|
|
|
|
|
title: $t('abp.deviceInfos.deviceAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
|
field: 'ioTPlatformDeviceOpenInfo',
|
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformDeviceOpenInfo'),
|
2025-07-31 10:43:47 +08:00
|
|
|
|
minWidth: '180',
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'deviceOnlineStatusName',
|
|
|
|
|
|
title: $t('abp.deviceInfos.DeviceOnlineStatus'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'lastOnlineTime',
|
|
|
|
|
|
title: $t('abp.deviceInfos.LastOnlineTime'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
2025-08-05 17:33:47 +08:00
|
|
|
|
formatter: ({ cellValue }) => {
|
|
|
|
|
|
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-31 10:43:47 +08:00
|
|
|
|
field: 'lastOfflineTime',
|
|
|
|
|
|
title: $t('abp.deviceInfos.LastOfflineTime'),
|
|
|
|
|
|
minWidth: '150',
|
2025-08-05 17:33:47 +08:00
|
|
|
|
formatter: ({ cellValue }) => {
|
|
|
|
|
|
return cellValue ? dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
|
|
|
|
|
|
},
|
2025-07-31 10:43:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'platformPassword',
|
|
|
|
|
|
title: $t('abp.deviceInfos.platformPassword'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
|
field: 'ioTPlatformResponse',
|
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformResponse'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
minWidth: '150',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: $t('common.action'),
|
|
|
|
|
|
field: 'action',
|
|
|
|
|
|
fixed: 'right',
|
2025-08-01 17:36:42 +08:00
|
|
|
|
width: '180',
|
2025-07-08 16:04:14 +08:00
|
|
|
|
slots: { default: 'action' },
|
|
|
|
|
|
},
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
2025-07-25 17:27:41 +08:00
|
|
|
|
export const addDeviceFormSchema: any = computed(() => [
|
2025-08-05 10:57:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
component: 'Input',
|
|
|
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
|
component: 'ApiSelect',
|
2025-07-30 15:05:32 +08:00
|
|
|
|
fieldName: 'ioTPlatform',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatform'),
|
2025-07-28 16:50:59 +08:00
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: getCommonGetSelectList,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
query: {
|
|
|
|
|
|
typeName: 'IoTPlatformTypeEnum',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelField: 'value',
|
|
|
|
|
|
valueField: 'key',
|
|
|
|
|
|
optionsPropName: 'options',
|
|
|
|
|
|
immediate: true,
|
2025-07-31 17:34:07 +08:00
|
|
|
|
allowClear: true,
|
2025-08-01 16:01:58 +08:00
|
|
|
|
placeholder:
|
|
|
|
|
|
$t('common.pleaseSelect') + $t('abp.deviceInfos.ioTPlatform'),
|
2025-07-28 16:50:59 +08:00
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
|
if (Array.isArray(res)) {
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 items 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.items)) {
|
|
|
|
|
|
return res.items;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 data 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.data)) {
|
|
|
|
|
|
return res.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
rules: z.string().min(1, {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
|
2025-07-28 16:50:59 +08:00
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
2025-07-30 15:05:32 +08:00
|
|
|
|
fieldName: 'oneNETAccountId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetAccountListAsync,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
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) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
2025-07-30 23:44:47 +08:00
|
|
|
|
triggerFields: ['ioTPlatform'], // 添加这一行,使其能够响应平台切换
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingAccountListAsync,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelField: 'accountName',
|
2025-07-30 23:44:47 +08:00
|
|
|
|
valueField: 'accountId',
|
2025-07-30 15:05:32 +08:00
|
|
|
|
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) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
); // OneNET平台且已选择账号
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
) {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'oneNETAccountId'],
|
|
|
|
|
|
},
|
2025-07-28 16:50:59 +08:00
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetProductListAsync,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
params: (formValues: any) => ({
|
2025-07-28 16:50:59 +08:00
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
oneNETAccountId: formValues.oneNETAccountId,
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
2025-07-30 17:17:08 +08:00
|
|
|
|
}),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
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: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ctWingProductId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
); // CTWing平台且已选择账号
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
) {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'ctWingAccountId'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingProductListAsync,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
params: (formValues: any) => ({
|
2025-07-30 15:05:32 +08:00
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
ctWingAccountId: formValues.ctWingAccountId,
|
2025-07-28 16:50:59 +08:00
|
|
|
|
},
|
2025-07-30 17:17:08 +08:00
|
|
|
|
}),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
labelField: 'productName',
|
2025-07-28 16:50:59 +08:00
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
// 如果是 Axios 响应对象,提取 data
|
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
|
const data = res.data;
|
|
|
|
|
|
|
|
|
|
|
|
// 确保返回的是数组格式
|
2025-07-29 17:32:30 +08:00
|
|
|
|
let items = [];
|
2025-07-28 16:50:59 +08:00
|
|
|
|
if (Array.isArray(data)) {
|
2025-07-29 17:32:30 +08:00
|
|
|
|
items = data;
|
|
|
|
|
|
} else if (data && Array.isArray(data.items)) {
|
|
|
|
|
|
items = data.items;
|
|
|
|
|
|
} else if (data && Array.isArray(data.data)) {
|
|
|
|
|
|
items = data.data;
|
2025-07-28 16:50:59 +08:00
|
|
|
|
}
|
2025-07-29 17:32:30 +08:00
|
|
|
|
|
2025-07-30 23:44:47 +08:00
|
|
|
|
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
2025-07-29 17:32:30 +08:00
|
|
|
|
return items.map((item: any) => ({
|
|
|
|
|
|
...item,
|
2025-07-30 23:44:47 +08:00
|
|
|
|
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
2025-07-29 17:32:30 +08:00
|
|
|
|
}));
|
2025-07-28 16:50:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
2025-07-30 15:05:32 +08:00
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
|
2025-07-28 16:50:59 +08:00
|
|
|
|
},
|
2025-07-30 15:05:32 +08:00
|
|
|
|
rules: z.string().optional(),
|
|
|
|
|
|
},
|
2025-07-28 16:50:59 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
export const editDeviceFormSchemaEdit: any = computed(() => [
|
2025-07-08 16:04:14 +08:00
|
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
|
component: 'ApiSelect',
|
2025-07-30 15:05:32 +08:00
|
|
|
|
fieldName: 'ioTPlatform',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatform'),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
componentProps: {
|
2025-07-28 16:50:59 +08:00
|
|
|
|
api: getCommonGetSelectList,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
query: {
|
|
|
|
|
|
typeName: 'IoTPlatformTypeEnum',
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
2025-07-28 16:50:59 +08:00
|
|
|
|
labelField: 'value',
|
|
|
|
|
|
valueField: 'key',
|
|
|
|
|
|
optionsPropName: 'options',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
|
if (Array.isArray(res)) {
|
|
|
|
|
|
return res;
|
2025-07-08 16:04:14 +08:00
|
|
|
|
}
|
2025-07-28 16:50:59 +08:00
|
|
|
|
// 如果是包装在 items 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.items)) {
|
|
|
|
|
|
return res.items;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 data 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.data)) {
|
|
|
|
|
|
return res.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-07-30 15:05:32 +08:00
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'oneNETAccountId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetAccountListAsync,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
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) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return values.ioTPlatform === 1 || values.ioTPlatform === '1'; // CTWing平台
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
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(),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
|
component: 'ApiSelect',
|
2025-07-30 15:05:32 +08:00
|
|
|
|
fieldName: 'oneNETProductId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
); // OneNET平台且已选择账号
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
) {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'oneNETAccountId'],
|
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
|
componentProps: {
|
2025-07-28 16:50:59 +08:00
|
|
|
|
api: postOneNetProductListAsync,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
params: (formValues: any) => ({
|
2025-07-28 16:50:59 +08:00
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
oneNETAccountId: formValues.oneNETAccountId,
|
2025-07-28 16:50:59 +08:00
|
|
|
|
},
|
2025-07-30 17:17:08 +08:00
|
|
|
|
}),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
labelField: 'productName',
|
2025-07-28 16:50:59 +08:00
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
// 如果是 Axios 响应对象,提取 data
|
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
|
const data = res.data;
|
|
|
|
|
|
|
|
|
|
|
|
// 确保返回的是数组格式
|
2025-07-29 17:32:30 +08:00
|
|
|
|
let items = [];
|
2025-07-28 16:50:59 +08:00
|
|
|
|
if (Array.isArray(data)) {
|
2025-07-29 17:32:30 +08:00
|
|
|
|
items = data;
|
|
|
|
|
|
} else if (data && Array.isArray(data.items)) {
|
|
|
|
|
|
items = data.items;
|
|
|
|
|
|
} else if (data && Array.isArray(data.data)) {
|
|
|
|
|
|
items = data.data;
|
2025-07-28 16:50:59 +08:00
|
|
|
|
}
|
2025-07-29 17:32:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 为每个产品项添加组合标签
|
|
|
|
|
|
return items.map((item: any) => ({
|
|
|
|
|
|
...item,
|
2025-07-30 15:05:32 +08:00
|
|
|
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
2025-07-29 17:32:30 +08:00
|
|
|
|
}));
|
2025-07-28 16:50:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
2025-07-30 15:05:32 +08:00
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
2025-07-30 15:05:32 +08:00
|
|
|
|
rules: z.string().optional(),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ctWingProductId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
return (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
); // CTWing平台且已选择账号
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
2025-07-30 23:44:47 +08:00
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
) {
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'ctWingAccountId'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingProductListAsync,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
params: (formValues: any) => ({
|
2025-07-30 15:05:32 +08:00
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
2025-07-30 17:17:08 +08:00
|
|
|
|
ctWingAccountId: formValues.ctWingAccountId,
|
2025-07-30 15:05:32 +08:00
|
|
|
|
},
|
2025-07-30 17:17:08 +08:00
|
|
|
|
}),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-30 23:44:47 +08:00
|
|
|
|
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
2025-07-30 15:05:32 +08:00
|
|
|
|
return items.map((item: any) => ({
|
|
|
|
|
|
...item,
|
2025-07-30 23:44:47 +08:00
|
|
|
|
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
2025-07-30 15:05:32 +08:00
|
|
|
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: z.string().optional(),
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'Input',
|
2025-07-28 16:50:59 +08:00
|
|
|
|
fieldName: 'deviceAddress',
|
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
|
|
|
|
|
disabled: true,
|
2025-07-08 16:04:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
]);
|
2025-08-01 17:36:42 +08:00
|
|
|
|
|
|
|
|
|
|
export const commandFormSchema: any = computed(() => [
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'Textarea',
|
2025-08-05 17:33:47 +08:00
|
|
|
|
fieldName: 'CommandContent',
|
2025-08-01 17:36:42 +08:00
|
|
|
|
label: $t('abp.IoTDBBase.Command'),
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
rows: 8,
|
|
|
|
|
|
placeholder: $t('common.pleaseInput') + $t('abp.IoTDBBase.Command'),
|
|
|
|
|
|
showCount: true,
|
|
|
|
|
|
maxLength: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.IoTDBBase.Command')}`,
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
]);
|
2025-08-04 17:36:09 +08:00
|
|
|
|
|
|
|
|
|
|
export const batchAddDeviceFormSchema: any = computed(() => [
|
2025-08-05 10:57:01 +08:00
|
|
|
|
{
|
|
|
|
|
|
component: 'Textarea',
|
|
|
|
|
|
fieldName: 'addressList',
|
|
|
|
|
|
label: $t('abp.deviceInfos.deviceAddress'),
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
rows: 4,
|
2025-08-05 17:33:47 +08:00
|
|
|
|
placeholder: `${
|
|
|
|
|
|
$t('common.pleaseInput') + $t('abp.deviceInfos.deviceAddress')
|
|
|
|
|
|
},每行一个设备地址`,
|
2025-08-05 11:59:00 +08:00
|
|
|
|
showCount: false,
|
2025-08-05 17:33:47 +08:00
|
|
|
|
maxLength: 10_000,
|
2025-08-05 10:57:01 +08:00
|
|
|
|
style: {
|
|
|
|
|
|
resize: 'vertical',
|
|
|
|
|
|
minHeight: '32px',
|
|
|
|
|
|
maxHeight: '200px',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
2025-08-04 17:36:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ioTPlatform',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatform'),
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: getCommonGetSelectList,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
query: {
|
|
|
|
|
|
typeName: 'IoTPlatformTypeEnum',
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelField: 'value',
|
|
|
|
|
|
valueField: 'key',
|
|
|
|
|
|
optionsPropName: 'options',
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
allowClear: true,
|
|
|
|
|
|
placeholder:
|
|
|
|
|
|
$t('common.pleaseSelect') + $t('abp.deviceInfos.ioTPlatform'),
|
|
|
|
|
|
afterFetch: (res: any) => {
|
|
|
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
|
if (Array.isArray(res)) {
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 items 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.items)) {
|
|
|
|
|
|
return res.items;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果是包装在 data 中的,提取出来
|
|
|
|
|
|
if (res && Array.isArray(res.data)) {
|
|
|
|
|
|
return res.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'oneNETAccountId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
|
|
|
|
|
return values.ioTPlatform === 2 || values.ioTPlatform === '2'; // OneNET平台
|
|
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
|
|
|
|
|
if (values.ioTPlatform === 2 || values.ioTPlatform === '2') {
|
|
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetAccountListAsync,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
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 === 1 || values.ioTPlatform === '1'; // CTWing平台
|
|
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
|
|
|
|
|
if (values.ioTPlatform === 1 || values.ioTPlatform === '1') {
|
|
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform'], // 添加这一行,使其能够响应平台切换
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingAccountListAsync,
|
|
|
|
|
|
params: {
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
labelField: 'accountName',
|
|
|
|
|
|
valueField: 'accountId',
|
|
|
|
|
|
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 === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
); // OneNET平台且已选择账号
|
|
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
|
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 2 || values.ioTPlatform === '2') &&
|
|
|
|
|
|
values.oneNETAccountId
|
|
|
|
|
|
) {
|
|
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'oneNETAccountId'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postOneNetProductListAsync,
|
|
|
|
|
|
params: (formValues: any) => ({
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
oneNETAccountId: formValues.oneNETAccountId,
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
|
|
|
|
|
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: 'ApiSelect',
|
|
|
|
|
|
fieldName: 'ctWingProductId',
|
|
|
|
|
|
label: $t('abp.deviceInfos.ioTPlatformProductName'),
|
|
|
|
|
|
dependencies: {
|
|
|
|
|
|
show(values: any) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
); // CTWing平台且已选择账号
|
|
|
|
|
|
},
|
|
|
|
|
|
rules(values: any) {
|
|
|
|
|
|
if (
|
|
|
|
|
|
(values.ioTPlatform === 1 || values.ioTPlatform === '1') &&
|
|
|
|
|
|
values.ctWingAccountId
|
|
|
|
|
|
) {
|
|
|
|
|
|
return 'required';
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
},
|
|
|
|
|
|
triggerFields: ['ioTPlatform', 'ctWingAccountId'],
|
|
|
|
|
|
},
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: postCtWingProductListAsync,
|
|
|
|
|
|
params: (formValues: any) => ({
|
|
|
|
|
|
body: {
|
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
|
ctWingAccountId: formValues.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 为每个产品项添加组合标签,并确保产品ID是字符串类型
|
|
|
|
|
|
return items.map((item: any) => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
ioTPlatformProductId: String(item.ioTPlatformProductId || ''),
|
|
|
|
|
|
label: `${item.productName || ''} (${item.ioTPlatformProductId || ''})`,
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatformProductName')}`,
|
|
|
|
|
|
},
|
|
|
|
|
|
rules: z.string().optional(),
|
|
|
|
|
|
},
|
|
|
|
|
|
]);
|