修复数据联动ug
This commit is contained in:
parent
ce682c3679
commit
32f7469e84
@ -375,6 +375,12 @@ const saveToIndexedDB = async (force = false) => {
|
||||
const snapshot = JSON.stringify(payload.detailRows)
|
||||
if (!force && snapshot === lastSavedSnapshot.value) return
|
||||
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
|
||||
} catch (error) {
|
||||
console.error('saveToIndexedDB failed:', error)
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
import { roundTo, sumByNumber, toDecimal, toFiniteNumberOrNull } from '@/lib/decimal'
|
||||
import { getScaleBudgetFee } from '@/lib/pricingScaleFee'
|
||||
import { getScaleBudgetFeeByRow } from '@/lib/pricingScaleDetail'
|
||||
import { isInvestScaleSingleTotalService } from '@/lib/servicePricing'
|
||||
import { isInvestScaleSingleTotalService, resolveServicePricingCapabilities } from '@/lib/servicePricing'
|
||||
import { useZxFwPricingStore, type ServicePricingMethod } from '@/pinia/zxFwPricing'
|
||||
import { useKvStore } from '@/pinia/kv'
|
||||
|
||||
@ -88,7 +88,11 @@ interface MajorLite {
|
||||
|
||||
interface ServiceLite {
|
||||
defCoe: number | null
|
||||
enableInvestScale?: boolean | null
|
||||
enableLandScale?: boolean | null
|
||||
investScaleSingleTotal?: boolean | null
|
||||
scale?: boolean | null
|
||||
onlyCostScale?: boolean | null
|
||||
}
|
||||
|
||||
interface TaskLite {
|
||||
@ -229,6 +233,11 @@ const usesInvestScaleSingleTotal = (serviceId: string | number) => {
|
||||
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 majorIdAliasMap = getMajorIdAliasMap()
|
||||
|
||||
@ -748,6 +757,7 @@ const buildDefaultPricingMethodDetailRows = (
|
||||
serviceId: string,
|
||||
context: PricingMethodDefaultBuildContext
|
||||
): PricingMethodDefaultDetailRows => {
|
||||
const capabilities = getScaleMethodCapabilities(serviceId)
|
||||
const investScaleSingleTotal = usesInvestScaleSingleTotal(serviceId)
|
||||
const scaleRows = resolveScaleRows(
|
||||
serviceId,
|
||||
@ -757,7 +767,8 @@ const buildDefaultPricingMethodDetailRows = (
|
||||
context.majorFactorMap
|
||||
)
|
||||
|
||||
const investScale = investScaleSingleTotal
|
||||
const investScale = capabilities.investScaleEnabled
|
||||
? (investScaleSingleTotal
|
||||
? buildInvestScaleSingleTotalDetailRows(
|
||||
serviceId,
|
||||
context.htData?.detailRows as Array<Record<string, unknown>> | undefined,
|
||||
@ -770,8 +781,11 @@ const buildDefaultPricingMethodDetailRows = (
|
||||
if (!isCostMajorById(row.id)) return false
|
||||
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 {
|
||||
investScale,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { roundTo, sumByNumber, toDecimal } from '@/lib/decimal'
|
||||
import { ensurePricingMethodDetailRowsForServices } from '@/lib/pricingMethodTotals'
|
||||
import { isInvestScaleSingleTotalService } from '@/lib/servicePricing'
|
||||
import { isInvestScaleSingleTotalService, resolveServicePricingCapabilities } from '@/lib/servicePricing'
|
||||
import { getServiceDictItemById } from '@/sql'
|
||||
import {
|
||||
isSameNullableNumber,
|
||||
@ -65,7 +65,11 @@ type WorkloadDetailRow = {
|
||||
}
|
||||
|
||||
type ServiceLite = {
|
||||
enableInvestScale?: boolean | null
|
||||
enableLandScale?: boolean | null
|
||||
investScaleSingleTotal?: boolean | null
|
||||
scale?: boolean | null
|
||||
onlyCostScale?: boolean | null
|
||||
}
|
||||
|
||||
const normalizeServiceIdSet = (serviceIds?: Array<string | number>) =>
|
||||
@ -114,6 +118,11 @@ const usesInvestScaleSingleTotal = (serviceId: string) => {
|
||||
return isInvestScaleSingleTotalService(service)
|
||||
}
|
||||
|
||||
const getScaleMethodCapabilities = (serviceId: string) => {
|
||||
const service = getServiceDictItemById(serviceId) as ServiceLite | undefined
|
||||
return resolveServicePricingCapabilities(service)
|
||||
}
|
||||
|
||||
const matchesChangedScaleRow = (
|
||||
row: ScaleDetailRow,
|
||||
changedRowIds?: Set<string>,
|
||||
@ -244,6 +253,9 @@ export const syncContractScaleToPricing = async (
|
||||
let updatedRowCount = 0
|
||||
|
||||
for (const serviceId of selectedIds) {
|
||||
const capabilities = getScaleMethodCapabilities(serviceId)
|
||||
|
||||
if (capabilities.investScaleEnabled) {
|
||||
const investChangedCount = await syncScaleMethodRows({
|
||||
contractId,
|
||||
serviceId,
|
||||
@ -258,6 +270,9 @@ export const syncContractScaleToPricing = async (
|
||||
updatedMethodCount += 1
|
||||
updatedRowCount += investChangedCount
|
||||
}
|
||||
}
|
||||
|
||||
if (capabilities.landScaleEnabled) {
|
||||
const landChangedCount = await syncScaleMethodRows({
|
||||
contractId,
|
||||
serviceId,
|
||||
@ -273,6 +288,7 @@ export const syncContractScaleToPricing = async (
|
||||
updatedRowCount += landChangedCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
updatedServiceCount: updatedServiceIdSet.size,
|
||||
|
||||
@ -945,7 +945,8 @@ export const useZxFwPricingStore = defineStore('zxFwPricing', () => {
|
||||
getHtFeeMethodState,
|
||||
setHtFeeMethodState,
|
||||
loadHtFeeMethodState,
|
||||
removeHtFeeMethodState
|
||||
removeHtFeeMethodState,
|
||||
syncHtExtraFeeByContractBase
|
||||
}
|
||||
}, {
|
||||
persist: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user