From 966c8bfd0be7f44904523d3126a28259768eae38 Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Fri, 21 Sep 2018 10:28:10 +0800 Subject: [PATCH] JSON parse assigned fail --- .../reportTemplate/ReportTemplate.vue | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/components/reportTemplate/ReportTemplate.vue b/src/components/reportTemplate/ReportTemplate.vue index 467f829..5add44d 100644 --- a/src/components/reportTemplate/ReportTemplate.vue +++ b/src/components/reportTemplate/ReportTemplate.vue @@ -3,14 +3,13 @@
- - + +
-
@@ -22,24 +21,18 @@

-
-

- -
- - @@ -48,8 +41,7 @@
-

以下功能用于测试使用

+

以下功能用于测试使用


@@ -57,9 +49,8 @@ {{selectedCell}}
{{selectedRow}}
-
- + {{this.infos}}
@@ -97,6 +88,7 @@ let cellId = 9025; const initialInputColspan = 0; const initialInputHeight = 30; let undoRodoPointer = -1; +let undoOrRedo = false; export default Vue.extend({ components: { reportCell }, data() { @@ -133,10 +125,18 @@ export default Vue.extend({ } if ( + undoOrRedo === false && this.recordHistory[this.recordHistory.length - 1] !== - JSON.stringify(this.infos) + JSON.stringify(this.infos) ) { this.recordHistory.push(JSON.stringify(this.infos)); + + // console.log( + // 'computed 长度', + // this.recordHistory, + // '长度', + // this.recordHistory.length, + // ); } return this.infos; @@ -165,7 +165,7 @@ export default Vue.extend({ for (const index in this.infos) { if (this.selectedRow === this.infos[index].rowId) { this.infos.splice(Number(index), 0, { - rowId: (this.selectedRow += 0.1), + rowId: (this.selectedRow += 1), cells: [], }); this.selectedRow = 0; @@ -222,16 +222,25 @@ export default Vue.extend({ if (undoRodoPointer < 0) { undoRodoPointer = this.recordHistory.length - 1; } + // console.log('总长度', this.recordHistory.length, '指针', undoRodoPointer); + // 赋值不成功 this.infos = JSON.parse(this.recordHistory[undoRodoPointer - 1]); - undoRodoPointer -= 1; + + console.log(JSON.parse(this.recordHistory[undoRodoPointer - 1])); + + console.log(this.infos); + + undoOrRedo = true; }, redoHandler() { if (undoRodoPointer < 0) { undoRodoPointer = this.recordHistory.length - 1; } - this.infos = JSON.parse(this.recordHistory[undoRodoPointer + 1]); - undoRodoPointer += 1; + // console.log('总长度', this.recordHistory.length, '指针', undoRodoPointer); + + this.infos = JSON.parse(this.recordHistory[(undoRodoPointer += 1)]); + undoOrRedo = true; }, importData() { for (const row of this.infos) {