'20260305修复bug'
This commit is contained in:
1 parent
53c1b2c0db
commit
75f293f877
20 files changed
+1167
-1400
No files matched your search
@@ -1,5 +1,11 @@
|
||||
import localforage from 'localforage'
|
||||
import { expertList, majorList, serviceList, taskList } from '@/sql'
|
||||
import {
|
||||
expertList,
|
||||
getMajorDictEntries,
|
||||
getMajorIdAliasMap,
|
||||
getServiceDictById,
|
||||
taskList
|
||||
} from '@/sql'
|
||||
import { roundTo, sumByNumber, toDecimal } from '@/lib/decimal'
|
||||
import { toFiniteNumberOrNull } from '@/lib/number'
|
||||
import { getBenchmarkBudgetByScale, getScaleBudgetFee } from '@/lib/pricingScaleFee'
|
||||
@@ -73,20 +79,23 @@ const toRowMap = <TRow extends { id: string }>(rows?: TRow[]) => {
|
||||
}
|
||||
|
||||
const getDefaultConsultCategoryFactor = (serviceId: string | number) => {
|
||||
const service = (serviceList as Record<string, ServiceLite | undefined>)[String(serviceId)]
|
||||
const service = (getServiceDictById() as Record<string, ServiceLite | undefined>)[String(serviceId)]
|
||||
return toFiniteNumberOrNull(service?.defCoe)
|
||||
}
|
||||
|
||||
const majorById = new Map(getMajorDictEntries().map(({ id, item }) => [id, item as MajorLite]))
|
||||
const majorIdAliasMap = getMajorIdAliasMap()
|
||||
|
||||
const getDefaultMajorFactorById = (id: string) => {
|
||||
const major = (majorList as Record<string, MajorLite | undefined>)[id]
|
||||
const resolvedId = majorById.has(id) ? id : majorIdAliasMap.get(id) || id
|
||||
const major = majorById.get(resolvedId)
|
||||
return toFiniteNumberOrNull(major?.defCoe)
|
||||
}
|
||||
|
||||
const getMajorLeafIds = () =>
|
||||
Object.entries(majorList as Record<string, MajorLite>)
|
||||
.sort((a, b) => Number(a[0]) - Number(b[0]))
|
||||
.filter(([, item]) => Boolean(item?.code && item.code.includes('-')))
|
||||
.map(([id]) => id)
|
||||
getMajorDictEntries()
|
||||
.filter(({ item }) => Boolean(item?.code && String(item.code).includes('-')))
|
||||
.map(({ id }) => id)
|
||||
|
||||
const buildDefaultScaleRows = (serviceId: string | number): ScaleRow[] => {
|
||||
const defaultConsultCategoryFactor = getDefaultConsultCategoryFactor(serviceId)
|
||||
@@ -104,6 +113,13 @@ const mergeScaleRows = (
|
||||
rowsFromDb: Array<Partial<ScaleRow> & Pick<ScaleRow, 'id'>> | undefined
|
||||
): ScaleRow[] => {
|
||||
const dbValueMap = toRowMap(rowsFromDb)
|
||||
for (const row of rowsFromDb || []) {
|
||||
const rowId = String(row.id)
|
||||
const nextId = majorIdAliasMap.get(rowId)
|
||||
if (nextId && !dbValueMap.has(nextId)) {
|
||||
dbValueMap.set(nextId, row as ScaleRow)
|
||||
}
|
||||
}
|
||||
|
||||
const defaultConsultCategoryFactor = getDefaultConsultCategoryFactor(serviceId)
|
||||
return buildDefaultScaleRows(serviceId).map(row => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import localforage from 'localforage'
|
||||
import { majorList, serviceList } from '@/sql'
|
||||
import { getMajorDictById, getMajorIdAliasMap, getServiceDictById } from '@/sql'
|
||||
import { toFiniteNumberOrNull } from '@/lib/number'
|
||||
|
||||
const CONSULT_CATEGORY_FACTOR_KEY = 'xm-consult-category-factor-v1'
|
||||
@@ -43,20 +43,22 @@ const resolveFactorValue = (
|
||||
|
||||
const loadFactorMap = async (
|
||||
storageKey: string,
|
||||
dict: FactorDict
|
||||
dict: FactorDict,
|
||||
aliases?: Map<string, string>
|
||||
): 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)
|
||||
const rowId = String(row.id)
|
||||
const id = map.has(rowId) ? rowId : aliases?.get(rowId) || rowId
|
||||
map.set(id, resolveFactorValue(row, map.get(id) ?? null))
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
export const loadConsultCategoryFactorMap = async () =>
|
||||
loadFactorMap(CONSULT_CATEGORY_FACTOR_KEY, serviceList as FactorDict)
|
||||
loadFactorMap(CONSULT_CATEGORY_FACTOR_KEY, getServiceDictById() as FactorDict)
|
||||
|
||||
export const loadMajorFactorMap = async () =>
|
||||
loadFactorMap(MAJOR_FACTOR_KEY, majorList as FactorDict)
|
||||
loadFactorMap(MAJOR_FACTOR_KEY, getMajorDictById() as FactorDict, getMajorIdAliasMap())
|
||||
Reference in new issue
Block a user