Files
dm-manage-web/src/views/zs/clue/components/UploadDialog.vue

91 lines
2.9 KiB
Vue
Raw Normal View History

2023-04-11 18:36:41 +08:00
<template>
2023-05-11 00:46:52 +08:00
<el-dialog :title="title" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="400px">
2023-09-15 01:56:26 +08:00
<el-upload ref="upload" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?ydtData=' + ydtData+ '&dYData=' + dYData" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
2023-04-11 18:36:41 +08:00
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<el-link type="info" style="font-size: 12px" @click="importTemplate">下载模板</el-link>
</div>
<div slot="tip" class="el-upload__tip" style="color: red">提示仅允许导入xlsxlsx格式文件</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
2023-05-11 00:46:52 +08:00
<el-button @click="visible = false"> </el-button>
2023-04-11 18:36:41 +08:00
</div>
</el-dialog>
</template>
<script>
2023-05-11 00:46:52 +08:00
import { getToken } from '@/utils/auth';
2023-04-11 18:36:41 +08:00
export default {
name: 'UploadDialog',
data() {
return {
visible: false,
canSubmit: true,
isUploading: true,
ydtData: false,
2023-09-15 01:56:26 +08:00
dYData: false,
2023-04-11 18:36:41 +08:00
title: '学员信息导入',
upload: {
// 是否禁用上传
isUploading: false,
// 设置上传的请求头部
headers: { Authorization: 'Bearer ' + getToken() },
// 上传的地址
2023-05-11 00:46:52 +08:00
url: process.env.VUE_APP_BASE_API + '/zs/clue/importData'
}
2023-04-11 18:36:41 +08:00
};
},
methods: {
2023-09-15 01:56:26 +08:00
init(info = {}) {
2023-04-11 18:36:41 +08:00
this.visible = true;
this.ydtData = false;
2023-09-15 01:56:26 +08:00
this.ydtData = false;
this.canSubmit = true;
2023-04-11 18:36:41 +08:00
this.$nextTick(() => {
if (info) {
2023-09-15 01:56:26 +08:00
this.ydtData = info.ydtData;
this.dYData = info.dYData;
if(this.ydtData){
this.title = "一点通" + this.title;
}
if(this.dYData){
this.title = "抖音" + this.title;
}
2023-04-11 18:36:41 +08:00
}
});
},
/** 下载模板操作 */
importTemplate() {
2023-09-15 01:56:26 +08:00
debugger
this.download('zs/clue/importTemplate?ydtData=' + this.ydtData + '&dYData=' + this.dYData, {}, `clue_template_${new Date().getTime()}.xlsx`);
2023-04-11 18:36:41 +08:00
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.visible = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
dangerouslyUseHTMLString: true
});
this.$emit('refreshDataList');
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
2023-05-11 00:46:52 +08:00
}
2023-04-11 18:36:41 +08:00
}
};
</script>
2023-05-11 00:46:52 +08:00