feat(client): show actionable customs count on sidebar

This commit is contained in:
2026-10-09 18:14:19 +08:00
parent 639b1ae22c
commit c0b151bc15
10 changed files with 136 additions and 2 deletions
@@ -0,0 +1,40 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getMerchantCustomsPendingCount } from '../api/customs'
export const useCustomsPendingStore = defineStore('client-customs-pending', () => {
const count = ref<number | null>(null)
const loading = ref(false)
const error = ref('')
let scope = ''
let requestVersion = 0
function setScope(value: string) {
if (scope === value) return
scope = value
requestVersion++
count.value = null
error.value = ''
loading.value = false
}
async function refresh(force = false) {
if (!scope || (loading.value && !force)) return
const request = ++requestVersion
loading.value = true
try {
const result = await getMerchantCustomsPendingCount()
if (request !== requestVersion) return
count.value = result
error.value = ''
} catch {
if (request !== requestVersion) return
count.value = null
error.value = '报关待办数量加载失败,请进入报关资料刷新'
} finally {
if (request === requestVersion) loading.value = false
}
}
return { count, loading, error, setScope, refresh }
})