导入批量修改价格明细
This commit is contained in:
@@ -95,7 +95,7 @@ const props = defineProps({
|
||||
// 上传接口地址(必传)
|
||||
action: {
|
||||
type: String,
|
||||
required: true
|
||||
default: ''
|
||||
},
|
||||
// 模板下载接口地址(后端接口,走 proxy.download),不传则不显示下载模板链接
|
||||
templateAction: {
|
||||
@@ -156,6 +156,11 @@ const props = defineProps({
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// Custom async submit: (uploadFile) => Promise<string|void>
|
||||
submitHandler: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 确定按钮文字
|
||||
submitText: {
|
||||
type: String,
|
||||
@@ -291,7 +296,7 @@ function handleSuccess(response) {
|
||||
}
|
||||
|
||||
// 提交上传
|
||||
function handleSubmit() {
|
||||
async function handleSubmit() {
|
||||
if (typeof props.beforeSubmit === 'function') {
|
||||
const msg = props.beforeSubmit()
|
||||
if (msg) {
|
||||
@@ -305,6 +310,29 @@ function handleSubmit() {
|
||||
proxy.$modal.msgError(err)
|
||||
return
|
||||
}
|
||||
if (typeof props.submitHandler === 'function') {
|
||||
isUploading.value = true
|
||||
progressPercent.value = 0
|
||||
try {
|
||||
const resultMsg = await props.submitHandler(file)
|
||||
visible.value = false
|
||||
validateError.value = ''
|
||||
selectedFile.value = null
|
||||
uploadRef.value?.clearFiles()
|
||||
const html = resultMsg == null || resultMsg === ''
|
||||
? '导入完成'
|
||||
: String(resultMsg)
|
||||
proxy.$alert("<div style='overflow:auto;overflow-x:hidden;max-height:70vh;padding:10px 20px 0;'>" + html + '</div>', '导入结果', { dangerouslyUseHTMLString: true })
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
const tip = (e && e.message) ? e.message : '导入失败'
|
||||
proxy.$modal.msgError(tip)
|
||||
} finally {
|
||||
isUploading.value = false
|
||||
progressPercent.value = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
uploadRef.value.submit()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user