完善设备端物模型管理
This commit is contained in:
parent
0ffc2a3098
commit
142584be52
@ -1312,20 +1312,23 @@ export const CopyIoTPlatformThingModelToDeviceInputSchema = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const CopyStandardThingModelInputSchema = {
|
export const CopyStandardThingModelInputSchema = {
|
||||||
|
required: ['filedTypes', 'ioTPlatform', 'ioTPlatformProductId'],
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
filedType: {
|
filedTypes: {
|
||||||
type: 'string',
|
type: 'array',
|
||||||
description: '物联网平台中对应产品物模型属性或者事件类型 JiShe.ServicePro.Core.DataDictionaryTypeConst',
|
items: {
|
||||||
nullable: true
|
type: 'string'
|
||||||
|
},
|
||||||
|
description: '物联网平台中对应产品物模型属性或者事件类型 JiShe.ServicePro.Core.DataDictionaryTypeConst'
|
||||||
},
|
},
|
||||||
ioTPlatform: {
|
ioTPlatform: {
|
||||||
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
|
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
|
||||||
},
|
},
|
||||||
ioTPlatformProductId: {
|
ioTPlatformProductId: {
|
||||||
|
minLength: 1,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: '平台产品ID',
|
description: '平台产品ID'
|
||||||
nullable: true
|
|
||||||
},
|
},
|
||||||
dataDictionaries: {
|
dataDictionaries: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
@ -2990,6 +2993,11 @@ export const DeviceThingModelPropertyInfoDtoSchema = {
|
|||||||
description: '反转获取数量',
|
description: '反转获取数量',
|
||||||
format: 'int32',
|
format: 'int32',
|
||||||
nullable: true
|
nullable: true
|
||||||
|
},
|
||||||
|
filedTypeName: {
|
||||||
|
type: 'string',
|
||||||
|
description: '物模型属性或者事件类型名称',
|
||||||
|
nullable: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
@ -5492,6 +5500,11 @@ export const IoTPlatformThingModelInfoDtoSchema = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
description: '物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型',
|
description: '物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型',
|
||||||
nullable: true
|
nullable: true
|
||||||
|
},
|
||||||
|
filedTypeName: {
|
||||||
|
type: 'string',
|
||||||
|
description: '物模型属性或者事件类型名称',
|
||||||
|
nullable: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
|
|||||||
@ -547,7 +547,7 @@ export const postDeviceThingModelManagementBuildAnalysisScriptAsync = <ThrowOnEr
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据物模型ID将解析脚本更新Redis并发布订阅
|
* 根据物模型ID和解析标识决定是否将解析脚本更新Redis并发布订阅
|
||||||
*/
|
*/
|
||||||
export const postDeviceThingModelManagementUpdateAnalysisScriptByIdAsync = <ThrowOnError extends boolean = false>(options?: Options<PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncData, ThrowOnError>) => {
|
export const postDeviceThingModelManagementUpdateAnalysisScriptByIdAsync = <ThrowOnError extends boolean = false>(options?: Options<PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncData, ThrowOnError>) => {
|
||||||
return (options?.client ?? client).post<PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncResponse, PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncError, ThrowOnError>({
|
return (options?.client ?? client).post<PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncResponse, PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncError, ThrowOnError>({
|
||||||
|
|||||||
@ -302,12 +302,12 @@ export type CopyStandardThingModelInput = {
|
|||||||
/**
|
/**
|
||||||
* 物联网平台中对应产品物模型属性或者事件类型 JiShe.ServicePro.Core.DataDictionaryTypeConst
|
* 物联网平台中对应产品物模型属性或者事件类型 JiShe.ServicePro.Core.DataDictionaryTypeConst
|
||||||
*/
|
*/
|
||||||
filedType?: (string) | null;
|
filedTypes: Array<(string)>;
|
||||||
ioTPlatform?: IoTPlatformTypeEnum;
|
ioTPlatform: IoTPlatformTypeEnum;
|
||||||
/**
|
/**
|
||||||
* 平台产品ID
|
* 平台产品ID
|
||||||
*/
|
*/
|
||||||
ioTPlatformProductId?: (string) | null;
|
ioTPlatformProductId: string;
|
||||||
/**
|
/**
|
||||||
* 标准物模型集合
|
* 标准物模型集合
|
||||||
*/
|
*/
|
||||||
@ -1712,6 +1712,10 @@ export type DeviceThingModelPropertyInfoDto = {
|
|||||||
* 反转获取数量
|
* 反转获取数量
|
||||||
*/
|
*/
|
||||||
reversalTakeNumber?: (number) | null;
|
reversalTakeNumber?: (number) | null;
|
||||||
|
/**
|
||||||
|
* 物模型属性或者事件类型名称
|
||||||
|
*/
|
||||||
|
filedTypeName?: (string) | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeviceThingModelPropertyInfoDtoPagedResultDto = {
|
export type DeviceThingModelPropertyInfoDtoPagedResultDto = {
|
||||||
@ -2782,6 +2786,10 @@ export type IoTPlatformThingModelInfoDto = {
|
|||||||
* 物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型
|
* 物联网平台中对应产品物模型标识符扩展,用于扩展结构体类型
|
||||||
*/
|
*/
|
||||||
ioTPlatformRawFieldExtension?: (string) | null;
|
ioTPlatformRawFieldExtension?: (string) | null;
|
||||||
|
/**
|
||||||
|
* 物模型属性或者事件类型名称
|
||||||
|
*/
|
||||||
|
filedTypeName?: (string) | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IoTPlatformThingModelInfoDtoPagedResultDto = {
|
export type IoTPlatformThingModelInfoDtoPagedResultDto = {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
field: 'filedType',
|
field: 'filedTypeName',
|
||||||
title: '物模型类型',
|
title: '物模型类型',
|
||||||
minWidth: 160,
|
minWidth: 160,
|
||||||
showOverflow: 'tooltip',
|
showOverflow: 'tooltip',
|
||||||
@ -223,6 +223,7 @@ const [EditPropertyFormModal, editPropertyFormModalApi] = useVbenModal({
|
|||||||
// 快速复制平台端物模型属性弹窗
|
// 快速复制平台端物模型属性弹窗
|
||||||
const [CopyPropertyModal, copyPropertyModalApi] = useVbenModal({
|
const [CopyPropertyModal, copyPropertyModalApi] = useVbenModal({
|
||||||
draggable: true,
|
draggable: true,
|
||||||
|
centered: true,
|
||||||
footer: true,
|
footer: true,
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
showConfirmButton: true,
|
showConfirmButton: true,
|
||||||
@ -598,16 +599,16 @@ watch(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// 快速复制表单(选择平台和产品)
|
// 快速复制表单(选择平台和产品,纵向单列布局)
|
||||||
const [CopyPropertyForm, copyPropertyFormApi] = useVbenForm({
|
const [CopyPropertyForm, copyPropertyFormApi] = useVbenForm({
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
labelWidth: 140,
|
labelWidth: 140,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-4/5',
|
class: 'w-full',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
layout: 'horizontal',
|
layout: 'vertical',
|
||||||
schema: [
|
schema: [
|
||||||
{
|
{
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
@ -690,7 +691,7 @@ const [CopyPropertyForm, copyPropertyFormApi] = useVbenForm({
|
|||||||
],
|
],
|
||||||
showCollapseButton: false,
|
showCollapseButton: false,
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-1',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 快速复制设备端物模型表单
|
// 快速复制设备端物模型表单
|
||||||
|
|||||||
@ -634,7 +634,6 @@ onMounted(async () => {
|
|||||||
auth: ['AbpIdentity.Users.Update'],
|
auth: ['AbpIdentity.Users.Update'],
|
||||||
onClick: openPropertyModal.bind(null, row),
|
onClick: openPropertyModal.bind(null, row),
|
||||||
},
|
},
|
||||||
]" :drop-down-actions="[
|
|
||||||
{
|
{
|
||||||
label: '指令管理',
|
label: '指令管理',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
@ -642,6 +641,7 @@ onMounted(async () => {
|
|||||||
auth: ['AbpIdentity.Users.Update'],
|
auth: ['AbpIdentity.Users.Update'],
|
||||||
onClick: openCommandModal.bind(null, row),
|
onClick: openCommandModal.bind(null, row),
|
||||||
},
|
},
|
||||||
|
]" :drop-down-actions="[
|
||||||
{
|
{
|
||||||
label: row.functionAnalysisFlag ? '禁用解析' : '启用解析',
|
label: row.functionAnalysisFlag ? '禁用解析' : '启用解析',
|
||||||
type: 'input',
|
type: 'input',
|
||||||
|
|||||||
@ -152,7 +152,7 @@ export const tableSchema = computed(() => [
|
|||||||
{
|
{
|
||||||
field: 'action',
|
field: 'action',
|
||||||
title: $t('common.action'),
|
title: $t('common.action'),
|
||||||
width: 160,
|
width: 250,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
},
|
},
|
||||||
|
|||||||
@ -23,8 +23,9 @@ import { TableAction } from '#/components/table-action';
|
|||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getAddThingModelFormSchema,
|
copyStandardThingModelFormSchema,
|
||||||
copyThingModelFormSchema,
|
copyThingModelFormSchema,
|
||||||
|
getAddThingModelFormSchema,
|
||||||
getEditThingModelFormSchema,
|
getEditThingModelFormSchema,
|
||||||
querySchema,
|
querySchema,
|
||||||
tableSchema,
|
tableSchema,
|
||||||
@ -44,14 +45,17 @@ const ioTPlatform = ref<string>((route.query.ioTPlatform as string) || '2');
|
|||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
schema: querySchema.value,
|
schema: querySchema.value,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
ioTPlatform: route.query.ioTPlatform ? String(route.query.ioTPlatform) : undefined,
|
ioTPlatform: route.query.ioTPlatform
|
||||||
ioTPlatformProductId: route.query.productId ? String(route.query.productId) : undefined,
|
? String(route.query.ioTPlatform)
|
||||||
|
: undefined,
|
||||||
|
ioTPlatformProductId: route.query.productId
|
||||||
|
? String(route.query.productId)
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
submitOnChange: false,
|
submitOnChange: false,
|
||||||
handleValuesChange: async (values, changedFields) => {
|
handleValuesChange: async (values, changedFields) => {
|
||||||
// 当平台类型变化时,清空产品ID
|
// 当平台类型变化时,清空产品ID
|
||||||
if (changedFields.includes('ioTPlatform')) {
|
if (changedFields.includes('ioTPlatform') && values.ioTPlatform) {
|
||||||
if (values.ioTPlatform) {
|
|
||||||
ioTPlatform.value = String(values.ioTPlatform);
|
ioTPlatform.value = String(values.ioTPlatform);
|
||||||
// 清空产品ID,因为平台变化了
|
// 清空产品ID,因为平台变化了
|
||||||
if (gridApi?.formApi) {
|
if (gridApi?.formApi) {
|
||||||
@ -62,7 +66,6 @@ const formOptions: VbenFormProps = {
|
|||||||
productId.value = '';
|
productId.value = '';
|
||||||
productName.value = '';
|
productName.value = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 当产品ID变化时,更新响应式变量并重新加载数据
|
// 当产品ID变化时,更新响应式变量并重新加载数据
|
||||||
if (changedFields.includes('ioTPlatformProductId')) {
|
if (changedFields.includes('ioTPlatformProductId')) {
|
||||||
@ -115,7 +118,7 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
: formValues || {};
|
: formValues || {};
|
||||||
|
|
||||||
// 优先使用从表单API获取的值(最新的),如果没有则使用传入的formValues
|
// 优先使用从表单API获取的值(最新的),如果没有则使用传入的formValues
|
||||||
const finalFormValues = { ...(formValues || {}), ...currentFormValues };
|
const finalFormValues = { ...formValues, ...currentFormValues };
|
||||||
|
|
||||||
const currentPlatform = finalFormValues?.ioTPlatform;
|
const currentPlatform = finalFormValues?.ioTPlatform;
|
||||||
const currentProductId = finalFormValues?.ioTPlatformProductId;
|
const currentProductId = finalFormValues?.ioTPlatformProductId;
|
||||||
@ -135,7 +138,9 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
|
|
||||||
// 添加平台参数(必须)
|
// 添加平台参数(必须)
|
||||||
if (currentPlatform) {
|
if (currentPlatform) {
|
||||||
queryParams.ioTPlatform = Number.parseInt(String(currentPlatform)) as 1 | 2;
|
queryParams.ioTPlatform = Number.parseInt(
|
||||||
|
String(currentPlatform),
|
||||||
|
) as 1 | 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加产品ID参数(必须)
|
// 添加产品ID参数(必须)
|
||||||
@ -192,19 +197,21 @@ const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
|||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
// 编辑时从 editRow.value 获取
|
// 编辑时从 editRow.value 获取
|
||||||
platformValue = editRow.value.ioTPlatform
|
platformValue = editRow.value.ioTPlatform
|
||||||
? (typeof editRow.value.ioTPlatform === 'string'
|
? ((typeof editRow.value.ioTPlatform === 'string'
|
||||||
? Number.parseInt(editRow.value.ioTPlatform)
|
? Number.parseInt(editRow.value.ioTPlatform)
|
||||||
: editRow.value.ioTPlatform) as 1 | 2
|
: editRow.value.ioTPlatform) as 1 | 2)
|
||||||
: Number.parseInt(ioTPlatform.value) as 1 | 2;
|
: (Number.parseInt(ioTPlatform.value) as 1 | 2);
|
||||||
productIdValue = editRow.value.ioTPlatformProductId || productId.value;
|
productIdValue = editRow.value.ioTPlatformProductId || productId.value;
|
||||||
} else {
|
} else {
|
||||||
// 新增时从搜索表单获取最新的值
|
// 新增时从搜索表单获取最新的值
|
||||||
const formValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
|
const formValues = gridApi?.formApi
|
||||||
|
? await gridApi.formApi.getValues()
|
||||||
|
: {};
|
||||||
platformValue = formValues.ioTPlatform
|
platformValue = formValues.ioTPlatform
|
||||||
? (typeof formValues.ioTPlatform === 'string'
|
? ((typeof formValues.ioTPlatform === 'string'
|
||||||
? Number.parseInt(formValues.ioTPlatform)
|
? Number.parseInt(formValues.ioTPlatform)
|
||||||
: formValues.ioTPlatform) as 1 | 2
|
: formValues.ioTPlatform) as 1 | 2)
|
||||||
: Number.parseInt(ioTPlatform.value) as 1 | 2;
|
: (Number.parseInt(ioTPlatform.value) as 1 | 2);
|
||||||
productIdValue = formValues.ioTPlatformProductId || productId.value;
|
productIdValue = formValues.ioTPlatformProductId || productId.value;
|
||||||
|
|
||||||
// 同步更新响应式变量
|
// 同步更新响应式变量
|
||||||
@ -231,7 +238,9 @@ const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
|||||||
|
|
||||||
// 手动触发平台物模型编码字段的重新加载
|
// 手动触发平台物模型编码字段的重新加载
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const fieldRef = formApi.getFieldComponentRef('ioTPlatformRawFieldName');
|
const fieldRef = formApi.getFieldComponentRef(
|
||||||
|
'ioTPlatformRawFieldName',
|
||||||
|
);
|
||||||
if (fieldRef && typeof fieldRef.updateParam === 'function') {
|
if (fieldRef && typeof fieldRef.updateParam === 'function') {
|
||||||
fieldRef.updateParam({
|
fieldRef.updateParam({
|
||||||
body: {
|
body: {
|
||||||
@ -262,12 +271,29 @@ const [CopyModal, copyModalApi] = useVbenModal({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 复制标准模型弹窗
|
||||||
|
const [CopyStandardModal, copyStandardModalApi] = useVbenModal({
|
||||||
|
draggable: true,
|
||||||
|
footer: true,
|
||||||
|
showCancelButton: true,
|
||||||
|
showConfirmButton: true,
|
||||||
|
onConfirm: submitCopyStandard,
|
||||||
|
onBeforeClose: () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
onCancel: () => {
|
||||||
|
copyStandardModalApi.close();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// 创建新增表单 schema(传入获取平台和产品ID的函数,作为后备方案)
|
// 创建新增表单 schema(传入获取平台和产品ID的函数,作为后备方案)
|
||||||
// 注意:实际使用时,值会从表单的 _ioTPlatform 和 _ioTPlatformProductId 字段获取
|
// 注意:实际使用时,值会从表单的 _ioTPlatform 和 _ioTPlatformProductId 字段获取
|
||||||
const addThingModelFormSchema = getAddThingModelFormSchema(
|
const addThingModelFormSchema = getAddThingModelFormSchema(
|
||||||
() => {
|
() => {
|
||||||
// 作为后备方案,返回响应式变量的值
|
// 作为后备方案,返回响应式变量的值
|
||||||
return ioTPlatform.value ? Number.parseInt(ioTPlatform.value) as 1 | 2 : undefined;
|
return ioTPlatform.value
|
||||||
|
? (Number.parseInt(ioTPlatform.value) as 1 | 2)
|
||||||
|
: undefined;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
// 作为后备方案,返回响应式变量的值
|
// 作为后备方案,返回响应式变量的值
|
||||||
@ -301,7 +327,9 @@ const editThingModelFormSchema = getEditThingModelFormSchema(
|
|||||||
: editRow.value.ioTPlatform;
|
: editRow.value.ioTPlatform;
|
||||||
}
|
}
|
||||||
// 如果没有,使用响应式变量
|
// 如果没有,使用响应式变量
|
||||||
return ioTPlatform.value ? Number.parseInt(ioTPlatform.value) as 1 | 2 : undefined;
|
return ioTPlatform.value
|
||||||
|
? (Number.parseInt(ioTPlatform.value) as 1 | 2)
|
||||||
|
: undefined;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
// 编辑时优先从 editRow 获取
|
// 编辑时优先从 editRow 获取
|
||||||
@ -340,6 +368,22 @@ const [CopyForm, copyFormApi] = useVbenForm({
|
|||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 复制标准模型表单(多选物模型类型)
|
||||||
|
const [CopyStandardForm, copyStandardFormApi] = useVbenForm({
|
||||||
|
collapsed: false,
|
||||||
|
commonConfig: {
|
||||||
|
labelWidth: 160,
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-4/5',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: copyStandardThingModelFormSchema.value,
|
||||||
|
showCollapseButton: false,
|
||||||
|
showDefaultActions: false,
|
||||||
|
wrapperClass: 'grid-cols-1',
|
||||||
|
});
|
||||||
|
|
||||||
// 监听路由参数变化,自动加载数据
|
// 监听路由参数变化,自动加载数据
|
||||||
watch(
|
watch(
|
||||||
() => [route.query.productId, route.query.ioTPlatform],
|
() => [route.query.productId, route.query.ioTPlatform],
|
||||||
@ -451,9 +495,6 @@ async function submit() {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('提交失败:', error);
|
console.error('提交失败:', error);
|
||||||
Message.error(
|
|
||||||
editRow.value.id ? $t('common.editFail') : $t('common.addFail'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,10 +502,10 @@ async function onEdit(record: any) {
|
|||||||
editRow.value = record;
|
editRow.value = record;
|
||||||
// 编辑时从选中对象获取平台和产品ID
|
// 编辑时从选中对象获取平台和产品ID
|
||||||
const platformValue = record.ioTPlatform
|
const platformValue = record.ioTPlatform
|
||||||
? (typeof record.ioTPlatform === 'string'
|
? ((typeof record.ioTPlatform === 'string'
|
||||||
? Number.parseInt(record.ioTPlatform)
|
? Number.parseInt(record.ioTPlatform)
|
||||||
: record.ioTPlatform) as 1 | 2
|
: record.ioTPlatform) as 1 | 2)
|
||||||
: Number.parseInt(ioTPlatform.value) as 1 | 2;
|
: (Number.parseInt(ioTPlatform.value) as 1 | 2);
|
||||||
const productIdValue = record.ioTPlatformProductId || productId.value;
|
const productIdValue = record.ioTPlatformProductId || productId.value;
|
||||||
|
|
||||||
thingModelModalApi.open();
|
thingModelModalApi.open();
|
||||||
@ -477,7 +518,9 @@ async function onEdit(record: any) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 手动触发平台物模型编码字段的重新加载
|
// 手动触发平台物模型编码字段的重新加载
|
||||||
const fieldRef = editFormApi.getFieldComponentRef('ioTPlatformRawFieldName');
|
const fieldRef = editFormApi.getFieldComponentRef(
|
||||||
|
'ioTPlatformRawFieldName',
|
||||||
|
);
|
||||||
if (fieldRef && typeof fieldRef.updateParam === 'function') {
|
if (fieldRef && typeof fieldRef.updateParam === 'function') {
|
||||||
fieldRef.updateParam({
|
fieldRef.updateParam({
|
||||||
body: {
|
body: {
|
||||||
@ -494,10 +537,10 @@ const openAddModal = async () => {
|
|||||||
// 打开新增弹窗时,从搜索表单中获取平台和产品ID(确保是最新的值)
|
// 打开新增弹窗时,从搜索表单中获取平台和产品ID(确保是最新的值)
|
||||||
const formValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
|
const formValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
|
||||||
const platformValue = formValues.ioTPlatform
|
const platformValue = formValues.ioTPlatform
|
||||||
? (typeof formValues.ioTPlatform === 'string'
|
? ((typeof formValues.ioTPlatform === 'string'
|
||||||
? Number.parseInt(formValues.ioTPlatform)
|
? Number.parseInt(formValues.ioTPlatform)
|
||||||
: formValues.ioTPlatform) as 1 | 2
|
: formValues.ioTPlatform) as 1 | 2)
|
||||||
: Number.parseInt(ioTPlatform.value) as 1 | 2;
|
: (Number.parseInt(ioTPlatform.value) as 1 | 2);
|
||||||
const productIdValue = formValues.ioTPlatformProductId || productId.value;
|
const productIdValue = formValues.ioTPlatformProductId || productId.value;
|
||||||
|
|
||||||
// 更新响应式变量(保持同步)
|
// 更新响应式变量(保持同步)
|
||||||
@ -580,7 +623,59 @@ async function submitCopy() {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('复制模型失败:', error);
|
console.error('复制模型失败:', error);
|
||||||
Message.error('复制模型失败');
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开复制标准模型模态框(逻辑与“复制已有模型”保持一致)
|
||||||
|
const openCopyStandardThingModelModal = () => {
|
||||||
|
console.log('打开复制标准模型模态框,当前参数:', {
|
||||||
|
productId: productId.value,
|
||||||
|
productName: productName.value,
|
||||||
|
ioTPlatform: ioTPlatform.value,
|
||||||
|
});
|
||||||
|
copyStandardModalApi.open();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 复制标准模型提交逻辑(带物模型类型多选)
|
||||||
|
async function submitCopyStandard() {
|
||||||
|
// 检查是否有产品ID
|
||||||
|
if (!productId.value) {
|
||||||
|
Message.error('产品ID不存在,无法复制标准模型');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { valid } = await copyStandardFormApi.validate();
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
const formValues = await copyStandardFormApi.getValues();
|
||||||
|
|
||||||
|
console.log('复制标准模型提交参数:', {
|
||||||
|
formValues,
|
||||||
|
params: {
|
||||||
|
productId: productId.value,
|
||||||
|
productName: productName.value,
|
||||||
|
ioTPlatform: ioTPlatform.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
|
||||||
|
body: {
|
||||||
|
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||||
|
ioTPlatformProductId: productId.value,
|
||||||
|
// 按物模型类型多选复制(使用字段 filedTypes,值为字典 key 列表)
|
||||||
|
filedTypes: formValues.filedTypes,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (resp.data) {
|
||||||
|
Message.success('复制标准模型成功');
|
||||||
|
copyStandardModalApi.close();
|
||||||
|
gridApi.reload();
|
||||||
|
} else {
|
||||||
|
Message.error('复制标准模型失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('复制标准模型失败:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,36 +693,10 @@ async function onDel(record: any) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('删除失败:', error);
|
console.error('删除失败:', error);
|
||||||
Message.error($t('common.deleteFail'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制标准模型函数
|
// 旧的“复制标准模型”直调接口函数已不再使用,保留逻辑由新的弹窗 + submitCopyStandard 代替
|
||||||
async function copyStandardThingModel() {
|
|
||||||
// 检查是否有产品ID
|
|
||||||
if (!productId.value) {
|
|
||||||
Message.error('产品ID不存在,无法复制标准模型');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
|
|
||||||
body: {
|
|
||||||
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
|
||||||
ioTPlatformProductId: productId.value,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (resp.data) {
|
|
||||||
Message.success('复制标准模型成功');
|
|
||||||
gridApi.reload();
|
|
||||||
} else {
|
|
||||||
Message.error('复制标准模型失败');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('复制标准模型失败:', error);
|
|
||||||
Message.error('复制标准模型失败');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -647,7 +716,7 @@ async function copyStandardThingModel() {
|
|||||||
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
||||||
type: 'default',
|
type: 'default',
|
||||||
icon: 'ant-design:copy-outlined',
|
icon: 'ant-design:copy-outlined',
|
||||||
onClick: copyStandardThingModel,
|
onClick: openCopyStandardThingModelModal,
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
disabled: !productId,
|
disabled: !productId,
|
||||||
},
|
},
|
||||||
@ -703,5 +772,10 @@ async function copyStandardThingModel() {
|
|||||||
<CopyModal title="复制已有模型" class="w-[600px]">
|
<CopyModal title="复制已有模型" class="w-[600px]">
|
||||||
<CopyForm />
|
<CopyForm />
|
||||||
</CopyModal>
|
</CopyModal>
|
||||||
|
|
||||||
|
<!-- 复制标准模型(按物模型类型多选)模态框 -->
|
||||||
|
<CopyStandardModal title="复制标准模型" class="w-[600px]">
|
||||||
|
<CopyStandardForm />
|
||||||
|
</CopyStandardModal>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -105,7 +105,7 @@ export const querySchema = computed(() => [
|
|||||||
|
|
||||||
export const tableSchema = computed(() => [
|
export const tableSchema = computed(() => [
|
||||||
{
|
{
|
||||||
field: 'filedType',
|
field: 'filedTypeName',
|
||||||
title: $t('abp.thingModelInfos.FiledType'),
|
title: $t('abp.thingModelInfos.FiledType'),
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
showOverflow: 'tooltip',
|
showOverflow: 'tooltip',
|
||||||
@ -180,7 +180,11 @@ export const tableSchema = computed(() => [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// 添加物模型表单schema
|
// 添加物模型表单schema
|
||||||
export const getAddThingModelFormSchema = (getPlatform: () => number | string | undefined, getProductId: () => string | undefined) => computed(() => [
|
export const getAddThingModelFormSchema = (
|
||||||
|
getPlatform: () => number | string | undefined,
|
||||||
|
getProductId: () => string | undefined,
|
||||||
|
) =>
|
||||||
|
computed(() => [
|
||||||
{
|
{
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
fieldName: 'filedType',
|
fieldName: 'filedType',
|
||||||
@ -276,7 +280,8 @@ export const getAddThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
},
|
},
|
||||||
placeholder:
|
placeholder:
|
||||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName'),
|
$t('common.pleaseSelect') +
|
||||||
|
$t('abp.thingModelInfos.StandardFieldName'),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -310,7 +315,8 @@ export const getAddThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
|
|
||||||
// 如果表单值中没有,尝试从其他字段获取
|
// 如果表单值中没有,尝试从其他字段获取
|
||||||
if (!platform && formValues?.ioTPlatform) {
|
if (!platform && formValues?.ioTPlatform) {
|
||||||
platform = typeof formValues.ioTPlatform === 'string'
|
platform =
|
||||||
|
typeof formValues.ioTPlatform === 'string'
|
||||||
? Number.parseInt(formValues.ioTPlatform)
|
? Number.parseInt(formValues.ioTPlatform)
|
||||||
: formValues.ioTPlatform;
|
: formValues.ioTPlatform;
|
||||||
}
|
}
|
||||||
@ -322,7 +328,8 @@ export const getAddThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
if (!platform) {
|
if (!platform) {
|
||||||
const externalPlatform = getPlatform();
|
const externalPlatform = getPlatform();
|
||||||
if (externalPlatform) {
|
if (externalPlatform) {
|
||||||
platform = typeof externalPlatform === 'string'
|
platform =
|
||||||
|
typeof externalPlatform === 'string'
|
||||||
? Number.parseInt(externalPlatform)
|
? Number.parseInt(externalPlatform)
|
||||||
: externalPlatform;
|
: externalPlatform;
|
||||||
}
|
}
|
||||||
@ -474,13 +481,18 @@ export const getAddThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
label: '平台物模型值类型扩展',
|
label: '平台物模型值类型扩展',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
rows: 4,
|
rows: 4,
|
||||||
placeholder: '请输入平台原始字段扩展信息(用于扩展结构体类型,JSON格式)',
|
placeholder:
|
||||||
|
'请输入平台原始字段扩展信息(用于扩展结构体类型,JSON格式)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 编辑物模型表单schema
|
// 编辑物模型表单schema
|
||||||
export const getEditThingModelFormSchema = (getPlatform: () => number | string | undefined, getProductId: () => string | undefined) => computed(() => [
|
export const getEditThingModelFormSchema = (
|
||||||
|
getPlatform: () => number | string | undefined,
|
||||||
|
getProductId: () => string | undefined,
|
||||||
|
) =>
|
||||||
|
computed(() => [
|
||||||
{
|
{
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
fieldName: 'filedType',
|
fieldName: 'filedType',
|
||||||
@ -589,7 +601,8 @@ export const getEditThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder:
|
placeholder:
|
||||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName'),
|
$t('common.pleaseSelect') +
|
||||||
|
$t('abp.thingModelInfos.StandardFieldName'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -609,7 +622,8 @@ export const getEditThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
|
|
||||||
// 如果表单值中没有,尝试从其他字段获取
|
// 如果表单值中没有,尝试从其他字段获取
|
||||||
if (!platform && formValues?.ioTPlatform) {
|
if (!platform && formValues?.ioTPlatform) {
|
||||||
platform = typeof formValues.ioTPlatform === 'string'
|
platform =
|
||||||
|
typeof formValues.ioTPlatform === 'string'
|
||||||
? Number.parseInt(formValues.ioTPlatform)
|
? Number.parseInt(formValues.ioTPlatform)
|
||||||
: formValues.ioTPlatform;
|
: formValues.ioTPlatform;
|
||||||
}
|
}
|
||||||
@ -621,7 +635,8 @@ export const getEditThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
if (!platform) {
|
if (!platform) {
|
||||||
const externalPlatform = getPlatform();
|
const externalPlatform = getPlatform();
|
||||||
if (externalPlatform) {
|
if (externalPlatform) {
|
||||||
platform = typeof externalPlatform === 'string'
|
platform =
|
||||||
|
typeof externalPlatform === 'string'
|
||||||
? Number.parseInt(externalPlatform)
|
? Number.parseInt(externalPlatform)
|
||||||
: externalPlatform;
|
: externalPlatform;
|
||||||
}
|
}
|
||||||
@ -771,7 +786,8 @@ export const getEditThingModelFormSchema = (getPlatform: () => number | string |
|
|||||||
label: '平台物模型值类型扩展',
|
label: '平台物模型值类型扩展',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
rows: 4,
|
rows: 4,
|
||||||
placeholder: '请输入平台原始字段扩展信息(用于扩展结构体类型,JSON格式)',
|
placeholder:
|
||||||
|
'请输入平台原始字段扩展信息(用于扩展结构体类型,JSON格式)',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -819,3 +835,46 @@ export const copyThingModelFormSchema = computed(() => [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 复制标准模型(按物模型类型多选)表单 schema
|
||||||
|
export const copyStandardThingModelFormSchema = computed(() => [
|
||||||
|
{
|
||||||
|
component: 'ApiSelect',
|
||||||
|
fieldName: 'filedTypes',
|
||||||
|
label: '选择要复制的物模型类型',
|
||||||
|
rules: z.preprocess(
|
||||||
|
(v) => (v == null ? [] : v),
|
||||||
|
z.array(z.string()).min(1, '请至少选择一个物模型类型'),
|
||||||
|
),
|
||||||
|
componentProps: {
|
||||||
|
api: getCommonGetSelectList,
|
||||||
|
params: {
|
||||||
|
query: {
|
||||||
|
// 与物模型字段类型相同的数据字典(Property / Service / Event)
|
||||||
|
typeName: 'DataDictionaryTypeConst',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
labelField: 'value',
|
||||||
|
valueField: 'key',
|
||||||
|
optionsPropName: 'options',
|
||||||
|
immediate: true,
|
||||||
|
allowClear: true,
|
||||||
|
mode: 'multiple',
|
||||||
|
placeholder: '请选择要复制的物模型类型(可多选)',
|
||||||
|
maxTagCount: 'responsive',
|
||||||
|
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 [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user