<template>
|
<el-dialog
|
class="center-title"
|
:title="title"
|
width="55%"
|
top="30vh"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<p class="tip-warn"><i class="el-icon-warning"></i>导入说明:<br>
|
1.请先下载文件模板,并按照模板要去填写表格内容;<br>
|
2.下载模版为当前系统已录入的全量主题观察项数据;<br>
|
3.每次全量导入将覆盖更新与表格数据、层级关系不一致的数据配置项,请谨慎操作!<br>
|
</p>
|
<el-form class="demo-form-inline" >
|
<el-form-item label="选择导入文件" required>
|
<div style="width: 100%;display: flex;align-items: center;">
|
<el-button type="primary" @click="clickRef">点击上传</el-button>
|
<el-button type="text" @click="exportTemplate" :loading="exporting">点击下载模版.EXCEL</el-button>
|
</div>
|
<div style="font-size: 14px; color: black;" v-if="fileName">{{fileName}}</div>
|
</el-form-item>
|
</el-form>
|
<input type="file" style="position: fixed; left: 0; top: -50px;" accept=".xlsx" ref="fileExcel" @change="result" />
|
<template v-slot:footer>
|
<el-button @click="visible=false">返回</el-button>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import { importDcaExcel, exportDcaExcel } from '@/api/business/category'
|
export default {
|
name: 'OperaCategoryImportWindow',
|
extends: BaseOpera,
|
components: {},
|
data () {
|
return {
|
exporting: false,
|
importing: false,
|
fileName: ''
|
}
|
},
|
methods: {
|
open (title, companyType) {
|
this.title = title
|
this.fileName = ''
|
this.visible = true
|
},
|
// 导出模板
|
exportTemplate () {
|
this.$dialog.exportConfirm('确认导出下载模版吗?')
|
.then(() => {
|
this.exporting = true
|
exportDcaExcel({}).then(response => {
|
this.exporting = false
|
this.download(response)
|
})
|
.catch(e => {
|
this.$tip.apiFailed(e)
|
})
|
.finally(() => {
|
this.exporting = false
|
})
|
})
|
.catch(() => {})
|
},
|
clickRef () {
|
this.$refs.fileExcel.click()
|
},
|
result (e) {
|
const data = new FormData()
|
data.append('file', e.target.files[0])
|
importDcaExcel(data)
|
.then(res => {
|
this.$message.success('导入成功')
|
this.$emit('success')
|
this.visible = false
|
})
|
.catch(err => {
|
this.$message.error(err)
|
this.fileName = ''
|
})
|
.finally(() => {
|
this.$refs.fileExcel.value = null
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
|
</style>
|