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 { postOneNetAccountListAsync } from '#/api-client';
|
2025-07-29 10:06:30 +08:00
|
|
|
import { $t } from '#/locales';
|
2025-07-08 16:04:14 +08:00
|
|
|
|
|
|
|
|
export const querySchema = computed(() => [
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-28 15:24:23 +08:00
|
|
|
fieldName: 'productName',
|
|
|
|
|
label: $t('abp.OneNETManagement.ProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
]);
|
2025-07-28 15:24:23 +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-29 10:06:30 +08:00
|
|
|
field: 'oneNETAccountName',
|
|
|
|
|
title: $t('abp.OneNETManagement.BelongingAccountName'),
|
|
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'ioTPlatformProductId',
|
2025-07-28 15:24:23 +08:00
|
|
|
title: $t('abp.OneNETManagement.OneNETProductId'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-28 15:24:23 +08:00
|
|
|
field: 'productName',
|
|
|
|
|
title: $t('abp.OneNETManagement.ProductName'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-29 10:06:30 +08:00
|
|
|
field: 'productAccesskey',
|
|
|
|
|
title: $t('abp.OneNETManagement.ProductAccesskey'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-29 10:06:30 +08:00
|
|
|
field: 'communicationAddress',
|
|
|
|
|
title: $t('abp.OneNETManagement.CommunicationAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-29 10:06:30 +08:00
|
|
|
field: 'communicationAddressTLS',
|
|
|
|
|
title: $t('abp.OneNETManagement.CommunicationAddressTLS'),
|
2025-07-08 16:04:14 +08:00
|
|
|
minWidth: '150',
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-07-29 10:06:30 +08:00
|
|
|
field: 'isEnabled',
|
2025-07-08 16:04:14 +08:00
|
|
|
title: $t('common.isEnable'),
|
|
|
|
|
minWidth: '150',
|
|
|
|
|
slots: { default: 'isEnable' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: $t('common.action'),
|
|
|
|
|
field: 'action',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
width: '150',
|
|
|
|
|
slots: { default: 'action' },
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
2025-07-28 15:24:23 +08:00
|
|
|
export const addProductFormSchema: any = computed(() => [
|
2025-07-28 16:50:59 +08:00
|
|
|
{
|
|
|
|
|
component: 'ApiSelect',
|
|
|
|
|
fieldName: 'oneNETAccountId',
|
|
|
|
|
label: $t('abp.OneNETManagement.BelongingAccountName'),
|
|
|
|
|
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;
|
2025-07-29 10:06:30 +08:00
|
|
|
|
2025-07-28 16:50:59 +08:00
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-29 10:06:30 +08:00
|
|
|
|
2025-07-28 16:50:59 +08:00
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
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-29 10:06:30 +08:00
|
|
|
fieldName: 'IoTPlatformProductId',
|
2025-07-28 15:24:23 +08:00
|
|
|
label: $t('abp.OneNETManagement.OneNETProductId'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-28 15:24:23 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-29 10:06:30 +08:00
|
|
|
fieldName: 'productAccesskey',
|
|
|
|
|
label: $t('abp.OneNETManagement.ProductAccesskey'),
|
2025-07-28 15:24:23 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-29 10:06:30 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductAccesskey')}`,
|
2025-07-28 15:24:23 +08:00
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-29 10:06:30 +08:00
|
|
|
fieldName: 'communicationAddress',
|
|
|
|
|
label: $t('abp.OneNETManagement.CommunicationAddress'),
|
2025-07-08 16:04:14 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-29 10:06:30 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddress')}`,
|
2025-07-08 16:04:14 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-29 10:06:30 +08:00
|
|
|
fieldName: 'CommunicationAddressTLS',
|
|
|
|
|
label: $t('abp.OneNETManagement.CommunicationAddressTLS'),
|
2025-07-28 15:24:23 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-29 10:06:30 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddressTLS')}`,
|
2025-07-28 15:24:23 +08:00
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
2025-07-29 10:06:30 +08:00
|
|
|
fieldName: 'DeviceThingModelUrl',
|
|
|
|
|
label: $t('abp.OneNETManagement.DeviceThingModelUrl'),
|
2025-07-28 15:24:23 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-29 10:06:30 +08:00
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.DeviceThingModelUrl')}`,
|
2025-07-28 15:24:23 +08:00
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
2025-07-29 10:06:30 +08:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
export const editProductFormSchemaEdit: any = computed(() => [
|
2025-07-08 16:04:14 +08:00
|
|
|
{
|
2025-07-28 16:50:59 +08:00
|
|
|
component: 'ApiSelect',
|
2025-07-29 10:06:30 +08:00
|
|
|
fieldName: 'oneNETAccountId',
|
|
|
|
|
label: $t('abp.OneNETManagement.BelongingAccountName'),
|
2025-07-28 16:50:59 +08:00
|
|
|
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;
|
2025-07-29 10:06:30 +08:00
|
|
|
|
2025-07-28 16:50:59 +08:00
|
|
|
// 确保返回的是数组格式
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-29 10:06:30 +08:00
|
|
|
|
2025-07-28 16:50:59 +08:00
|
|
|
// 如果都不是,返回空数组
|
|
|
|
|
return [];
|
|
|
|
|
},
|
2025-07-29 10:06:30 +08:00
|
|
|
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
2025-07-28 16:50:59 +08:00
|
|
|
},
|
2025-07-28 15:24:23 +08:00
|
|
|
rules: z.string().min(1, {
|
2025-07-29 10:06:30 +08:00
|
|
|
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
2025-07-28 15:24:23 +08:00
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
{
|
2025-07-29 10:06:30 +08:00
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'IoTPlatformProductId',
|
|
|
|
|
label: $t('abp.OneNETManagement.OneNETProductId'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'productAccesskey',
|
|
|
|
|
label: $t('abp.OneNETManagement.ProductAccesskey'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductAccesskey')}`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'communicationAddress',
|
|
|
|
|
label: $t('abp.OneNETManagement.CommunicationAddress'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddress')}`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'CommunicationAddressTLS',
|
|
|
|
|
label: $t('abp.OneNETManagement.CommunicationAddressTLS'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddressTLS')}`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: 'Input',
|
|
|
|
|
fieldName: 'DeviceThingModelUrl',
|
|
|
|
|
label: $t('abp.OneNETManagement.DeviceThingModelUrl'),
|
|
|
|
|
rules: z.string().min(1, {
|
|
|
|
|
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.DeviceThingModelUrl')}`,
|
|
|
|
|
}),
|
2025-07-08 16:04:14 +08:00
|
|
|
},
|
|
|
|
|
]);
|