This commit is contained in:
zwgczx committed 2026-03-02 16:55:27 +08:00
1 parent 757de9a43f
commit 3950057707
17 files changed
+2681 -202

No files matched your search

+5 -8
View File
@@ -1,8 +1,4 @@
import {
GridOptions,
themeQuartz
} from "ag-grid-community"
import { GridOptions, themeQuartz } from "ag-grid-community"
const borderConfig = {
style: "solid", // 虚线改实线更简洁,也可保留 dotted 但建议用 solid
width: 0.3, // 更细的边框,减少视觉干扰
@@ -13,7 +9,7 @@ const borderConfig = {
export const myTheme = themeQuartz.withParams({
// 核心:移除外边框,减少视觉包裹感
wrapperBorder: false,
// 表头样式(柔和浅蓝,无加粗,更轻盈)
headerBackgroundColor: "#f0f2f3", // 极浅的背景色,替代深一点的 #e7f3fc
headerTextColor: "#374151", // 深灰色文字,比纯黑更柔和
@@ -24,8 +20,7 @@ export const myTheme = themeQuartz.withParams({
rowBorder: borderConfig,
columnBorder: borderConfig,
headerRowBorder: borderConfig,
// 可选:偶数行背景色(轻微区分,更清新)
dataBackgroundColor: "#fefefe"
});
@@ -43,6 +38,8 @@ export const gridOptions: GridOptions<any> = {
// },
groupDefaultExpanded: -1,
suppressFieldDotNotation: true,
// Keep group expand/collapse state when rowData updates after edits/saves.
getRowId: params => String(params.data?.id ?? params.data?.path?.join('/') ?? ''),
getDataPath: data => data.path,
getContextMenuItems: () => ['copy', 'paste', 'separator', 'export'],
defaultColDef: {
+39 -14
View File
@@ -1,4 +1,5 @@
import localforage from 'localforage'
import { majorList, serviceList } from '@/sql'
const CONSULT_CATEGORY_FACTOR_KEY = 'xm-consult-category-factor-v1'
const MAJOR_FACTOR_KEY = 'xm-major-factor-v1'
@@ -13,27 +14,51 @@ type XmFactorState = {
detailRows?: XmFactorRow[]
}
type FactorDictItem = {
defCoe?: number | null
}
type FactorDict = Record<string, FactorDictItem>
const toFiniteNumberOrNull = (value: unknown): number | null =>
typeof value === 'number' && Number.isFinite(value) ? value : null
const resolveFactorValue = (row: Partial<XmFactorRow> | undefined): number | null => {
if (!row) return null
const budgetValue = toFiniteNumberOrNull(row.budgetValue)
if (budgetValue != null) return budgetValue
return toFiniteNumberOrNull(row.standardFactor)
}
const loadFactorMap = async (storageKey: string): Promise<Map<string, number | null>> => {
const data = await localforage.getItem<XmFactorState>(storageKey)
const buildStandardFactorMap = (dict: FactorDict): Map<string, number | null> => {
const map = new Map<string, number | null>()
for (const row of data?.detailRows || []) {
if (!row?.id) continue
map.set(String(row.id), resolveFactorValue(row))
for (const [id, item] of Object.entries(dict)) {
map.set(String(id), toFiniteNumberOrNull(item?.defCoe))
}
return map
}
export const loadConsultCategoryFactorMap = async () => loadFactorMap(CONSULT_CATEGORY_FACTOR_KEY)
const resolveFactorValue = (
row: Partial<XmFactorRow> | undefined,
fallbackStandard: number | null
): number | null => {
if (!row) return null
const budgetValue = toFiniteNumberOrNull(row.budgetValue)
if (budgetValue != null) return budgetValue
const standardFactor = toFiniteNumberOrNull(row.standardFactor)
if (standardFactor != null) return standardFactor
return fallbackStandard
}
export const loadMajorFactorMap = async () => loadFactorMap(MAJOR_FACTOR_KEY)
const loadFactorMap = async (
storageKey: string,
dict: FactorDict
): Promise<Map<string, number | null>> => {
const data = await localforage.getItem<XmFactorState>(storageKey)
const map = buildStandardFactorMap(dict)
for (const row of data?.detailRows || []) {
if (!row?.id) continue
const id = String(row.id)
map.set(id, resolveFactorValue(row, map.get(id) ?? null))
}
return map
}
export const loadConsultCategoryFactorMap = async () =>
loadFactorMap(CONSULT_CATEGORY_FACTOR_KEY, serviceList as FactorDict)
export const loadMajorFactorMap = async () =>
loadFactorMap(MAJOR_FACTOR_KEY, majorList as FactorDict)