|
@@ -108,7 +108,7 @@
|
|
|
accept=".xlsx, .xls" drag action="#" multiple>
|
|
|
<i class="el-icon-upload"></i>
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
- <div class="el-upload__tip" slot="tip" style="text-align: center">仅允许导入xls、xlsx格式文件。</div>
|
|
|
+ <div class="el-upload__tip" slot="tip" style="text-align: center">仅允许导入xls、xlsx格式文件。<span style="color: #409EFF;cursor: pointer" @click="getExcelFile">下载模板</span></div>
|
|
|
</el-upload>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="upload.open = false">取 消</el-button>
|
|
@@ -120,6 +120,7 @@
|
|
|
|
|
|
<script>
|
|
|
import api from '../../api/index'
|
|
|
+ import XLSX from 'xlsx'
|
|
|
|
|
|
export default {
|
|
|
name: 'NewMediaMatrix',
|
|
@@ -211,7 +212,6 @@
|
|
|
return;
|
|
|
}
|
|
|
if (this.workTitle == '编辑媒体') {
|
|
|
- fd.append('id', this.postManagement.id);
|
|
|
api.updateArticle(this.postManagement).then(r => {
|
|
|
if (r.data.result) {
|
|
|
this.$message.success('编辑成功');
|
|
@@ -347,6 +347,18 @@
|
|
|
this.upload.isUploading = false;
|
|
|
this.$message.error("上传失败");
|
|
|
})
|
|
|
+ },
|
|
|
+ exportExcel(name, titleArr, sheetName) {
|
|
|
+ // 导出EXCEL
|
|
|
+ const ws = XLSX.utils.aoa_to_sheet(titleArr)
|
|
|
+ const wb = XLSX.utils.book_new()
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, sheetName)
|
|
|
+ XLSX.writeFile(wb, name + '.xlsx')
|
|
|
+ },
|
|
|
+ getExcelFile() {
|
|
|
+ // 获取EXCEL导入示例
|
|
|
+ const titleArr = [['公众号', '标题', 'url', '排序', '创建时间']] // 表头中文名
|
|
|
+ this.exportExcel('example', titleArr, 'sheet1')
|
|
|
}
|
|
|
},
|
|
|
}
|