|
@@ -161,6 +161,11 @@
|
|
>保存</el-button
|
|
>保存</el-button
|
|
>
|
|
>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div style="margin-right:10px">
|
|
|
|
+ <el-button type="primary" size="mini" @click="exportExlec"
|
|
|
|
+ >导出</el-button
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
@@ -229,7 +234,7 @@
|
|
<div v-else style="padding-top: 10px;">
|
|
<div v-else style="padding-top: 10px;">
|
|
<!-- {{ reverseString(k.testid.test) }} -->
|
|
<!-- {{ reverseString(k.testid.test) }} -->
|
|
<div
|
|
<div
|
|
- v-for="(item2, index) in k.testid.test"
|
|
|
|
|
|
+ v-for="(item2) in k.testid.test"
|
|
:key="item2.courseId"
|
|
:key="item2.courseId"
|
|
class="orgData"
|
|
class="orgData"
|
|
>
|
|
>
|
|
@@ -536,6 +541,124 @@ export default {
|
|
this.getTeaList();
|
|
this.getTeaList();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ exportExlec(){
|
|
|
|
+ let headers = [
|
|
|
|
+ ['一级指标', '二级指标', '评价方法', '分值', '自评', '自评概述', '认定', '认定概述']
|
|
|
|
+ ];
|
|
|
|
+ var XLSX = require("xlsx");
|
|
|
|
+ let data = [
|
|
|
|
+ ...headers,
|
|
|
|
+ ...this.PageBaseData.flatMap(parent =>
|
|
|
|
+ parent.children.map(child => [
|
|
|
|
+ parent.name, // 一级指标
|
|
|
|
+ child.name, // 二级指标
|
|
|
|
+ child.evaMethod, // 评分方法
|
|
|
|
+ child.score, // 分值
|
|
|
|
+ child.sco1, // 自评
|
|
|
|
+ child.selfSummary, // 自评概述
|
|
|
|
+ child.sco2, // 认定
|
|
|
|
+ child.cogSum // 认定概述
|
|
|
|
+
|
|
|
|
+ ]))
|
|
|
|
+ ]
|
|
|
|
+ const wb = XLSX.utils.book_new(); //创建一个新的工作簿对象
|
|
|
|
+ // 创建一个Worksheet对象
|
|
|
|
+ let ws = XLSX.utils.aoa_to_sheet(data);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// 定义通用样式(包含居中)
|
|
|
|
+const commonStyle = {
|
|
|
|
+ alignment: {
|
|
|
|
+ horizontal: "center",
|
|
|
|
+ vertical: "center"
|
|
|
|
+ },
|
|
|
|
+ font: {
|
|
|
|
+ sz: 12
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 定义表头特殊样式
|
|
|
|
+const headerStyle = {
|
|
|
|
+ ...commonStyle,
|
|
|
|
+ fill: { fgColor: { rgb: "FFFF00" } },
|
|
|
|
+ font: { ...commonStyle.font, bold: true, sz: 14 }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 应用样式到所有单元格
|
|
|
|
+for (let r = 0; r < data.length; ++r) {
|
|
|
|
+ for (let c = 0; c < data[r].length; ++c) {
|
|
|
|
+ const cellRef = XLSX.utils.encode_cell({ r, c });
|
|
|
|
+ ws[cellRef] = ws[cellRef] || {};
|
|
|
|
+ ws[cellRef].s = r === 0 ? headerStyle : commonStyle;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 设置列宽
|
|
|
|
+ws['!cols'] = [
|
|
|
|
+ { wch: 20 }, // 一级指标
|
|
|
|
+ { wch: 20 }, // 二级指标
|
|
|
|
+ { wch: 30 }, // 评价方法
|
|
|
|
+ { wch: 10 }, // 分值
|
|
|
|
+ { wch: 10 }, // 自评
|
|
|
|
+ { wch: 30 }, // 自评概述
|
|
|
|
+ { wch: 10 }, // 认定
|
|
|
|
+ { wch: 30 } // 认定概述
|
|
|
|
+];
|
|
|
|
+
|
|
|
|
+// 设置行高
|
|
|
|
+ws['!rows'] = [
|
|
|
|
+ { hpx: 30 }, // 表头行
|
|
|
|
+ { hpx: 25 }, // 其他行的默认高度
|
|
|
|
+ // 根据需要继续添加行高设置
|
|
|
|
+];
|
|
|
|
+ console.log('kk',data);
|
|
|
|
+ // 合并单元格
|
|
|
|
+ ws['!merges'] = [];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 记录合并单元格的逻辑
|
|
|
|
+ let startRow = 1; // 数据开始行
|
|
|
|
+ let previousParentName = null;
|
|
|
|
+ let count = 0; // 计数连续相同的一级指标行
|
|
|
|
+
|
|
|
|
+ for (let index = 1; index < data.length; index++) {
|
|
|
|
+ const currentParentName = data[index][0]; // 当前行的一级指标
|
|
|
|
+
|
|
|
|
+ if (currentParentName === previousParentName) {
|
|
|
|
+ count++; // 继续计数
|
|
|
|
+ } else {
|
|
|
|
+ if (count > 0) { // 如果有连续的相同项
|
|
|
|
+ ws['!merges'].push({
|
|
|
|
+ s: { r: startRow, c: 0 },
|
|
|
|
+ e: { r: startRow + count, c: 0 }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // 更新开始行和计数
|
|
|
|
+ startRow = index; // 更新为当前行的开始行
|
|
|
|
+ count = 0; // 重置计数
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ previousParentName = currentParentName; // 更新前一个一级指标
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 检查最后一组
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ ws['!merges'].push({
|
|
|
|
+ s: { r: startRow, c: 0 },
|
|
|
|
+ e: { r: startRow + count, c: 0 }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
|
|
|
|
+ XLSX.writeFile(wb, "教师发展.xlsx");
|
|
|
|
+ this.$message({
|
|
|
|
+ message: "导出成功",
|
|
|
|
+ type: "success"
|
|
|
|
+ });
|
|
|
|
+ },
|
|
// 禁用滚轮事件
|
|
// 禁用滚轮事件
|
|
handleWheel(event) {
|
|
handleWheel(event) {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
@@ -753,9 +876,11 @@ export default {
|
|
remindExamine() {
|
|
remindExamine() {
|
|
this.remDig = true;
|
|
this.remDig = true;
|
|
},
|
|
},
|
|
|
|
+
|
|
// 下载excel
|
|
// 下载excel
|
|
getExcel() {
|
|
getExcel() {
|
|
var res = this.tableData;
|
|
var res = this.tableData;
|
|
|
|
+
|
|
// console.log('导出数据',res);
|
|
// console.log('导出数据',res);
|
|
//如果value的json字段的key值和想要的headers值不一致时,可做如下更改
|
|
//如果value的json字段的key值和想要的headers值不一致时,可做如下更改
|
|
//将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
|
|
//将和下面的Object.fromEntries结合,将json字段的key值改变为要求的excel的header值
|