平台产品聚合服务

This commit is contained in:
ChenYi 2025-12-17 15:51:26 +08:00
parent fdc07134a8
commit 288b153e43
5 changed files with 266 additions and 25 deletions

View File

@ -5154,6 +5154,38 @@ export const IoTDBDynamicObjectPagedResultDtoSchema = {
additionalProperties: false
} as const;
export const IoTPlatformProductInfoInputSchema = {
type: 'object',
properties: {
ioTPlatformType: {
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
}
},
additionalProperties: false,
description: '产品信息输入'
} as const;
export const IoTPlatformProductInfoOutputSchema = {
type: 'object',
properties: {
ioTPlatformType: {
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
},
ioTPlatformProductId: {
type: 'string',
description: '物联网平台对应的产品Id',
nullable: true
},
productName: {
type: 'string',
description: '产品名称',
nullable: true
}
},
additionalProperties: false,
description: '平台产品信息'
} as const;
export const IoTPlatformThingModelCreateInputSchema = {
type: 'object',
properties: {

File diff suppressed because one or more lines are too long

View File

@ -2561,6 +2561,28 @@ export type IoTDBDynamicObjectPagedResultDto = {
totalCount?: number;
};
/**
*
*/
export type IoTPlatformProductInfoInput = {
ioTPlatformType?: IoTPlatformTypeEnum;
};
/**
*
*/
export type IoTPlatformProductInfoOutput = {
ioTPlatformType?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
*
*/
productName?: (string) | null;
};
export type IoTPlatformThingModelCreateInput = {
ioTPlatform?: IoTPlatformTypeEnum;
/**
@ -6175,6 +6197,16 @@ export type PostIdentitySecurityLogsPageResponse = (PagingIdentitySecurityLogOut
export type PostIdentitySecurityLogsPageError = (RemoteServiceErrorResponse);
export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncData = {
query?: {
input?: IoTPlatformProductInfoInput;
};
};
export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncResponse = (Array<IoTPlatformProductInfoOutput>);
export type PostAggregationIoTplatformGetIoTplatformProductInfoAsyncError = unknown;
export type PostIoTplatformThingModelInfoCreateAsyncData = {
query?: {
input?: IoTPlatformThingModelCreateInput;

View File

@ -12,12 +12,14 @@ import { message as Message, Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
postCtWingProductListAsync,
postIoTplatformThingModelInfoCopyAnotherThingModelAsync,
postIoTplatformThingModelInfoCopyStandardThingModel,
postIoTplatformThingModelInfoCreateAsync,
postIoTplatformThingModelInfoDeleteAsync,
postIoTplatformThingModelInfoPageAsync,
postIoTplatformThingModelInfoUpdateAsync,
postOneNetProductListAsync,
} from '#/api-client';
import { TableAction } from '#/components/table-action';
import { $t } from '#/locales';
@ -43,6 +45,76 @@ const ioTPlatform = ref<string>((route.query.ioTPlatform as string) || '2');
const formOptions: VbenFormProps = {
schema: querySchema.value,
initialValues: {
ioTPlatform: route.query.ioTPlatform ? String(route.query.ioTPlatform) : undefined,
ioTPlatformProductId: route.query.productId ? String(route.query.productId) : undefined,
},
submitOnChange: false,
handleValuesChange: async (values, changedFields) => {
// ID
if (changedFields.includes('ioTPlatform')) {
if (values.ioTPlatform) {
ioTPlatform.value = String(values.ioTPlatform);
// ID
if (gridApi?.formApi) {
await gridApi.formApi.setValues({
ioTPlatformProductId: undefined,
});
}
productId.value = '';
productName.value = '';
}
}
// ID
if (changedFields.includes('ioTPlatformProductId')) {
if (values.ioTPlatformProductId) {
productId.value = String(values.ioTPlatformProductId);
//
const platform = values.ioTPlatform;
if (platform) {
try {
const api = platform === 2 || platform === '2'
? postOneNetProductListAsync
: platform === 1 || platform === '1'
? postCtWingProductListAsync
: null;
if (api) {
const { data } = await api({
body: {
pageIndex: 1,
pageSize: 1000,
},
});
const items = data?.items || [];
const selectedProduct = items.find((item: any) =>
String(item.ioTPlatformProductId) === String(values.ioTPlatformProductId)
);
if (selectedProduct) {
productName.value = selectedProduct.productName || '';
}
}
} catch (error) {
console.error('获取产品名称失败:', error);
}
}
} else {
productId.value = '';
productName.value = '';
}
//
setTimeout(async () => {
if (gridApi && gridApi.reload) {
try {
await gridApi.reload();
} catch (error) {
console.error('重新加载数据时出错:', error);
}
}
}, 100);
}
},
};
const gridOptions: VxeGridProps<any> = {
@ -63,8 +135,12 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
// 使使
const currentPlatform = formValues?.ioTPlatform || ioTPlatform.value;
const currentProductId = formValues?.ioTPlatformProductId || productId.value;
// ID
if (!productId.value) {
if (!currentProductId || !currentPlatform) {
hasData.value = false;
return {
items: [],
@ -74,14 +150,12 @@ const gridOptions: VxeGridProps<any> = {
try {
const { data } = await postIoTplatformThingModelInfoPageAsync({
query: {
input: {
pageIndex: page.currentPage,
pageSize: page.pageSize,
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
},
body: {
pageIndex: page.currentPage,
pageSize: page.pageSize,
ioTPlatform: Number.parseInt(String(currentPlatform)) as 1 | 2,
ioTPlatformProductId: String(currentProductId),
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
},
});
//
@ -235,6 +309,21 @@ onMounted(async () => {
setTimeout(async () => {
if (gridApi && gridApi.reload) {
try {
//
if (route.query.ioTPlatform || route.query.productId) {
const formValues = await gridApi.formApi.getValues();
if (route.query.ioTPlatform && !formValues.ioTPlatform) {
await gridApi.formApi.setValues({
ioTPlatform: route.query.ioTPlatform,
});
}
if (route.query.productId && !formValues.ioTPlatformProductId) {
await gridApi.formApi.setValues({
ioTPlatformProductId: route.query.productId,
});
}
await nextTick();
}
await gridApi.reload();
} catch (error) {
console.error('初始化加载数据时出错:', error);
@ -270,7 +359,7 @@ async function submit() {
};
try {
const resp = await api({ query: { input: fetchParams } });
const resp = await api({ body: fetchParams });
if (resp.data) {
Message.success(
editRow.value.id ? $t('common.editSuccess') : $t('common.addSuccess'),
@ -335,12 +424,10 @@ async function submitCopy() {
try {
const resp = await postIoTplatformThingModelInfoCopyAnotherThingModelAsync({
query: {
input: {
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
sourceProductId: formValues.ioTPlatformProductId,
},
body: {
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
sourceProductId: formValues.ioTPlatformProductId,
},
});
@ -361,9 +448,7 @@ async function submitCopy() {
async function onDel(record: any) {
try {
const resp = await postIoTplatformThingModelInfoDeleteAsync({
query: {
input: { id: record.id },
},
body: { id: record.id },
});
if (resp.data) {
Message.success($t('common.deleteSuccess'));
@ -387,11 +472,9 @@ async function copyStandardThingModel() {
try {
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
query: {
input: {
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
},
body: {
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
},
});
if (resp.data) {

View File

@ -6,11 +6,95 @@ import dayjs from 'dayjs';
import {
getCommonGetSelectList,
postAggregationIoTplatformGetIoTplatformProductInfoAsync,
postOneNetProductListAsync,
} from '#/api-client';
import { $t } from '#/locales';
export const querySchema = computed(() => [
{
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;
}
if (res && Array.isArray(res.items)) {
return res.items;
}
if (res && Array.isArray(res.data)) {
return res.data;
}
return [];
},
},
},
{
component: 'ApiSelect',
fieldName: 'ioTPlatformProductId',
label: $t('common.BelongingProductName'),
dependencies: {
show(values: any) {
return !!values.ioTPlatform;
},
triggerFields: ['ioTPlatform'],
},
componentProps: (formValues: any) => {
const platform = formValues?.ioTPlatform;
return {
api: platform
? postAggregationIoTplatformGetIoTplatformProductInfoAsync
: null,
params: {
body: {
// 聚合服务要求 JSON Body 格式参数
ioTPlatformType:
typeof platform === 'string'
? Number.parseInt(platform)
: platform,
},
},
labelField: 'productName',
valueField: 'ioTPlatformProductId',
optionsPropName: 'options',
immediate: false,
allowClear: true,
placeholder: `${$t('common.pleaseSelect')}${$t('common.BelongingProductName')}`,
afterFetch: (res: any) => {
// 确保返回的是数组格式
if (Array.isArray(res)) {
return res;
}
if (res && Array.isArray(res.items)) {
return res.items;
}
if (res && Array.isArray(res.data)) {
return res.data;
}
if (res && res.data && Array.isArray(res.data.items)) {
return res.data.items;
}
return [];
},
};
},
},
{
component: 'Input',
fieldName: 'SearchKeyWords',