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-07-28 16:50:59 +08:00
|
|
|
import {
|
|
|
|
|
getCommonGetSelectList,
|
|
|
|
|
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-07-28 16:50:59 +08:00
|
|
|
|
|
|
|
|
export const ioTPlatformOptions = [
|
2025-07-08 16:04:14 +08:00
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
label: 'OneNET',
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
label: 'CTWing',
|
2025-07-08 16:04:14 +08:00
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
label: 'Other',
|
|
|
|
|
value: 0,
|
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-25 17:27:41 +08:00
|
|
|
field: 'deviceName',
|
|
|
|
|
title: $t('abp.deviceInfos.deviceName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
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: 'ioTPlatform',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatform'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformName'),
|
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'),
|
|
|
|
|
minWidth: '100',
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +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: 'ioTPlatformProductName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-25 17:27:41 +08:00
|
|
|
field: 'ioTPlatformAccountName',
|
|
|
|
|
title: $t('abp.deviceInfos.ioTPlatformAccountName'),
|
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',
|
|
|
|
|
width: '150',
|
|
|
|
|
slots: { default: 'action' },
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
2025-07-25 17:27:41 +08:00
|
|
|
export const addDeviceFormSchema: any = computed(() => [
|
2025-07-08 16:04:14 +08:00
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
component: 'ApiSelect',
|
|
|
|
|
fieldName: 'IoTPlatform',
|
|
|
|
|
label: $t('common.IoTPlatform'),
|
|
|
|
|
componentProps: {
|
|
|
|
|
api: getCommonGetSelectList,
|
|
|
|
|
params: {
|
|
|
|
|
query: {
|
|
|
|
|
typeName: 'IoTPlatformTypeEnum',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
labelField: 'value',
|
|
|
|
|
valueField: 'key',
|
|
|
|
|
optionsPropName: 'options',
|
|
|
|
|
immediate: true,
|
|
|
|
|
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-28 16:50:59 +08:00
|
|
|
message: `${$t('common.pleaseSelect')}${$t('common.IoTPlatform')}`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
fieldName: 'ioTPlatformProductId',
|
|
|
|
|
label: $t('abp.OneNETManagement.BelongingProductName'),
|
|
|
|
|
componentProps: {
|
|
|
|
|
api: postOneNetProductListAsync,
|
|
|
|
|
params: {
|
|
|
|
|
body: {
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
labelField: 'ProductName',
|
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
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.OneNETManagement.BelongingAccountName')}`,
|
|
|
|
|
},
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
rules: z.string().min(1, {
|
2025-07-28 16:50:59 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
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',
|
|
|
|
|
fieldName: 'IoTPlatform',
|
|
|
|
|
label: $t('common.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-28 16:50:59 +08:00
|
|
|
component: 'ApiSelect',
|
|
|
|
|
fieldName: 'ioTPlatformProductId',
|
|
|
|
|
label: $t('abp.OneNETManagement.BelongingProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
componentProps: {
|
2025-07-28 16:50:59 +08:00
|
|
|
api: postOneNetProductListAsync,
|
|
|
|
|
params: {
|
|
|
|
|
body: {
|
|
|
|
|
pageIndex: 1,
|
|
|
|
|
pageSize: 1000,
|
|
|
|
|
},
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
2025-07-28 16:50:59 +08:00
|
|
|
labelField: 'ProductName',
|
|
|
|
|
valueField: 'ioTPlatformProductId',
|
|
|
|
|
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.OneNETManagement.BelongingAccountName')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
2025-07-28 16:50:59 +08:00
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
|
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-28 16:50:59 +08:00
|
|
|
fieldName: 'deviceName',
|
|
|
|
|
label: $t('abp.deviceInfos.deviceName'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceName')}`,
|
|
|
|
|
}),
|
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
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-28 16:50:59 +08:00
|
|
|
fieldName: 'platformPassword',
|
|
|
|
|
label: $t('abp.deviceInfos.platformPassword'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`,
|
|
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
]);
|