修改产品物模型管理按钮,更新nswag接口信息

This commit is contained in:
ChenYi 2025-12-17 11:19:31 +08:00
parent 28479396f9
commit fdc07134a8
6 changed files with 2294 additions and 206 deletions

12
.vscode/settings.json vendored
View File

@ -237,5 +237,15 @@
"nolebase",
"rollup",
"vitest"
]
],
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition",
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition",
"editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.revealDefinition",
"editor.selectionHighlight": false,
"files.autoSave": "onFocusChange",
"editor.quickSuggestions": {
"other": "on",
"comments": "off",
"strings": "on"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -172,6 +172,38 @@ export type BatchCreateDeviceAggregationInput = {
deviceSourceTypeEnum?: DeviceSourceTypeEnum;
};
/**
*
*/
export type BuildAnalysisScriptInput = {
/**
* Id
*/
id?: string;
/**
*
*/
scriptName?: (string) | null;
/**
*
*/
functionScript?: (string) | null;
};
/**
*
*/
export type BuildAnalysisScriptOutput = {
/**
*
*/
functionName?: (string) | null;
/**
*
*/
functionCode?: (string) | null;
};
export type ChangePasswordInput = {
currentPassword?: (string) | null;
newPassword: string;
@ -200,6 +232,21 @@ export type ControllerInterfaceApiDescriptionModel = {
methods?: Array<InterfaceMethodApiDescriptionModel> | null;
};
/**
*
*/
export type CopyAnotherDeviceInput = {
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
deviceThingModelId?: string;
/**
* ID
*/
sourceProductId?: string;
};
/**
*
*/
@ -983,13 +1030,13 @@ export type DeleteTextTemplateInput = {
*
*/
export type DeviceCommandForApiInput = {
id?: string;
id: string;
/**
* JSON格式
*
*/
commandContent: string;
deviceType?: DeviceTypeEnum;
telemetryType?: DeviceTelemetryCommandTypeEnum;
commandContent: {
[key: string]: unknown;
};
};
export type DeviceManagementInfoDto = {
@ -1095,10 +1142,14 @@ export type DeviceManagementInfoDto = {
*
*/
readonly deviceTypeName?: (string) | null;
/**
* false
*/
isNeedConfigDevicMdoel?: boolean;
/**
* Id
*/
deviceThingModelDataId?: string;
deviceThingModelDataId?: (string) | null;
};
export type DeviceManagementInfoDtoPagedResultDto = {
@ -1208,9 +1259,545 @@ export type DeviceTableModelDataInfoPageOutputPagedResultDto = {
};
/**
*
*
*/
export type DeviceTelemetryCommandTypeEnum = 1 | 2;
export type DeviceThingModelCommandInfoCreateInput = {
/**
* Id
*/
deviceThingModelId: string;
/**
*
*/
commandName: string;
/**
*
*/
issueCommand: string;
/**
* ,JSON格式字符串数组
*/
propertyArray: Array<(string)>;
};
/**
*
*/
export type DeviceThingModelCommandInfoDto = {
id?: string;
creationTime?: string;
creatorId?: (string) | null;
lastModificationTime?: (string) | null;
lastModifierId?: (string) | null;
isDeleted?: boolean;
deleterId?: (string) | null;
deletionTime?: (string) | null;
/**
* Id
*/
tenantId?: (string) | null;
/**
*
*/
remark?: (string) | null;
/**
* Id
*/
osaCreatorId?: (number) | null;
/**
* Id
*/
osaLastModifierId?: (number) | null;
/**
* Id
*/
osaDeleterId?: (number) | null;
/**
* ,,JSON格式
*/
extraProperties?: {
[key: string]: unknown;
} | null;
/**
* Id
*/
deviceThingModelId?: string;
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
*
*/
commandName?: (string) | null;
/**
*
*/
issueCommand?: (string) | null;
/**
* ,JSON格式字符串数组
*/
propertyArray?: Array<(string)> | null;
};
export type DeviceThingModelCommandInfoDtoPagedResultDto = {
items?: Array<DeviceThingModelCommandInfoDto> | null;
totalCount?: number;
};
/**
*
*/
export type DeviceThingModelCommandInfoPageInput = {
/**
* .1
*/
pageIndex?: number;
/**
* .
*/
pageSize?: number;
/**
*
*/
readonly skipCount?: number;
/**
*
* <example>
* name desc
* </example>
*/
sorting?: (string) | null;
/**
* Id
*/
deviceThingModelId: string;
ioTPlatform?: IoTPlatformTypeEnum;
/**
*
*/
searchKeyWords?: (string) | null;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
isPage?: boolean;
};
/**
*
*/
export type DeviceThingModelCommandInfoUpdateInput = {
/**
* Id
*/
deviceThingModelId: string;
/**
*
*/
commandName: string;
/**
*
*/
issueCommand: string;
/**
* ,JSON格式字符串数组
*/
propertyArray: Array<(string)>;
id: string;
};
export type DeviceThingModelCreateInput = {
/**
*
*/
deviceModelName?: (string) | null;
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
*
*/
scriptName?: (string) | null;
/**
*
*/
functionScript?: (string) | null;
};
/**
*
*/
export type DeviceThingModelManagementDto = {
id?: string;
creationTime?: string;
creatorId?: (string) | null;
lastModificationTime?: (string) | null;
lastModifierId?: (string) | null;
isDeleted?: boolean;
deleterId?: (string) | null;
deletionTime?: (string) | null;
/**
* Id
*/
tenantId?: (string) | null;
/**
*
*/
remark?: (string) | null;
/**
* Id
*/
osaCreatorId?: (number) | null;
/**
* Id
*/
osaLastModifierId?: (number) | null;
/**
* Id
*/
osaDeleterId?: (number) | null;
/**
* ,,JSON格式
*/
extraProperties?: {
[key: string]: unknown;
} | null;
/**
*
*/
deviceModelName?: (string) | null;
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
*
*/
scriptName?: (string) | null;
/**
*
*/
functionScript?: (string) | null;
parsingSequence?: ParsingSequenceTypeEnum;
/**
* false
*/
functionAnalysisFlag?: boolean;
/**
*
*/
propertyInfos?: Array<DeviceThingModelPropertyInfoDto> | null;
/**
*
*/
commandInfos?: Array<DeviceThingModelCommandInfoDto> | null;
};
export type DeviceThingModelManagementDtoPagedResultDto = {
items?: Array<DeviceThingModelManagementDto> | null;
totalCount?: number;
};
export type DeviceThingModelPageInput = {
/**
* .1
*/
pageIndex?: number;
/**
* .
*/
pageSize?: number;
/**
*
*/
readonly skipCount?: number;
/**
*
* <example>
* name desc
* </example>
*/
sorting?: (string) | null;
ioTPlatform?: IoTPlatformTypeEnum;
/**
*
*/
searchKeyWords?: (string) | null;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
isPage?: boolean;
};
/**
*
*/
export type DeviceThingModelPropertyCreateInput = {
/**
* Id
*/
deviceThingModelId: string;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
ioTPlatformRawFieldName: string;
/**
* JiShe.ServicePro.Core.OneNETAllThingModel
*/
ioTPlatformRawFieldDataType: string;
/**
*
*/
standardFieldName: string;
/**
*
*/
standardFieldValueType: string;
/**
*
*/
standardFieldDisplayName: string;
/**
*
*/
isValueNeedConvert?: boolean;
/**
*
*/
skipNumber?: number;
/**
*
*/
takeNumber?: number;
};
/**
*
*/
export type DeviceThingModelPropertyInfoDto = {
id?: string;
creationTime?: string;
creatorId?: (string) | null;
lastModificationTime?: (string) | null;
lastModifierId?: (string) | null;
isDeleted?: boolean;
deleterId?: (string) | null;
deletionTime?: (string) | null;
/**
* Id
*/
tenantId?: (string) | null;
/**
*
*/
remark?: (string) | null;
/**
* Id
*/
osaCreatorId?: (number) | null;
/**
* Id
*/
osaLastModifierId?: (number) | null;
/**
* Id
*/
osaDeleterId?: (number) | null;
/**
* ,,JSON格式
*/
extraProperties?: {
[key: string]: unknown;
} | null;
/**
* Id
*/
deviceThingModelId?: string;
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
ioTPlatformRawFieldName?: (string) | null;
/**
* JiShe.ServicePro.Core.OneNETAllThingModel
*/
ioTPlatformRawFieldDataType?: (string) | null;
/**
*
*/
standardFieldName?: (string) | null;
/**
*
*/
standardFieldValueType?: (string) | null;
/**
*
*/
standardFieldDisplayName?: (string) | null;
/**
*
*/
isValueNeedConvert?: boolean;
/**
*
*/
skipNumber?: number;
/**
*
*/
takeNumber?: number;
};
export type DeviceThingModelPropertyInfoDtoPagedResultDto = {
items?: Array<DeviceThingModelPropertyInfoDto> | null;
totalCount?: number;
};
/**
*
*/
export type DeviceThingModelPropertyPageInput = {
/**
* .1
*/
pageIndex?: number;
/**
* .
*/
pageSize?: number;
/**
*
*/
readonly skipCount?: number;
/**
*
* <example>
* name desc
* </example>
*/
sorting?: (string) | null;
/**
* Id
*/
deviceThingModelId: string;
ioTPlatform?: IoTPlatformTypeEnum;
/**
*
*/
searchKeyWords?: (string) | null;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
isPage?: boolean;
};
/**
*
*/
export type DeviceThingModelPropertyUpdateInput = {
/**
* Id
*/
deviceThingModelId: string;
/**
* JiShe.ServicePro.Core.DataDictionaryTypeConst
*/
filedType?: (string) | null;
/**
*
*/
ioTPlatformRawFieldName: string;
/**
* JiShe.ServicePro.Core.OneNETAllThingModel
*/
ioTPlatformRawFieldDataType: string;
/**
*
*/
standardFieldName: string;
/**
*
*/
standardFieldValueType: string;
/**
*
*/
standardFieldDisplayName: string;
/**
*
*/
isValueNeedConvert?: boolean;
/**
*
*/
skipNumber?: number;
/**
*
*/
takeNumber?: number;
id: string;
};
export type DeviceThingModelUpdateInput = {
/**
*
*/
deviceModelName?: (string) | null;
ioTPlatform?: IoTPlatformTypeEnum;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
/**
*
*/
scriptName?: (string) | null;
/**
*
*/
functionScript?: (string) | null;
id?: string;
};
/**
*
@ -1958,7 +2545,7 @@ export type IdentityUserUpdateDto = {
};
export type IdInput = {
id?: string;
id: string;
};
export type InterfaceMethodApiDescriptionModel = {
@ -2077,6 +2664,10 @@ export type IoTPlatformThingModelInfoDto = {
*
*/
isSpecialIdentifier?: boolean;
/**
*
*/
ioTPlatformRawFieldExtension?: (string) | null;
};
export type IoTPlatformThingModelInfoDtoPagedResultDto = {
@ -2251,6 +2842,26 @@ export type LoginResultType = 1 | 2 | 3 | 4 | 5;
*/
export type MenuType = 10 | 20;
/**
*
*/
export type MessageAnalysisTestInput = {
/**
*
*/
functionName?: (string) | null;
/**
*
*/
functionCode?: (string) | null;
/**
*
*/
parameters?: {
[key: string]: unknown;
} | null;
};
/**
*
*/
@ -2772,7 +3383,7 @@ export type OneNETProductInfoDto = {
*/
communicationAddressTLS?: (string) | null;
/**
*
*
*/
thingModelInfos?: (string) | null;
};
@ -3436,6 +4047,9 @@ export type PagingAuditLogInput = {
readonly skipCount?: number;
/**
*
* <example>
* name desc
* </example>
*/
sorting?: (string) | null;
/**
@ -4015,6 +4629,11 @@ export type ParameterApiDescriptionModel = {
descriptorName?: (string) | null;
};
/**
*
*/
export type ParsingSequenceTypeEnum = 1 | 2;
export type PermissionOutput = {
grants?: Array<(string)> | null;
allGrants?: Array<(string)> | null;
@ -4571,7 +5190,7 @@ export type SettingOutput = {
};
export type StringIdInput = {
id?: (string) | null;
id: string;
};
export type StringStringFromSelector = {
@ -5254,6 +5873,242 @@ export type PostDeviceInfoCacheDeviceDataToRedisResponse = (boolean);
export type PostDeviceInfoCacheDeviceDataToRedisError = unknown;
export type PostDeviceThingModelManagementCreateAsyncData = {
query?: {
input?: DeviceThingModelCreateInput;
};
};
export type PostDeviceThingModelManagementCreateAsyncResponse = (DeviceThingModelManagementDto);
export type PostDeviceThingModelManagementCreateAsyncError = unknown;
export type PostDeviceThingModelManagementUpdateAsyncData = {
query?: {
input?: DeviceThingModelUpdateInput;
};
};
export type PostDeviceThingModelManagementUpdateAsyncResponse = (DeviceThingModelManagementDto);
export type PostDeviceThingModelManagementUpdateAsyncError = unknown;
export type PostDeviceThingModelManagementDeleteAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementDeleteAsyncResponse = (boolean);
export type PostDeviceThingModelManagementDeleteAsyncError = unknown;
export type PostDeviceThingModelManagementFindByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementFindByIdAsyncResponse = (DeviceThingModelManagementDto);
export type PostDeviceThingModelManagementFindByIdAsyncError = unknown;
export type PostDeviceThingModelManagementGetDeviceThingModelAllInfoByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementGetDeviceThingModelAllInfoByIdAsyncResponse = (DeviceThingModelManagementDto);
export type PostDeviceThingModelManagementGetDeviceThingModelAllInfoByIdAsyncError = unknown;
export type PostDeviceThingModelManagementBuildAnalysisScriptByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementBuildAnalysisScriptByIdAsyncResponse = (BuildAnalysisScriptOutput);
export type PostDeviceThingModelManagementBuildAnalysisScriptByIdAsyncError = unknown;
export type PostDeviceThingModelManagementBuildAnalysisScriptAsyncData = {
query?: {
input?: BuildAnalysisScriptInput;
};
};
export type PostDeviceThingModelManagementBuildAnalysisScriptAsyncResponse = (boolean);
export type PostDeviceThingModelManagementBuildAnalysisScriptAsyncError = unknown;
export type PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncResponse = (boolean);
export type PostDeviceThingModelManagementUpdateAnalysisScriptByIdAsyncError = unknown;
export type PostDeviceThingModelManagementMessageAnalysisTestAsyncData = {
query?: {
input?: MessageAnalysisTestInput;
};
};
export type PostDeviceThingModelManagementMessageAnalysisTestAsyncResponse = ({
[key: string]: unknown;
});
export type PostDeviceThingModelManagementMessageAnalysisTestAsyncError = unknown;
export type PostDeviceThingModelManagementFindByPlatformProductIdAsyncData = {
query?: {
input?: StringIdInput;
};
};
export type PostDeviceThingModelManagementFindByPlatformProductIdAsyncResponse = (Array<DeviceThingModelManagementDto>);
export type PostDeviceThingModelManagementFindByPlatformProductIdAsyncError = unknown;
export type PostDeviceThingModelManagementCopyAnotherThingModelAsyncData = {
query?: {
input?: CopyAnotherDeviceInput;
};
};
export type PostDeviceThingModelManagementCopyAnotherThingModelAsyncResponse = (boolean);
export type PostDeviceThingModelManagementCopyAnotherThingModelAsyncError = unknown;
export type PostDeviceThingModelManagementPageAsyncData = {
query?: {
input?: DeviceThingModelPageInput;
};
};
export type PostDeviceThingModelManagementPageAsyncResponse = (DeviceThingModelManagementDtoPagedResultDto);
export type PostDeviceThingModelManagementPageAsyncError = unknown;
export type PostDeviceThingModelManagementPropertyCreateAsyncData = {
query?: {
input?: DeviceThingModelPropertyCreateInput;
};
};
export type PostDeviceThingModelManagementPropertyCreateAsyncResponse = (DeviceThingModelPropertyInfoDto);
export type PostDeviceThingModelManagementPropertyCreateAsyncError = unknown;
export type PostDeviceThingModelManagementPropertyUpdateAsyncData = {
query?: {
input?: DeviceThingModelPropertyUpdateInput;
};
};
export type PostDeviceThingModelManagementPropertyUpdateAsyncResponse = (DeviceThingModelPropertyInfoDto);
export type PostDeviceThingModelManagementPropertyUpdateAsyncError = unknown;
export type PostDeviceThingModelManagementPropertyDeleteAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementPropertyDeleteAsyncResponse = (boolean);
export type PostDeviceThingModelManagementPropertyDeleteAsyncError = unknown;
export type PostDeviceThingModelManagementPropertyFindByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementPropertyFindByIdAsyncResponse = (DeviceThingModelPropertyInfoDto);
export type PostDeviceThingModelManagementPropertyFindByIdAsyncError = unknown;
export type PostDeviceThingModelManagementPropertyPageAsyncData = {
query?: {
input?: DeviceThingModelPropertyPageInput;
};
};
export type PostDeviceThingModelManagementPropertyPageAsyncResponse = (DeviceThingModelPropertyInfoDtoPagedResultDto);
export type PostDeviceThingModelManagementPropertyPageAsyncError = unknown;
export type PostDeviceThingModelManagementCommandCreateAsyncData = {
query?: {
input?: DeviceThingModelCommandInfoCreateInput;
};
};
export type PostDeviceThingModelManagementCommandCreateAsyncResponse = (DeviceThingModelCommandInfoDto);
export type PostDeviceThingModelManagementCommandCreateAsyncError = unknown;
export type PostDeviceThingModelManagementCommandUpdateAsyncData = {
query?: {
input?: DeviceThingModelCommandInfoUpdateInput;
};
};
export type PostDeviceThingModelManagementCommandUpdateAsyncResponse = (DeviceThingModelCommandInfoDto);
export type PostDeviceThingModelManagementCommandUpdateAsyncError = unknown;
export type PostDeviceThingModelManagementCommandDeleteAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementCommandDeleteAsyncResponse = (boolean);
export type PostDeviceThingModelManagementCommandDeleteAsyncError = unknown;
export type PostDeviceThingModelManagementCommandFindByIdAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementCommandFindByIdAsyncResponse = (DeviceThingModelCommandInfoDto);
export type PostDeviceThingModelManagementCommandFindByIdAsyncError = unknown;
export type PostDeviceThingModelManagementCommandPageAsyncData = {
query?: {
input?: DeviceThingModelCommandInfoPageInput;
};
};
export type PostDeviceThingModelManagementCommandPageAsyncResponse = (DeviceThingModelCommandInfoDtoPagedResultDto);
export type PostDeviceThingModelManagementCommandPageAsyncError = unknown;
export type PostDeviceThingModelManagementCacheDeviceThingModelToRedisAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostDeviceThingModelManagementCacheDeviceThingModelToRedisAsyncResponse = (boolean);
export type PostDeviceThingModelManagementCacheDeviceThingModelToRedisAsyncError = unknown;
export type PostDeviceThingModelManagementCacheAllDeviceThingModelToRedisAsyncResponse = (boolean);
export type PostDeviceThingModelManagementCacheAllDeviceThingModelToRedisAsyncError = unknown;
export type PostFeaturesListData = {
body?: GetFeatureListResultInput;
};
@ -5694,6 +6549,16 @@ export type PostOneNetProductProductStatusChangeAsyncResponse = (OneNETProductIn
export type PostOneNetProductProductStatusChangeAsyncError = unknown;
export type PostOneNetProductUpdateThingModelAsyncData = {
query?: {
input?: IdInput;
};
};
export type PostOneNetProductUpdateThingModelAsyncResponse = (OneNETProductInfoDto);
export type PostOneNetProductUpdateThingModelAsyncError = unknown;
export type PostOneNetProductListAsyncData = {
query?: {
input?: OneNetProductInfoListInput;

View File

@ -23,8 +23,6 @@ import {
import { TableAction } from '#/components/table-action';
import { $t } from '#/locales';
import ThingModelInfoModal from '#/views/thingmodelinfo/ioTPlatformThingModelInfo/index.vue';
import {
addProductFormSchema,
editProductFormSchemaEdit,
@ -78,10 +76,6 @@ const editRow: Record<string, any> = ref({});
//
let selectedFile: File | null = null;
//
const thingModelModalVisible = ref(false);
const currentProductInfo = ref<any>({});
//
setFileSelectedCallback((file) => {
selectedFile = file;
@ -330,22 +324,15 @@ function onDeviceManagement(record: any) {
//
function onThingModelManagement(record: any) {
console.log('物模型管理按钮被点击', record);
//
currentProductInfo.value = {
productId: record.ioTPlatformProductId,
// ID
router.push({
path: '/thingmodelinfo/ioTPlatformThingModelInfo',
query: {
productId: record.ioTPlatformProductId, // ID
productName: record.productName,
ioTPlatform: '2', // OneNET2
};
console.log('设置产品信息:', currentProductInfo.value);
//
thingModelModalVisible.value = true;
console.log('模态框状态设置为:', thingModelModalVisible.value);
}
//
function closeThingModelModal() {
thingModelModalVisible.value = false;
currentProductInfo.value = {};
},
});
}
</script>
@ -428,14 +415,5 @@ function closeThingModelModal() {
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
<component :is="editRow.id ? EditForm : AddForm" />
</UserModal>
<!-- 物模型信息模态框 -->
<ThingModelInfoModal
v-model:visible="thingModelModalVisible"
:product-id="currentProductInfo.productId"
:product-name="currentProductInfo.productName"
:io-t-platform="currentProductInfo.ioTPlatform"
@close="closeThingModelModal"
/>
</Page>
</template>

View File

@ -2,11 +2,12 @@
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { h, nextTick, ref, watch } from 'vue';
import { h, nextTick, onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useVbenModal } from '@vben/common-ui';
import { Page, useVbenModal } from '@vben/common-ui';
import { message as Message, Modal, Tag } from 'ant-design-vue';
import { message as Message, Tag } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
@ -30,29 +31,15 @@ import {
} from './schema';
defineOptions({
name: 'ThingModelInfoModal',
name: 'IoTPlatformThingModelInfo',
});
const props = withDefaults(defineProps<Props>(), {
visible: false,
productId: '',
productName: '',
ioTPlatform: '2',
});
const route = useRoute();
// emits
const emit = defineEmits<{
close: [];
'update:visible': [value: boolean];
}>();
// props
interface Props {
visible?: boolean;
productId?: string;
productName?: string;
ioTPlatform?: string;
}
//
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 formOptions: VbenFormProps = {
schema: querySchema.value,
@ -76,20 +63,38 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
// ID
if (!productId.value) {
hasData.value = false;
return {
items: [],
totalCount: 0,
};
}
try {
const { data } = await postIoTplatformThingModelInfoPageAsync({
query: {
input: {
pageIndex: page.currentPage,
pageSize: page.pageSize,
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
ioTPlatformProductId: props.productId,
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
},
},
});
//
hasData.value = data?.items && data.items.length > 0;
return data;
return data || { items: [], totalCount: 0 };
} catch (error) {
console.error('查询物模型信息失败:', error);
hasData.value = false;
return {
items: [],
totalCount: 0,
};
}
},
},
},
@ -183,41 +188,69 @@ const [CopyForm, copyFormApi] = useVbenForm({
wrapperClass: 'grid-cols-2',
});
// props
//
watch(
() => [props.visible, props.productId, props.ioTPlatform],
async ([visible, productId, ioTPlatform]) => {
console.log('物模型模态框props变化:', { visible, productId, ioTPlatform });
console.log('所有props:', props);
if (visible && productId) {
() => [route.query.productId, route.query.ioTPlatform],
async ([newProductId, newIoTPlatform]) => {
if (newProductId) {
productId.value = newProductId as string;
}
if (newIoTPlatform) {
ioTPlatform.value = newIoTPlatform as string;
}
if (route.query.productName) {
productName.value = route.query.productName as string;
}
//
if (gridApi) {
setTimeout(async () => {
try {
//
const filterValues: any = {};
// ioTPlatformProductId API props.productId
// SearchKeyWords
console.log('设置筛选条件:', filterValues);
//
if (Object.keys(filterValues).length > 0) {
await gridApi.formApi.setValues(filterValues);
}
// 使 productId
await gridApi.reload();
} catch (error) {
console.error('设置筛选条件时出错:', error);
console.error('加载数据时出错:', error);
}
}, 100);
}
},
{ immediate: true },
{ immediate: false },
);
//
onMounted(async () => {
//
if (route.query.productId) {
productId.value = route.query.productId as string;
}
if (route.query.productName) {
productName.value = route.query.productName as string;
}
if (route.query.ioTPlatform) {
ioTPlatform.value = route.query.ioTPlatform as string;
}
//
// 使 productId
await nextTick();
setTimeout(async () => {
if (gridApi && gridApi.reload) {
try {
await gridApi.reload();
} catch (error) {
console.error('初始化加载数据时出错:', error);
}
}
}, 300);
});
//
async function submit() {
// ID
if (!productId.value) {
Message.error('产品ID不存在无法保存物模型信息');
return;
}
const isEdit = !!editRow.value.id;
const formApi = isEdit ? editFormApi : addFormApi;
const api = isEdit
@ -230,8 +263,8 @@ async function submit() {
const fetchParams: any = {
...formValues,
//
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
ioTPlatformProductId: props.productId,
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
// ID
...(isEdit && { id: editRow.value.id }),
};
@ -270,16 +303,22 @@ const openAddModal = async () => {
//
const openCopyAnotherThingModelModal = async () => {
console.log('打开复制模态框,当前props:', {
productId: props.productId,
productName: props.productName,
ioTPlatform: props.ioTPlatform,
console.log('打开复制模态框,当前参数:', {
productId: productId.value,
productName: productName.value,
ioTPlatform: ioTPlatform.value,
});
copyModalApi.open();
};
//
async function submitCopy() {
// ID
if (!productId.value) {
Message.error('产品ID不存在无法复制物模型信息');
return;
}
const { valid } = await copyFormApi.validate();
if (!valid) return;
@ -287,10 +326,10 @@ async function submitCopy() {
console.log('复制提交参数:', {
formValues,
props: {
productId: props.productId,
productName: props.productName,
ioTPlatform: props.ioTPlatform,
params: {
productId: productId.value,
productName: productName.value,
ioTPlatform: ioTPlatform.value,
},
});
@ -298,8 +337,8 @@ async function submitCopy() {
const resp = await postIoTplatformThingModelInfoCopyAnotherThingModelAsync({
query: {
input: {
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
ioTPlatformProductId: props.productId,
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
sourceProductId: formValues.ioTPlatformProductId,
},
},
@ -340,12 +379,18 @@ async function onDel(record: any) {
//
async function copyStandardThingModel() {
// ID
if (!productId.value) {
Message.error('产品ID不存在无法复制标准模型');
return;
}
try {
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
query: {
input: {
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
ioTPlatformProductId: props.productId,
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
ioTPlatformProductId: productId.value,
},
},
});
@ -360,20 +405,11 @@ async function copyStandardThingModel() {
Message.error('复制标准模型失败');
}
}
//
function closeModal() {
emit('update:visible', false);
emit('close');
}
</script>
<template>
<Modal :open="visible" :title="`${props.ioTPlatform === 1 ? 'CTWing' : 'OneNET'}物模型管理 - ${productName || '产品'}`"
width="90%" :footer="null" @cancel="closeModal" @ok="closeModal"
:body-style="{ height: '70vh', overflow: 'hidden' }">
<div style="display: flex; flex-direction: column; height: 100%">
<Grid style="flex: 1; overflow: hidden">
<Page auto-content-height>
<Grid>
<template #toolbar-actions>
<TableAction :actions="[
{
@ -382,6 +418,7 @@ function closeModal() {
icon: 'ant-design:plus-outlined',
onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'],
disabled: !productId,
},
{
label: $t('abp.thingModelInfos.copyStandardThingModel'),
@ -389,6 +426,7 @@ function closeModal() {
icon: 'ant-design:copy-outlined',
onClick: copyStandardThingModel,
auth: ['AbpIdentity.Users.Create'],
disabled: !productId,
},
{
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
@ -397,6 +435,7 @@ function closeModal() {
onClick: openCopyAnotherThingModelModal,
auth: ['AbpIdentity.Users.Create'],
ifShow: !hasData,
disabled: !productId,
},
]" />
</template>
@ -433,7 +472,6 @@ function closeModal() {
]" />
</template>
</Grid>
</div>
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
<component :is="editRow.id ? EditForm : AddForm" />
</ThingModelModal>
@ -442,5 +480,5 @@ function closeModal() {
<CopyModal title="复制已有模型" class="w-[600px]">
<CopyForm />
</CopyModal>
</Modal>
</Page>
</template>