<div>
<a-upload
name="file"
:showUploadList="false"
:multiple="false"
:headers="tokenHeader"
:action="importExcelUrl"
@change="handleImportExcel"
:data="{
shipId: props.shipId || null
}"
>
<a-button type="primary">{{ props.title }}</a-button>
</a-upload>
</div>
</template>
<script setup name="PartyPaymentMange">
import { reactive, ref, defineEmits } from 'vue'
import { message } from 'ant-design-vue'
import tool from '@/utils/tool'
const props = defineProps({
url: {
type: String,
default: () => ''
},
shipId: {
type: String,
default: () => ''
},
title: {
type: String,
default: () => {
return '导入'
}
}
})
const importExcelUrl = ref(`${props.url}`)
const tokenHeader = reactive({ Token: tool.data.get('TOKEN') })
const emit = defineEmits(['leadInSuccess'])
const handleImportExcel = (info) => {
if (info.file.status === 'done') {
if (info.file.response.code === 200) {
message.success(info.file.response.message || `${info.file.name} 文件上传成功`)
emit('leadInSuccess', info.file.response.data || info.file.response.msg)
} else {
message.error(`${info.file.name} ${info.file.response.message}.`)
}
} else if (info.file.status === 'error') {
message.error('文件上传失败')
}
}
</script>
<style lang="less" scoped></style>