diff --git a/src/views/modules/satisfaction/detail/index.vue b/src/views/modules/satisfaction/detail/index.vue index 0b21db30a..4be5f9f4e 100644 --- a/src/views/modules/satisfaction/detail/index.vue +++ b/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, diff --git a/src/views/modules/shequzhili/event/eventList.vue b/src/views/modules/shequzhili/event/eventList.vue index e8b22c840..cb2373758 100644 --- a/src/views/modules/shequzhili/event/eventList.vue +++ b/src/views/modules/shequzhili/event/eventList.vue @@ -101,6 +101,14 @@
新增 + 下载模板 + + 导入 + 导出 @@ -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: "导入中,请到系统管理-导入记录中查看进度", + duration: 3000 + }); + let than = this; + document.getElementById('clickA').addEventListener('click', function () { + than.$router.replace('/main/importRecord-index'); + }); + const formData = new FormData(); //FormData对象,添加参数只能通过append('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) {