OneNET物模型管理实现
This commit is contained in:
parent
328e4b2c2f
commit
5fe1af6a75
@ -1190,10 +1190,15 @@ export const CopyAnotherProductInputSchema = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
description: '平台产品ID',
|
description: '平台产品ID',
|
||||||
nullable: true
|
nullable: true
|
||||||
|
},
|
||||||
|
sourceProductId: {
|
||||||
|
type: 'string',
|
||||||
|
description: '源产品ID',
|
||||||
|
nullable: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
description: '根据数据ID复制已存在物模型信息'
|
description: '复制已存在产品设备物模型信息'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const CopyStandardThingModelInputSchema = {
|
export const CopyStandardThingModelInputSchema = {
|
||||||
|
|||||||
@ -201,7 +201,7 @@ export type ControllerInterfaceApiDescriptionModel = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据数据ID复制已存在物模型信息
|
* 复制已存在产品设备物模型信息
|
||||||
*/
|
*/
|
||||||
export type CopyAnotherProductInput = {
|
export type CopyAnotherProductInput = {
|
||||||
ioTPlatform?: IoTPlatformTypeEnum;
|
ioTPlatform?: IoTPlatformTypeEnum;
|
||||||
@ -209,6 +209,10 @@ export type CopyAnotherProductInput = {
|
|||||||
* 平台产品ID
|
* 平台产品ID
|
||||||
*/
|
*/
|
||||||
ioTPlatformProductId?: (string) | null;
|
ioTPlatformProductId?: (string) | null;
|
||||||
|
/**
|
||||||
|
* 源产品ID
|
||||||
|
*/
|
||||||
|
sourceProductId?: (string) | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -224,7 +224,9 @@
|
|||||||
"StandardFieldName": "StandardFieldName",
|
"StandardFieldName": "StandardFieldName",
|
||||||
"StandardFieldDisplayName": "StandardFieldDisplayName",
|
"StandardFieldDisplayName": "StandardFieldDisplayName",
|
||||||
"IsValueNeedConvert": "IsValueNeedConvert",
|
"IsValueNeedConvert": "IsValueNeedConvert",
|
||||||
"StandardFieldValueType": "StandardFieldValueType"
|
"StandardFieldValueType": "StandardFieldValueType",
|
||||||
|
"copyStandardThingModel": "CopyStandardThingModel",
|
||||||
|
"copyAnotherThingModelModal": "CopyAnotherThingModelModal"
|
||||||
},
|
},
|
||||||
"IoTDBBase": {
|
"IoTDBBase": {
|
||||||
"IoTDataType": "IoTDataType",
|
"IoTDataType": "IoTDataType",
|
||||||
|
|||||||
@ -217,7 +217,9 @@
|
|||||||
"StandardFieldName": "标准物模型编码",
|
"StandardFieldName": "标准物模型编码",
|
||||||
"StandardFieldDisplayName": "标准物模型名称",
|
"StandardFieldDisplayName": "标准物模型名称",
|
||||||
"IsValueNeedConvert": "是否需要值类型转换",
|
"IsValueNeedConvert": "是否需要值类型转换",
|
||||||
"StandardFieldValueType": "标准物模型值类型"
|
"StandardFieldValueType": "标准物模型值类型",
|
||||||
|
"copyStandardThingModel": "复制标准模型",
|
||||||
|
"copyAnotherThingModelModal": "复制已有模型"
|
||||||
},
|
},
|
||||||
"IoTDBBase": {
|
"IoTDBBase": {
|
||||||
"IoTDataType": "数据类型",
|
"IoTDataType": "数据类型",
|
||||||
|
|||||||
@ -187,6 +187,7 @@ watch(
|
|||||||
() => [props.visible, props.productId, props.ioTPlatform],
|
() => [props.visible, props.productId, props.ioTPlatform],
|
||||||
async ([visible, productId, ioTPlatform]) => {
|
async ([visible, productId, ioTPlatform]) => {
|
||||||
console.log('物模型模态框props变化:', { visible, productId, ioTPlatform });
|
console.log('物模型模态框props变化:', { visible, productId, ioTPlatform });
|
||||||
|
console.log('所有props:', props);
|
||||||
if (visible && productId) {
|
if (visible && productId) {
|
||||||
// 延迟执行,确保组件完全初始化
|
// 延迟执行,确保组件完全初始化
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
@ -274,6 +275,11 @@ const openAddModal = async () => {
|
|||||||
|
|
||||||
// 打开复制已有模型模态框
|
// 打开复制已有模型模态框
|
||||||
const openCopyAnotherThingModelModal = async () => {
|
const openCopyAnotherThingModelModal = async () => {
|
||||||
|
console.log('打开复制模态框,当前props:', {
|
||||||
|
productId: props.productId,
|
||||||
|
productName: props.productName,
|
||||||
|
ioTPlatform: props.ioTPlatform
|
||||||
|
});
|
||||||
copyModalApi.open();
|
copyModalApi.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -284,13 +290,21 @@ async function submitCopy() {
|
|||||||
|
|
||||||
const formValues = await copyFormApi.getValues();
|
const formValues = await copyFormApi.getValues();
|
||||||
|
|
||||||
|
console.log('复制提交参数:', {
|
||||||
|
formValues,
|
||||||
|
props: {
|
||||||
|
productId: props.productId,
|
||||||
|
productName: props.productName,
|
||||||
|
ioTPlatform: props.ioTPlatform
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await postThingModelInfoCopyAnotherThingModelAsync({
|
const resp = await postThingModelInfoCopyAnotherThingModelAsync({
|
||||||
body: {
|
body: {
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
||||||
ioTPlatformProductId: props.productId,
|
ioTPlatformProductId: props.productId,
|
||||||
sourceProductId: formValues.sourceProductId,
|
sourceProductId: formValues.ioTPlatformProductId,
|
||||||
filedType: formValues.filedType,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -370,14 +384,14 @@ function closeModal() {
|
|||||||
auth: ['AbpIdentity.Users.Create'],
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '复制标准模型',
|
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
||||||
type: 'default',
|
type: 'default',
|
||||||
icon: 'ant-design:copy-outlined',
|
icon: 'ant-design:copy-outlined',
|
||||||
onClick: copyStandardThingModel,
|
onClick: copyStandardThingModel,
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '复制已有模型',
|
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
||||||
type: 'default',
|
type: 'default',
|
||||||
icon: 'ant-design:copy-outlined',
|
icon: 'ant-design:copy-outlined',
|
||||||
onClick: openCopyAnotherThingModelModal,
|
onClick: openCopyAnotherThingModelModal,
|
||||||
@ -423,10 +437,10 @@ function closeModal() {
|
|||||||
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||||
<component :is="editRow.id ? EditForm : AddForm" />
|
<component :is="editRow.id ? EditForm : AddForm" />
|
||||||
</ThingModelModal>
|
</ThingModelModal>
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<!-- 复制已有模型模态框 -->
|
<!-- 复制已有模型模态框 -->
|
||||||
<CopyModal title="复制已有模型" class="w-[600px]">
|
<CopyModal title="复制已有模型" class="w-[600px]">
|
||||||
<CopyForm />
|
<CopyForm />
|
||||||
</CopyModal>
|
</CopyModal>
|
||||||
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -4,7 +4,10 @@ import { z } from '@vben/common-ui';
|
|||||||
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { getCommonGetSelectList, postOneNetProductListAsync } from '#/api-client';
|
import {
|
||||||
|
getCommonGetSelectList,
|
||||||
|
postOneNetProductListAsync,
|
||||||
|
} from '#/api-client';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
export const querySchema = computed(() => [
|
export const querySchema = computed(() => [
|
||||||
@ -251,7 +254,8 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
optionsPropName: 'options',
|
optionsPropName: 'options',
|
||||||
immediate: true,
|
immediate: true,
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder: $t('common.pleaseSelect') + $t('abp.thingModelInfos.FiledType'),
|
placeholder:
|
||||||
|
$t('common.pleaseSelect') + $t('abp.thingModelInfos.FiledType'),
|
||||||
afterFetch: (res: any) => {
|
afterFetch: (res: any) => {
|
||||||
// 确保返回的是数组格式
|
// 确保返回的是数组格式
|
||||||
if (Array.isArray(res)) {
|
if (Array.isArray(res)) {
|
||||||
@ -277,7 +281,8 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
),
|
),
|
||||||
componentProps: {
|
componentProps: {
|
||||||
// disabled: true, // 编辑时禁用
|
// disabled: true, // 编辑时禁用
|
||||||
placeholder: $t('common.pleaseInput') +
|
placeholder:
|
||||||
|
$t('common.pleaseInput') +
|
||||||
$t('abp.thingModelInfos.IoTPlatformRawFieldName'),
|
$t('abp.thingModelInfos.IoTPlatformRawFieldName'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -298,7 +303,9 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
.toString()
|
.toString()
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
},
|
},
|
||||||
placeholder: $t('common.pleaseInput') + $t('abp.thingModelInfos.StandardFieldDisplayName'),
|
placeholder:
|
||||||
|
$t('common.pleaseInput') +
|
||||||
|
$t('abp.thingModelInfos.StandardFieldDisplayName'),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -308,7 +315,8 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
rules: z.string().min(1, $t('common.required')),
|
rules: z.string().min(1, $t('common.required')),
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder: $t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName')
|
placeholder:
|
||||||
|
$t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -330,7 +338,8 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder: $t('common.pleaseSelect') +
|
placeholder:
|
||||||
|
$t('common.pleaseSelect') +
|
||||||
$t('abp.thingModelInfos.StandardFieldValueType'),
|
$t('abp.thingModelInfos.StandardFieldValueType'),
|
||||||
afterFetch: (res: any) => {
|
afterFetch: (res: any) => {
|
||||||
let items = [];
|
let items = [];
|
||||||
@ -365,7 +374,7 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
export const copyThingModelFormSchema = computed(() => [
|
export const copyThingModelFormSchema = computed(() => [
|
||||||
{
|
{
|
||||||
component: 'ApiSelect',
|
component: 'ApiSelect',
|
||||||
fieldName: 'sourceProductId',
|
fieldName: 'ioTPlatformProductId',
|
||||||
label: '选择要复制的产品',
|
label: '选择要复制的产品',
|
||||||
rules: z.preprocess(
|
rules: z.preprocess(
|
||||||
(v) => (v == null ? '' : v),
|
(v) => (v == null ? '' : v),
|
||||||
@ -375,15 +384,13 @@ export const copyThingModelFormSchema = computed(() => [
|
|||||||
api: postOneNetProductListAsync,
|
api: postOneNetProductListAsync,
|
||||||
params: {
|
params: {
|
||||||
query: {
|
query: {
|
||||||
input: {
|
pageIndex: 1,
|
||||||
pageIndex: 1,
|
pageSize: 1000,
|
||||||
pageSize: 1000,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
labelField: 'productName',
|
labelField: 'productName',
|
||||||
valueField: 'ioTPlatformProductId',
|
valueField: 'ioTPlatformProductId',
|
||||||
optionsPropName: 'items',
|
optionsPropName: 'options',
|
||||||
immediate: true,
|
immediate: true,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
placeholder: '请选择产品',
|
placeholder: '请选择产品',
|
||||||
@ -398,41 +405,8 @@ export const copyThingModelFormSchema = computed(() => [
|
|||||||
if (res && Array.isArray(res.data)) {
|
if (res && Array.isArray(res.data)) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
return [];
|
if (res && Array.isArray(res.data.items)) {
|
||||||
},
|
return res.data.items;
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: 'ApiSelect',
|
|
||||||
fieldName: 'filedType',
|
|
||||||
label: '选择物模型类型',
|
|
||||||
rules: z.preprocess(
|
|
||||||
(v) => (v == null ? '' : v),
|
|
||||||
z.string().min(1, '请选择物模型类型'),
|
|
||||||
),
|
|
||||||
componentProps: {
|
|
||||||
api: getCommonGetSelectList,
|
|
||||||
params: {
|
|
||||||
query: {
|
|
||||||
typeName: 'DataDictionaryTypeConst',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
labelField: 'value',
|
|
||||||
valueField: 'key',
|
|
||||||
optionsPropName: 'options',
|
|
||||||
immediate: true,
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请选择物模型类型',
|
|
||||||
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 [];
|
return [];
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user