Compare commits
No commits in common. "5fe1af6a75a87115aa827daef51796b389b9ef94" and "7f3328c8db92e28b5c562f767b29527c38af49c2" have entirely different histories.
5fe1af6a75
...
7f3328c8db
@ -1190,15 +1190,10 @@ 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: '复制已存在产品设备物模型信息'
|
description: '根据数据ID复制已存在物模型信息'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const CopyStandardThingModelInputSchema = {
|
export const CopyStandardThingModelInputSchema = {
|
||||||
|
|||||||
@ -517,7 +517,7 @@ export const postThingModelInfoFindByPlatformProductIdAsync = <ThrowOnError exte
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制已存在产品设备物模型信息
|
* 根据数据ID复制已存在物模型信息
|
||||||
*/
|
*/
|
||||||
export const postThingModelInfoCopyAnotherThingModelAsync = <ThrowOnError extends boolean = false>(options?: Options<PostThingModelInfoCopyAnotherThingModelAsyncData, ThrowOnError>) => {
|
export const postThingModelInfoCopyAnotherThingModelAsync = <ThrowOnError extends boolean = false>(options?: Options<PostThingModelInfoCopyAnotherThingModelAsyncData, ThrowOnError>) => {
|
||||||
return (options?.client ?? client).post<PostThingModelInfoCopyAnotherThingModelAsyncResponse, PostThingModelInfoCopyAnotherThingModelAsyncError, ThrowOnError>({
|
return (options?.client ?? client).post<PostThingModelInfoCopyAnotherThingModelAsyncResponse, PostThingModelInfoCopyAnotherThingModelAsyncError, ThrowOnError>({
|
||||||
@ -537,7 +537,7 @@ export const postThingModelInfoCopyStandardThingModel = <ThrowOnError extends bo
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询物模型信息
|
* 分页查询设备信息
|
||||||
*/
|
*/
|
||||||
export const postThingModelInfoPageAsync = <ThrowOnError extends boolean = false>(options?: Options<PostThingModelInfoPageAsyncData, ThrowOnError>) => {
|
export const postThingModelInfoPageAsync = <ThrowOnError extends boolean = false>(options?: Options<PostThingModelInfoPageAsyncData, ThrowOnError>) => {
|
||||||
return (options?.client ?? client).post<PostThingModelInfoPageAsyncResponse, PostThingModelInfoPageAsyncError, ThrowOnError>({
|
return (options?.client ?? client).post<PostThingModelInfoPageAsyncResponse, PostThingModelInfoPageAsyncError, ThrowOnError>({
|
||||||
|
|||||||
@ -201,7 +201,7 @@ export type ControllerInterfaceApiDescriptionModel = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制已存在产品设备物模型信息
|
* 根据数据ID复制已存在物模型信息
|
||||||
*/
|
*/
|
||||||
export type CopyAnotherProductInput = {
|
export type CopyAnotherProductInput = {
|
||||||
ioTPlatform?: IoTPlatformTypeEnum;
|
ioTPlatform?: IoTPlatformTypeEnum;
|
||||||
@ -209,10 +209,6 @@ export type CopyAnotherProductInput = {
|
|||||||
* 平台产品ID
|
* 平台产品ID
|
||||||
*/
|
*/
|
||||||
ioTPlatformProductId?: (string) | null;
|
ioTPlatformProductId?: (string) | null;
|
||||||
/**
|
|
||||||
* 源产品ID
|
|
||||||
*/
|
|
||||||
sourceProductId?: (string) | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -224,9 +224,7 @@
|
|||||||
"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,9 +217,7 @@
|
|||||||
"StandardFieldName": "标准物模型编码",
|
"StandardFieldName": "标准物模型编码",
|
||||||
"StandardFieldDisplayName": "标准物模型名称",
|
"StandardFieldDisplayName": "标准物模型名称",
|
||||||
"IsValueNeedConvert": "是否需要值类型转换",
|
"IsValueNeedConvert": "是否需要值类型转换",
|
||||||
"StandardFieldValueType": "标准物模型值类型",
|
"StandardFieldValueType": "标准物模型值类型"
|
||||||
"copyStandardThingModel": "复制标准模型",
|
|
||||||
"copyAnotherThingModelModal": "复制已有模型"
|
|
||||||
},
|
},
|
||||||
"IoTDBBase": {
|
"IoTDBBase": {
|
||||||
"IoTDataType": "数据类型",
|
"IoTDataType": "数据类型",
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import { message as Message, Modal, Tag } from 'ant-design-vue';
|
|||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
postThingModelInfoCopyAnotherThingModelAsync,
|
|
||||||
postThingModelInfoCopyStandardThingModel,
|
postThingModelInfoCopyStandardThingModel,
|
||||||
postThingModelInfoCreateAsync,
|
postThingModelInfoCreateAsync,
|
||||||
postThingModelInfoDeleteAsync,
|
postThingModelInfoDeleteAsync,
|
||||||
@ -23,7 +22,6 @@ import { $t } from '#/locales';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
addThingModelFormSchema,
|
addThingModelFormSchema,
|
||||||
copyThingModelFormSchema,
|
|
||||||
editThingModelFormSchema,
|
editThingModelFormSchema,
|
||||||
querySchema,
|
querySchema,
|
||||||
tableSchema,
|
tableSchema,
|
||||||
@ -77,16 +75,12 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page }, formValues) => {
|
query: async ({ page }, formValues) => {
|
||||||
const { data } = await postThingModelInfoPageAsync({
|
const { data } = await postThingModelInfoPageAsync({
|
||||||
query: {
|
body: {
|
||||||
pageIndex: page.currentPage,
|
pageIndex: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
|
||||||
ioTPlatformProductId: props.productId,
|
|
||||||
...formValues,
|
...formValues,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// 更新数据状态,检查是否有数据
|
|
||||||
hasData.value = data?.items && data.items.length > 0;
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -97,10 +91,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
|||||||
|
|
||||||
const editRow: Record<string, any> = ref({});
|
const editRow: Record<string, any> = ref({});
|
||||||
|
|
||||||
// 跟踪数据状态,用于控制按钮显示
|
|
||||||
const hasData = ref(true);
|
|
||||||
|
|
||||||
|
|
||||||
const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
||||||
draggable: true,
|
draggable: true,
|
||||||
footer: true,
|
footer: true,
|
||||||
@ -123,20 +113,6 @@ const [ThingModelModal, thingModelModalApi] = useVbenModal({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const [CopyModal, copyModalApi] = useVbenModal({
|
|
||||||
draggable: true,
|
|
||||||
footer: true,
|
|
||||||
showCancelButton: true,
|
|
||||||
showConfirmButton: true,
|
|
||||||
onConfirm: submitCopy,
|
|
||||||
onBeforeClose: () => {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onCancel: () => {
|
|
||||||
copyModalApi.close();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const [AddForm, addFormApi] = useVbenForm({
|
const [AddForm, addFormApi] = useVbenForm({
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
@ -167,27 +143,11 @@ const [EditForm, editFormApi] = useVbenForm({
|
|||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [CopyForm, copyFormApi] = useVbenForm({
|
|
||||||
collapsed: false,
|
|
||||||
commonConfig: {
|
|
||||||
labelWidth: 110,
|
|
||||||
componentProps: {
|
|
||||||
class: 'w-4/5',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
layout: 'horizontal',
|
|
||||||
schema: copyThingModelFormSchema.value,
|
|
||||||
showCollapseButton: false,
|
|
||||||
showDefaultActions: false,
|
|
||||||
wrapperClass: 'grid-cols-2',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 监听props变化,自动设置筛选条件
|
// 监听props变化,自动设置筛选条件
|
||||||
watch(
|
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 () => {
|
||||||
@ -273,54 +233,6 @@ const openAddModal = async () => {
|
|||||||
thingModelModalApi.open();
|
thingModelModalApi.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开复制已有模型模态框
|
|
||||||
const openCopyAnotherThingModelModal = async () => {
|
|
||||||
console.log('打开复制模态框,当前props:', {
|
|
||||||
productId: props.productId,
|
|
||||||
productName: props.productName,
|
|
||||||
ioTPlatform: props.ioTPlatform
|
|
||||||
});
|
|
||||||
copyModalApi.open();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 复制提交逻辑
|
|
||||||
async function submitCopy() {
|
|
||||||
const { valid } = await copyFormApi.validate();
|
|
||||||
if (!valid) return;
|
|
||||||
|
|
||||||
const formValues = await copyFormApi.getValues();
|
|
||||||
|
|
||||||
console.log('复制提交参数:', {
|
|
||||||
formValues,
|
|
||||||
props: {
|
|
||||||
productId: props.productId,
|
|
||||||
productName: props.productName,
|
|
||||||
ioTPlatform: props.ioTPlatform
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const resp = await postThingModelInfoCopyAnotherThingModelAsync({
|
|
||||||
body: {
|
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
|
||||||
ioTPlatformProductId: props.productId,
|
|
||||||
sourceProductId: formValues.ioTPlatformProductId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (resp.data) {
|
|
||||||
Message.success('复制模型成功');
|
|
||||||
copyModalApi.close();
|
|
||||||
gridApi.reload();
|
|
||||||
} else {
|
|
||||||
Message.error('复制模型失败');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('复制模型失败:', error);
|
|
||||||
Message.error('复制模型失败');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除函数
|
// 删除函数
|
||||||
async function onDel(record: any) {
|
async function onDel(record: any) {
|
||||||
try {
|
try {
|
||||||
@ -365,7 +277,6 @@ function closeModal() {
|
|||||||
emit('update:visible', false);
|
emit('update:visible', false);
|
||||||
emit('close');
|
emit('close');
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -384,20 +295,12 @@ function closeModal() {
|
|||||||
auth: ['AbpIdentity.Users.Create'],
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
label: '复制标准模型',
|
||||||
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: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
|
||||||
type: 'default',
|
|
||||||
icon: 'ant-design:copy-outlined',
|
|
||||||
onClick: openCopyAnotherThingModelModal,
|
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
|
||||||
ifShow: !hasData,
|
|
||||||
},
|
|
||||||
]" />
|
]" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -437,10 +340,5 @@ 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>
|
||||||
|
|
||||||
<!-- 复制已有模型模态框 -->
|
|
||||||
<CopyModal title="复制已有模型" class="w-[600px]">
|
|
||||||
<CopyForm />
|
|
||||||
</CopyModal>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -4,10 +4,7 @@ import { z } from '@vben/common-ui';
|
|||||||
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import {
|
import { getCommonGetSelectList } from '#/api-client';
|
||||||
getCommonGetSelectList,
|
|
||||||
postOneNetProductListAsync,
|
|
||||||
} from '#/api-client';
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
export const querySchema = computed(() => [
|
export const querySchema = computed(() => [
|
||||||
@ -254,8 +251,7 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
optionsPropName: 'options',
|
optionsPropName: 'options',
|
||||||
immediate: true,
|
immediate: true,
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder:
|
placeholder: $t('common.pleaseSelect') + $t('abp.thingModelInfos.FiledType'),
|
||||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.FiledType'),
|
|
||||||
afterFetch: (res: any) => {
|
afterFetch: (res: any) => {
|
||||||
// 确保返回的是数组格式
|
// 确保返回的是数组格式
|
||||||
if (Array.isArray(res)) {
|
if (Array.isArray(res)) {
|
||||||
@ -281,8 +277,7 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
),
|
),
|
||||||
componentProps: {
|
componentProps: {
|
||||||
// disabled: true, // 编辑时禁用
|
// disabled: true, // 编辑时禁用
|
||||||
placeholder:
|
placeholder: $t('common.pleaseInput') +
|
||||||
$t('common.pleaseInput') +
|
|
||||||
$t('abp.thingModelInfos.IoTPlatformRawFieldName'),
|
$t('abp.thingModelInfos.IoTPlatformRawFieldName'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -303,9 +298,7 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
.toString()
|
.toString()
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
},
|
},
|
||||||
placeholder:
|
placeholder: $t('common.pleaseInput') + $t('abp.thingModelInfos.StandardFieldDisplayName'),
|
||||||
$t('common.pleaseInput') +
|
|
||||||
$t('abp.thingModelInfos.StandardFieldDisplayName'),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -315,8 +308,7 @@ 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:
|
placeholder: $t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName')
|
||||||
$t('common.pleaseSelect') + $t('abp.thingModelInfos.StandardFieldName'),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -338,8 +330,7 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
disabled: true, // 编辑时禁用
|
disabled: true, // 编辑时禁用
|
||||||
placeholder:
|
placeholder: $t('common.pleaseSelect') +
|
||||||
$t('common.pleaseSelect') +
|
|
||||||
$t('abp.thingModelInfos.StandardFieldValueType'),
|
$t('abp.thingModelInfos.StandardFieldValueType'),
|
||||||
afterFetch: (res: any) => {
|
afterFetch: (res: any) => {
|
||||||
let items = [];
|
let items = [];
|
||||||
@ -369,47 +360,3 @@ export const editThingModelFormSchema = computed(() => [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 复制已有模型表单schema
|
|
||||||
export const copyThingModelFormSchema = computed(() => [
|
|
||||||
{
|
|
||||||
component: 'ApiSelect',
|
|
||||||
fieldName: 'ioTPlatformProductId',
|
|
||||||
label: '选择要复制的产品',
|
|
||||||
rules: z.preprocess(
|
|
||||||
(v) => (v == null ? '' : v),
|
|
||||||
z.string().min(1, '请选择要复制的产品'),
|
|
||||||
),
|
|
||||||
componentProps: {
|
|
||||||
api: postOneNetProductListAsync,
|
|
||||||
params: {
|
|
||||||
query: {
|
|
||||||
pageIndex: 1,
|
|
||||||
pageSize: 1000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
labelField: 'productName',
|
|
||||||
valueField: 'ioTPlatformProductId',
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (res && Array.isArray(res.data.items)) {
|
|
||||||
return res.data.items;
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user