forked from github/dataease
feat(视图): 表格支持斑马纹
This commit is contained in:
parent
a32f0130d1
commit
762c367f79
@ -62,7 +62,7 @@ import { exportExcelDownload } from '@/views/chart/components/js/util'
|
|||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const dialogShow = ref(false)
|
const dialogShow = ref(false)
|
||||||
let viewInfo = ref(null)
|
let viewInfo = ref<DeepPartial<ChartObj>>(null)
|
||||||
const config = ref(null)
|
const config = ref(null)
|
||||||
const canvasStyleData = ref(null)
|
const canvasStyleData = ref(null)
|
||||||
const viewContainer = ref(null)
|
const viewContainer = ref(null)
|
||||||
@ -74,8 +74,15 @@ const { dvInfo } = storeToRefs(dvMainStore)
|
|||||||
const dialogInit = (canvasStyle, view, item, opt) => {
|
const dialogInit = (canvasStyle, view, item, opt) => {
|
||||||
optType.value = opt
|
optType.value = opt
|
||||||
dialogShow.value = true
|
dialogShow.value = true
|
||||||
viewInfo.value = deepCopy(view)
|
viewInfo.value = deepCopy(view) as DeepPartial<ChartObj>
|
||||||
viewInfo.value.customStyle.text.show = false
|
viewInfo.value.customStyle.text.show = false
|
||||||
|
if (!viewInfo.value.type?.includes('table')) {
|
||||||
|
viewInfo.value.customAttr.tableHeader.tableHeaderBgColor = '#F8F8F9'
|
||||||
|
viewInfo.value.customAttr.tableHeader.tableHeaderFontColor = '#7C7E81'
|
||||||
|
viewInfo.value.customAttr.tableCell.tableItemBgColor = '#FFFFFF'
|
||||||
|
viewInfo.value.customAttr.tableCell.tableFontColor = '#7C7E81'
|
||||||
|
viewInfo.value.customAttr.tableCell.enableTableCrossBG = false
|
||||||
|
}
|
||||||
config.value = deepCopy(item)
|
config.value = deepCopy(item)
|
||||||
canvasStyleData.value = canvasStyle
|
canvasStyleData.value = canvasStyle
|
||||||
if (opt === 'details') {
|
if (opt === 'details') {
|
||||||
|
@ -246,6 +246,14 @@ declare interface ChartTableCellAttr {
|
|||||||
* 单元格行高
|
* 单元格行高
|
||||||
*/
|
*/
|
||||||
tableItemHeight: number
|
tableItemHeight: number
|
||||||
|
/**
|
||||||
|
* 是否开启斑马纹
|
||||||
|
*/
|
||||||
|
enableTableCrossBG: boolean
|
||||||
|
/**
|
||||||
|
* 斑马纹单数行颜色
|
||||||
|
*/
|
||||||
|
tableItemSubBgColor: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,6 +82,34 @@ onMounted(() => {
|
|||||||
@change="changeTableCell('tableItemBgColor')"
|
@change="changeTableCell('tableItemBgColor')"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
:class="'form-item-' + themes"
|
||||||
|
class="form-item"
|
||||||
|
v-if="showProperty('enableTableCrossBG')"
|
||||||
|
label=""
|
||||||
|
>
|
||||||
|
<el-checkbox
|
||||||
|
v-model="state.tableCellForm.enableTableCrossBG"
|
||||||
|
:label="t('chart.stripe')"
|
||||||
|
:effect="themes"
|
||||||
|
@change="changeTableCell('enableTableCrossBG')"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
:class="'form-item-' + themes"
|
||||||
|
class="form-item"
|
||||||
|
label=""
|
||||||
|
v-if="showProperty('tableItemSubBgColor')"
|
||||||
|
>
|
||||||
|
<el-color-picker
|
||||||
|
v-model="state.tableCellForm.tableItemSubBgColor"
|
||||||
|
:effect="themes"
|
||||||
|
:predefine="predefineColors"
|
||||||
|
:disabled="!state.tableCellForm.enableTableCrossBG"
|
||||||
|
is-custom
|
||||||
|
@change="changeTableCell('tableItemSubBgColor')"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-space>
|
<el-space>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
class="form-item"
|
class="form-item"
|
||||||
|
@ -39,7 +39,8 @@ export const DEFAULT_COLOR_CASE: DeepPartial<ChartAttr> = {
|
|||||||
},
|
},
|
||||||
tableCell: {
|
tableCell: {
|
||||||
tableItemBgColor: '#FFFFFF',
|
tableItemBgColor: '#FFFFFF',
|
||||||
tableFontColor: '#000000'
|
tableFontColor: '#000000',
|
||||||
|
tableItemSubBgColor: '#EEEEEE'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,8 @@ export const DEFAULT_COLOR_CASE_LIGHT: DeepPartial<ChartAttr> = {
|
|||||||
},
|
},
|
||||||
tableCell: {
|
tableCell: {
|
||||||
tableItemBgColor: '#FFFFFF',
|
tableItemBgColor: '#FFFFFF',
|
||||||
tableFontColor: '#000000'
|
tableFontColor: '#000000',
|
||||||
|
tableItemSubBgColor: '#EEEEEE'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +121,8 @@ export const DEFAULT_COLOR_CASE_DARK: DeepPartial<ChartAttr> = {
|
|||||||
},
|
},
|
||||||
tableCell: {
|
tableCell: {
|
||||||
tableItemBgColor: '#131E42',
|
tableItemBgColor: '#131E42',
|
||||||
tableFontColor: '#ffffff'
|
tableFontColor: '#ffffff',
|
||||||
|
tableItemSubBgColor: '#EEEEEE'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +336,9 @@ export const DEFAULT_TABLE_CELL: ChartTableCellAttr = {
|
|||||||
tableItemAlign: 'right',
|
tableItemAlign: 'right',
|
||||||
tableItemBgColor: '#FFFFFF',
|
tableItemBgColor: '#FFFFFF',
|
||||||
tableItemFontSize: 12,
|
tableItemFontSize: 12,
|
||||||
tableItemHeight: 36
|
tableItemHeight: 36,
|
||||||
|
enableTableCrossBG: false,
|
||||||
|
tableItemSubBgColor: '#EEEEEE'
|
||||||
}
|
}
|
||||||
export const DEFAULT_TITLE_STYLE: ChartTextStyle = {
|
export const DEFAULT_TITLE_STYLE: ChartTextStyle = {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -27,7 +27,9 @@ export const TABLE_EDITOR_PROPERTY_INNER: EditorPropertyInner = {
|
|||||||
'tableItemFontSize',
|
'tableItemFontSize',
|
||||||
'tableFontColor',
|
'tableFontColor',
|
||||||
'tableItemAlign',
|
'tableItemAlign',
|
||||||
'tableItemHeight'
|
'tableItemHeight',
|
||||||
|
'enableTableCrossBG',
|
||||||
|
'tableItemSubBgColor'
|
||||||
],
|
],
|
||||||
'title-selector': [
|
'title-selector': [
|
||||||
'title',
|
'title',
|
||||||
|
@ -236,7 +236,8 @@ export function getCustomTheme(chart: Chart): S2Theme {
|
|||||||
if (tableCell) {
|
if (tableCell) {
|
||||||
const tableFontColor = hexColorToRGBA(tableCell.tableFontColor, basicStyle.alpha)
|
const tableFontColor = hexColorToRGBA(tableCell.tableFontColor, basicStyle.alpha)
|
||||||
const tableItemBgColor = hexColorToRGBA(tableCell.tableItemBgColor, basicStyle.alpha)
|
const tableItemBgColor = hexColorToRGBA(tableCell.tableItemBgColor, basicStyle.alpha)
|
||||||
const { tableItemAlign, tableItemFontSize } = tableCell
|
const tableItemSubBgColor = hexColorToRGBA(tableCell.tableItemSubBgColor, basicStyle.alpha)
|
||||||
|
const { tableItemAlign, tableItemFontSize, enableTableCrossBG } = tableCell
|
||||||
const tmpTheme: S2Theme = {
|
const tmpTheme: S2Theme = {
|
||||||
rowCell: {
|
rowCell: {
|
||||||
cell: {
|
cell: {
|
||||||
@ -267,7 +268,7 @@ export function getCustomTheme(chart: Chart): S2Theme {
|
|||||||
},
|
},
|
||||||
dataCell: {
|
dataCell: {
|
||||||
cell: {
|
cell: {
|
||||||
crossBackgroundColor: tableItemBgColor,
|
crossBackgroundColor: enableTableCrossBG ? tableItemSubBgColor : tableItemBgColor,
|
||||||
backgroundColor: tableItemBgColor
|
backgroundColor: tableItemBgColor
|
||||||
},
|
},
|
||||||
bolderText: {
|
bolderText: {
|
||||||
@ -381,8 +382,11 @@ export function getConditions(chart: Chart) {
|
|||||||
if (conditions?.length > 0) {
|
if (conditions?.length > 0) {
|
||||||
const { tableCell, basicStyle } = parseJson(chart.customAttr)
|
const { tableCell, basicStyle } = parseJson(chart.customAttr)
|
||||||
const valueColor = tableCell.tableFontColor
|
const valueColor = tableCell.tableFontColor
|
||||||
const valueBgColor = hexColorToRGBA(tableCell.tableItemBgColor, basicStyle.alpha)
|
let valueBgColor = hexColorToRGBA(tableCell.tableItemBgColor, basicStyle.alpha)
|
||||||
|
const enableTableCrossBG = tableCell.enableTableCrossBG
|
||||||
|
if (enableTableCrossBG) {
|
||||||
|
valueBgColor = null
|
||||||
|
}
|
||||||
for (let i = 0; i < conditions.length; i++) {
|
for (let i = 0; i < conditions.length; i++) {
|
||||||
const field = conditions[i]
|
const field = conditions[i]
|
||||||
res.text.push({
|
res.text.push({
|
||||||
@ -396,9 +400,8 @@ export function getConditions(chart: Chart) {
|
|||||||
res.background.push({
|
res.background.push({
|
||||||
field: field.field.dataeaseName,
|
field: field.field.dataeaseName,
|
||||||
mapping(value) {
|
mapping(value) {
|
||||||
return {
|
const fill = mappingColor(value, valueBgColor, field, 'backgroundColor')
|
||||||
fill: mappingColor(value, valueBgColor, field, 'backgroundColor')
|
return fill ? { fill } : null
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -614,7 +617,8 @@ class SortTooltip extends BaseTooltip {
|
|||||||
style: {
|
style: {
|
||||||
left: `${this.position?.x}px`,
|
left: `${this.position?.x}px`,
|
||||||
top: `${this.position?.y}px`,
|
top: `${this.position?.y}px`,
|
||||||
pointerEvents: enterable ? 'all' : 'none'
|
pointerEvents: enterable ? 'all' : 'none',
|
||||||
|
zIndex: 9999
|
||||||
},
|
},
|
||||||
visible: true
|
visible: true
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user