|
|
@@ -23,7 +23,7 @@
|
|
|
<img src="@/assets/document/4.svg" class="img-hover" v-if="!showUpload" />
|
|
|
<img src="@/assets/document/5.svg" class="img-active" v-if="showUpload" />
|
|
|
</div>
|
|
|
- <p>已选择 {{ fileList.length }} 个文档</p>
|
|
|
+ <p>已选择 {{ tableData.length }} 个文档</p>
|
|
|
</div>
|
|
|
<template #content>
|
|
|
<div :class="{ 'upload-wrap': true, 'upload-wrap-narrow': uploadFile }">
|
|
|
@@ -38,9 +38,16 @@
|
|
|
</header>
|
|
|
<div>
|
|
|
<section v-if="agengtName == '智能数据'">
|
|
|
- <a-upload draggable :multiple="true" :limit="50" :show-file-list="false" @before-upload="onBeforeUpload"
|
|
|
- @exceed-limit="onExceedLimit" @before-remove="onBeforeRemove" :custom-request="customRequest"
|
|
|
- :show-upload-button="{ showOnExceedLimit: true }" accept=".xls,.xlsx,.csv,.db">
|
|
|
+ <a-upload draggable
|
|
|
+ :multiple="true"
|
|
|
+ :limit="50"
|
|
|
+ :show-file-list="false"
|
|
|
+ @before-upload="onBeforeUpload"
|
|
|
+ @exceed-limit="onExceedLimit"
|
|
|
+ @before-remove="onBeforeRemove"
|
|
|
+ :custom-request="customRequest"
|
|
|
+ :show-upload-button="{ showOnExceedLimit: true }"
|
|
|
+ accept=".xls,.xlsx,.csv,.db">
|
|
|
<template #upload-button>
|
|
|
<div class="upload-main">
|
|
|
<p>拖拽文档到这里,或<span>点此上传</span></p>
|
|
|
@@ -53,9 +60,16 @@
|
|
|
</section>
|
|
|
|
|
|
<section v-else>
|
|
|
- <a-upload draggable :multiple="!uploadFile" :limit="50" :show-file-list="false"
|
|
|
- @before-upload="onBeforeUpload" @exceed-limit="onExceedLimit" @before-remove="onBeforeRemove"
|
|
|
- :custom-request="customRequest" :show-upload-button="{ showOnExceedLimit: true }" accept="*">
|
|
|
+ <a-upload draggable
|
|
|
+ :multiple="!uploadFile"
|
|
|
+ :limit="50"
|
|
|
+ :show-file-list="false"
|
|
|
+ @before-upload="onBeforeUpload"
|
|
|
+ @exceed-limit="onExceedLimit"
|
|
|
+ @before-remove="onBeforeRemove"
|
|
|
+ :custom-request="customRequest"
|
|
|
+ :show-upload-button="{ showOnExceedLimit: true }"
|
|
|
+ accept="*">
|
|
|
<template #upload-button>
|
|
|
<div class="upload-main">
|
|
|
<p>拖拽文档到这里,或<span>点此上传</span></p>
|
|
|
@@ -114,7 +128,7 @@
|
|
|
<a-button :loading="buttonLoading" type="primary" @click="selectFiles(true, 'paper')">去{{
|
|
|
uploadFile ? '提问'
|
|
|
: '合并'
|
|
|
- }}({{ fileList.length
|
|
|
+ }}({{ tableData.length
|
|
|
}})</a-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -204,6 +218,12 @@ export default defineComponent({
|
|
|
helper.message("error", `上传文件大小不能超过10M`);
|
|
|
return false;
|
|
|
}
|
|
|
+ const fileName = file.name;
|
|
|
+ const existingFile = tableData.find(item => item.name === fileName);
|
|
|
+ if (existingFile) {
|
|
|
+ helper.message("error", `文件 "${fileName}" 已经上传过`);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return true;
|
|
|
};
|
|
|
const onExceedLimit = () => {
|
|
|
@@ -212,15 +232,18 @@ export default defineComponent({
|
|
|
const customRequest = async (option) => {
|
|
|
const { onSuccess, fileItem } = option;
|
|
|
const { file } = fileItem;
|
|
|
- fileList.value.push(file);
|
|
|
- tableData.push({
|
|
|
- key: `uid-${Date.now()}-${Math.floor(Math.random() * 1000)}`,
|
|
|
- name: file.name,
|
|
|
- type: file.type,
|
|
|
- size: helper.formatSize(file.size),
|
|
|
- time: dayjs(file.lastModified).format("YYYY-MM-DD HH:mm:ss")
|
|
|
- });
|
|
|
- onSuccess();
|
|
|
+ const existingFile = tableData.find(item => item.name === file.name);
|
|
|
+ if (!existingFile) {
|
|
|
+ tableData.push({
|
|
|
+ key: `uid-${Date.now()}-${Math.floor(Math.random() * 1000)}`,
|
|
|
+ name: file.name,
|
|
|
+ type: file.type,
|
|
|
+ size: helper.formatSize(file.size),
|
|
|
+ time: dayjs(file.lastModified).format("YYYY-MM-DD HH:mm:ss")
|
|
|
+ });
|
|
|
+ fileList.value.push(file);
|
|
|
+ }
|
|
|
+ onSuccess();
|
|
|
};
|
|
|
const onBeforeRemove = (data) => {
|
|
|
fileList.value = fileList.value.filter((item) => item.id !== data.uid);
|