feat:修改表格样式不生效的问题

main
liu.shiyi 2 years ago
parent 5c4b3c4d65
commit cb1abb6c86

@ -31,6 +31,7 @@
import commonMixins from 'packages/js/mixins/commonMixins' import commonMixins from 'packages/js/mixins/commonMixins'
import paramsMixins from 'packages/js/mixins/paramsMixins' import paramsMixins from 'packages/js/mixins/paramsMixins'
import linkageMixins from 'packages/js/mixins/linkageMixins' import linkageMixins from 'packages/js/mixins/linkageMixins'
import _ from 'lodash'
export default { export default {
name: 'TableChart', name: 'TableChart',
mixins: [paramsMixins, commonMixins, linkageMixins], mixins: [paramsMixins, commonMixins, linkageMixins],
@ -46,6 +47,7 @@ export default {
}, },
data () { data () {
return { return {
updateKey: '',
headerCellStyleObj: { headerCellStyleObj: {
backgroundColor: 'transparent' backgroundColor: 'transparent'
}, },
@ -110,14 +112,15 @@ export default {
created () { }, created () { },
mounted () { mounted () {
this.chartInit() this.chartInit()
this.initStyle() this.changeStyle(this.config)
}, },
methods: { methods: {
// //
rowClick (row) { rowClick (row) {
this.linkage(row) this.linkage(row)
}, },
initStyle () { changeStyle (oldConfig) {
const config = _.cloneDeep(oldConfig)
if (this.customTheme === 'custom') { if (this.customTheme === 'custom') {
this.headerCellStyleToObj() this.headerCellStyleToObj()
this.cellStyleToObj() this.cellStyleToObj()
@ -126,7 +129,7 @@ export default {
this.headerCellStyleToObj() this.headerCellStyleToObj()
this.cellStyleToObj() this.cellStyleToObj()
} }
if (this.config.customize.stripe) { if (config.customize.stripe) {
const trs = document const trs = document
.getElementById(this.config.code) .getElementById(this.config.code)
?.querySelectorAll('tr.el-table__row--striped') ?.querySelectorAll('tr.el-table__row--striped')
@ -142,7 +145,7 @@ export default {
} }
} else { } else {
const trs = document const trs = document
.getElementById(this.config.code) .getElementById(config.code)
?.querySelectorAll('tr.el-table__row--striped') ?.querySelectorAll('tr.el-table__row--striped')
if (trs) { if (trs) {
trs.forEach(tr => { trs.forEach(tr => {
@ -159,21 +162,23 @@ export default {
// }); // });
} }
// this.chartInit(); // this.chartInit();
if (this.config.customize.evenRowBackgroundColor && !this.config.customize.oddRowBackgroundColor) { if (config.customize.evenRowBackgroundColor && !config.customize.oddRowBackgroundColor) {
this.config.customize.oddRowBackgroundColor = this.config.customize.bodyBackgroundColor config.customize.oddRowBackgroundColor = config.customize.bodyBackgroundColor
} else if (!this.config.customize.evenRowBackgroundColor && this.config.customize.oddRowBackgroundColor) { } else if (!config.customize.evenRowBackgroundColor && config.customize.oddRowBackgroundColor) {
this.config.customize.evenRowBackgroundColor = this.config.customize.bodyBackgroundColor config.customize.evenRowBackgroundColor = config.customize.bodyBackgroundColor
} else if (!(!this.config.customize.evenRowBackgroundColor && !this.config.customize.oddRowBackgroundColor)) { } else if (!(!config.customize.evenRowBackgroundColor && !config.customize.oddRowBackgroundColor)) {
this.config.customize.bodyBackgroundColor = '' config.customize.bodyBackgroundColor = ''
} }
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
document.querySelectorAll(`.even-row${this.config.code}`).forEach(node => { document.querySelectorAll(`.even-row${config.code}`).forEach(node => {
node.style.backgroundColor = this.config.customize.evenRowBackgroundColor node.style.backgroundColor = config.customize.evenRowBackgroundColor
}) })
document.querySelectorAll(`.odd-row${this.config.code}`).forEach(node => { document.querySelectorAll(`.odd-row${config.code}`).forEach(node => {
node.style.backgroundColor = this.config.customize.oddRowBackgroundColor node.style.backgroundColor = config.customize.oddRowBackgroundColor
}) })
}) })
this.updateKey = new Date().getTime()
return config
}, },
// //
tableRowClassName ({ row, rowIndex }) { tableRowClassName ({ row, rowIndex }) {
@ -195,6 +200,7 @@ export default {
} else { } else {
config.option.columnData = columnData config.option.columnData = columnData
} }
this.updateKey = new Date().getTime()
return config return config
}, },
// , // ,

Loading…
Cancel
Save