diff --git a/src/components/common/HtFeeGrid.vue b/src/components/common/HtFeeGrid.vue index 7b0783c..26679d7 100644 --- a/src/components/common/HtFeeGrid.vue +++ b/src/components/common/HtFeeGrid.vue @@ -167,9 +167,11 @@ const syncComputedValuesToRows = () => { let hasValidRow = false for (const row of detailRows.value) { if (isSubtotalRow(row)) continue + const hasFeeItem = typeof row.feeItem === 'string' && row.feeItem.trim() !== '' + const hasUnit = typeof row.unit === 'string' && row.unit.trim() !== '' const quantity = typeof row.quantity === 'number' && Number.isFinite(row.quantity) ? row.quantity : null const unitPrice = typeof row.unitPrice === 'number' && Number.isFinite(row.unitPrice) ? row.unitPrice : null - if (quantity == null || unitPrice == null) { + if (!hasFeeItem || !hasUnit || quantity == null || unitPrice == null) { row.budgetFee = null continue } diff --git a/src/components/common/HtFeeMethodGrid.vue b/src/components/common/HtFeeMethodGrid.vue index 3b8549b..48cfbd5 100644 --- a/src/components/common/HtFeeMethodGrid.vue +++ b/src/components/common/HtFeeMethodGrid.vue @@ -129,7 +129,9 @@ const loadContractServiceFeeBase = async (): Promise => { } const sumHourlyMethodFee = (state: MethodHourlyState | null): number | null => { - const rows = Array.isArray(state?.detailRows) ? state.detailRows : [] + + + const rows=state?.detailRows?state?.detailRows?.filter(e=>e.serviceBudget!== null):[] if (rows.length === 0) return null let total = 0 @@ -154,7 +156,7 @@ const sumHourlyMethodFee = (state: MethodHourlyState | null): number | null => { } const sumQuantityMethodFee = (state: MethodQuantityState | null): number | null => { - const rows = Array.isArray(state?.detailRows) ? state.detailRows : [] + const rows=state?.detailRows?state?.detailRows?.filter(e=>e.budgetFee!== null):[] if (rows.length === 0) return null let total = 0 @@ -196,6 +198,7 @@ const hydrateRowsFromMethodStores = async (rows: FeeMethodRow[]): Promise { - 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 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) diff --git a/src/pinia/Plugin/indexdb.ts b/src/pinia/Plugin/indexdb.ts index 5b87bd3..6cfa828 100644 --- a/src/pinia/Plugin/indexdb.ts +++ b/src/pinia/Plugin/indexdb.ts @@ -50,6 +50,19 @@ const resolvePersistOptions = (persist: PersistOption | undefined) => { return persist } +const trimStringValuesDeep = (value: unknown): unknown => { + if (typeof value === 'string') return value.trim() + if (Array.isArray(value)) return value.map(item => trimStringValuesDeep(item)) + if (value && typeof value === 'object') { + const normalized: Record = {} + for (const [key, child] of Object.entries(value as Record)) { + normalized[key] = trimStringValuesDeep(child) + } + return normalized + } + return value +} + export default (config?: PiniaStorageConfig) => { const finalConfig = { ...baseConfig, ...(config || {}) } const { mode = 'single', debounce = 300, ...forageConfig } = finalConfig @@ -67,7 +80,10 @@ export default (config?: PiniaStorageConfig) => { let timer: ReturnType | null = null let hydrating = false let userMutatedBeforeHydrate = false - const writeState = (state: unknown) => lf.setItem(key, JSON.parse(JSON.stringify(state))) + const writeState = (state: unknown) => { + const clonedState = JSON.parse(JSON.stringify(state)) + return lf.setItem(key, trimStringValuesDeep(clonedState)) + } const storeExt = context.store as typeof context.store & PersistStoreExt storeExt.$persistNow = async () => { diff --git a/src/pinia/tab.ts b/src/pinia/tab.ts index acd4151..71e350f 100644 --- a/src/pinia/tab.ts +++ b/src/pinia/tab.ts @@ -65,7 +65,6 @@ export const useTabStore = defineStore( const closeAllTabs = () => { tabs.value = createDefaultTabs() - console.log(tabs.value) activeTabId.value = HOME_TAB_ID } diff --git a/src/sql.ts b/src/sql.ts index 9bb3267..339e59d 100644 --- a/src/sql.ts +++ b/src/sql.ts @@ -728,7 +728,6 @@ async function generateTemplate(data) { data.contracts[4].reserve = null; // data.contracts[5].addtional = null; // data.contracts[5].reserve = null; - console.log(data) try { // 获取模板 let templateExcel = 'template20260226001test010';