feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

View File

@@ -0,0 +1,79 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { PageResult } from '@/types/api'
import type { Contract, ContractQuery } from '@/types/business/contract'
import {
getContractDetail,
getContractList,
getSignQr,
refreshSignQr,
} from '@/api/contract'
function createDefaultQuery(): ContractQuery {
return {
keyword: '',
page: 1,
pageSize: 8,
}
}
/** 合同中心数据(列表 / 筛选 / 分页 / 详情 / 签署二维码) */
export const useContractStore = defineStore('contract', () => {
const query = ref<ContractQuery>(createDefaultQuery())
const list = ref<Contract[]>([])
const total = ref(0)
const current = ref<Contract | null>(null)
const signExpires = ref(272)
async function fetchList(): Promise<void> {
const result: PageResult<Contract> = await getContractList(query.value)
list.value = result.list
total.value = result.total
}
async function fetchDetail(id: string): Promise<void> {
current.value = await getContractDetail(id)
}
function setQuery(next: ContractQuery): void {
query.value = next
}
/** 确定筛选(重置页码后取数) */
async function search(): Promise<void> {
query.value = { ...query.value, page: 1 }
await fetchList()
}
/** 重置全部条件 */
async function resetQuery(): Promise<void> {
query.value = createDefaultQuery()
await fetchList()
}
async function changePage(page: number): Promise<void> {
query.value = { ...query.value, page }
await fetchList()
}
/** 获取/刷新签署二维码(refresh=true 时走刷新接口) */
async function fetchSignQr(id: string, refresh = false): Promise<void> {
const result = refresh ? await refreshSignQr(id) : await getSignQr(id)
signExpires.value = result.expiresInSeconds
}
return {
query,
list,
total,
current,
signExpires,
fetchList,
fetchDetail,
setQuery,
search,
resetQuery,
changePage,
fetchSignQr,
}
})