你好,改成了refresh()还是时而生效时而不生效,和之前的效果一样,以下是完整代码
- async downloadLeftTemplateFun(templateName) {
- let that = this
- await downloadExcelTemplate({
- templateName: templateName
- }).then(res => {
- this.$store.dispatch('comLoadingDisableFun', true);
- const blob = new Blob([res.data]);
- let excelIO = new IO();
- excelIO.open(blob, ((json) => {
- this.LeftExcelSpread.fromJSON(json);
- // 设置移动端滚动条样式
- this.LeftExcelSpread.options.showHorizontalScrollbar = true;
- // this.LeftExcelSpread.options.scrollbarAppearance = GC.Spread.Sheets.ScrollbarAppearance.mobile;
- // 控制滚动区域
- this.LeftExcelSpread.options.scrollbarMaxAlign = true;
- var activeSheet = this.LeftExcelSpread.getActiveSheet()
- activeSheet.name(this.categoryType)
- activeSheet.zoom(0.6);
- activeSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, function (sender, args) {
- //垂直滚动同步
- that.newTopRow = args.newTopRow
- let rsheet = that.RightExcelSpread.getSheet(0)
- rsheet.showRow(args.newTopRow, GC.Spread.Sheets.VerticalPosition.top);
- });
- activeSheet.bind(GC.Spread.Sheets.Events.LeftColumnChanged, function (sender, args) {
- //水平滚动同步
- that.newLeftCol = args.newLeftCol
- let rsheet = that.RightExcelSpread.getSheet(0)
- rsheet.showColumn(args.newLeftCol, GC.Spread.Sheets.HorizontalPosition.left);
- });
- activeSheet.bind(GC.Spread.Sheets.Events.RangeGroupStateChanged, function (e, info) {
- console.log('range group state changed', e, info)
- console.log(activeSheet.rowOutlines.isCollapsed(info.index));
- let collapse = activeSheet.rowOutlines.isCollapsed(info.index)
- let rsheet = that.RightExcelSpread.getSheet(0)
- rsheet.rowOutlines.setCollapsed(info.index, collapse);
- });
- activeSheet.bind(GC.Spread.Sheets.Events.RangeGroupStateChanged, function (e, args) {
- let rsheet = that.RightExcelSpread.getActiveSheet()
- let lsheet = that.LeftExcelSpread.getActiveSheet()
- // 判断是行分组还是列分组,行/列分组要分开处理
- if (!args.isRowGroup) {
- // 判断展开列还是折叠列,另外一个Excel要跟着联动
- var groupIndex = lsheet.columnOutlines.direction() === 0 ? args.index - 1 : args.index;
- rsheet.columnOutlines.setCollapsed(groupIndex, lsheet.columnOutlines.isCollapsed(args.index));
- let leftColumn = lsheet.getViewportLeftColumn(1)
- rsheet.showColumn(leftColumn, GC.Spread.Sheets.HorizontalPosition.left);
- that.RightExcelSpread.refresh()
- }
- });
- // NOTE: 隐藏行/列号
- activeSheet.options.rowHeaderVisible = false;
- activeSheet.options.colHeaderVisible = false;
- this.LeftExcelSpread.suspendEvent();
- this.LeftExcelSpread.suspendPaint();
- // NOTE: 启用表单保护
- this.ProtectedFun(true, 'left');
- sheetEdit(this.LeftExcelSpread);
- for (var i = 0; i < this.LeftExcelSpread.getSheetCount(); i++) {
- this.LeftExcelSpread.getSheet(i).options.protectionOptions = {
- allowResizeRows: true, // 用户是否可以改变行高
- allowResizeColumns: true, // 用户是否可以改变列宽
- allowFilter: true,
- allowInsertColumns: false, // 用户是否可以插入列
- allowInsertRows: true, // 用户是否可以插入行
- allowOutlineRows: true, // 开启保护后,允许分组行折叠展开
- allowOutlineColumns: true, // 开启保护后,允许分组列折叠展开
- allowDeleteRows: true, // 用户是否可以删除行
- allowDeleteColumns: true, // 用户是否可以删除列
- }
- }
- // this.initFillLeftSheetData()
- this.initFillLeftDrillDownData()
- this.LeftExcelSpread.resumeEvent();
- this.LeftExcelSpread.resumePaint();
- this.LeftExcelSpread.repaint()
- this.$store.dispatch('comLoadingDisableFun', false);
- }))
- })
- },
复制代码
|