文件管理优化,OneNET产品管理优化
This commit is contained in:
parent
9a9420f423
commit
ee179e1f6d
@ -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,
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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": "物模型文件链接"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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',
|
||||
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')}`,
|
||||
}),
|
||||
},
|
||||
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')}`,
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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中处理,不需要表单字段
|
||||
]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user