Skip to content

Commit d3323b7

Browse files
fix: Optimize file upload
1 parent 923e451 commit d3323b7

8 files changed

Lines changed: 30 additions & 11 deletions

File tree

ui/src/components/dynamics-form/items/upload/LocalFileUpload.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
:auto-upload="false"
1212
:show-file-list="false"
1313
:accept="accept"
14-
:limit="file_count_limit"
1514
:on-exceed="onExceed"
1615
:on-change="fileHandleChange"
1716
@click.prevent="handlePreview(false)"
@@ -60,6 +59,10 @@
6059
{{ $t('dynamicsForm.UploadInput.reUpload') }}
6160
</el-button>
6261
</span>
62+
<span v-else-if="successCount === fileArray.length" class="flex align-center">
63+
<el-icon class="color-success"><WarningFilled /></el-icon>
64+
<span class="ml-4">{{ $t('dynamicsForm.UploadInput.allSuccess') }}</span>
65+
</span>
6366
</div>
6467
<el-row :gutter="8" v-if="fileArray?.length" class="mt-8">
6568
<template v-for="(item, index) in sortedFileArray" :key="index">
@@ -170,6 +173,7 @@ const sortedFileArray = computed(() =>
170173
const retryAll = () => {
171174
retryList.value.forEach((i: any) => uploadFile(i))
172175
}
176+
173177
// 上传on-change事件
174178
const fileHandleChange = (file: any, fileList: UploadFiles) => {
175179
// 按文件唯一标识精确定位并移除当前文件

ui/src/locales/lang/en-US/dynamics-form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default {
139139
uploadStatus: 'Completed {success} / {total} files',
140140
failedStatus: '{count} files failed',
141141
uploading: 'Uploading',
142+
allSuccess: 'All successful',
142143
},
143144
AssignmentMethod: {
144145
label: 'Assignment Method',

ui/src/locales/lang/zh-CN/dynamics-form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default {
139139
uploadStatus: '已完成 {success} / {total} 个文件',
140140
failedStatus: '失败 {count} 个文件',
141141
uploading: '上传中',
142+
allSuccess: '全部成功',
142143
},
143144
AssignmentMethod: {
144145
label: '赋值方式',

ui/src/locales/lang/zh-Hant/dynamics-form.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default {
139139
uploadStatus: '已完成 {success} / {total} 個文件',
140140
failedStatus: '失敗 {count} 個文件',
141141
uploading: '上傳中',
142+
allSuccess: '全部成功',
142143
},
143144
AssignmentMethod: {
144145
label: '賦值方式',

ui/src/views/document/ImportWorkflowDocument.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
>
3838
<el-button
3939
v-if="base_form_list.length > 0 && active == 'data_source'"
40-
:disabled="loading"
40+
:disabled="loading || actionUploading"
4141
@click="next"
4242
>
4343
{{ $t('common.steps.next') }}
@@ -46,7 +46,7 @@
4646
v-if="base_form_list.length > 0 ? active == 'knowledge_base' : active == 'data_source'"
4747
@click="upload"
4848
type="primary"
49-
:disabled="loading"
49+
:disabled="loading || actionUploading"
5050
>
5151
{{ $t('views.document.buttons.import') }}
5252
</el-button>
@@ -113,6 +113,9 @@ const action_id = ref<string>()
113113
const form_data = ref<any>({})
114114
const active = ref<'data_source' | 'knowledge_base' | 'result'>('data_source')
115115
const _workflow = ref<any>(null)
116+
const actionUploading = computed(
117+
() => active.value === 'data_source' && ActionRef.value?.uploadingCount > 0,
118+
)
116119
117120
const base_form_list = computed(() => {
118121
const kBase = _workflow.value?.nodes?.find((n: any) => n.type === WorkflowType.KnowledgeBase)
@@ -122,6 +125,7 @@ const base_form_list = computed(() => {
122125
return []
123126
})
124127
const next = () => {
128+
if (actionUploading.value) return
125129
ActionRef.value.validate().then(() => {
126130
form_data.value[active.value] = ActionRef.value.get_data()
127131
active.value = 'knowledge_base'
@@ -133,6 +137,7 @@ const up = () => {
133137
})
134138
}
135139
const upload = () => {
140+
if (actionUploading.value) return
136141
ActionRef.value.validate().then(() => {
137142
form_data.value[active.value] = ActionRef.value.get_data()
138143
loadSharedApi({ type: 'knowledge', systemType: apiType.value })

ui/src/views/document/UploadDocument.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
@click="next"
3636
type="primary"
3737
v-if="active === 0"
38-
:disabled="SetRulesRef?.loading || loading"
38+
:disabled="SetRulesRef?.loading || loading || uploadComponentUploading"
3939
>
4040
{{
41-
documentsType === 'txt'
42-
? $t('common.steps.next')
43-
: $t('views.document.buttons.import')
41+
documentsType === 'txt' ? $t('common.steps.next') : $t('views.document.buttons.import')
4442
}}
4543
</el-button>
4644
<el-button
@@ -96,7 +94,9 @@ const loading = ref(false)
9694
const disabled = ref(false)
9795
const active = ref(0)
9896
const successInfo = ref<any>(null)
97+
const uploadComponentUploading = computed(() =>UploadComponentRef.value?.uploadingCount> 0)
9998
async function next() {
99+
if (uploadComponentUploading.value) return
100100
disabled.value = true
101101
if (await UploadComponentRef.value.validate()) {
102102
if (documentsType.value === 'QA') {

ui/src/views/document/upload/UploadComponent.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
:auto-upload="false"
5454
:show-file-list="false"
5555
accept=".xlsx, .xls, .csv,.zip"
56-
:limit="file_count_limit"
5756
:on-exceed="onExceed"
5857
:on-change="fileHandleChange"
5958
@click.prevent="handlePreview(false)"
@@ -111,7 +110,6 @@
111110
:auto-upload="false"
112111
:show-file-list="false"
113112
accept=".xlsx, .xls, .csv"
114-
:limit="file_count_limit"
115113
:on-exceed="onExceed"
116114
:on-change="fileHandleChange"
117115
@click.prevent="handlePreview(false)"
@@ -157,7 +155,6 @@
157155
:auto-upload="false"
158156
:show-file-list="false"
159157
accept=".txt, .md, .log, .docx, .pdf, .html,.zip,.xlsx,.xls,.csv"
160-
:limit="file_count_limit"
161158
:on-exceed="onExceed"
162159
:on-change="fileHandleChange"
163160
@click.prevent="handlePreview(false)"
@@ -207,6 +204,10 @@
207204
{{ $t('dynamicsForm.UploadInput.reUpload') }}
208205
</el-button>
209206
</span>
207+
<span v-else-if="successCount === form.fileList.length" class="flex align-center">
208+
<el-icon class="color-success"><WarningFilled /></el-icon>
209+
<span class="ml-4">{{ $t('dynamicsForm.UploadInput.allSuccess') }}</span>
210+
</span>
210211
</div>
211212
<el-row :gutter="8" v-if="form.fileList?.length" class="mt-8">
212213
<template v-for="(item, index) in sortedFileList" :key="index">
@@ -335,6 +336,7 @@ const sortedFileList = computed(() =>
335336
const retryAll = () => {
336337
retryList.value.forEach((i: any) => uploadFile(i))
337338
}
339+
338340
const filterSuccessFiles = (data: any): any => {
339341
return data?.filter((f: any) => f.status === 'success') || []
340342
}
@@ -527,6 +529,7 @@ onUnmounted(() => {
527529
defineExpose({
528530
validate,
529531
form,
532+
uploadingCount,
530533
})
531534
</script>
532535
<style scoped lang="scss"></style>

ui/src/views/knowledge-workflow/component/action/DataSource.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ const base_form_data_rule = ref<FormRules>({
143143
const validate = () => {
144144
return dynamicsFormRef.value?.validate()
145145
}
146+
const uploadingCount = computed(
147+
() =>
148+
(form_data.value as any)?.file_list?.filter((f: any) => f.status === 'uploading').length || 0,
149+
)
146150
const filterSuccessFiles = (data: any): any => {
147151
return {
148152
...data,
@@ -164,6 +168,6 @@ watch(
164168
{ immediate: true },
165169
)
166170
167-
defineExpose({ validate, get_data })
171+
defineExpose({ validate, get_data, uploadingCount })
168172
</script>
169173
<style lang="scss" scoped></style>

0 commit comments

Comments
 (0)