JSON parse assigned fail
This commit is contained in:
parent
d5fb8b135b
commit
966c8bfd0b
@ -3,14 +3,13 @@
|
|||||||
<div class='empty'></div>
|
<div class='empty'></div>
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<table>
|
<table>
|
||||||
<tr v-for="row in rows" :key="row.rowId" :cells="row.cells">
|
<tr v-for="(row,index) in rows" :key="row.rowId" :cells="row.cells">
|
||||||
<input class='row-counter' type="button" :value='row.rowId' @click="rowClickHandler(row)">
|
<input class='row-counter' type="button" :value='index' @click="rowClickHandler(row)">
|
||||||
<reportCell v-for="cell in row.cells" :cell="cell" v-on:cellIdFromChild="getCellFromChildren" :key="cell.cellId" v-bind:class="{active:cell.cellId===selectedCell}"></reportCell>
|
<reportCell v-for="cell in row.cells" :cell="cell" v-on:cellIdFromChild="getCellFromChildren" :key="cell.cellId" v-bind:class="{active:cell.cellId===selectedCell}"></reportCell>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class='side'>
|
<div class='side'>
|
||||||
|
|
||||||
<div class='row-tool'>
|
<div class='row-tool'>
|
||||||
<button @click="addRow">添加行</button>
|
<button @click="addRow">添加行</button>
|
||||||
<button @click="deleteRow">删除行</button>
|
<button @click="deleteRow">删除行</button>
|
||||||
@ -22,24 +21,18 @@
|
|||||||
<div>
|
<div>
|
||||||
|
|
||||||
<label>表头:</label><input type="text" v-model="inputTitle"><br>
|
<label>表头:</label><input type="text" v-model="inputTitle"><br>
|
||||||
|
|
||||||
<label>宽度:</label><input type="number" v-model="inputColspan"><br>
|
<label>宽度:</label><input type="number" v-model="inputColspan"><br>
|
||||||
|
|
||||||
<label>高度:</label><input type="number" v-model="inputHeight"><br>
|
<label>高度:</label><input type="number" v-model="inputHeight"><br>
|
||||||
<label>字体大小:</label><input type="number" v-model="fontSize"><br>
|
<label>字体大小:</label><input type="number" v-model="fontSize"><br>
|
||||||
|
|
||||||
<label>字体样式:</label>
|
<label>字体样式:</label>
|
||||||
<input type="radio" id="styleone" value="normal" v-model="fontStyle">
|
<input type="radio" id="styleone" value="normal" v-model="fontStyle">
|
||||||
<label for="styleone">正常</label>
|
<label for="styleone">正常</label>
|
||||||
|
|
||||||
<input type="radio" id="styletwo" value="bold" v-model="fontStyle">
|
<input type="radio" id="styletwo" value="bold" v-model="fontStyle">
|
||||||
<label for="styletwo">加粗</label>
|
<label for="styletwo">加粗</label>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label>字体位置:</label>
|
<label>字体位置:</label>
|
||||||
<input type="radio" id="one" value="left" v-model="textAlign">
|
<input type="radio" id="one" value="left" v-model="textAlign">
|
||||||
<label for="one">居左</label>
|
<label for="one">居左</label>
|
||||||
|
|
||||||
<input type="radio" id="two" value="center" v-model="textAlign">
|
<input type="radio" id="two" value="center" v-model="textAlign">
|
||||||
<label for="two">居中</label>
|
<label for="two">居中</label>
|
||||||
<input type="radio" id="three" value="right" v-model="textAlign">
|
<input type="radio" id="three" value="right" v-model="textAlign">
|
||||||
@ -48,8 +41,7 @@
|
|||||||
<button @click="undoHandler">undo</button>
|
<button @click="undoHandler">undo</button>
|
||||||
<button @click="redoHandler">redo</button><br>
|
<button @click="redoHandler">redo</button><br>
|
||||||
<div>
|
<div>
|
||||||
<p style="
|
<p style="color: blue">以下功能用于测试使用</p>
|
||||||
color: blue">以下功能用于测试使用</p>
|
|
||||||
<!-- <button @click="importTemplate">导入设计模板</button> -->
|
<!-- <button @click="importTemplate">导入设计模板</button> -->
|
||||||
<button @click="importTemplate">导入设计样式</button>
|
<button @click="importTemplate">导入设计样式</button>
|
||||||
<button @click="importData">导入数据</button><br>
|
<button @click="importData">导入数据</button><br>
|
||||||
@ -57,9 +49,8 @@
|
|||||||
<span>{{selectedCell}}</span><br>
|
<span>{{selectedCell}}</span><br>
|
||||||
<label>行ID:</label>
|
<label>行ID:</label>
|
||||||
<span>{{selectedRow}}</span><br>
|
<span>{{selectedRow}}</span><br>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{{this.infos}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -97,6 +88,7 @@ let cellId = 9025;
|
|||||||
const initialInputColspan = 0;
|
const initialInputColspan = 0;
|
||||||
const initialInputHeight = 30;
|
const initialInputHeight = 30;
|
||||||
let undoRodoPointer = -1;
|
let undoRodoPointer = -1;
|
||||||
|
let undoOrRedo = false;
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
components: { reportCell },
|
components: { reportCell },
|
||||||
data() {
|
data() {
|
||||||
@ -133,10 +125,18 @@ export default Vue.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
undoOrRedo === false &&
|
||||||
this.recordHistory[this.recordHistory.length - 1] !==
|
this.recordHistory[this.recordHistory.length - 1] !==
|
||||||
JSON.stringify(this.infos)
|
JSON.stringify(this.infos)
|
||||||
) {
|
) {
|
||||||
this.recordHistory.push(JSON.stringify(this.infos));
|
this.recordHistory.push(JSON.stringify(this.infos));
|
||||||
|
|
||||||
|
// console.log(
|
||||||
|
// 'computed 长度',
|
||||||
|
// this.recordHistory,
|
||||||
|
// '长度',
|
||||||
|
// this.recordHistory.length,
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.infos;
|
return this.infos;
|
||||||
@ -165,7 +165,7 @@ export default Vue.extend({
|
|||||||
for (const index in this.infos) {
|
for (const index in this.infos) {
|
||||||
if (this.selectedRow === this.infos[index].rowId) {
|
if (this.selectedRow === this.infos[index].rowId) {
|
||||||
this.infos.splice(Number(index), 0, {
|
this.infos.splice(Number(index), 0, {
|
||||||
rowId: (this.selectedRow += 0.1),
|
rowId: (this.selectedRow += 1),
|
||||||
cells: [],
|
cells: [],
|
||||||
});
|
});
|
||||||
this.selectedRow = 0;
|
this.selectedRow = 0;
|
||||||
@ -222,16 +222,25 @@ export default Vue.extend({
|
|||||||
if (undoRodoPointer < 0) {
|
if (undoRodoPointer < 0) {
|
||||||
undoRodoPointer = this.recordHistory.length - 1;
|
undoRodoPointer = this.recordHistory.length - 1;
|
||||||
}
|
}
|
||||||
|
// console.log('总长度', this.recordHistory.length, '指针', undoRodoPointer);
|
||||||
|
// 赋值不成功
|
||||||
this.infos = JSON.parse(this.recordHistory[undoRodoPointer - 1]);
|
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() {
|
redoHandler() {
|
||||||
if (undoRodoPointer < 0) {
|
if (undoRodoPointer < 0) {
|
||||||
undoRodoPointer = this.recordHistory.length - 1;
|
undoRodoPointer = this.recordHistory.length - 1;
|
||||||
}
|
}
|
||||||
this.infos = JSON.parse(this.recordHistory[undoRodoPointer + 1]);
|
// console.log('总长度', this.recordHistory.length, '指针', undoRodoPointer);
|
||||||
undoRodoPointer += 1;
|
|
||||||
|
this.infos = JSON.parse(this.recordHistory[(undoRodoPointer += 1)]);
|
||||||
|
undoOrRedo = true;
|
||||||
},
|
},
|
||||||
importData() {
|
importData() {
|
||||||
for (const row of this.infos) {
|
for (const row of this.infos) {
|
||||||
|
Loading…
Reference in New Issue
Block a user