增加可修改计费重功能
This commit is contained in:
@@ -186,6 +186,11 @@ const props = defineProps({
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// Custom template download: () => void | Promise; overrides templateUrl / templateAction
|
||||
templateDownloadHandler: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 确定按钮文字
|
||||
submitText: {
|
||||
type: String,
|
||||
@@ -217,7 +222,7 @@ const uploadUrl = computed(() => {
|
||||
return import.meta.env.VITE_APP_BASE_API + props.action + '?' + query.toString()
|
||||
})
|
||||
|
||||
const hasTemplate = computed(() => !!(props.templateUrl || props.templateAction))
|
||||
const hasTemplate = computed(() => !!(props.templateDownloadHandler || props.templateUrl || props.templateAction))
|
||||
|
||||
// 打开对话框(供父组件通过 ref 调用)
|
||||
function open() {
|
||||
@@ -231,6 +236,10 @@ function open() {
|
||||
})
|
||||
}
|
||||
|
||||
function close() {
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
function handleClosed() {
|
||||
isUploading.value = false
|
||||
progressPercent.value = 0
|
||||
@@ -238,8 +247,17 @@ function handleClosed() {
|
||||
selectedFile.value = null
|
||||
}
|
||||
|
||||
// 下载模板:静态文件直接 <a download>,接口走 proxy.download
|
||||
function handleDownloadTemplate() {
|
||||
// 下载模板:自定义 handler > 静态文件 > 接口 proxy.download
|
||||
async function handleDownloadTemplate() {
|
||||
if (typeof props.templateDownloadHandler === 'function') {
|
||||
try {
|
||||
await props.templateDownloadHandler()
|
||||
} catch (e) {
|
||||
const tip = (e && e.message) ? e.message : '下载模板失败'
|
||||
proxy.$modal.msgError(tip)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (props.templateUrl) {
|
||||
const link = document.createElement('a')
|
||||
link.href = props.templateUrl
|
||||
@@ -353,7 +371,7 @@ async function handleSubmit() {
|
||||
uploadRef.value?.submit?.()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
defineExpose({ open, close })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user