文件管理优化,OneNET产品管理优化

This commit is contained in:
ChenYi 2025-07-29 10:06:30 +08:00
parent 9a9420f423
commit ee179e1f6d
8 changed files with 206 additions and 153 deletions

View File

@ -3362,11 +3362,11 @@ export const IoTDBDynamicObjectPagedResultDtoSchema = {
} as const; } as const;
export const IoTPlatformTypeEnumSchema = { export const IoTPlatformTypeEnumSchema = {
enum: [0, 1, 2], enum: [1, 2],
type: 'integer', type: 'integer',
description: '物联网平台类型枚举', description: '物联网平台类型枚举',
format: 'int32', format: 'int32',
'说明:': '无=0,电信CTWing=1,移动OneNET=2' '说明:': '电信CTWing=1,移动OneNET=2'
} as const; } as const;
export const LanguageInfoSchema = { export const LanguageInfoSchema = {
@ -4429,6 +4429,11 @@ export const OneNETProductInfoDtoSchema = {
description: 'OneNET账户Id', description: 'OneNET账户Id',
nullable: true nullable: true
}, },
oneNETAccountName: {
type: 'string',
description: 'OneNET账户',
nullable: true
},
ioTPlatformProductId: { ioTPlatformProductId: {
type: 'string', type: 'string',
description: '物联网平台对应的产品Id', description: '物联网平台对应的产品Id',
@ -4449,10 +4454,6 @@ export const OneNETProductInfoDtoSchema = {
description: '设备物模型文件管理地址', description: '设备物模型文件管理地址',
nullable: true nullable: true
}, },
isEncrypted: {
type: 'boolean',
description: '通信是否加密'
},
isEnabled: { isEnabled: {
type: 'boolean', type: 'boolean',
description: '是否启用' description: '是否启用'
@ -4655,32 +4656,38 @@ export const OneNetAccountModifyInputSchema = {
} as const; } as const;
export const OneNetProductInfoInsertInputSchema = { export const OneNetProductInfoInsertInputSchema = {
required: ['communicationAddress', 'ioTPlatformProductId', 'oneNETAccountId', 'productAccesskey'],
type: 'object', type: 'object',
properties: { properties: {
oneNETAccountId: { oneNETAccountId: {
minLength: 1,
type: 'string', type: 'string',
description: 'OneNET 账号ID', description: 'OneNET 账号ID'
nullable: true
}, },
ioTPlatformProductId: { ioTPlatformProductId: {
minLength: 1,
type: 'string', type: 'string',
description: '物联网平台对应的产品Id', description: '物联网平台对应的产品Id'
nullable: true
}, },
productAccesskey: { productAccesskey: {
minLength: 1,
type: 'string', type: 'string',
description: '产品访问密钥', description: '产品访问密钥'
nullable: true
}, },
communicationAddress: { communicationAddress: {
minLength: 1,
type: 'string', type: 'string',
description: '通讯服务地址', description: '通讯服务地址'
nullable: true
}, },
communicationAddressTLS: { communicationAddressTLS: {
type: 'string', type: 'string',
description: 'TLS通讯服务地址', description: 'TLS通讯服务地址',
nullable: true nullable: true
},
deviceThingModelUrl: {
type: 'string',
description: '物模型文件链接',
nullable: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -4733,11 +4740,43 @@ export const OneNetProductInfoListInputSchema = {
} as const; } as const;
export const OneNetProductInfoModifyInputSchema = { export const OneNetProductInfoModifyInputSchema = {
required: ['communicationAddress', 'ioTPlatformProductId', 'oneNETAccountId', 'productAccesskey'],
type: 'object', type: 'object',
properties: { properties: {
id: { id: {
type: 'string', type: 'string',
description: '产品数据ID',
format: 'uuid' format: 'uuid'
},
oneNETAccountId: {
minLength: 1,
type: 'string',
description: 'OneNET 账号ID'
},
ioTPlatformProductId: {
minLength: 1,
type: 'string',
description: '物联网平台对应的产品Id'
},
productAccesskey: {
minLength: 1,
type: 'string',
description: '产品访问密钥'
},
communicationAddress: {
minLength: 1,
type: 'string',
description: '通讯服务地址'
},
communicationAddressTLS: {
type: 'string',
description: 'TLS通讯服务地址',
nullable: true
},
deviceThingModelUrl: {
type: 'string',
description: '物模型文件链接',
nullable: true
} }
}, },
additionalProperties: false, additionalProperties: false,

View File

@ -1380,7 +1380,7 @@ export type IoTDBDynamicObjectPagedResultDto = {
/** /**
* *
*/ */
export type IoTPlatformTypeEnum = 0 | 1 | 2; export type IoTPlatformTypeEnum = 1 | 2;
export type IStringValueType = { export type IStringValueType = {
readonly name?: (string) | null; readonly name?: (string) | null;
@ -2107,6 +2107,10 @@ export type OneNETProductInfoDto = {
* OneNET账户Id * OneNET账户Id
*/ */
oneNETAccountId?: (string) | null; oneNETAccountId?: (string) | null;
/**
* OneNET账户
*/
oneNETAccountName?: (string) | null;
/** /**
* Id * Id
*/ */
@ -2123,10 +2127,6 @@ export type OneNETProductInfoDto = {
* *
*/ */
deviceThingModelUrl?: (string) | null; deviceThingModelUrl?: (string) | null;
/**
*
*/
isEncrypted?: boolean;
/** /**
* *
*/ */
@ -2200,23 +2200,27 @@ export type OneNetProductInfoInsertInput = {
/** /**
* OneNET ID * OneNET ID
*/ */
oneNETAccountId?: (string) | null; oneNETAccountId: string;
/** /**
* Id * Id
*/ */
ioTPlatformProductId?: (string) | null; ioTPlatformProductId: string;
/** /**
* 访 * 访
*/ */
productAccesskey?: (string) | null; productAccesskey: string;
/** /**
* *
*/ */
communicationAddress?: (string) | null; communicationAddress: string;
/** /**
* TLS通讯服务地址 * TLS通讯服务地址
*/ */
communicationAddressTLS?: (string) | null; communicationAddressTLS?: (string) | null;
/**
*
*/
deviceThingModelUrl?: (string) | null;
}; };
export type OneNetProductInfoListInput = { export type OneNetProductInfoListInput = {
@ -2257,7 +2261,34 @@ export type OneNetProductInfoListInput = {
* OneNET产品 * OneNET产品
*/ */
export type OneNetProductInfoModifyInput = { export type OneNetProductInfoModifyInput = {
/**
* ID
*/
id?: string; id?: string;
/**
* OneNET ID
*/
oneNETAccountId: string;
/**
* Id
*/
ioTPlatformProductId: string;
/**
* 访
*/
productAccesskey: string;
/**
*
*/
communicationAddress: string;
/**
* TLS通讯服务地址
*/
communicationAddressTLS?: (string) | null;
/**
*
*/
deviceThingModelUrl?: (string) | null;
}; };
/** /**

View File

@ -269,12 +269,13 @@
"ProductCount": "ProductCount", "ProductCount": "ProductCount",
"OneNETAccountId": "OneNETAccountId", "OneNETAccountId": "OneNETAccountId",
"OneNETProductId": "OneNETProductId", "OneNETProductId": "OneNETProductId",
"ProductKey": "ProductKey",
"ProductSecret": "ProductSecret",
"IoTPlatformProductId": "IoTPlatformProductId", "IoTPlatformProductId": "IoTPlatformProductId",
"ProductName": "ProductName", "ProductName": "ProductName",
"ProductAccesskey": "ProductAccesskey", "ProductAccesskey": "ProductAccesskey",
"IsEncrypted": "IsEncrypted", "IsEncrypted": "IsEncrypted",
"BelongingProductName": "BelongingProductName" "BelongingProductName": "Belonging ProductName",
"CommunicationAddress": "Communication Address",
"CommunicationAddressTLS": "TLS Communication Address",
"DeviceThingModelUrl": "DeviceThingModelUrl"
} }
} }

View File

@ -271,12 +271,13 @@
"ProductCount": "产品数量", "ProductCount": "产品数量",
"OneNETAccountId": "OneNET账户Id", "OneNETAccountId": "OneNET账户Id",
"OneNETProductId": "OneNET产品Id", "OneNETProductId": "OneNET产品Id",
"ProductKey": "产品密钥",
"ProductSecret": "产品密钥",
"IoTPlatformProductId": "物联网平台对应的产品Id", "IoTPlatformProductId": "物联网平台对应的产品Id",
"ProductName": "产品名称", "ProductName": "产品名称",
"ProductAccesskey": "产品访问密钥", "ProductAccesskey": "产品密钥",
"IsEncrypted": "是否加密", "IsEncrypted": "是否加密",
"BelongingProductName": "所属产品" "BelongingProductName": "所属产品",
"CommunicationAddress": "通讯服务地址",
"CommunicationAddressTLS": "TLS通讯服务地址",
"DeviceThingModelUrl": "物模型文件链接"
} }
} }

View File

@ -4,8 +4,8 @@ import { computed } from 'vue';
import { z } from '@vben/common-ui'; import { z } from '@vben/common-ui';
import { $t } from '#/locales';
import { postOneNetAccountListAsync } from '#/api-client'; import { postOneNetAccountListAsync } from '#/api-client';
import { $t } from '#/locales';
export const querySchema = computed(() => [ export const querySchema = computed(() => [
{ {
@ -18,7 +18,12 @@ export const querySchema = computed(() => [
export const tableSchema: any = computed((): VxeGridProps['columns'] => [ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ title: $t('common.seq'), type: 'seq', width: 50 }, { title: $t('common.seq'), type: 'seq', width: 50 },
{ {
field: 'oneNETProductId', field: 'oneNETAccountName',
title: $t('abp.OneNETManagement.BelongingAccountName'),
minWidth: '150',
},
{
field: 'ioTPlatformProductId',
title: $t('abp.OneNETManagement.OneNETProductId'), title: $t('abp.OneNETManagement.OneNETProductId'),
minWidth: '150', minWidth: '150',
}, },
@ -28,22 +33,22 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'productKey', field: 'productAccesskey',
title: $t('abp.OneNETManagement.ProductKey'), title: $t('abp.OneNETManagement.ProductAccesskey'),
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'productSecret', field: 'communicationAddress',
title: $t('abp.OneNETManagement.ProductSecret'), title: $t('abp.OneNETManagement.CommunicationAddress'),
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'accountName', field: 'communicationAddressTLS',
title: $t('abp.OneNETManagement.AccountName'), title: $t('abp.OneNETManagement.CommunicationAddressTLS'),
minWidth: '150', minWidth: '150',
}, },
{ {
field: 'enabled', field: 'isEnabled',
title: $t('common.isEnable'), title: $t('common.isEnable'),
minWidth: '150', minWidth: '150',
slots: { default: 'isEnable' }, slots: { default: 'isEnable' },
@ -74,32 +79,25 @@ export const addProductFormSchema: any = computed(() => [
valueField: 'oneNETAccountId', valueField: 'oneNETAccountId',
immediate: true, immediate: true,
afterFetch: (res: any) => { afterFetch: (res: any) => {
console.log('ApiSelect afterFetch res:', res);
// 如果是 Axios 响应对象,提取 data // 如果是 Axios 响应对象,提取 data
if (res && res.data) { if (res && res.data) {
console.log('提取 res.data:', res.data);
const data = res.data; const data = res.data;
// 确保返回的是数组格式 // 确保返回的是数组格式
if (Array.isArray(data)) { if (Array.isArray(data)) {
console.log('返回数组,长度:', data.length);
return data; return data;
} }
// 如果是包装在 items 中的,提取出来 // 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) { if (data && Array.isArray(data.items)) {
console.log('返回items数组长度:', data.items.length);
return data.items; return data.items;
} }
// 如果是包装在 data 中的,提取出来 // 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) { if (data && Array.isArray(data.data)) {
console.log('返回data数组长度:', data.data.length);
return data.data; return data.data;
} }
} }
// 如果都不是,返回空数组 // 如果都不是,返回空数组
console.log('没有找到数组数据,返回空数组');
return []; return [];
}, },
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`, placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
@ -110,7 +108,7 @@ export const addProductFormSchema: any = computed(() => [
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'oneNETProductId', fieldName: 'IoTPlatformProductId',
label: $t('abp.OneNETManagement.OneNETProductId'), label: $t('abp.OneNETManagement.OneNETProductId'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
@ -118,73 +116,43 @@ export const addProductFormSchema: any = computed(() => [
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'productName', fieldName: 'productAccesskey',
label: $t('abp.OneNETManagement.ProductName'), label: $t('abp.OneNETManagement.ProductAccesskey'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductName')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductAccesskey')}`,
}), }),
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'productKey', fieldName: 'communicationAddress',
label: $t('abp.OneNETManagement.ProductKey'), label: $t('abp.OneNETManagement.CommunicationAddress'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductKey')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddress')}`,
}), }),
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'productSecret', fieldName: 'CommunicationAddressTLS',
label: $t('abp.OneNETManagement.ProductSecret'), label: $t('abp.OneNETManagement.CommunicationAddressTLS'),
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductSecret')}`, message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddressTLS')}`,
}), }),
}, },
{ {
component: 'Switch', component: 'Input',
componentProps: { fieldName: 'DeviceThingModelUrl',
class: 'w-auto', label: $t('abp.OneNETManagement.DeviceThingModelUrl'),
}, rules: z.string().min(1, {
fieldName: 'enabled', message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.DeviceThingModelUrl')}`,
label: $t('common.isEnable'), }),
}, },
]); ]);
export const editProductFormSchemaEdit: any = computed(() => [ export const editProductFormSchemaEdit: any = computed(() => [
{
component: 'Input',
fieldName: 'oneNETProductId',
label: $t('abp.OneNETManagement.OneNETProductId'),
disabled: true,
},
{
component: 'Input',
fieldName: 'productName',
label: $t('abp.OneNETManagement.ProductName'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductName')}`,
}),
},
{
component: 'Input',
fieldName: 'productKey',
label: $t('abp.OneNETManagement.ProductKey'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductKey')}`,
}),
},
{
component: 'Input',
fieldName: 'productSecret',
label: $t('abp.OneNETManagement.ProductSecret'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductSecret')}`,
}),
},
{ {
component: 'ApiSelect', component: 'ApiSelect',
fieldName: 'accountName', fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.AccountName'), label: $t('abp.OneNETManagement.BelongingAccountName'),
componentProps: { componentProps: {
api: postOneNetAccountListAsync, api: postOneNetAccountListAsync,
params: { params: {
@ -197,46 +165,71 @@ export const editProductFormSchemaEdit: any = computed(() => [
valueField: 'oneNETAccountId', valueField: 'oneNETAccountId',
immediate: true, immediate: true,
afterFetch: (res: any) => { afterFetch: (res: any) => {
console.log('ApiSelect afterFetch res:', res);
// 如果是 Axios 响应对象,提取 data // 如果是 Axios 响应对象,提取 data
if (res && res.data) { if (res && res.data) {
console.log('提取 res.data:', res.data);
const data = res.data; const data = res.data;
// 确保返回的是数组格式 // 确保返回的是数组格式
if (Array.isArray(data)) { if (Array.isArray(data)) {
console.log('返回数组,长度:', data.length);
return data; return data;
} }
// 如果是包装在 items 中的,提取出来 // 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) { if (data && Array.isArray(data.items)) {
console.log('返回items数组长度:', data.items.length);
return data.items; return data.items;
} }
// 如果是包装在 data 中的,提取出来 // 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) { if (data && Array.isArray(data.data)) {
console.log('返回data数组长度:', data.data.length);
return data.data; return data.data;
} }
} }
// 如果都不是,返回空数组 // 如果都不是,返回空数组
console.log('没有找到数组数据,返回空数组');
return []; return [];
}, },
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`, placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
}, },
rules: z.string().min(1, { rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`, message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
}), }),
}, },
{ {
component: 'Switch', component: 'Input',
componentProps: { fieldName: 'IoTPlatformProductId',
class: 'w-auto', label: $t('abp.OneNETManagement.OneNETProductId'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
}),
}, },
fieldName: 'enabled', {
label: $t('common.isEnable'), component: 'Input',
fieldName: 'productAccesskey',
label: $t('abp.OneNETManagement.ProductAccesskey'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.ProductAccesskey')}`,
}),
},
{
component: 'Input',
fieldName: 'communicationAddress',
label: $t('abp.OneNETManagement.CommunicationAddress'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddress')}`,
}),
},
{
component: 'Input',
fieldName: 'CommunicationAddressTLS',
label: $t('abp.OneNETManagement.CommunicationAddressTLS'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.CommunicationAddressTLS')}`,
}),
},
{
component: 'Input',
fieldName: 'DeviceThingModelUrl',
label: $t('abp.OneNETManagement.DeviceThingModelUrl'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.DeviceThingModelUrl')}`,
}),
}, },
]); ]);

View File

@ -9,9 +9,12 @@ import { $t } from '#/locales';
import { addFormSchema } from './schema'; import { addFormSchema } from './schema';
import { postFilesUpload } from '#/api-client/index'; import { postFilesUpload } from '#/api-client/index';
import { useUserStore } from '@vben/stores';
const emit = defineEmits(['reload']); const emit = defineEmits(['reload']);
const userStore = useUserStore();
// //
const UploadIcon = createIconifyIcon('mdi:upload'); const UploadIcon = createIconifyIcon('mdi:upload');
const FolderIcon = createIconifyIcon('mdi:folder'); const FolderIcon = createIconifyIcon('mdi:folder');
@ -144,51 +147,39 @@ const handleUpload = async () => {
uploading.value = true; uploading.value = true;
try { try {
//
const formValues = await formApi.getValues();
console.log('Form values:', formValues);
console.log('File list:', fileList.value); console.log('File list:', fileList.value);
// FormData //
const uploadFormData = new FormData(); const files = fileList.value
.map(fileInfo => fileInfo.originFileObj)
.filter(file => file !== null && file !== undefined);
// FormData console.log('Extracted files:', files);
fileList.value.forEach((fileInfo, index) => {
if (fileInfo.originFileObj) {
console.log(`Adding file ${index}:`, fileInfo.name, fileInfo.originFileObj);
uploadFormData.append('files', fileInfo.originFileObj);
}
});
// // - 使API
if (formValues) { console.log('Sending request to /Files/Upload...');
Object.keys(formValues).forEach(key => {
if (formValues[key] !== undefined && formValues[key] !== null) {
console.log(`Adding form field ${key}:`, formValues[key]);
uploadFormData.append(key, formValues[key]);
}
});
}
// FormData
for (let [key, value] of uploadFormData.entries()) {
console.log(`FormData entry: ${key} =`, value);
}
//
const result = await postFilesUpload({ const result = await postFilesUpload({
body: uploadFormData as any, body: {
files: files
},
headers: {
'Authorization': `Bearer ${userStore.userInfo?.token}`,
},
}); });
console.log('Upload result:', result); console.log('Upload result:', result);
console.log('Response status:', result.status);
console.log('Response data:', result.data);
console.log('Response headers:', result.headers);
// //
if (result.status === 204 || result.status === 200) { if (result.status === 204 || result.status === 200) {
message.success(`文件上传成功!共上传 ${fileList.value.length} 个文件`); message.success(`文件上传成功!共上传 ${fileList.value.length} 个文件`);
console.log('Emitting reload event...');
emit('reload'); emit('reload');
modalApi.close(); modalApi.close();
} else { } else {
message.error('文件上传失败,请重试'); message.error(`文件上传失败,状态码: ${result.status}`);
} }
} catch (error) { } catch (error) {
console.error('Upload error:', error); console.error('Upload error:', error);

View File

@ -73,6 +73,11 @@ const [AddVbenModal, addModalApi] = useVbenModal({
connectedComponent: AddModal, connectedComponent: AddModal,
}); });
const handleReload = () => {
console.log('Reloading file list...');
gridApi.reload();
};
const handleAdd = () => { const handleAdd = () => {
addModalApi.open(); addModalApi.open();
}; };
@ -144,7 +149,7 @@ const handleDown = async (row: any) => {
/> />
</template> </template>
</Grid> </Grid>
<AddVbenModal @reload="gridApi.reload" /> <AddVbenModal @reload="handleReload" />
</Page> </Page>
</template> </template>
<style scoped></style> <style scoped></style>

View File

@ -69,13 +69,5 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
]); ]);
export const addFormSchema = computed(() => [ export const addFormSchema = computed(() => [
// 文件上传现在在AddModal中处理 // 文件上传现在在AddModal中处理不需要表单字段
{
component: 'Input',
fieldName: 'note',
label: $t('common.note'),
componentProps: {
placeholder: '请输入备注信息',
},
},
]); ]);