From cb1abb6c863d84e4fe457915220f3b1cb6d99979 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Wed, 28 Jun 2023 15:49:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/BasicComponents/Tables/index.vue | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/data-room-ui/packages/BasicComponents/Tables/index.vue b/data-room-ui/packages/BasicComponents/Tables/index.vue index ad2cdc8b..795447f6 100644 --- a/data-room-ui/packages/BasicComponents/Tables/index.vue +++ b/data-room-ui/packages/BasicComponents/Tables/index.vue @@ -31,6 +31,7 @@ import commonMixins from 'packages/js/mixins/commonMixins' import paramsMixins from 'packages/js/mixins/paramsMixins' import linkageMixins from 'packages/js/mixins/linkageMixins' +import _ from 'lodash' export default { name: 'TableChart', mixins: [paramsMixins, commonMixins, linkageMixins], @@ -46,6 +47,7 @@ export default { }, data () { return { + updateKey: '', headerCellStyleObj: { backgroundColor: 'transparent' }, @@ -110,14 +112,15 @@ export default { created () { }, mounted () { this.chartInit() - this.initStyle() + this.changeStyle(this.config) }, methods: { // 表格点击事件 rowClick (row) { this.linkage(row) }, - initStyle () { + changeStyle (oldConfig) { + const config = _.cloneDeep(oldConfig) if (this.customTheme === 'custom') { this.headerCellStyleToObj() this.cellStyleToObj() @@ -126,7 +129,7 @@ export default { this.headerCellStyleToObj() this.cellStyleToObj() } - if (this.config.customize.stripe) { + if (config.customize.stripe) { const trs = document .getElementById(this.config.code) ?.querySelectorAll('tr.el-table__row--striped') @@ -142,7 +145,7 @@ export default { } } else { const trs = document - .getElementById(this.config.code) + .getElementById(config.code) ?.querySelectorAll('tr.el-table__row--striped') if (trs) { trs.forEach(tr => { @@ -159,21 +162,23 @@ export default { // }); } // this.chartInit(); - if (this.config.customize.evenRowBackgroundColor && !this.config.customize.oddRowBackgroundColor) { - this.config.customize.oddRowBackgroundColor = this.config.customize.bodyBackgroundColor - } else if (!this.config.customize.evenRowBackgroundColor && this.config.customize.oddRowBackgroundColor) { - this.config.customize.evenRowBackgroundColor = this.config.customize.bodyBackgroundColor - } else if (!(!this.config.customize.evenRowBackgroundColor && !this.config.customize.oddRowBackgroundColor)) { - this.config.customize.bodyBackgroundColor = '' + if (config.customize.evenRowBackgroundColor && !config.customize.oddRowBackgroundColor) { + config.customize.oddRowBackgroundColor = config.customize.bodyBackgroundColor + } else if (!config.customize.evenRowBackgroundColor && config.customize.oddRowBackgroundColor) { + config.customize.evenRowBackgroundColor = config.customize.bodyBackgroundColor + } else if (!(!config.customize.evenRowBackgroundColor && !config.customize.oddRowBackgroundColor)) { + config.customize.bodyBackgroundColor = '' } window.requestAnimationFrame(() => { - document.querySelectorAll(`.even-row${this.config.code}`).forEach(node => { - node.style.backgroundColor = this.config.customize.evenRowBackgroundColor + document.querySelectorAll(`.even-row${config.code}`).forEach(node => { + node.style.backgroundColor = config.customize.evenRowBackgroundColor }) - document.querySelectorAll(`.odd-row${this.config.code}`).forEach(node => { - node.style.backgroundColor = this.config.customize.oddRowBackgroundColor + document.querySelectorAll(`.odd-row${config.code}`).forEach(node => { + node.style.backgroundColor = config.customize.oddRowBackgroundColor }) }) + this.updateKey = new Date().getTime() + return config }, // 表格行样式 tableRowClassName ({ row, rowIndex }) { @@ -195,6 +200,7 @@ export default { } else { config.option.columnData = columnData } + this.updateKey = new Date().getTime() return config }, // 将样式字符串转成对象, 用于自定义主题,表格头部样式