1
This commit is contained in:
1 parent
fd1b782803
commit
2a224c74ff
16 files changed
+526
-157
No files matched your search
@@ -6,6 +6,9 @@ export { toFiniteNumber, toFiniteNumberOrZero }
|
||||
interface ScaleMethodRowLike {
|
||||
id: string
|
||||
majorDictId?: unknown
|
||||
hasCost?: unknown
|
||||
hasArea?: unknown
|
||||
isGroupRow?: unknown
|
||||
amount: number | null
|
||||
landArea: number | null
|
||||
benchmarkBudgetBasicChecked?: unknown
|
||||
@@ -33,12 +36,16 @@ interface WorkContentRowLike {
|
||||
|
||||
interface FactorRowLike {
|
||||
id: string
|
||||
standardFactor?: unknown
|
||||
budgetValue?: unknown
|
||||
remark?: unknown
|
||||
}
|
||||
|
||||
interface ScaleRowLike {
|
||||
id: string
|
||||
hasCost?: unknown
|
||||
hasArea?: unknown
|
||||
isGroupRow?: unknown
|
||||
amount: number | null
|
||||
landArea: number | null
|
||||
}
|
||||
@@ -89,7 +96,6 @@ interface QuantityMethodRowLike {
|
||||
}
|
||||
|
||||
interface ExportScaleRowLike {
|
||||
majorid: number
|
||||
major: number
|
||||
cost: number | null
|
||||
area: number | null
|
||||
@@ -249,6 +255,7 @@ const dedupeScaleMethodRows = (rows: ScaleMethodRowLike[] | undefined): ScaleMet
|
||||
if (!Array.isArray(rows) || rows.length === 0) return []
|
||||
const deduped = new Map<string, ScaleMethodRowLike>()
|
||||
for (const row of rows) {
|
||||
if (row?.isGroupRow === true) continue
|
||||
const major = toScaleMajorId(row)
|
||||
if (major == null) continue
|
||||
const proNum = toScaleProNum(row)
|
||||
@@ -258,6 +265,20 @@ const dedupeScaleMethodRows = (rows: ScaleMethodRowLike[] | undefined): ScaleMet
|
||||
return Array.from(deduped.values())
|
||||
}
|
||||
|
||||
const isScaleLeafRow = (row: { isGroupRow?: unknown; hasCost?: unknown; hasArea?: unknown } | null | undefined) => {
|
||||
if (!row || row.isGroupRow === true) return false
|
||||
if (row.hasCost === true || row.hasArea === true) return true
|
||||
return row.hasCost == null && row.hasArea == null
|
||||
}
|
||||
|
||||
const isExportableScaleMethodRow = (
|
||||
row: ScaleMethodRowLike | null | undefined,
|
||||
mode: 'cost' | 'area'
|
||||
) => {
|
||||
if (!isScaleLeafRow(row)) return false
|
||||
return mode === 'cost' ? row?.hasCost === true : row?.hasArea === true
|
||||
}
|
||||
|
||||
export const normalizeTaskText = (value: unknown): string => String(value || '').trim()
|
||||
|
||||
export const resolveTaskRowServiceId = (row: WorkContentRowLike): number | null =>
|
||||
@@ -361,11 +382,11 @@ export const buildProjectServiceCoes = (rows: FactorRowLike[] | undefined) => {
|
||||
return rows
|
||||
.map(row => {
|
||||
const serviceid = toSafeInteger(row.id)
|
||||
if (serviceid == null || row.budgetValue == null) return null
|
||||
const coe = toFiniteNumber(row.budgetValue)
|
||||
const coe = toFiniteNumber(row.budgetValue) ?? toFiniteNumber(row.standardFactor)
|
||||
if (serviceid == null || coe == null) return null
|
||||
return {
|
||||
serviceid,
|
||||
coe: coe ?? 0,
|
||||
coe,
|
||||
remark: typeof row.remark === 'string' ? row.remark : ''
|
||||
}
|
||||
})
|
||||
@@ -377,11 +398,11 @@ export const buildProjectMajorCoes = (rows: FactorRowLike[] | undefined) => {
|
||||
return rows
|
||||
.map(row => {
|
||||
const majorid = toSafeInteger(row.id)
|
||||
if (majorid == null || row.budgetValue == null) return null
|
||||
const coe = toFiniteNumber(row.budgetValue)
|
||||
const coe = toFiniteNumber(row.budgetValue) ?? toFiniteNumber(row.standardFactor)
|
||||
if (majorid == null || coe == null) return null
|
||||
return {
|
||||
majorid,
|
||||
coe: coe ?? 0,
|
||||
coe,
|
||||
remark: typeof row.remark === 'string' ? row.remark : ''
|
||||
}
|
||||
})
|
||||
@@ -391,11 +412,11 @@ export const buildProjectMajorCoes = (rows: FactorRowLike[] | undefined) => {
|
||||
export const toExportScaleRows = (rows: ScaleRowLike[] | undefined) => {
|
||||
if (!Array.isArray(rows)) return []
|
||||
return rows
|
||||
.filter(row => isScaleLeafRow(row))
|
||||
.map(row => {
|
||||
const majorid = toSafeInteger(row.id)
|
||||
if (majorid == null || (row.amount == null && row.landArea == null)) return null
|
||||
return {
|
||||
majorid,
|
||||
major: majorid,
|
||||
cost: row.amount,
|
||||
area: row.landArea
|
||||
@@ -411,6 +432,7 @@ export const buildMethod1 = (rows: ScaleMethodRowLike[] | undefined) => {
|
||||
const proSet = new Set<number>()
|
||||
const det = normalizedRows
|
||||
.map(row => {
|
||||
if (!isExportableScaleMethodRow(row, 'cost')) return null
|
||||
const major = toScaleMajorId(row)
|
||||
if (major == null) return null
|
||||
const proNum = toScaleProNum(row)
|
||||
@@ -461,6 +483,7 @@ export const buildMethod2 = (rows: ScaleMethodRowLike[] | undefined) => {
|
||||
const proSet = new Set<number>()
|
||||
const det = normalizedRows
|
||||
.map(row => {
|
||||
if (!isExportableScaleMethodRow(row, 'area')) return null
|
||||
const major = toScaleMajorId(row)
|
||||
if (major == null) return null
|
||||
const proNum = toScaleProNum(row)
|
||||
|
||||
Reference in new issue
Block a user