feat: block upload file replace other system file
This commit is contained in:
parent
fb70e5174a
commit
b100da112d
4 changed files with 12 additions and 19 deletions
|
|
@ -10,7 +10,7 @@ const props = withDefaults(
|
|||
defineProps<{
|
||||
open: boolean
|
||||
error: {
|
||||
fileExistMetadata?: boolean
|
||||
externalFileExist?: boolean
|
||||
fileExist?: boolean
|
||||
fileName2Long?: boolean
|
||||
}
|
||||
|
|
@ -189,12 +189,12 @@ const file = ref<File | undefined>()
|
|||
: 'เลือกไฟล์'
|
||||
"
|
||||
:error="
|
||||
!!error.fileExistMetadata ||
|
||||
!!error.externalFileExist ||
|
||||
!!error.fileExist ||
|
||||
!!error.fileName2Long
|
||||
"
|
||||
:error-message="
|
||||
error.fileExistMetadata
|
||||
error.externalFileExist
|
||||
? 'พบไฟล์ชื่อซ้ำในระบบอื่น'
|
||||
: error.fileExist
|
||||
? 'พบไฟล์ชื่อซ้ำในระบบ ไฟล์ชื่อนี้ภายในระบบจะถูกเขียนทับ'
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ const fileFormData = ref<{
|
|||
}>({})
|
||||
const fileFormType = ref<'edit' | 'create'>('create')
|
||||
const fileFormError = ref<{
|
||||
fileExistMetadata?: boolean
|
||||
externalFileExist?: boolean
|
||||
fileExist?: boolean
|
||||
fileName2Long?: boolean
|
||||
}>({})
|
||||
const fileExistNotification = ref<boolean>(false)
|
||||
const errorState = ref<'fileExist' | 'fileExistMetadata'>('fileExist')
|
||||
const errorState = ref<'fileExist' | 'externalFileExist'>('fileExist')
|
||||
const fileFormComponent = ref<InstanceType<typeof FileForm>>()
|
||||
const fileNameLabel = ref<string>()
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ async function submitFileForm(
|
|||
|
||||
if (fileInfo?.metadata && Object.keys(fileInfo.metadata).length > 0) {
|
||||
fileExistNotification.value = true
|
||||
errorState.value = 'fileExistMetadata'
|
||||
errorState.value = 'externalFileExist'
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ async function submitFileForm(
|
|||
@reset="() => (fileFormError = {})"
|
||||
@filechange="
|
||||
(name: string) => {
|
||||
fileFormError.fileExistMetadata = checkFileExistMetadata(name)
|
||||
fileFormError.externalFileExist = checkFileExistMetadata(name)
|
||||
;(fileFormError.fileExist = checkFileExist(name, fileNameLabel)),
|
||||
(fileFormError.fileName2Long = checkFileName2Long(
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -377,14 +377,7 @@ const onRowClick = ((_, row) => {
|
|||
@click.stop="
|
||||
() =>
|
||||
fileFormComponent?.triggerFileEdit(
|
||||
{
|
||||
title: data.row.title,
|
||||
description: data.row.description,
|
||||
keyword: data.row.keyword,
|
||||
category: data.row.category,
|
||||
author: data.row.author,
|
||||
metadata: data.row.metadata,
|
||||
},
|
||||
data.row,
|
||||
data.row.pathname,
|
||||
data.row.fileName,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
defineProps<{
|
||||
notification: boolean
|
||||
errorState: 'fileExist' | 'fileExistMetadata'
|
||||
errorState: 'fileExist' | 'externalFileExist'
|
||||
}>()
|
||||
|
||||
defineEmits(['update:notification', 'confirm', 'cancel'])
|
||||
|
|
@ -25,14 +25,14 @@ defineEmits(['update:notification', 'confirm', 'cancel'])
|
|||
<div>
|
||||
<h6 class="q-my-none">
|
||||
{{
|
||||
errorState === 'fileExistMetadata'
|
||||
errorState === 'externalFileExist'
|
||||
? 'พบไฟล์ชื่อช้ำในระบบอื่น'
|
||||
: 'ยืนยันการเพิ่มข้อมูล'
|
||||
}}
|
||||
</h6>
|
||||
<p class="q-my-none">
|
||||
{{
|
||||
errorState === 'fileExistMetadata'
|
||||
errorState === 'externalFileExist'
|
||||
? 'พบไฟล์ชื่อช้ำในระบบอื่น จะไม่สามารถอัปโหลดไฟล์นี้ได้'
|
||||
: 'ไฟล์ที่มีอยู่จะถูกแทนที่ด้วยไฟล์ใหม่ต้องการยืนยันการอัปโหลดไฟล์นี้หรือไม่'
|
||||
}}
|
||||
|
|
@ -55,7 +55,7 @@ defineEmits(['update:notification', 'confirm', 'cancel'])
|
|||
color="warning"
|
||||
@click="
|
||||
() =>
|
||||
errorState === 'fileExistMetadata'
|
||||
errorState === 'externalFileExist'
|
||||
? $emit('cancel')
|
||||
: $emit('confirm')
|
||||
"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue