修复数据联动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)
|
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)
|
||||||
|
|||||||
@ -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,7 +767,8 @@ const buildDefaultPricingMethodDetailRows = (
|
|||||||
context.majorFactorMap
|
context.majorFactorMap
|
||||||
)
|
)
|
||||||
|
|
||||||
const investScale = investScaleSingleTotal
|
const investScale = capabilities.investScaleEnabled
|
||||||
|
? (investScaleSingleTotal
|
||||||
? buildInvestScaleSingleTotalDetailRows(
|
? buildInvestScaleSingleTotalDetailRows(
|
||||||
serviceId,
|
serviceId,
|
||||||
context.htData?.detailRows as Array<Record<string, unknown>> | undefined,
|
context.htData?.detailRows as Array<Record<string, unknown>> | undefined,
|
||||||
@ -770,8 +781,11 @@ const buildDefaultPricingMethodDetailRows = (
|
|||||||
if (!isCostMajorById(row.id)) return false
|
if (!isCostMajorById(row.id)) return false
|
||||||
if (context.excludeInvestmentCostAndAreaRows && isDualScaleMajorById(row.id)) return false
|
if (context.excludeInvestmentCostAndAreaRows && isDualScaleMajorById(row.id)) return false
|
||||||
return true
|
return true
|
||||||
})
|
}))
|
||||||
const landScale = scaleRows.filter(row => isAreaMajorById(row.id))
|
: []
|
||||||
|
const landScale = capabilities.landScaleEnabled
|
||||||
|
? scaleRows.filter(row => isAreaMajorById(row.id))
|
||||||
|
: []
|
||||||
|
|
||||||
return {
|
return {
|
||||||
investScale,
|
investScale,
|
||||||
|
|||||||
@ -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,6 +253,9 @@ export const syncContractScaleToPricing = async (
|
|||||||
let updatedRowCount = 0
|
let updatedRowCount = 0
|
||||||
|
|
||||||
for (const serviceId of selectedIds) {
|
for (const serviceId of selectedIds) {
|
||||||
|
const capabilities = getScaleMethodCapabilities(serviceId)
|
||||||
|
|
||||||
|
if (capabilities.investScaleEnabled) {
|
||||||
const investChangedCount = await syncScaleMethodRows({
|
const investChangedCount = await syncScaleMethodRows({
|
||||||
contractId,
|
contractId,
|
||||||
serviceId,
|
serviceId,
|
||||||
@ -258,6 +270,9 @@ export const syncContractScaleToPricing = async (
|
|||||||
updatedMethodCount += 1
|
updatedMethodCount += 1
|
||||||
updatedRowCount += investChangedCount
|
updatedRowCount += investChangedCount
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (capabilities.landScaleEnabled) {
|
||||||
const landChangedCount = await syncScaleMethodRows({
|
const landChangedCount = await syncScaleMethodRows({
|
||||||
contractId,
|
contractId,
|
||||||
serviceId,
|
serviceId,
|
||||||
@ -273,6 +288,7 @@ export const syncContractScaleToPricing = async (
|
|||||||
updatedRowCount += landChangedCount
|
updatedRowCount += landChangedCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
updatedServiceCount: updatedServiceIdSet.size,
|
updatedServiceCount: updatedServiceIdSet.size,
|
||||||
|
|||||||
@ -945,7 +945,8 @@ export const useZxFwPricingStore = defineStore('zxFwPricing', () => {
|
|||||||
getHtFeeMethodState,
|
getHtFeeMethodState,
|
||||||
setHtFeeMethodState,
|
setHtFeeMethodState,
|
||||||
loadHtFeeMethodState,
|
loadHtFeeMethodState,
|
||||||
removeHtFeeMethodState
|
removeHtFeeMethodState,
|
||||||
|
syncHtExtraFeeByContractBase
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
persist: true
|
persist: true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user