From 3d26b0b259e07355557ad2469ab1108ade3de70c Mon Sep 17 00:00:00 2001 From: wintsa <770775984@qq.com> Date: Wed, 11 Mar 2026 12:01:16 +0800 Subject: [PATCH] =?UTF-8?q?fix,=E5=8E=BB=E6=8E=89=E5=A4=A7=E9=83=A8?= =?UTF-8?q?=E5=88=86indexdb=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/HtFeeMethodGrid.vue | 8 +- src/components/common/XmFactorGrid.vue | 7 +- src/components/common/xmCommonAgGrid.vue | 11 +- src/components/views/Ht.vue | 23 +-- .../views/HtConsultCategoryFactor.vue | 5 +- src/components/views/HtMajorFactor.vue | 5 +- .../views/XmConsultCategoryFactor.vue | 5 +- src/components/views/XmMajorFactor.vue | 5 +- src/components/views/htInfo.vue | 4 +- src/components/views/info.vue | 7 +- .../InvestmentScalePricingPane.vue | 13 +- .../pricingView/LandScalePricingPane.vue | 13 +- src/components/views/xmCard.vue | 5 +- src/components/views/zxFw.vue | 7 +- src/layout/tab.vue | 140 +++++++++++++++--- src/lib/pricingMethodTotals.ts | 70 +++++---- src/lib/xmFactorDefaults.ts | 13 +- src/pinia/kv.ts | 90 +++++++++++ src/pinia/zxFwPricing.ts | 88 ++++++++++- 19 files changed, 416 insertions(+), 103 deletions(-) create mode 100644 src/pinia/kv.ts diff --git a/src/components/common/HtFeeMethodGrid.vue b/src/components/common/HtFeeMethodGrid.vue index 9e34b20..c90fea5 100644 --- a/src/components/common/HtFeeMethodGrid.vue +++ b/src/components/common/HtFeeMethodGrid.vue @@ -172,10 +172,10 @@ const hydrateRowsFromMethodStores = async (rows: FeeMethodRow[]): Promise() +const kvStore = useKvStore() const detailRows = ref([]) const gridApi = ref | null>(null) @@ -227,7 +228,7 @@ const saveToIndexedDB = async () => { const payload: GridState = { detailRows: JSON.parse(JSON.stringify(detailRows.value)) } - await localforage.setItem(props.storageKey, payload) + await kvStore.setItem(props.storageKey, payload) } catch (error) { console.error('saveToIndexedDB failed:', error) } @@ -235,7 +236,7 @@ const saveToIndexedDB = async () => { const loadGridState = async (storageKey: string): Promise => { if (!storageKey) return null - const data = await localforage.getItem(storageKey) + const data = await kvStore.getItem(storageKey) if (!data?.detailRows || !Array.isArray(data.detailRows)) return null return data } diff --git a/src/components/common/xmCommonAgGrid.vue b/src/components/common/xmCommonAgGrid.vue index 7cbbc05..999b6e9 100644 --- a/src/components/common/xmCommonAgGrid.vue +++ b/src/components/common/xmCommonAgGrid.vue @@ -4,11 +4,11 @@ import { AgGridVue } from 'ag-grid-vue3' import type { CellValueChangedEvent, ColDef, GridApi, GridReadyEvent } from 'ag-grid-community' import { AG_GRID_LOCALE_CN } from '@ag-grid-community/locale' import { myTheme, gridOptions } from '@/lib/diyAgGridOptions' -import localforage from 'localforage' import { decimalAggSum, roundTo, sumByNumber } from '@/lib/decimal' import { formatThousandsFlexible } from '@/lib/numberFormat' import { industryTypeList, getMajorDictEntries, isMajorIdInIndustryScope } from '@/sql' import { SwitchRoot, SwitchThumb } from 'reka-ui' +import { useKvStore } from '@/pinia/kv' @@ -42,6 +42,7 @@ interface XmBaseInfoState { const BASE_INFO_KEY = 'xm-base-info-v1' type MajorLite = { code: string; name: string; hasCost?: boolean; hasArea?: boolean } +const kvStore = useKvStore() const detailRows = ref([]) const detailDict = ref([]) @@ -157,8 +158,8 @@ const applyPinnedTotalAmount = ( const loadFromIndexedDB = async (api: GridApi) => { try { const [baseInfo, contractData] = await Promise.all([ - localforage.getItem(BASE_INFO_KEY), - localforage.getItem(props.dbKey) + kvStore.getItem(BASE_INFO_KEY), + kvStore.getItem(props.dbKey) ]) activeIndustryId.value = @@ -204,7 +205,7 @@ const loadFromIndexedDB = async (api: GridApi) => { if (props.xmInfoKey) { // 首次创建合同段时,默认继承项目规模信息(同一套专业字典,按 id 对齐) - const xmData = await localforage.getItem(props.xmInfoKey) + const xmData = await kvStore.getItem(props.xmInfoKey) roughCalcEnabled.value = Boolean(xmData?.roughCalcEnabled) applyPinnedTotalAmount(api, xmData?.totalAmount) @@ -405,7 +406,7 @@ const saveToIndexedDB = async () => { } payload.roughCalcEnabled = roughCalcEnabled.value payload.totalAmount = pinnedTopRowData.value[0].amount - await localforage.setItem(props.dbKey, payload) + await kvStore.setItem(props.dbKey, payload) } catch (error) { console.error('saveToIndexedDB failed:', error) } diff --git a/src/components/views/Ht.vue b/src/components/views/Ht.vue index 314af5b..d0b6fb5 100644 --- a/src/components/views/Ht.vue +++ b/src/components/views/Ht.vue @@ -1,13 +1,13 @@