|
@@ -395,6 +395,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import shareBox from "./shareBox/index";
|
|
import shareBox from "./shareBox/index";
|
|
|
|
+import XLSX from 'xlsx-js-style'
|
|
export default {
|
|
export default {
|
|
directives: {
|
|
directives: {
|
|
stopMousewheel: {
|
|
stopMousewheel: {
|
|
@@ -547,10 +548,12 @@ export default {
|
|
let headers = [
|
|
let headers = [
|
|
['一级指标', '二级指标', '评价方法', '分值', '自评', '自评概述', '认定', '认定概述']
|
|
['一级指标', '二级指标', '评价方法', '分值', '自评', '自评概述', '认定', '认定概述']
|
|
];
|
|
];
|
|
- var XLSX = require("xlsx");
|
|
|
|
|
|
+ let info = [['姓名:'+this.digUsername ,'','','','','自评分数:'+this.DigSelfSco,'','认定分数:'+this.computedSco]]
|
|
|
|
+ // var XLSX = require("xlsx");
|
|
let data = [
|
|
let data = [
|
|
|
|
+ ...info,
|
|
...headers,
|
|
...headers,
|
|
- ...this.PageBaseData.flatMap(parent =>
|
|
|
|
|
|
+ ...this.PageBaseData.flatMap(parent =>
|
|
parent.children.map(child => [
|
|
parent.children.map(child => [
|
|
parent.name, // 一级指标
|
|
parent.name, // 一级指标
|
|
child.name, // 二级指标
|
|
child.name, // 二级指标
|
|
@@ -581,19 +584,13 @@ const commonStyle = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-// 定义表头特殊样式
|
|
|
|
-const headerStyle = {
|
|
|
|
- ...commonStyle,
|
|
|
|
- fill: { fgColor: { rgb: "FFFF00" } },
|
|
|
|
- font: { ...commonStyle.font, bold: true, sz: 14 }
|
|
|
|
-};
|
|
|
|
|
|
|
|
// 应用样式到所有单元格
|
|
// 应用样式到所有单元格
|
|
for (let r = 0; r < data.length; ++r) {
|
|
for (let r = 0; r < data.length; ++r) {
|
|
for (let c = 0; c < data[r].length; ++c) {
|
|
for (let c = 0; c < data[r].length; ++c) {
|
|
const cellRef = XLSX.utils.encode_cell({ r, c });
|
|
const cellRef = XLSX.utils.encode_cell({ r, c });
|
|
ws[cellRef] = ws[cellRef] || {};
|
|
ws[cellRef] = ws[cellRef] || {};
|
|
- ws[cellRef].s = r === 0 ? headerStyle : commonStyle;
|
|
|
|
|
|
+ ws[cellRef].s = commonStyle;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -611,17 +608,17 @@ ws['!cols'] = [
|
|
|
|
|
|
// 设置行高
|
|
// 设置行高
|
|
ws['!rows'] = [
|
|
ws['!rows'] = [
|
|
- { hpx: 30 }, // 表头行
|
|
|
|
|
|
+ { hpx: 25 }, // 表头行
|
|
{ hpx: 25 }, // 其他行的默认高度
|
|
{ hpx: 25 }, // 其他行的默认高度
|
|
// 根据需要继续添加行高设置
|
|
// 根据需要继续添加行高设置
|
|
];
|
|
];
|
|
- console.log('kk',data);
|
|
|
|
|
|
+ console.log('kk',data);
|
|
// 合并单元格
|
|
// 合并单元格
|
|
ws['!merges'] = [];
|
|
ws['!merges'] = [];
|
|
|
|
|
|
|
|
|
|
// 记录合并单元格的逻辑
|
|
// 记录合并单元格的逻辑
|
|
- let startRow = 1; // 数据开始行
|
|
|
|
|
|
+ let startRow = 2; // 数据开始行
|
|
let previousParentName = null;
|
|
let previousParentName = null;
|
|
let count = 0; // 计数连续相同的一级指标行
|
|
let count = 0; // 计数连续相同的一级指标行
|
|
|
|
|
|
@@ -644,15 +641,20 @@ ws['!rows'] = [
|
|
|
|
|
|
previousParentName = currentParentName; // 更新前一个一级指标
|
|
previousParentName = currentParentName; // 更新前一个一级指标
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 检查最后一组
|
|
|
|
- if (count > 0) {
|
|
|
|
- ws['!merges'].push({
|
|
|
|
- s: { r: startRow, c: 0 },
|
|
|
|
- e: { r: startRow + count, c: 0 }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ ws['A1'].s = { alignment: { horizontal: 'left' } }
|
|
|
|
+ ws['F1'].s = { alignment: { horizontal: 'left' } }
|
|
|
|
+ ws['H1'].s = { alignment: { horizontal: 'left' } }
|
|
|
|
+ // 检查最后一组
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ ws['!merges'].push({
|
|
|
|
+ s: { r: startRow, c: 0 },
|
|
|
|
+ e: { r: startRow + count, c: 0 }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ ws['!merges'].push( { s: { r: 0, c: 0 }, e: { r: 0, c: 4 } }, // 合并姓名部分(A1-E1)
|
|
|
|
+ { s: { r: 0, c: 5 }, e: { r: 0, c: 6 } }, // 单独保留自评分数(G1)
|
|
|
|
+ { s: { r: 0, c: 7 }, e: { r: 0, c: 7 } } // 单独保留认定分数(H1));
|
|
|
|
+)
|
|
|
|
|
|
XLSX.utils.book_append_sheet(wb, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
|
|
XLSX.utils.book_append_sheet(wb, ws, "sheet1"); //把sheet添加到workbook里,第三个参数是sheet名
|
|
XLSX.writeFile(wb, this.digUsername +'-'+ (this.digType == 1 ? '班主任考核' :'专任教师')+".xlsx");
|
|
XLSX.writeFile(wb, this.digUsername +'-'+ (this.digType == 1 ? '班主任考核' :'专任教师')+".xlsx");
|
|
@@ -878,11 +880,11 @@ ws['!rows'] = [
|
|
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值
|