提交 bc2fb40c authored 作者: matian's avatar matian

fix:修改文件上传删除问题

上级 39f73449
...@@ -49,7 +49,12 @@ const handleSuccess = (response: any, file: any, files: any) => { ...@@ -49,7 +49,12 @@ const handleSuccess = (response: any, file: any, files: any) => {
'update:modelValue', 'update:modelValue',
files.map((item: any) => { files.map((item: any) => {
console.log(item, 'items') console.log(item, 'items')
return { name: item.name, url: item.url || item.raw.url, size: item.raw.size, type: item.raw.type || item.raw.url } return {
name: item.name,
url: item.url || item.raw.url,
size: item.raw.size,
type: item.raw.type || item.raw.url
}
}) })
) )
} else { } else {
...@@ -64,12 +69,16 @@ const handleExceed: UploadProps['onExceed'] = () => { ...@@ -64,12 +69,16 @@ const handleExceed: UploadProps['onExceed'] = () => {
// 删除 // 删除
const handleRemove: UploadProps['onRemove'] = (file, files) => { const handleRemove: UploadProps['onRemove'] = (file, files) => {
emit( if (showFileList.value) {
'update:modelValue', emit(
files.map((item: any) => { 'update:modelValue',
return { name: item.name, url: item.url || item.raw.url } files.map((item: any) => {
}) return { name: item.name, url: item.url || item.raw.url }
) })
)
} else {
emit('update:modelValue', '')
}
} }
// 预览 // 预览
...@@ -94,7 +103,7 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => { ...@@ -94,7 +103,7 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
<template v-if="showFileList"> <template v-if="showFileList">
<template v-if="$attrs['list-type'] === 'picture-card'"> <template v-if="$attrs['list-type'] === 'picture-card'">
<el-icon><Plus /></el-icon> <el-icon><Plus /></el-icon>
</template> </template>
<template v-else> <template v-else>
<el-button type="primary" class="app-upload-btn">点击上传</el-button> <el-button type="primary" class="app-upload-btn">点击上传</el-button>
</template> </template>
......
...@@ -54,9 +54,7 @@ let form: any = $ref({ ...@@ -54,9 +54,7 @@ let form: any = $ref({
watch( watch(
() => form.file, () => form.file,
value => { value => {
console.log(form.file) form.name = value[0]?.name.slice(0, value[0]?.name.lastIndexOf('.')) || ''
const name = value[0]?.name
form.name = name.slice(0, name.lastIndexOf('.')) || ''
} }
) )
......
...@@ -54,8 +54,7 @@ let form: any = $ref({ ...@@ -54,8 +54,7 @@ let form: any = $ref({
watch( watch(
() => form.file, () => form.file,
value => { value => {
const name = value[0]?.name form.name = value[0]?.name.slice(0, value[0]?.name.lastIndexOf('.')) || ''
form.name = name.slice(0, name.lastIndexOf('.')) || ''
} }
) )
...@@ -142,7 +141,7 @@ const createResources = (params: any) => { ...@@ -142,7 +141,7 @@ const createResources = (params: any) => {
// 协议 // 协议
const protocol = ref(false) const protocol = ref(false)
const changeProtocol = (data:any) => { const changeProtocol = (data: any) => {
protocol.value = data.value protocol.value = data.value
} }
</script> </script>
......
...@@ -54,8 +54,7 @@ let form: any = $ref({ ...@@ -54,8 +54,7 @@ let form: any = $ref({
watch( watch(
() => form.file, () => form.file,
value => { value => {
const name = value[0]?.name form.name = value[0]?.name.slice(0, value[0]?.name.lastIndexOf('.')) || ''
form.name = name.slice(0, name.lastIndexOf('.')) || ''
} }
) )
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论