|
@@ -73,7 +73,13 @@
|
|
|
<span class="serach_icon" @click="searchCourse"></span>
|
|
|
</div>
|
|
|
<div class="btnA" v-if="stype == 1 && !pdfLoading" @click="exportPDF">导出PDF</div>
|
|
|
- <div class="btnA" v-if="stype == 2" @click="exportAllWord">导出人员数据</div>
|
|
|
+ <div class="btnA" v-if="stype == 2" @mouseenter="btnDisplay = true" @mouseleave="btnDisplay = false">
|
|
|
+ 导出数据
|
|
|
+ <div v-show="btnDisplay" class="buttonBox">
|
|
|
+ <div type="primary" @click="exportExcel">下载汇总表格</div>
|
|
|
+ <div type="primary" @click="exportAllWord">导出人员数据</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="btnA" v-if="stype == 3" @click="exportAllWord2">导出人员数据</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -159,7 +165,7 @@
|
|
|
</div>
|
|
|
<div class="table_content" v-if="stype == 2">
|
|
|
<el-table class="el-table" ref="table" :data="worksArray" border :fit="true" :key="2"
|
|
|
- v-loading="isLoading" style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }">
|
|
|
+ v-loading="isLoading" style="width: 100%" :header-cell-style="{ background: '#f1f1f1', fontSize: '17px' }" @filter-change="handleFilterChange">
|
|
|
<el-table-column fixed label="序号" width="80px" align="left">
|
|
|
<template slot-scope="scope">
|
|
|
{{ scope.$index + 1 }}
|
|
@@ -265,6 +271,9 @@ import { downloadPDF } from '../../../tools/pdf'
|
|
|
import JSZip from "jszip";
|
|
|
import FileSaver from "file-saver";
|
|
|
|
|
|
+import XLSX from "xlsx-js-style";
|
|
|
+
|
|
|
+
|
|
|
export default {
|
|
|
components: {
|
|
|
shareBox,
|
|
@@ -318,7 +327,8 @@ export default {
|
|
|
wurl: "",
|
|
|
chapters: [],
|
|
|
filterPlacement: 'bottom-end',
|
|
|
- pdfLoading: false
|
|
|
+ pdfLoading: false,
|
|
|
+ btnDisplay: false
|
|
|
};
|
|
|
},
|
|
|
watch: {},
|
|
@@ -1096,6 +1106,78 @@ export default {
|
|
|
}, 2000);
|
|
|
});
|
|
|
},
|
|
|
+ handleFilterChange(){
|
|
|
+ console.log( this.$refs.table.store.states.data);
|
|
|
+ },
|
|
|
+ exportExcel(){
|
|
|
+ let res = this.$refs.table.store.states.data
|
|
|
+ if(!res.length){
|
|
|
+ this.$message.error('无导出数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isLoading = true;
|
|
|
+ let chapters = this.chapters
|
|
|
+
|
|
|
+ var array = [];
|
|
|
+ for (var i = 0; i < res.length; i++) {
|
|
|
+ var _json = {};
|
|
|
+ _json["序号"] = i+1;
|
|
|
+ _json["提交人"] = res[i].name;
|
|
|
+ _json["提交时间"] = res[i].time;
|
|
|
+ for(var j = 0; j < chapters.length; j++){
|
|
|
+ _json[j+1+"."+chapters[j].json.title] = '';
|
|
|
+ if(res[i].array[j].type == 1 && res[i].array[j].json.answer2){
|
|
|
+ let a = []
|
|
|
+ for(var answer2 = 0;answer2 < res[i].array[j].json.answer2.length; answer2++){
|
|
|
+ a.push(res[i].array[j].json.array[answer2].option)
|
|
|
+ }
|
|
|
+ _json[j+1+"."+chapters[j].json.title] = a.join('、')
|
|
|
+ }else if(res[i].array[j].type == 3 && res[i].array[j].json.answer2){
|
|
|
+ _json[j+1+"."+chapters[j].json.title] = res[i].array[j].json.answer2
|
|
|
+ }else if(res[i].array[j].type == 5 && res[i].array[j].json.file){
|
|
|
+ let files = []
|
|
|
+ for (let file = 0; file < res[i].array[j].json.file.length; file++) {
|
|
|
+ let check = res[i].array[j].json.file[file]
|
|
|
+ files.push(file+1+'.'+check.name+'----'+check.url)
|
|
|
+ }
|
|
|
+ _json[j+1+"."+chapters[j].json.title] = files.join('\n')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ array.push(_json);
|
|
|
+ }
|
|
|
+ let widthJson = []
|
|
|
+ let widthArray = Object.keys(array[0])
|
|
|
+ for(let i = 0; i < widthArray.length; i++){
|
|
|
+ if(i == 0){
|
|
|
+ widthJson.push({wch: 5})
|
|
|
+ }else{
|
|
|
+ widthJson.push({wch: 30})
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const workbook = XLSX.utils.book_new(); //创建一个新的工作簿对象
|
|
|
+ let ws = XLSX.utils.json_to_sheet(array); //将json对象数组转化成工作表
|
|
|
+ ws["!cols"] = widthJson;
|
|
|
+ const styleObj = { alignment: {
|
|
|
+ horizontal: "center",
|
|
|
+ vertical: "center" // 设置垂直居中
|
|
|
+ } }; // 设置居中对齐和加粗样式
|
|
|
+
|
|
|
+ for (let cell in ws) {
|
|
|
+ if (!cell[0].startsWith("!")) {
|
|
|
+ ws[cell]["s"] = styleObj;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ XLSX.utils.book_append_sheet(workbook, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
|
|
|
+
|
|
|
+ XLSX.writeFile(workbook, this.testJson.title+".xlsx");
|
|
|
+ this.isLoading = false;
|
|
|
+ this.$message({
|
|
|
+ message: "导出成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
document.getElementsByTagName('html')[0].style.overflow = ''
|
|
@@ -1659,5 +1741,34 @@ export default {
|
|
|
justify-content: center;
|
|
|
line-height: 1;
|
|
|
margin-right: 10px;
|
|
|
+ position: relative;
|
|
|
+}
|
|
|
+
|
|
|
+.buttonBox {
|
|
|
+ position: absolute;
|
|
|
+ bottom: -0;
|
|
|
+ transform: translateY(100%);
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 5px;
|
|
|
+ box-shadow: 0 0 3px 1px #e3e3e3;
|
|
|
+ width: 100%;
|
|
|
+ z-index: 999;
|
|
|
+}
|
|
|
+
|
|
|
+.buttonBox>div {
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ width: 100%;
|
|
|
+ text-align: center;
|
|
|
+ color: #000;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.buttonBox>div+div {
|
|
|
+ border-top: 1px solid #e0e0e0;
|
|
|
+}
|
|
|
+
|
|
|
+.buttonBox>div:hover {
|
|
|
+ background: #f6f8ff;
|
|
|
}
|
|
|
</style>
|