|
|
@@ -227,6 +227,7 @@
|
|
|
if (this.verify(_colspan, rowspan, this.selectedItems, _rowIndex)) {
|
|
|
return;
|
|
|
}
|
|
|
+ console.log(this.selectedItems, 'this.selectedItems');
|
|
|
for (let index = 0; index < this.selectedItems.length; index++) {
|
|
|
let item = this.selectedItems[index];
|
|
|
if (index != 0) {
|
|
|
@@ -250,12 +251,19 @@
|
|
|
}
|
|
|
|
|
|
item.colspan = 0;
|
|
|
- item.style = {
|
|
|
- border: 'none'
|
|
|
- };
|
|
|
+ if (item.style) {
|
|
|
+ item.style.border = 'none';
|
|
|
+ } else {
|
|
|
+ item.style = {
|
|
|
+ width: 100,
|
|
|
+ border: 'none'
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
this.$set(this.columns[item.columnIndex], item.rowIndex, item);
|
|
|
}
|
|
|
}
|
|
|
+ console.log(this.selectedItems[0], 'this.selectedItems[0]');
|
|
|
this.$set(this.columns[_columnIndex], _rowIndex, this.selectedItems[0]);
|
|
|
},
|
|
|
colspanSum(rowIndex) {
|
|
|
@@ -305,15 +313,15 @@
|
|
|
);
|
|
|
}
|
|
|
},
|
|
|
- getInput() {
|
|
|
+ getInput(width) {
|
|
|
return {
|
|
|
readonly: 1,
|
|
|
value: '',
|
|
|
rowspan: 1,
|
|
|
colspan: 1,
|
|
|
colspanKey: [],
|
|
|
- width: 100,
|
|
|
- style: { width: 100 },
|
|
|
+ width: width||100,
|
|
|
+ style: { width: width||100 },
|
|
|
id: generateRandomString(5)
|
|
|
};
|
|
|
},
|
|
|
@@ -394,7 +402,8 @@
|
|
|
}
|
|
|
|
|
|
this.columns.forEach((item, index) => {
|
|
|
- this.columns[index].splice(_rowIndex + 1, 0, this.getInput());
|
|
|
+
|
|
|
+ this.columns[index].splice(_rowIndex + 1, 0, this.getInput(this.columns[index][_rowIndex-1]?.style.width));
|
|
|
});
|
|
|
|
|
|
// }
|
|
|
@@ -438,12 +447,12 @@
|
|
|
});
|
|
|
},
|
|
|
getWidth(item) {
|
|
|
- let width = Number(item.style.width) || 100;
|
|
|
+ let width = Number(item.style.width);
|
|
|
if (item.colspanKey.length) {
|
|
|
this.columns.forEach((cell) => {
|
|
|
cell.forEach((row) => {
|
|
|
if (item.colspanKey.includes(row.id)) {
|
|
|
- width += Number(row.style.width || 100);
|
|
|
+ width += Number(row.style.width);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
@@ -479,22 +488,24 @@
|
|
|
this.units = units || {};
|
|
|
},
|
|
|
editInputChange(domObj) {
|
|
|
- if (domObj.equation) {
|
|
|
- this.equation[this.domId] = domObj.equation;
|
|
|
+ console.log(domObj, 'domObj');
|
|
|
+ let data = JSON.parse(JSON.stringify(domObj));
|
|
|
+ if (data.equation) {
|
|
|
+ this.equation[this.domId] = data.equation;
|
|
|
}
|
|
|
- if (domObj.units) {
|
|
|
- this.units[this.domId] = domObj.units;
|
|
|
+ if (data.units) {
|
|
|
+ this.units[this.domId] = data.units;
|
|
|
}
|
|
|
- let dom = document.getElementById(domObj.id);
|
|
|
+ let dom = document.getElementById(data.id);
|
|
|
|
|
|
this.columns.forEach((item, index) => {
|
|
|
let rowsIndex = item.findIndex((cells) => cells.id == this.domId);
|
|
|
|
|
|
if (rowsIndex >= 0) {
|
|
|
- let width = domObj.width - dom.parentElement.offsetWidth;
|
|
|
+ let width = data.width - dom.parentElement.offsetWidth;
|
|
|
let newWidth = this.columns[index][rowsIndex].style.width + width;
|
|
|
this.columns[index][0].width = newWidth;
|
|
|
- this.$set(this.columns[index], rowsIndex, domObj);
|
|
|
+ this.$set(this.columns[index], rowsIndex, data);
|
|
|
item.forEach((cell, _index) => {
|
|
|
this.$set(this.columns[index][_index].style, 'width', newWidth);
|
|
|
this.$set(this.columns[index][_index], 'width', newWidth);
|