Pre Merge pull request !289 from CyberShen123/dev

CyberShen123 2025-09-25 13:27:01 +00:00 committed by Gitee
commit 1b49cb43bb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 60 additions and 1 deletions

View File

@ -9,6 +9,7 @@
:maxCount="props.uploadNumber"
:progress="progress"
@change="handleChange"
@remove="handleRemove"
:showUploadList="props.showUploadList"
:accept="accept"
:disabled="props.disabled"
@ -30,6 +31,7 @@
list-type="picture-card"
@change="handleChange"
@preview="handlePreview"
@remove="handleRemove"
:progress="progress"
:showUploadList="props.showUploadList"
:accept="accept"
@ -52,6 +54,7 @@
list-type="picture-card"
@change="handleChange"
@preview="handlePreview"
@remove="handleRemove"
:progress="progress"
:showUploadList="props.showUploadList"
:accept="accept"
@ -109,8 +112,11 @@
<script setup name="uploadIndex">
import tool from '@/utils/tool'
import sysConfig from '@/config/index'
import fileApi from '@/api/dev/fileApi';
import { createVNode } from 'vue';
import { convertUrl } from '@/utils/apiAdaptive'
import { message, Upload } from 'ant-design-vue'
import { message, Upload, Modal } from 'ant-design-vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { cloneDeep } from 'lodash-es'
const fileList = ref([])
const emit = defineEmits(['update:value', 'onChange', 'onSuccessful'])
@ -384,6 +390,59 @@
emit('update:value', undefined)
emit('onChange', undefined)
}
//
const handleRemove = (file) => {
return new Promise((resolve,reject) => {
Modal.confirm({
title: '删除确认',
icon: createVNode(ExclamationCircleOutlined),
content: '确定要删除吗?这将从服务器删除该文件',
okText: '确认',
cancelText: '取消',
onOk(){
//
fileList.value = fileList.value.filter((f) => f.url !== file.url)
// id
var fileId = file.url.substring(file.url.lastIndexOf('=') + 1)
fileApi.fileDeleteAbsolute({id:fileId}).then(res => {
if (props.uploadResultCategory === 'interval') {
const resultIntervalValue = ref('')
fileList.value.forEach((data) => {
resultIntervalValue.value =
data.response.data + (resultIntervalValue.value ? ',' + resultIntervalValue.value : '')
})
emit('update:value', resultIntervalValue)
emit('onChange', resultIntervalValue)
} else if (props.uploadResultCategory === 'array') {
if (props.completeResult) {
// thumbUrlbase64
let newResult = cloneDeep(fileList.value)
newResult.map((e) => {
if (e.thumbUrl) {
delete e.thumbUrl
}
})
emit('update:value', newResult)
emit('onChange', newResult)
} else {
const resultArrayValue = ref([])
fileList.value.forEach((data) => {
resultArrayValue.value.push(data.response.data)
})
emit('update:value', resultArrayValue)
emit('onChange', resultArrayValue)
}
}
resolve(file)
})
},
onCancel() {
reject()
},
})
})
}
// DOM
const uploadFileList = () => {
if (fileList.value) {