diff --git a/anrui-scm/anrui-scm-ui/src/api/specialrebate/specialrebatemanagement.js b/anrui-scm/anrui-scm-ui/src/api/specialrebate/specialrebatemanagement.js index 457e7e719c..5e4a6fcec0 100644 --- a/anrui-scm/anrui-scm-ui/src/api/specialrebate/specialrebatemanagement.js +++ b/anrui-scm/anrui-scm-ui/src/api/specialrebate/specialrebatemanagement.js @@ -53,5 +53,14 @@ export default { responseType: 'blob', // 表明返回服务器返回的数据类型 headers: { 'Content-Type': 'application/json' } }) + }, + // 下载模板 + downloadExcel: function() { + return request({ + url: '/scm/v1/scmspecialrebate/downloadExcel', + method: 'post', + responseType: 'blob', // 表明返回服务器返回的数据类型 + headers: { 'Content-Type': 'application/json' } + }) } } diff --git a/anrui-scm/anrui-scm-ui/src/views/specialrebate/specialrebatemanagement/specialrebatemanagement.vue b/anrui-scm/anrui-scm-ui/src/views/specialrebate/specialrebatemanagement/specialrebatemanagement.vue index b536bdce6c..3c2c74cebb 100644 --- a/anrui-scm/anrui-scm-ui/src/views/specialrebate/specialrebatemanagement/specialrebatemanagement.vue +++ b/anrui-scm/anrui-scm-ui/src/views/specialrebate/specialrebatemanagement/specialrebatemanagement.vue @@ -97,6 +97,43 @@ + + + 下载专项返利模板 + + + + + 选取文件 + 上传 + + + + 文件上传结果 + + {{ uploadResultMesssage }} + + + + + @@ -129,6 +166,13 @@ export default { btnKey: 'toAdd', btnLabel: '新增' }, + { + type: 'success', + size: 'small', + icon: 'Import', + btnKey: 'doImport', + btnLabel: '导入' + }, { type: 'success', size: 'small', @@ -211,7 +255,19 @@ export default { size: 5, total: 0 }, - rules: {} + rules: {}, + dialogVisible: false, + updateAction: process.env.VUE_APP_BASE_API + '/scm/v1/scmspecialrebate/getExcelInfo', + fileList: [], + uploadResultMesssage: '', + uploadData: { + sid: '', + userSid: '', + orgPath: '' + }, + headers: { + token: window.sessionStorage.getItem('token') + } } }, created() { @@ -250,6 +306,9 @@ export default { case 'toAdd': this.toAdd() break + case 'doImport': + this.doImport() + break case 'doExport': this.doExport() break @@ -370,6 +429,63 @@ export default { }).catch(() => { }) }, + doImport() { + this.dialogVisible = true + this.fileList = [] + this.uploadResultMesssage = '' + }, + downLoad() { + const loading = this.$loading({ + lock: true, + text: 'Loading', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + req.downloadExcel().then((resp) => { + loading.close() + const blob = new Blob([resp], { + type: 'application/vnd.ms-excel' + }) + const fileName = '专项返利模版' + '.xls' + const elink = document.createElement('a') + elink.download = fileName + elink.style.display = 'none' + elink.href = URL.createObjectURL(blob) + document.body.appendChild(elink) + elink.click() + URL.revokeObjectURL(elink.href) + document.body.removeChild(elink) + }).catch(() => { + loading.close() + }) + }, + handleRemove() { + this.uploadResultMesssage = '' + }, + submitUpload() { + this.uploadData.userSid = window.sessionStorage.getItem('userSid') + this.uploadData.orgPath = window.sessionStorage.getItem('defaultOrgPath') + this.$refs.upload.submit() + }, + handleSuccess(resp, file, fileList) { + const _this = this + if (resp.success) { + _this.uploadResultMesssage = resp.msg + } else { + _this.uploadResultMesssage = resp.msg + } + }, + handleConfirm() { + if (this.uploadResultMesssage === '') { + this.$message({ showClose: true, type: 'error', message: '请先上传专项返利模版' }) + return + } else { + this.dialogVisible = false + this.uploadData.userSid = '' + this.uploadData.orgPath = '' + this.getList() + } + }, doExport() { const loading = this.$loading({ lock: true,