|
@@ -8,6 +8,8 @@
|
|
|
<el-button type="primary" @click="addRow(columns[0].length)" v-if="edit"
|
|
<el-button type="primary" @click="addRow(columns[0].length)" v-if="edit"
|
|
|
>新增行</el-button
|
|
>新增行</el-button
|
|
|
>
|
|
>
|
|
|
|
|
+ <el-button type="primary" @click="copy()" v-if="edit">复制表格</el-button>
|
|
|
|
|
+
|
|
|
<el-checkbox v-model="isMerge" style="margin-left: 10px" v-if="edit"
|
|
<el-checkbox v-model="isMerge" style="margin-left: 10px" v-if="edit"
|
|
|
>合并单元格</el-checkbox
|
|
>合并单元格</el-checkbox
|
|
|
>
|
|
>
|
|
@@ -365,6 +367,9 @@
|
|
|
this.columns[columnIndex].forEach((cell, rowIndex) => {
|
|
this.columns[columnIndex].forEach((cell, rowIndex) => {
|
|
|
if (cell.colspanKey.length) {
|
|
if (cell.colspanKey.length) {
|
|
|
//当前删除的列其他行有合并过单元格的处理
|
|
//当前删除的列其他行有合并过单元格的处理
|
|
|
|
|
+ if (!this.columns[columnIndex + 1]) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
let data = this.columns[columnIndex + 1][rowIndex];
|
|
let data = this.columns[columnIndex + 1][rowIndex];
|
|
|
|
|
|
|
|
data.colspan = cell.colspan - 1;
|
|
data.colspan = cell.colspan - 1;
|
|
@@ -535,7 +540,34 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+ copy() {
|
|
|
|
|
+ let columns = JSON.parse(JSON.stringify(this.columns));
|
|
|
|
|
+ columns.forEach((item, index) => {
|
|
|
|
|
+ item.forEach((cell, _index) => {
|
|
|
|
|
+ if (cell.colspanKey.length) {
|
|
|
|
|
+ cell.colspanKey.forEach((key, index) => {
|
|
|
|
|
+ let id = generateRandomString(5);
|
|
|
|
|
+ let { columnIndex, rowIndex } = this.getIndex(key);
|
|
|
|
|
+ columns[columnIndex][rowIndex]['copyId'] = id;
|
|
|
|
|
+ cell.colspanKey[index] = id;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cell.copyId) {
|
|
|
|
|
+ cell.id = cell.copyId;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ cell.id = generateRandomString(5);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ this.$emit('copy', {
|
|
|
|
|
+ value: null,
|
|
|
|
|
+ equation: {},
|
|
|
|
|
+ units: {},
|
|
|
|
|
+ valueObj: {
|
|
|
|
|
+ columns
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
inputClick(item, type) {
|
|
inputClick(item, type) {
|
|
|
if (!this.edit) {
|
|
if (!this.edit) {
|
|
|
return;
|
|
return;
|