46 lines
943 B
Vue
46 lines
943 B
Vue
<template>
|
|
<el-button type="warning" plain icon="el-icon-download" @click="download" :loading="loading"></el-button>
|
|
</template>
|
|
|
|
<script setup>
|
|
import api from "@/api"
|
|
import {ref, getCurrentInstance} from "vue"
|
|
import tools from "@/utils/tools"
|
|
|
|
const {proxy} = getCurrentInstance()
|
|
const props = defineProps({
|
|
apiObj: {
|
|
type: Object, default: () => {
|
|
}
|
|
},
|
|
params: {
|
|
type: Object, default: () => {
|
|
}
|
|
},
|
|
module: {type: String, default: "demo"},
|
|
name: {type: String, default: "数据导出"},
|
|
})
|
|
|
|
let loading = ref(false)
|
|
|
|
async function download() {
|
|
const data = {module: props.module, name: props.name, params: props.params}
|
|
let apiObj = props.apiObj
|
|
if (!apiObj) {
|
|
apiObj = api.tools.file.export
|
|
}
|
|
loading.value = true
|
|
const [res, err] = await tools.go(apiObj(data))
|
|
loading.value = false
|
|
if (err) {
|
|
proxy.$message.error(res.msg)
|
|
return
|
|
}
|
|
proxy.$message.success(res.msg)
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style>
|