完善平台端物模型
This commit is contained in:
parent
f61f46a69b
commit
9197411c7b
@ -3693,6 +3693,11 @@ export const DeviceUpgradeRecordDtoSchema = {
|
||||
description: '扩展属性,用于存储自定义字段,JSON格式',
|
||||
nullable: true
|
||||
},
|
||||
deviceDataId: {
|
||||
type: 'string',
|
||||
description: '设备数据Id',
|
||||
format: 'uuid'
|
||||
},
|
||||
deviceName: {
|
||||
type: 'string',
|
||||
description: '设备名称',
|
||||
@ -5958,6 +5963,9 @@ export const IoTPlatformThingModelCreateInputSchema = {
|
||||
type: 'string',
|
||||
description: '物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode',
|
||||
nullable: true
|
||||
},
|
||||
identifierType: {
|
||||
'$ref': '#/components/schemas/ThingModelIdentifierTypeEnum'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
@ -6101,6 +6109,9 @@ export const IoTPlatformThingModelInfoDtoSchema = {
|
||||
type: 'string',
|
||||
description: '物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode',
|
||||
nullable: true
|
||||
},
|
||||
identifierType: {
|
||||
'$ref': '#/components/schemas/ThingModelIdentifierTypeEnum'
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
@ -6178,6 +6189,14 @@ export const IoTPlatformThingModelPageInputSchema = {
|
||||
type: 'boolean',
|
||||
description: '是否可操作标识符',
|
||||
nullable: true
|
||||
},
|
||||
accessMode: {
|
||||
type: 'string',
|
||||
description: '物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode',
|
||||
nullable: true
|
||||
},
|
||||
identifierType: {
|
||||
'$ref': '#/components/schemas/ThingModelIdentifierTypeEnum'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
@ -6246,6 +6265,9 @@ export const IoTPlatformThingModelUpdateInputSchema = {
|
||||
description: '物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode',
|
||||
nullable: true
|
||||
},
|
||||
identifierType: {
|
||||
'$ref': '#/components/schemas/ThingModelIdentifierTypeEnum'
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
format: 'uuid'
|
||||
@ -10860,6 +10882,14 @@ export const TenantDtoPagedResultDtoSchema = {
|
||||
additionalProperties: false
|
||||
} as const;
|
||||
|
||||
export const ThingModelIdentifierTypeEnumSchema = {
|
||||
enum: [1, 2],
|
||||
type: 'integer',
|
||||
description: '设备物模型标识符类型枚举',
|
||||
format: 'int32',
|
||||
'说明:': '数据标识符=1,属性标识符=2'
|
||||
} as const;
|
||||
|
||||
export const TimeZoneSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
||||
@ -2151,6 +2151,10 @@ export type DeviceUpgradeRecordDto = {
|
||||
extraProperties?: {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
/**
|
||||
* 设备数据Id
|
||||
*/
|
||||
deviceDataId?: string;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@ -3067,6 +3071,7 @@ export type IoTPlatformThingModelCreateInput = {
|
||||
* 物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode
|
||||
*/
|
||||
accessMode?: (string) | null;
|
||||
identifierType?: ThingModelIdentifierTypeEnum;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -3160,6 +3165,7 @@ export type IoTPlatformThingModelInfoDto = {
|
||||
* 物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode
|
||||
*/
|
||||
accessMode?: (string) | null;
|
||||
identifierType?: ThingModelIdentifierTypeEnum;
|
||||
};
|
||||
|
||||
export type IoTPlatformThingModelInfoDtoPagedResultDto = {
|
||||
@ -3208,6 +3214,11 @@ export type IoTPlatformThingModelPageInput = {
|
||||
* 是否可操作标识符
|
||||
*/
|
||||
isOperableIdentifier?: (boolean) | null;
|
||||
/**
|
||||
* 物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode
|
||||
*/
|
||||
accessMode?: (string) | null;
|
||||
identifierType?: ThingModelIdentifierTypeEnum;
|
||||
};
|
||||
|
||||
export type IoTPlatformThingModelUpdateInput = {
|
||||
@ -3260,6 +3271,7 @@ export type IoTPlatformThingModelUpdateInput = {
|
||||
* 物模型标识符访问模式 JiShe.ServicePro.Core.DevicePropertyAccessMode
|
||||
*/
|
||||
accessMode?: (string) | null;
|
||||
identifierType?: ThingModelIdentifierTypeEnum;
|
||||
id?: string;
|
||||
};
|
||||
|
||||
@ -5949,6 +5961,11 @@ export type TenantDtoPagedResultDto = {
|
||||
totalCount?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* 设备物模型标识符类型枚举
|
||||
*/
|
||||
export type ThingModelIdentifierTypeEnum = 1 | 2;
|
||||
|
||||
export type TimeZone = {
|
||||
iana?: IanaTimeZone;
|
||||
windows?: WindowsTimeZone;
|
||||
|
||||
@ -228,10 +228,12 @@
|
||||
"StandardFieldDisplayName": "StandardFieldDisplayName",
|
||||
"IsValueNeedConvert": "IsValueNeedConvert",
|
||||
"AccessMode": "AccessMode",
|
||||
"IdentifierType": "IdentifierType",
|
||||
"IsOperableIdentifier": "IsOperableIdentifier",
|
||||
"StandardFieldValueType": "StandardFieldValueType",
|
||||
"copyStandardThingModel": "CopyStandardThingModel",
|
||||
"copyAnotherThingModelModal": "CopyAnotherThingModelModal"
|
||||
"copyAnotherThingModelModal": "CopyAnotherThingModelModal",
|
||||
"ioTPlatformProduct": "IoTPlatformProduct"
|
||||
},
|
||||
"IoTDBBase": {
|
||||
"IoTDataType": "IoTDataType",
|
||||
|
||||
@ -219,12 +219,14 @@
|
||||
"IoTPlatformRawFieldName": "平台物模型编码",
|
||||
"StandardFieldName": "标准物模型编码",
|
||||
"StandardFieldDisplayName": "标准物模型名称",
|
||||
"IsValueNeedConvert": "是否需要值类型转换",
|
||||
"IsValueNeedConvert": "是否值类型转换",
|
||||
"AccessMode": "访问模式",
|
||||
"IsOperableIdentifier": "是否可操作物模型标识符",
|
||||
"IdentifierType": "标识符类型",
|
||||
"IsOperableIdentifier": "是否可操作标识符",
|
||||
"StandardFieldValueType": "标准物模型值类型",
|
||||
"copyStandardThingModel": "复制标准模型",
|
||||
"copyAnotherThingModelModal": "复制已有模型"
|
||||
"copyAnotherThingModelModal": "复制已有模型",
|
||||
"ioTPlatformProduct": "所属产品"
|
||||
},
|
||||
"IoTDBBase": {
|
||||
"IoTDataType": "数据类型",
|
||||
|
||||
@ -12,6 +12,7 @@ import { message as Message, Tag } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
getCommonGetSelectList,
|
||||
postIoTplatformThingModelInfoCopyAnotherThingModelAsync,
|
||||
postIoTplatformThingModelInfoCopyStandardThingModel,
|
||||
postIoTplatformThingModelInfoCreateAsync,
|
||||
@ -42,6 +43,41 @@ const productId = ref<string>((route.query.productId as string) || '');
|
||||
const productName = ref<string>((route.query.productName as string) || '');
|
||||
const ioTPlatform = ref<string>((route.query.ioTPlatform as string) || '2');
|
||||
|
||||
// 标识符类型选项映射
|
||||
const identifierTypeMap = ref<Record<number | string, string>>({});
|
||||
|
||||
// 获取标识符类型选项
|
||||
const loadIdentifierTypeOptions = async () => {
|
||||
try {
|
||||
const res = await getCommonGetSelectList({
|
||||
query: {
|
||||
typeName: 'ThingModelIdentifierTypeEnum',
|
||||
},
|
||||
});
|
||||
const items = Array.isArray(res.data)
|
||||
? res.data
|
||||
: Array.isArray(res.data?.items)
|
||||
? res.data.items
|
||||
: Array.isArray(res.data?.data)
|
||||
? res.data.data
|
||||
: [];
|
||||
const map: Record<number | string, string> = {};
|
||||
items.forEach((item: any) => {
|
||||
if (item.key !== undefined && item.value) {
|
||||
map[item.key] = item.value;
|
||||
}
|
||||
});
|
||||
identifierTypeMap.value = map;
|
||||
} catch (error) {
|
||||
console.error('获取标识符类型选项失败:', error);
|
||||
// 使用默认映射
|
||||
identifierTypeMap.value = {
|
||||
1: '数据标识符',
|
||||
2: '属性标识符',
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
schema: querySchema.value,
|
||||
initialValues: {
|
||||
@ -148,6 +184,21 @@ const gridOptions: VxeGridProps<any> = {
|
||||
queryParams.ioTPlatformProductId = String(currentProductId);
|
||||
}
|
||||
|
||||
// 添加访问模式参数
|
||||
if (finalFormValues?.accessMode) {
|
||||
queryParams.accessMode = finalFormValues.accessMode;
|
||||
}
|
||||
|
||||
// 添加标识符类型参数
|
||||
if (
|
||||
finalFormValues?.identifierType !== undefined &&
|
||||
finalFormValues?.identifierType !== null
|
||||
) {
|
||||
queryParams.identifierType = Number.parseInt(
|
||||
String(finalFormValues.identifierType),
|
||||
) as 1 | 2;
|
||||
}
|
||||
|
||||
const { data } = await postIoTplatformThingModelInfoPageAsync({
|
||||
body: queryParams,
|
||||
});
|
||||
@ -237,6 +288,12 @@ const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
||||
...(isEdit ? editRow.value : {}),
|
||||
_ioTPlatform: platformValue,
|
||||
_ioTPlatformProductId: productIdValue,
|
||||
// 确保 identifierType 转换为字符串格式,以便与下拉框的 key 匹配
|
||||
...(isEdit &&
|
||||
editRow.value.identifierType !== undefined &&
|
||||
editRow.value.identifierType !== null && {
|
||||
identifierType: String(editRow.value.identifierType),
|
||||
}),
|
||||
});
|
||||
|
||||
// 手动触发平台物模型编码字段的重新加载
|
||||
@ -423,6 +480,9 @@ watch(
|
||||
|
||||
// 页面初始化时加载数据
|
||||
onMounted(async () => {
|
||||
// 加载标识符类型选项
|
||||
await loadIdentifierTypeOptions();
|
||||
|
||||
// 从路由参数初始化
|
||||
if (route.query.productId) {
|
||||
productId.value = route.query.productId as string;
|
||||
@ -483,9 +543,7 @@ async function submit() {
|
||||
? await gridApi.formApi.getValues()
|
||||
: {};
|
||||
finalProductId =
|
||||
searchFormValues.ioTPlatformProductId ||
|
||||
productId.value ||
|
||||
undefined;
|
||||
searchFormValues.ioTPlatformProductId || productId.value || undefined;
|
||||
if (finalProductId) {
|
||||
finalProductId = String(finalProductId);
|
||||
}
|
||||
@ -521,6 +579,13 @@ async function submit() {
|
||||
// 自动添加平台和产品信息
|
||||
ioTPlatform: finalPlatform,
|
||||
ioTPlatformProductId: finalProductId,
|
||||
// 转换标识符类型为数字类型(如果存在)
|
||||
...(formValues.identifierType !== undefined &&
|
||||
formValues.identifierType !== null && {
|
||||
identifierType: Number.parseInt(
|
||||
String(formValues.identifierType),
|
||||
) as 1 | 2,
|
||||
}),
|
||||
// 编辑时需要添加ID
|
||||
...(isEdit && { id: editRow.value.id }),
|
||||
};
|
||||
@ -562,6 +627,11 @@ async function onEdit(record: any) {
|
||||
...record,
|
||||
_ioTPlatform: platformValue,
|
||||
_ioTPlatformProductId: productIdValue,
|
||||
// 确保 identifierType 转换为字符串格式,以便与下拉框的 key 匹配
|
||||
...(record.identifierType !== undefined &&
|
||||
record.identifierType !== null && {
|
||||
identifierType: String(record.identifierType),
|
||||
}),
|
||||
});
|
||||
|
||||
// 手动触发平台物模型编码字段的重新加载
|
||||
@ -793,6 +863,35 @@ async function onDel(record: any) {
|
||||
" />
|
||||
</template>
|
||||
|
||||
<template #accessMode="{ row }">
|
||||
<component :is="h(
|
||||
Tag,
|
||||
{
|
||||
color:
|
||||
row.accessMode === 'rw'
|
||||
? 'green'
|
||||
: row.accessMode === 'r'
|
||||
? 'orange'
|
||||
: row.accessMode === 'w'
|
||||
? 'red'
|
||||
: 'default',
|
||||
},
|
||||
() =>
|
||||
row.accessMode === 'rw'
|
||||
? '读写模式'
|
||||
: row.accessMode === 'r'
|
||||
? '只读模式'
|
||||
: row.accessMode === 'w'
|
||||
? '只写模式'
|
||||
: '-',
|
||||
)
|
||||
" />
|
||||
</template>
|
||||
|
||||
<template #identifierType="{ row }">
|
||||
{{ identifierTypeMap[row.identifierType] || '-' }}
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
{
|
||||
|
||||
@ -96,6 +96,70 @@ export const querySchema = computed(() => [
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'accessMode',
|
||||
label: $t('abp.thingModelInfos.AccessMode'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'DevicePropertyAccessMode',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.thingModelInfos.AccessMode')}`,
|
||||
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: 'identifierType',
|
||||
label: $t('abp.thingModelInfos.IdentifierType'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'ThingModelIdentifierTypeEnum',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.thingModelInfos.IdentifierType')}`,
|
||||
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: 'Input',
|
||||
fieldName: 'SearchKeyWords',
|
||||
@ -104,6 +168,13 @@ export const querySchema = computed(() => [
|
||||
]);
|
||||
|
||||
export const tableSchema = computed(() => [
|
||||
{
|
||||
field: 'ioTPlatformProductId',
|
||||
title: $t('abp.thingModelInfos.ioTPlatformProduct'),
|
||||
minWidth: 150,
|
||||
showOverflow: 'tooltip',
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'filedTypeName',
|
||||
title: $t('abp.thingModelInfos.FiledType'),
|
||||
@ -167,13 +238,14 @@ export const tableSchema = computed(() => [
|
||||
field: 'accessMode',
|
||||
title: $t('abp.thingModelInfos.AccessMode'),
|
||||
minWidth: 120,
|
||||
formatter: ({ cellValue }: { cellValue: any }) => {
|
||||
return cellValue === 'rw'
|
||||
? '读写模式'
|
||||
: cellValue === 'r'
|
||||
? '只读模式'
|
||||
: '只写模式';
|
||||
},
|
||||
slots: { default: 'accessMode' },
|
||||
},
|
||||
{
|
||||
field: 'identifierType',
|
||||
title: $t('abp.thingModelInfos.IdentifierType'),
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip',
|
||||
slots: { default: 'identifierType' },
|
||||
},
|
||||
{
|
||||
field: 'isOperableIdentifier',
|
||||
@ -511,6 +583,39 @@ export const getAddThingModelFormSchema = (
|
||||
style: { width: 'auto' },
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'identifierType',
|
||||
label: $t('abp.thingModelInfos.IdentifierType'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'ThingModelIdentifierTypeEnum',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder:
|
||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.IdentifierType'),
|
||||
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: 'ioTPlatformRawFieldDataType',
|
||||
@ -872,6 +977,39 @@ export const getEditThingModelFormSchema = (
|
||||
style: { width: 'auto' },
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'identifierType',
|
||||
label: $t('abp.thingModelInfos.IdentifierType'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'ThingModelIdentifierTypeEnum',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder:
|
||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.IdentifierType'),
|
||||
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: 'ioTPlatformRawFieldDataType',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user