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 @@