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

View File

@ -1380,7 +1380,7 @@ export type IoTDBDynamicObjectPagedResultDto = {
/**
*
*/
export type IoTPlatformTypeEnum = 0 | 1 | 2;
export type IoTPlatformTypeEnum = 1 | 2;
export type IStringValueType = {
readonly name?: (string) | null;
@ -2107,6 +2107,10 @@ export type OneNETProductInfoDto = {
* OneNET账户Id
*/
oneNETAccountId?: (string) | null;
/**
* OneNET账户
*/
oneNETAccountName?: (string) | null;
/**
* Id
*/
@ -2123,10 +2127,6 @@ export type OneNETProductInfoDto = {
*
*/
deviceThingModelUrl?: (string) | null;
/**
*
*/
isEncrypted?: boolean;
/**
*
*/
@ -2200,23 +2200,27 @@ export type OneNetProductInfoInsertInput = {
/**
* OneNET ID
*/
oneNETAccountId?: (string) | null;
oneNETAccountId: string;
/**
* Id
*/
ioTPlatformProductId?: (string) | null;
ioTPlatformProductId: string;
/**
* 访
*/
productAccesskey?: (string) | null;
productAccesskey: string;
/**
*
*/
communicationAddress?: (string) | null;
communicationAddress: string;
/**
* TLS通讯服务地址
*/
communicationAddressTLS?: (string) | null;
/**
*
*/
deviceThingModelUrl?: (string) | null;
};
export type OneNetProductInfoListInput = {
@ -2257,7 +2261,34 @@ export type OneNetProductInfoListInput = {
* OneNET产品
*/
export type OneNetProductInfoModifyInput = {
/**
* ID
*/
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",
"OneNETAccountId": "OneNETAccountId",
"OneNETProductId": "OneNETProductId",
"ProductKey": "ProductKey",
"ProductSecret": "ProductSecret",
"IoTPlatformProductId": "IoTPlatformProductId",
"ProductName": "ProductName",
"ProductAccesskey": "ProductAccesskey",
"IsEncrypted": "IsEncrypted",
"BelongingProductName": "BelongingProductName"
"BelongingProductName": "Belonging ProductName",
"CommunicationAddress": "Communication Address",
"CommunicationAddressTLS": "TLS Communication Address",
"DeviceThingModelUrl": "DeviceThingModelUrl"
}
}

View File

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

View File

@ -4,8 +4,8 @@ import { computed } from 'vue';
import { z } from '@vben/common-ui';
import { $t } from '#/locales';
import { postOneNetAccountListAsync } from '#/api-client';
import { $t } from '#/locales';
export const querySchema = computed(() => [
{
@ -18,7 +18,12 @@ export const querySchema = computed(() => [
export const tableSchema: any = computed((): VxeGridProps['columns'] => [
{ 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'),
minWidth: '150',
},
@ -28,22 +33,22 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
minWidth: '150',
},
{
field: 'productKey',
title: $t('abp.OneNETManagement.ProductKey'),
field: 'productAccesskey',
title: $t('abp.OneNETManagement.ProductAccesskey'),
minWidth: '150',
},
{
field: 'productSecret',
title: $t('abp.OneNETManagement.ProductSecret'),
field: 'communicationAddress',
title: $t('abp.OneNETManagement.CommunicationAddress'),
minWidth: '150',
},
{
field: 'accountName',
title: $t('abp.OneNETManagement.AccountName'),
field: 'communicationAddressTLS',
title: $t('abp.OneNETManagement.CommunicationAddressTLS'),
minWidth: '150',
},
{
field: 'enabled',
field: 'isEnabled',
title: $t('common.isEnable'),
minWidth: '150',
slots: { default: 'isEnable' },
@ -74,32 +79,25 @@ export const addProductFormSchema: any = computed(() => [
valueField: 'oneNETAccountId',
immediate: true,
afterFetch: (res: any) => {
console.log('ApiSelect afterFetch res:', res);
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
console.log('提取 res.data:', res.data);
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
console.log('返回数组,长度:', data.length);
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
console.log('返回items数组长度:', data.items.length);
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
console.log('返回data数组长度:', data.data.length);
return data.data;
}
}
// 如果都不是,返回空数组
console.log('没有找到数组数据,返回空数组');
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
@ -110,7 +108,7 @@ export const addProductFormSchema: any = computed(() => [
},
{
component: 'Input',
fieldName: 'oneNETProductId',
fieldName: 'IoTPlatformProductId',
label: $t('abp.OneNETManagement.OneNETProductId'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
@ -118,73 +116,43 @@ export const addProductFormSchema: any = computed(() => [
},
{
component: 'Input',
fieldName: 'productName',
label: $t('abp.OneNETManagement.ProductName'),
fieldName: 'productAccesskey',
label: $t('abp.OneNETManagement.ProductAccesskey'),
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',
fieldName: 'productKey',
label: $t('abp.OneNETManagement.ProductKey'),
fieldName: 'communicationAddress',
label: $t('abp.OneNETManagement.CommunicationAddress'),
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',
fieldName: 'productSecret',
label: $t('abp.OneNETManagement.ProductSecret'),
fieldName: 'CommunicationAddressTLS',
label: $t('abp.OneNETManagement.CommunicationAddressTLS'),
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',
componentProps: {
class: 'w-auto',
},
fieldName: 'enabled',
label: $t('common.isEnable'),
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')}`,
}),
},
]);
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',
fieldName: 'accountName',
label: $t('abp.OneNETManagement.AccountName'),
fieldName: 'oneNETAccountId',
label: $t('abp.OneNETManagement.BelongingAccountName'),
componentProps: {
api: postOneNetAccountListAsync,
params: {
@ -197,46 +165,71 @@ export const editProductFormSchemaEdit: any = computed(() => [
valueField: 'oneNETAccountId',
immediate: true,
afterFetch: (res: any) => {
console.log('ApiSelect afterFetch res:', res);
// 如果是 Axios 响应对象,提取 data
if (res && res.data) {
console.log('提取 res.data:', res.data);
const data = res.data;
// 确保返回的是数组格式
if (Array.isArray(data)) {
console.log('返回数组,长度:', data.length);
return data;
}
// 如果是包装在 items 中的,提取出来
if (data && Array.isArray(data.items)) {
console.log('返回items数组长度:', data.items.length);
return data.items;
}
// 如果是包装在 data 中的,提取出来
if (data && Array.isArray(data.data)) {
console.log('返回data数组长度:', data.data.length);
return data.data;
}
}
// 如果都不是,返回空数组
console.log('没有找到数组数据,返回空数组');
return [];
},
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`,
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
},
rules: z.string().min(1, {
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.AccountName')}`,
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
}),
},
{
component: 'Switch',
componentProps: {
class: 'w-auto',
},
fieldName: 'enabled',
label: $t('common.isEnable'),
component: 'Input',
fieldName: 'IoTPlatformProductId',
label: $t('abp.OneNETManagement.OneNETProductId'),
rules: z.string().min(1, {
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.OneNETManagement.OneNETProductId')}`,
}),
},
{
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 { postFilesUpload } from '#/api-client/index';
import { useUserStore } from '@vben/stores';
const emit = defineEmits(['reload']);
const userStore = useUserStore();
//
const UploadIcon = createIconifyIcon('mdi:upload');
const FolderIcon = createIconifyIcon('mdi:folder');
@ -144,51 +147,39 @@ const handleUpload = async () => {
uploading.value = true;
try {
//
const formValues = await formApi.getValues();
console.log('Form values:', formValues);
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
fileList.value.forEach((fileInfo, index) => {
if (fileInfo.originFileObj) {
console.log(`Adding file ${index}:`, fileInfo.name, fileInfo.originFileObj);
uploadFormData.append('files', fileInfo.originFileObj);
}
});
console.log('Extracted files:', files);
//
if (formValues) {
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);
}
//
// - 使API
console.log('Sending request to /Files/Upload...');
const result = await postFilesUpload({
body: uploadFormData as any,
body: {
files: files
},
headers: {
'Authorization': `Bearer ${userStore.userInfo?.token}`,
},
});
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) {
message.success(`文件上传成功!共上传 ${fileList.value.length} 个文件`);
console.log('Emitting reload event...');
emit('reload');
modalApi.close();
} else {
message.error('文件上传失败,请重试');
message.error(`文件上传失败,状态码: ${result.status}`);
}
} catch (error) {
console.error('Upload error:', error);

View File

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

View File

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