//表格合同方法 --- 此處只合并了第一列
objectSpanMethod({ row, column, rowIndex, columnIndex }){
if (columnIndex === 0) {
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
};
}
},
//篩出行里面相同的數據的index 并組裝進數組--------請求完表格數據后調用一下這個方法
rowspan() {
this.tableData.forEach((item, index) => {
if (index === 0) {
this.spanArr.push(1);
this.position = 0;
} else {
if (this.tableData[index].name=== this.tableData[index - 1].name) {
this.spanArr[this.position] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.position = index;
}
}
});
},
表格單選
// @select="select" ref="myInventory"
select(selection, row) {
this.$refs.myInventory.clearSelection();
if (selection.length == 0) return;
row.editable = true; // 選中行可輸入
this.$refs.myInventory.toggleRowSelection(row, true);
},