fix
This commit is contained in:
1 parent
cd107604a9
commit
f4c768df29
6 files changed
+37
-25
No files matched your search
+12
-19
@@ -309,7 +309,7 @@ interface ExportMethod5 {
|
||||
|
||||
interface ExportAdditionalDetail {
|
||||
id: number
|
||||
ref?: unknown
|
||||
code?: unknown
|
||||
name: string
|
||||
fee: number
|
||||
m0?: ExportMethod0
|
||||
@@ -318,14 +318,14 @@ interface ExportAdditionalDetail {
|
||||
}
|
||||
|
||||
interface ExportAdditional {
|
||||
ref?: unknown
|
||||
code?: unknown
|
||||
name: string
|
||||
fee: number
|
||||
det: ExportAdditionalDetail[]
|
||||
}
|
||||
|
||||
interface ExportReserve {
|
||||
ref?: unknown
|
||||
code?: unknown
|
||||
name: string
|
||||
fee: number
|
||||
m0?: ExportMethod0
|
||||
@@ -1223,11 +1223,10 @@ const buildMethod0 = (payload: RateMethodRowLike | null | undefined): ExportMeth
|
||||
}
|
||||
|
||||
const buildMethod5 = (rows: QuantityMethodRowLike[] | undefined): ExportMethod5 | null => {
|
||||
console.log(rows)
|
||||
if (!Array.isArray(rows) || rows.length === 0) return null
|
||||
const subtotalRow = rows.find(row => String(row?.id || '') === 'fee-subtotal-fixed')
|
||||
const subtotalFee = toFiniteNumber(subtotalRow?.budgetFee)
|
||||
if (subtotalFee == null || subtotalRow?.budgetFee == null) return null
|
||||
if (subtotalFee == null ) return null
|
||||
const det = rows
|
||||
.filter(row => String(row?.id || '') !== 'fee-subtotal-fixed')
|
||||
.map(row => {
|
||||
@@ -1237,20 +1236,14 @@ const buildMethod5 = (rows: QuantityMethodRowLike[] | undefined): ExportMethod5
|
||||
const name = typeof row.feeItem === 'string' ? row.feeItem : ''
|
||||
const unit = typeof row.unit === 'string' ? row.unit : ''
|
||||
const remark = typeof row.remark === 'string' ? row.remark : ''
|
||||
const hasValue =
|
||||
quantity != null ||
|
||||
unitPrice != null ||
|
||||
fee != null ||
|
||||
isNonEmptyString(name) ||
|
||||
isNonEmptyString(unit) ||
|
||||
isNonEmptyString(remark)
|
||||
if (!hasValue) return null
|
||||
|
||||
if (row.budgetFee==null) return null
|
||||
return {
|
||||
name,
|
||||
unit,
|
||||
amount: quantity ?? 0,
|
||||
price: unitPrice ?? 0,
|
||||
fee: fee ?? 0,
|
||||
amount: quantity ,
|
||||
price: unitPrice ,
|
||||
fee: fee ,
|
||||
remark
|
||||
}
|
||||
})
|
||||
@@ -1317,7 +1310,7 @@ const buildAdditionalExport = async (contractId: string): Promise<ExportAddition
|
||||
if (!methodPayload) return null
|
||||
const item: ExportAdditionalDetail = {
|
||||
id: index,
|
||||
ref: { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: 'C' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: 'F' }] },
|
||||
code: { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: 'C' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: 'F' }] },
|
||||
|
||||
name: row.name,
|
||||
fee: methodPayload.fee
|
||||
@@ -1332,7 +1325,7 @@ const buildAdditionalExport = async (contractId: string): Promise<ExportAddition
|
||||
|
||||
if (det.length === 0) return null
|
||||
return {
|
||||
ref: { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: 'C' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: 'C' }] },
|
||||
code: { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: 'C' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: 'C' }] },
|
||||
|
||||
name: '附加工作',
|
||||
fee: sumNumbers(det.map(item => item.fee)),
|
||||
@@ -1581,8 +1574,8 @@ const exportReport = async () => {
|
||||
try {
|
||||
const now = new Date()
|
||||
const payload = await buildExportReportPayload()
|
||||
console.log(payload)
|
||||
const fileName = `${sanitizeFileNamePart(payload.name)}-报表-${formatExportTimestamp(now)}`
|
||||
console.log(payload)
|
||||
await exportFile(fileName, payload)
|
||||
} catch (error) {
|
||||
console.error('export report failed:', error)
|
||||
|
||||
Reference in new issue
Block a user