修复数据联动ug

This commit is contained in:
wintsa 2026-04-14 12:20:24 +08:00
parent ce682c3679
commit 32f7469e84
4 changed files with 81 additions and 44 deletions

View File

@ -375,6 +375,12 @@ const saveToIndexedDB = async (force = false) => {
const snapshot = JSON.stringify(payload.detailRows) const snapshot = JSON.stringify(payload.detailRows)
if (!force && snapshot === lastSavedSnapshot.value) return if (!force && snapshot === lastSavedSnapshot.value) return
zxFwPricingStore.setHtFeeMainState(props.storageKey, payload, { force }) zxFwPricingStore.setHtFeeMainState(props.storageKey, payload, { force })
if (String(props.storageKey || '').includes('-additional-work')) {
const contractId = String(props.contractId || '').trim()
if (contractId) {
await zxFwPricingStore.syncHtExtraFeeByContractBase(contractId)
}
}
lastSavedSnapshot.value = snapshot lastSavedSnapshot.value = snapshot
} catch (error) { } catch (error) {
console.error('saveToIndexedDB failed:', error) console.error('saveToIndexedDB failed:', error)

View File

@ -8,7 +8,7 @@ import {
import { roundTo, sumByNumber, toDecimal, toFiniteNumberOrNull } from '@/lib/decimal' import { roundTo, sumByNumber, toDecimal, toFiniteNumberOrNull } from '@/lib/decimal'
import { getScaleBudgetFee } from '@/lib/pricingScaleFee' import { getScaleBudgetFee } from '@/lib/pricingScaleFee'
import { getScaleBudgetFeeByRow } from '@/lib/pricingScaleDetail' import { getScaleBudgetFeeByRow } from '@/lib/pricingScaleDetail'
import { isInvestScaleSingleTotalService } from '@/lib/servicePricing' import { isInvestScaleSingleTotalService, resolveServicePricingCapabilities } from '@/lib/servicePricing'
import { useZxFwPricingStore, type ServicePricingMethod } from '@/pinia/zxFwPricing' import { useZxFwPricingStore, type ServicePricingMethod } from '@/pinia/zxFwPricing'
import { useKvStore } from '@/pinia/kv' import { useKvStore } from '@/pinia/kv'
@ -88,7 +88,11 @@ interface MajorLite {
interface ServiceLite { interface ServiceLite {
defCoe: number | null defCoe: number | null
enableInvestScale?: boolean | null
enableLandScale?: boolean | null
investScaleSingleTotal?: boolean | null investScaleSingleTotal?: boolean | null
scale?: boolean | null
onlyCostScale?: boolean | null
} }
interface TaskLite { interface TaskLite {
@ -229,6 +233,11 @@ const usesInvestScaleSingleTotal = (serviceId: string | number) => {
return isInvestScaleSingleTotalService(service) return isInvestScaleSingleTotalService(service)
} }
const getScaleMethodCapabilities = (serviceId: string | number) => {
const service = (getServiceDictById() as Record<string, ServiceLite | undefined>)[String(serviceId)]
return resolveServicePricingCapabilities(service)
}
const majorById = new Map(getMajorDictEntries().map(({ id, item }) => [id, item as MajorLite])) const majorById = new Map(getMajorDictEntries().map(({ id, item }) => [id, item as MajorLite]))
const majorIdAliasMap = getMajorIdAliasMap() const majorIdAliasMap = getMajorIdAliasMap()
@ -748,6 +757,7 @@ const buildDefaultPricingMethodDetailRows = (
serviceId: string, serviceId: string,
context: PricingMethodDefaultBuildContext context: PricingMethodDefaultBuildContext
): PricingMethodDefaultDetailRows => { ): PricingMethodDefaultDetailRows => {
const capabilities = getScaleMethodCapabilities(serviceId)
const investScaleSingleTotal = usesInvestScaleSingleTotal(serviceId) const investScaleSingleTotal = usesInvestScaleSingleTotal(serviceId)
const scaleRows = resolveScaleRows( const scaleRows = resolveScaleRows(
serviceId, serviceId,
@ -757,21 +767,25 @@ const buildDefaultPricingMethodDetailRows = (
context.majorFactorMap context.majorFactorMap
) )
const investScale = investScaleSingleTotal const investScale = capabilities.investScaleEnabled
? buildInvestScaleSingleTotalDetailRows( ? (investScaleSingleTotal
serviceId, ? buildInvestScaleSingleTotalDetailRows(
context.htData?.detailRows as Array<Record<string, unknown>> | undefined, serviceId,
context.consultCategoryFactorMap, context.htData?.detailRows as Array<Record<string, unknown>> | undefined,
context.majorFactorMap, context.consultCategoryFactorMap,
context.industryId, context.majorFactorMap,
context.htData?.totalAmount ?? null context.industryId,
) context.htData?.totalAmount ?? null
: scaleRows.filter(row => { )
if (!isCostMajorById(row.id)) return false : scaleRows.filter(row => {
if (context.excludeInvestmentCostAndAreaRows && isDualScaleMajorById(row.id)) return false if (!isCostMajorById(row.id)) return false
return true if (context.excludeInvestmentCostAndAreaRows && isDualScaleMajorById(row.id)) return false
}) return true
const landScale = scaleRows.filter(row => isAreaMajorById(row.id)) }))
: []
const landScale = capabilities.landScaleEnabled
? scaleRows.filter(row => isAreaMajorById(row.id))
: []
return { return {
investScale, investScale,

View File

@ -1,6 +1,6 @@
import { roundTo, sumByNumber, toDecimal } from '@/lib/decimal' import { roundTo, sumByNumber, toDecimal } from '@/lib/decimal'
import { ensurePricingMethodDetailRowsForServices } from '@/lib/pricingMethodTotals' import { ensurePricingMethodDetailRowsForServices } from '@/lib/pricingMethodTotals'
import { isInvestScaleSingleTotalService } from '@/lib/servicePricing' import { isInvestScaleSingleTotalService, resolveServicePricingCapabilities } from '@/lib/servicePricing'
import { getServiceDictItemById } from '@/sql' import { getServiceDictItemById } from '@/sql'
import { import {
isSameNullableNumber, isSameNullableNumber,
@ -65,7 +65,11 @@ type WorkloadDetailRow = {
} }
type ServiceLite = { type ServiceLite = {
enableInvestScale?: boolean | null
enableLandScale?: boolean | null
investScaleSingleTotal?: boolean | null investScaleSingleTotal?: boolean | null
scale?: boolean | null
onlyCostScale?: boolean | null
} }
const normalizeServiceIdSet = (serviceIds?: Array<string | number>) => const normalizeServiceIdSet = (serviceIds?: Array<string | number>) =>
@ -114,6 +118,11 @@ const usesInvestScaleSingleTotal = (serviceId: string) => {
return isInvestScaleSingleTotalService(service) return isInvestScaleSingleTotalService(service)
} }
const getScaleMethodCapabilities = (serviceId: string) => {
const service = getServiceDictItemById(serviceId) as ServiceLite | undefined
return resolveServicePricingCapabilities(service)
}
const matchesChangedScaleRow = ( const matchesChangedScaleRow = (
row: ScaleDetailRow, row: ScaleDetailRow,
changedRowIds?: Set<string>, changedRowIds?: Set<string>,
@ -244,33 +253,40 @@ export const syncContractScaleToPricing = async (
let updatedRowCount = 0 let updatedRowCount = 0
for (const serviceId of selectedIds) { for (const serviceId of selectedIds) {
const investChangedCount = await syncScaleMethodRows({ const capabilities = getScaleMethodCapabilities(serviceId)
contractId,
serviceId, if (capabilities.investScaleEnabled) {
method: 'investScale', const investChangedCount = await syncScaleMethodRows({
sourceRowMap, contractId,
sourceRowIdMap, serviceId,
projectTotals, method: 'investScale',
changedRowIds: changedRowIdSet sourceRowMap,
}) sourceRowIdMap,
if (investChangedCount > 0) { projectTotals,
updatedServiceIdSet.add(serviceId) changedRowIds: changedRowIdSet
updatedMethodCount += 1 })
updatedRowCount += investChangedCount if (investChangedCount > 0) {
updatedServiceIdSet.add(serviceId)
updatedMethodCount += 1
updatedRowCount += investChangedCount
}
} }
const landChangedCount = await syncScaleMethodRows({
contractId, if (capabilities.landScaleEnabled) {
serviceId, const landChangedCount = await syncScaleMethodRows({
method: 'landScale', contractId,
sourceRowMap, serviceId,
sourceRowIdMap, method: 'landScale',
projectTotals, sourceRowMap,
changedRowIds: changedRowIdSet sourceRowIdMap,
}) projectTotals,
if (landChangedCount > 0) { changedRowIds: changedRowIdSet
updatedServiceIdSet.add(serviceId) })
updatedMethodCount += 1 if (landChangedCount > 0) {
updatedRowCount += landChangedCount updatedServiceIdSet.add(serviceId)
updatedMethodCount += 1
updatedRowCount += landChangedCount
}
} }
} }

View File

@ -945,7 +945,8 @@ export const useZxFwPricingStore = defineStore('zxFwPricing', () => {
getHtFeeMethodState, getHtFeeMethodState,
setHtFeeMethodState, setHtFeeMethodState,
loadHtFeeMethodState, loadHtFeeMethodState,
removeHtFeeMethodState removeHtFeeMethodState,
syncHtExtraFeeByContractBase
} }
}, { }, {
persist: true persist: true