From 32f7469e8441e907f6bb4e015b95f711a4446035 Mon Sep 17 00:00:00 2001 From: wintsa <770775984@qq.com> Date: Tue, 14 Apr 2026 12:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E8=81=94?= =?UTF-8?q?=E5=8A=A8ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shared/components/HtFeeMethodGrid.vue | 6 ++ src/lib/pricingMethodTotals.ts | 46 +++++++----- src/lib/zxFwPricingSync.ts | 70 ++++++++++++------- src/pinia/zxFwPricing.ts | 3 +- 4 files changed, 81 insertions(+), 44 deletions(-) diff --git a/src/features/shared/components/HtFeeMethodGrid.vue b/src/features/shared/components/HtFeeMethodGrid.vue index 0fea023..99e2dae 100644 --- a/src/features/shared/components/HtFeeMethodGrid.vue +++ b/src/features/shared/components/HtFeeMethodGrid.vue @@ -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) diff --git a/src/lib/pricingMethodTotals.ts b/src/lib/pricingMethodTotals.ts index 1ab93f9..13593ad 100644 --- a/src/lib/pricingMethodTotals.ts +++ b/src/lib/pricingMethodTotals.ts @@ -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(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,21 +767,25 @@ const buildDefaultPricingMethodDetailRows = ( context.majorFactorMap ) - const investScale = investScaleSingleTotal - ? buildInvestScaleSingleTotalDetailRows( - serviceId, - context.htData?.detailRows as Array> | undefined, - context.consultCategoryFactorMap, - context.majorFactorMap, - context.industryId, - context.htData?.totalAmount ?? null - ) - : scaleRows.filter(row => { - 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 investScale = capabilities.investScaleEnabled + ? (investScaleSingleTotal + ? buildInvestScaleSingleTotalDetailRows( + serviceId, + context.htData?.detailRows as Array> | undefined, + context.consultCategoryFactorMap, + context.majorFactorMap, + context.industryId, + context.htData?.totalAmount ?? null + ) + : scaleRows.filter(row => { + if (!isCostMajorById(row.id)) return false + if (context.excludeInvestmentCostAndAreaRows && isDualScaleMajorById(row.id)) return false + return true + })) + : [] + const landScale = capabilities.landScaleEnabled + ? scaleRows.filter(row => isAreaMajorById(row.id)) + : [] return { investScale, diff --git a/src/lib/zxFwPricingSync.ts b/src/lib/zxFwPricingSync.ts index 498ee82..a3df7ad 100644 --- a/src/lib/zxFwPricingSync.ts +++ b/src/lib/zxFwPricingSync.ts @@ -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) => @@ -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, @@ -244,33 +253,40 @@ export const syncContractScaleToPricing = async ( let updatedRowCount = 0 for (const serviceId of selectedIds) { - const investChangedCount = await syncScaleMethodRows({ - contractId, - serviceId, - method: 'investScale', - sourceRowMap, - sourceRowIdMap, - projectTotals, - changedRowIds: changedRowIdSet - }) - if (investChangedCount > 0) { - updatedServiceIdSet.add(serviceId) - updatedMethodCount += 1 - updatedRowCount += investChangedCount + const capabilities = getScaleMethodCapabilities(serviceId) + + if (capabilities.investScaleEnabled) { + const investChangedCount = await syncScaleMethodRows({ + contractId, + serviceId, + method: 'investScale', + sourceRowMap, + sourceRowIdMap, + projectTotals, + changedRowIds: changedRowIdSet + }) + if (investChangedCount > 0) { + updatedServiceIdSet.add(serviceId) + updatedMethodCount += 1 + updatedRowCount += investChangedCount + } } - const landChangedCount = await syncScaleMethodRows({ - contractId, - serviceId, - method: 'landScale', - sourceRowMap, - sourceRowIdMap, - projectTotals, - changedRowIds: changedRowIdSet - }) - if (landChangedCount > 0) { - updatedServiceIdSet.add(serviceId) - updatedMethodCount += 1 - updatedRowCount += landChangedCount + + if (capabilities.landScaleEnabled) { + const landChangedCount = await syncScaleMethodRows({ + contractId, + serviceId, + method: 'landScale', + sourceRowMap, + sourceRowIdMap, + projectTotals, + changedRowIds: changedRowIdSet + }) + if (landChangedCount > 0) { + updatedServiceIdSet.add(serviceId) + updatedMethodCount += 1 + updatedRowCount += landChangedCount + } } } diff --git a/src/pinia/zxFwPricing.ts b/src/pinia/zxFwPricing.ts index aab0363..602ae01 100644 --- a/src/pinia/zxFwPricing.ts +++ b/src/pinia/zxFwPricing.ts @@ -945,7 +945,8 @@ export const useZxFwPricingStore = defineStore('zxFwPricing', () => { getHtFeeMethodState, setHtFeeMethodState, loadHtFeeMethodState, - removeHtFeeMethodState + removeHtFeeMethodState, + syncHtExtraFeeByContractBase } }, { persist: true