Browse Source

事件导入和导入模版下载功能,不满意人群清单导出

feature
luyan 2 years ago
parent
commit
4f6bd3c075
  1. 2
      src/views/modules/satisfaction/detail/index.vue
  2. 115
      src/views/modules/shequzhili/event/eventList.vue

2
src/views/modules/satisfaction/detail/index.vue

@ -291,7 +291,7 @@ export default {
},
async handleExport() {
const url = "/governance/icEvent/export";
const url = "/governance/eventInspect/export";
const { pageSize, pageNo, formData } = this;
axios({
url: window.SITE_CONFIG["apiURL"] + url,

115
src/views/modules/shequzhili/event/eventList.vue

@ -101,6 +101,14 @@
<div class="m-table">
<div class="div_btn">
<el-button size="small" type="primary" @click="handleAdd">新增</el-button>
<el-button class="diy-button--white" size="small" @click="handleExportModule('room')">下载模板</el-button>
<el-upload :headers="$getElUploadHeaders()" ref="upload" class="upload-btn" action="uploadUlr"
:limit="1" :accept="'.xls,.xlsx'" :with-credentials="true" :show-file-list="false"
:auto-upload="true" :on-progress="handleProgress" :on-success="handleExcelSuccess"
:before-upload="beforeExcelUpload" :http-request="uploadHttpRequest"
style="display: inline-block;margin:0px 10px">
<el-button size="small" class="diy-button--white" :loading="importLoading">导入</el-button>
</el-upload>
<el-button @click="handleExport" class="diy-button--white" size="small">导出</el-button>
<el-dropdown size="small" split-button type="primary" style="margin: 0 10px; height: 30px"
@command="(command) => handleMarkDiffcult(command)">
@ -491,6 +499,113 @@ export default {
this.$message.error(msg);
}
},
//
async handleExportModule() {
let url = '/governance/icEvent/downloadTemplate';
let params = {};
await this.$http({
method: 'POST',
url,
responseType: 'blob',
data: params
})
.then(res => {
if (res.headers['content-disposition']) {
let fileName = window.decodeURI(res.headers['content-disposition'].split(';')[1].split('=')[1]);
let blob = new Blob([res.data], {
type: 'application/vnd.ms-excel'
});
var url = window.URL.createObjectURL(blob);
var aLink = document.createElement('a');
aLink.style.display = 'none';
aLink.href = url;
aLink.setAttribute('download', fileName);
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink); //
window.URL.revokeObjectURL(url); //blob
} else this.$message.error('下载失败');
})
.catch(err => {
console.log('err', err);
return this.$message.error('网络错误');
});
},
handleExcelSuccess(res, file) {
if (!res.code === 0 && !res.msg === 'success') {
this.$message.error(res.msg);
}
},
handleProgress(event, file, fileList) {
},
beforeExcelUpload(file) {
const isType = file.type === 'application/vnd.ms-excel';
const isTypeComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const fileType = isType || isTypeComputer;
const isLt1M = file.size / 1024 / 1024 < 10;
if (!fileType) {
this.$message.error('上传文件只能是xls/xlsx格式!');
}
if (!isLt1M) {
this.$message.error('上传文件大小不能超过 10MB!');
}
return fileType && isLt1M;
},
async uploadHttpRequest(file) {
this.importLoading = true;
this.importBtnTitle = '正在上传中...';
this.$message({
showClose: true,
dangerouslyUseHTMLString: true,
message: "导入中,请到系统管理-<a id='clickA' style='cursor: pointer;'>导入记录</a>中查看进度",
duration: 3000
});
let than = this;
document.getElementById('clickA').addEventListener('click', function () {
than.$router.replace('/main/importRecord-index');
});
const formData = new FormData(); //FormDataappend('key', value)
formData.append('file', file.file); //
formData.append('code', ''); //
await this.$http
.post('/governance/icEvent/importEvent', formData)
.then(res => {
console.log('res-up', res);
if (res.data.code == 0 && res.data.msg == 'success') {
const data = res.data.data;
this.dataList = [
...Object.keys(data.option.exist).map(k => {
return {
index: k,
srcField: data.option.exist[k],
exist: true,
field: data.option.exist[k]
};
}),
...Object.keys(data.option.notExist).map(k => {
return {
index: k,
srcField: data.option.notExist[k],
exist: false,
field: ''
};
})
];
this.importOption = data.option;
this.importCode = data.code;
this.fileData = file;
} else this.$message.error(res.data.msg);
})
.catch(err => {
console.log('失败', err);
file.onError(); //
});
this.importLoading = false;
this.importBtnTitle = '导入';
this.$refs.upload.clearFiles();
},
//
handleShowVoice(url) {

Loading…
Cancel
Save