fix(图表): 修复明细表的日期字段,在条件样式中无法设置动态值的问题

This commit is contained in:
jianneng-fit2cloud
2024-12-04 17:11:57 +08:00
parent 1d90aaa25e
commit 4b322bcaac
2 changed files with 20 additions and 25 deletions

View File

@@ -191,7 +191,6 @@ const initOptions = (item, fieldObj) => {
item.options = JSON.parse(JSON.stringify(textOptions))
} else if (fieldObj.deType === 1) {
item.options = JSON.parse(JSON.stringify(dateOptions))
item.type = 'fixed'
} else {
item.options = JSON.parse(JSON.stringify(valueOptions))
}
@@ -375,12 +374,7 @@ const changeConditionItemType = item => {
}
}
const getFieldOptions = fieldItem => {
const deType = state.fields.filter(ele => ele.id === fieldItem.fieldId)?.[0]?.deType
if (deType === 1) {
return fieldOptions.filter(ele => ele.value === 'fixed')
} else {
return fieldOptions
}
return fieldOptions
}
init()

View File

@@ -49,7 +49,7 @@ import Exceljs from 'exceljs'
import { saveAs } from 'file-saver'
import { ElMessage } from 'element-plus-secondary'
import { useI18n } from '@/hooks/web/useI18n'
const { t } = useI18n()
const { t:i18nt } = useI18n()
export function getCustomTheme(chart: Chart): S2Theme {
const headerColor = hexColorToRGBA(
@@ -772,40 +772,41 @@ export function mappingColor(value, defaultColor, field, type, filedValueMap?, r
}
} else {
// time
const tv = new Date(t.value.replace(/-/g, '/') + ' GMT+8').getTime()
const fc = field.conditions[i]
tv = new Date(tv.replace(/-/g, '/') + ' GMT+8').getTime()
const v = new Date(value.replace(/-/g, '/') + ' GMT+8').getTime()
if (t.term === 'eq') {
if (fc.term === 'eq') {
if (v === tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'not_eq') {
} else if (fc.term === 'not_eq') {
if (v !== tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'lt') {
} else if (fc.term === 'lt') {
if (v < tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'gt') {
} else if (fc.term === 'gt') {
if (v > tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'le') {
} else if (fc.term === 'le') {
if (v <= tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'ge') {
} else if (fc.term === 'ge') {
if (v >= tv) {
color = t[type]
color = fc[type]
flag = true
}
} else if (t.term === 'default') {
color = t[type]
} else if (fc.term === 'default') {
color = fc[type]
flag = true
}
if (flag) {
@@ -1832,10 +1833,10 @@ export const configSummaryRow = (chart, s2Options, newData, tableHeader, basicSt
}
if (viewMeta.colIndex === 0) {
if (tableHeader.showIndex) {
viewMeta.fieldValue = basicStyle.summaryLabel ?? t('chart.total_show')
viewMeta.fieldValue = basicStyle.summaryLabel ?? i18nt('chart.total_show')
} else {
if (xAxis.length) {
viewMeta.fieldValue = basicStyle.summaryLabel ?? t('chart.total_show')
viewMeta.fieldValue = basicStyle.summaryLabel ?? i18nt('chart.total_show')
}
}
}