|
@@ -18,6 +18,11 @@
|
|
|
</el-row>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="具体数据" name="data">
|
|
|
+ <el-row type="flex" align="middle" justify="end" style="margin-bottom:20px">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button size="mini" type="primary" @click="toExcel">导出数据</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
<el-collapse v-model="collapse" accordion>
|
|
|
<el-collapse-item v-for="(data, qi) in cdata" :key="qi" :title="data.studentname" :name="`${qi}`">
|
|
|
<el-row type="flex" align="middle" justify="center" style="border-bottom: 1px solid #EBEEF5;">
|
|
@@ -145,6 +150,27 @@ export default {
|
|
|
toReturns() {
|
|
|
window.history.go(-1);
|
|
|
},
|
|
|
+ //导出excel数据
|
|
|
+ toExcel() {
|
|
|
+ const { export_json_to_excel } = require('@frame/excel/Export2Excel');
|
|
|
+ let duplicate = _.cloneDeep(this.cdata);
|
|
|
+ let data = [];
|
|
|
+ for (const dup of duplicate) {
|
|
|
+ const elm = { studentname: dup.studentname };
|
|
|
+ for (const answer of dup.answers) {
|
|
|
+ elm[answer.questionid] = answer.answer;
|
|
|
+ }
|
|
|
+ data.push(elm);
|
|
|
+ }
|
|
|
+ let dquest = _.cloneDeep(this.quest.question);
|
|
|
+ let qarr = dquest.map(i => ({ questionid: i._id, topic: i.topic }));
|
|
|
+ let tHeader = qarr.map(i => i.topic);
|
|
|
+ tHeader.unshift('学生姓名');
|
|
|
+ let filterVal = qarr.map(i => i.questionid);
|
|
|
+ filterVal.unshift('studentname');
|
|
|
+ data = data.map(v => filterVal.map(j => v[j]));
|
|
|
+ export_json_to_excel(tHeader, data, this.quest.name);
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user']),
|