Skip to content

Commit 9d01de1

Browse files
committed
增加table单元格颜色
1 parent adfe297 commit 9d01de1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Vol.Vue/src/components/basic/VolTable.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:data="url ? rowData : tableData"
2929
border
3030
:row-class-name="initIndex"
31+
:cell-style="getCellStyle"
3132
style="width: 100%">
3233
<el-table-column v-if="columnIndex"
3334
type="index"
@@ -414,6 +415,7 @@ export default {
414415
summaryData: [],
415416
summaryIndex: {},
416417
remoteColumns: [], //需要每次刷新或分页后从后台加载字典数据源的列配置
418+
cellStyleColumns: {}//有背景颜色的配置
417419
};
418420
},
419421
created () {
@@ -428,6 +430,9 @@ export default {
428430
this.summaryData.push(" ");
429431
}
430432
this.columns.forEach((x, _index) => {
433+
if (x.cellStyle) {
434+
this.cellStyleColumns[x.field] = x.cellStyle;
435+
}
431436
if (!x.hidden) {
432437
//this.summaryIndex[x.field] = _index;
433438
//2020.10.11修复求和列错位的问题
@@ -1122,6 +1127,13 @@ export default {
11221127
});
11231128
this.$set(this.summaryData, this.summaryIndex[column.field], sum);
11241129
},
1130+
getCellStyle (row) {//2020.12.13增加设置单元格颜色
1131+
if (row.column.property) {
1132+
return this.cellStyleColumns[row.column.property]
1133+
&& this.cellStyleColumns[row.column.property](row.row, row.rowIndex, row.columnIndex);
1134+
}
1135+
1136+
}
11251137
},
11261138
};
11271139
</script>

开发版dev/Vue.NetCore/Vol.Vue/src/components/basic/VolTable.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:data="url ? rowData : tableData"
2929
border
3030
:row-class-name="initIndex"
31+
:cell-style="getCellStyle"
3132
style="width: 100%">
3233
<el-table-column v-if="columnIndex"
3334
type="index"
@@ -414,6 +415,7 @@ export default {
414415
summaryData: [],
415416
summaryIndex: {},
416417
remoteColumns: [], //需要每次刷新或分页后从后台加载字典数据源的列配置
418+
cellStyleColumns: {}//有背景颜色的配置
417419
};
418420
},
419421
created () {
@@ -428,6 +430,9 @@ export default {
428430
this.summaryData.push(" ");
429431
}
430432
this.columns.forEach((x, _index) => {
433+
if (x.cellStyle) {
434+
this.cellStyleColumns[x.field] = x.cellStyle;
435+
}
431436
if (!x.hidden) {
432437
//this.summaryIndex[x.field] = _index;
433438
//2020.10.11修复求和列错位的问题
@@ -1122,6 +1127,13 @@ export default {
11221127
});
11231128
this.$set(this.summaryData, this.summaryIndex[column.field], sum);
11241129
},
1130+
getCellStyle (row) {//2020.12.13增加设置单元格颜色
1131+
if (row.column.property) {
1132+
return this.cellStyleColumns[row.column.property]
1133+
&& this.cellStyleColumns[row.column.property](row.row, row.rowIndex, row.columnIndex);
1134+
}
1135+
1136+
}
11251137
},
11261138
};
11271139
</script>

0 commit comments

Comments
 (0)