完善商务模块文件上传功能
This commit is contained in:
parent
196a5d864a
commit
0401a28037
|
@ -7,7 +7,66 @@ export {}
|
||||||
|
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
Avatar: typeof import('./../components/Avatar/index.vue')['default']
|
||||||
|
Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default']
|
||||||
|
CellCopy: typeof import('./../components/CellCopy/index.vue')['default']
|
||||||
|
Chart: typeof import('./../components/Chart/index.vue')['default']
|
||||||
|
ColumnSetting: typeof import('./../components/GiTable/src/components/ColumnSetting.vue')['default']
|
||||||
|
CronForm: typeof import('./../components/GenCron/CronForm/index.vue')['default']
|
||||||
|
CronModal: typeof import('./../components/GenCron/CronModal/index.vue')['default']
|
||||||
|
DateRangePicker: typeof import('./../components/DateRangePicker/index.vue')['default']
|
||||||
|
DayForm: typeof import('./../components/GenCron/CronForm/component/day-form.vue')['default']
|
||||||
|
FilePreview: typeof import('./../components/FilePreview/index.vue')['default']
|
||||||
|
GiCellAvatar: typeof import('./../components/GiCell/GiCellAvatar.vue')['default']
|
||||||
|
GiCellGender: typeof import('./../components/GiCell/GiCellGender.vue')['default']
|
||||||
|
GiCellStatus: typeof import('./../components/GiCell/GiCellStatus.vue')['default']
|
||||||
|
GiCellTag: typeof import('./../components/GiCell/GiCellTag.vue')['default']
|
||||||
|
GiCellTags: typeof import('./../components/GiCell/GiCellTags.vue')['default']
|
||||||
|
GiCodeView: typeof import('./../components/GiCodeView/index.vue')['default']
|
||||||
|
GiDot: typeof import('./../components/GiDot/index.tsx')['default']
|
||||||
|
GiEditTable: typeof import('./../components/GiEditTable/GiEditTable.vue')['default']
|
||||||
|
GiFooter: typeof import('./../components/GiFooter/index.vue')['default']
|
||||||
|
GiForm: typeof import('./../components/GiForm/src/GiForm.vue')['default']
|
||||||
|
GiIconBox: typeof import('./../components/GiIconBox/index.vue')['default']
|
||||||
|
GiIconSelector: typeof import('./../components/GiIconSelector/index.vue')['default']
|
||||||
|
GiIframe: typeof import('./../components/GiIframe/index.vue')['default']
|
||||||
|
GiOption: typeof import('./../components/GiOption/index.vue')['default']
|
||||||
|
GiOptionItem: typeof import('./../components/GiOptionItem/index.vue')['default']
|
||||||
|
GiPageLayout: typeof import('./../components/GiPageLayout/index.vue')['default']
|
||||||
|
GiSpace: typeof import('./../components/GiSpace/index.vue')['default']
|
||||||
|
GiSplitButton: typeof import('./../components/GiSplitButton/index.vue')['default']
|
||||||
|
GiSplitPane: typeof import('./../components/GiSplitPane/index.vue')['default']
|
||||||
|
GiSplitPaneFlexibleBox: typeof import('./../components/GiSplitPane/components/GiSplitPaneFlexibleBox.vue')['default']
|
||||||
|
GiSvgIcon: typeof import('./../components/GiSvgIcon/index.vue')['default']
|
||||||
|
GiTable: typeof import('./../components/GiTable/src/GiTable.vue')['default']
|
||||||
|
GiTag: typeof import('./../components/GiTag/index.tsx')['default']
|
||||||
|
GiThemeBtn: typeof import('./../components/GiThemeBtn/index.vue')['default']
|
||||||
|
HourForm: typeof import('./../components/GenCron/CronForm/component/hour-form.vue')['default']
|
||||||
|
Icon403: typeof import('./../components/icons/Icon403.vue')['default']
|
||||||
|
Icon404: typeof import('./../components/icons/Icon404.vue')['default']
|
||||||
|
Icon500: typeof import('./../components/icons/Icon500.vue')['default']
|
||||||
|
IconBorders: typeof import('./../components/icons/IconBorders.vue')['default']
|
||||||
|
IconTableSize: typeof import('./../components/icons/IconTableSize.vue')['default']
|
||||||
|
IconTreeAdd: typeof import('./../components/icons/IconTreeAdd.vue')['default']
|
||||||
|
IconTreeReduce: typeof import('./../components/icons/IconTreeReduce.vue')['default']
|
||||||
|
ImageImport: typeof import('./../components/ImageImport/index.vue')['default']
|
||||||
|
ImageImportWizard: typeof import('./../components/ImageImportWizard/index.vue')['default']
|
||||||
|
IndustrialImageList: typeof import('./../components/IndustrialImageList/index.vue')['default']
|
||||||
|
JsonPretty: typeof import('./../components/JsonPretty/index.vue')['default']
|
||||||
|
MinuteForm: typeof import('./../components/GenCron/CronForm/component/minute-form.vue')['default']
|
||||||
|
MonthForm: typeof import('./../components/GenCron/CronForm/component/month-form.vue')['default']
|
||||||
|
ParentView: typeof import('./../components/ParentView/index.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
SecondForm: typeof import('./../components/GenCron/CronForm/component/second-form.vue')['default']
|
||||||
|
SplitPanel: typeof import('./../components/SplitPanel/index.vue')['default']
|
||||||
|
TextCopy: typeof import('./../components/TextCopy/index.vue')['default']
|
||||||
|
TurbineGrid: typeof import('./../components/TurbineGrid/index.vue')['default']
|
||||||
|
UserSelect: typeof import('./../components/UserSelect/index.vue')['default']
|
||||||
|
Verify: typeof import('./../components/Verify/index.vue')['default']
|
||||||
|
VerifyPoints: typeof import('./../components/Verify/Verify/VerifyPoints.vue')['default']
|
||||||
|
VerifySlide: typeof import('./../components/Verify/Verify/VerifySlide.vue')['default']
|
||||||
|
WeekForm: typeof import('./../components/GenCron/CronForm/component/week-form.vue')['default']
|
||||||
|
YearForm: typeof import('./../components/GenCron/CronForm/component/year-form.vue')['default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,6 +409,7 @@
|
||||||
<!-- 上传按钮 -->
|
<!-- 上传按钮 -->
|
||||||
<a-upload
|
<a-upload
|
||||||
ref="uploadRef"
|
ref="uploadRef"
|
||||||
|
:key="uploadDialogVisible ? 'upload-open' : 'upload-closed'"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
:show-file-list="false"
|
:show-file-list="false"
|
||||||
@change="handleFileChange"
|
@change="handleFileChange"
|
||||||
|
@ -1080,11 +1081,38 @@ const handleFileChange = (info) => {
|
||||||
console.log('文件列表:', fileList);
|
console.log('文件列表:', fileList);
|
||||||
console.log('文件列表长度:', fileList.length);
|
console.log('文件列表长度:', fileList.length);
|
||||||
|
|
||||||
|
// 检查是否是组件内部状态触发的(可能是之前的状态)
|
||||||
|
if (fileList.length === 0) {
|
||||||
|
console.log('⚠️ 文件列表为空,可能是组件内部状态,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否是对话框刚打开时的触发(可能是之前的状态)
|
||||||
|
if (!uploadDialogVisible.value) {
|
||||||
|
console.log('⚠️ 对话框未显示,可能是之前的状态触发,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 获取当前已存在的文件UID列表,用于去重
|
// 获取当前已存在的文件UID列表,用于去重
|
||||||
const existingUids = fileListTemp.value.map(f => f.uid);
|
const existingUids = fileListTemp.value.map(f => f.uid);
|
||||||
console.log('已存在的文件UID:', existingUids);
|
console.log('已存在的文件UID:', existingUids);
|
||||||
|
|
||||||
// 处理新选择的文件 - 只处理当前选择的文件
|
// 获取当前文件夹中已存在的文件名列表,用于检查重复
|
||||||
|
const currentFolderFiles = fileList.value || [];
|
||||||
|
const existingFileNames = currentFolderFiles.map(f => f.fileName || f.name);
|
||||||
|
console.log('当前文件夹中的文件:', existingFileNames);
|
||||||
|
|
||||||
|
// 强制重置上传组件状态
|
||||||
|
if (uploadRef.value) {
|
||||||
|
try {
|
||||||
|
uploadRef.value.reset();
|
||||||
|
console.log('已强制重置上传组件');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('重置上传组件时出错:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理新选择的文件 - 支持多文件选择,同时避免重复
|
||||||
fileList.forEach((file, index) => {
|
fileList.forEach((file, index) => {
|
||||||
console.log(`处理第${index + 1}个文件:`, file);
|
console.log(`处理第${index + 1}个文件:`, file);
|
||||||
console.log('文件名称:', file.name);
|
console.log('文件名称:', file.name);
|
||||||
|
@ -1111,12 +1139,21 @@ const handleFileChange = (info) => {
|
||||||
|
|
||||||
console.log('开始验证新文件...');
|
console.log('开始验证新文件...');
|
||||||
|
|
||||||
|
// 检查文件是否已存在于当前文件夹中
|
||||||
|
if (existingFileNames.includes(fileObj.name)) {
|
||||||
|
fileObj.error = '文件已存在于当前文件夹中';
|
||||||
|
console.log('⚠️ 文件已存在于文件夹中:', fileObj.name);
|
||||||
|
// 显示友好的提示信息
|
||||||
|
Message.warning(`文件 "${fileObj.name}" 已存在于当前文件夹中,已跳过`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 验证文件
|
// 验证文件
|
||||||
const isValid = validateFile(fileObj);
|
const isValid = validateFile(fileObj);
|
||||||
console.log('文件验证结果:', isValid);
|
console.log('文件验证结果:', isValid);
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
// 添加文件到列表(支持多文件)
|
// 支持多文件:添加到列表
|
||||||
fileListTemp.value.push(fileObj);
|
fileListTemp.value.push(fileObj);
|
||||||
console.log('✅ 成功添加文件到列表:', fileObj.name);
|
console.log('✅ 成功添加文件到列表:', fileObj.name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1951,6 +1988,13 @@ const handleUploadFile = () => {
|
||||||
if (uploadRef.value) {
|
if (uploadRef.value) {
|
||||||
try {
|
try {
|
||||||
uploadRef.value.reset();
|
uploadRef.value.reset();
|
||||||
|
// 强制清空组件的内部文件列表
|
||||||
|
if (uploadRef.value.fileList) {
|
||||||
|
uploadRef.value.fileList = [];
|
||||||
|
}
|
||||||
|
if (uploadRef.value.fileListTemp) {
|
||||||
|
uploadRef.value.fileListTemp = [];
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('重置上传组件时出错:', error);
|
console.log('重置上传组件时出错:', error);
|
||||||
}
|
}
|
||||||
|
@ -1976,6 +2020,39 @@ watch(currentFolderId, (newId) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 监听上传对话框显示状态,确保文件列表清空
|
||||||
|
watch(uploadDialogVisible, (visible) => {
|
||||||
|
if (visible) {
|
||||||
|
console.log('=== 上传对话框已显示,确保文件列表清空 ===');
|
||||||
|
// 立即清空文件列表
|
||||||
|
fileListTemp.value = [];
|
||||||
|
console.log('✅ 已清空文件列表');
|
||||||
|
|
||||||
|
// 强制重置上传组件
|
||||||
|
if (uploadRef.value) {
|
||||||
|
try {
|
||||||
|
uploadRef.value.reset();
|
||||||
|
// 强制清空组件的内部文件列表
|
||||||
|
if (uploadRef.value.fileList) {
|
||||||
|
uploadRef.value.fileList = [];
|
||||||
|
}
|
||||||
|
if (uploadRef.value.fileListTemp) {
|
||||||
|
uploadRef.value.fileListTemp = [];
|
||||||
|
}
|
||||||
|
console.log('✅ 已重置上传组件');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('❌ 重置上传组件时出错:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 延迟再次清空,确保处理完所有可能的触发
|
||||||
|
setTimeout(() => {
|
||||||
|
fileListTemp.value = [];
|
||||||
|
console.log('✅ 延迟清空文件列表');
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 初始化加载
|
// 初始化加载
|
||||||
|
|
Loading…
Reference in New Issue