feat 完善注释

This commit is contained in:
Ironsp
2026-10-01 17:24:57 +08:00
parent 2b59f68fd7
commit 9f4a5c7cda
183 changed files with 485 additions and 3615 deletions

View File

@@ -43,42 +43,31 @@ function createDefaultInvoiceQuery(): InvoiceQuery {
return { keyword: '', status: 'all', page: 1, pageSize: 6 }
}
/** 财务中心数据(统计/账单/支付/发票/抬头) */
export const useFinanceStore = defineStore('finance', () => {
// —— 统计
const stats = ref<FinanceStats | null>(null)
// —— 账单列表
const list = ref<Bill[]>([])
const total = ref(0)
const query = ref<BillQuery>(createDefaultBillQuery())
const currentBill = ref<Bill | null>(null)
// —— 支付
const payment = ref<Payment | null>(null)
const result = ref<PaymentResult | null>(null)
// —— 收银台(确认支付页)
/** 收银台待支付账单(由路由 `?ids=` 拉取) */
const checkoutBills = ref<Bill[]>([])
const checkoutLoading = ref(false)
/** 最近一次下单响应(微信 codeUrl / 支付宝跳转地址) */
const payOrder = ref<PayOrderResponse | null>(null)
// —— 发票
const invoices = ref<Invoice[]>([])
const invoiceTotal = ref(0)
const invoiceQuery = ref<InvoiceQuery>(createDefaultInvoiceQuery())
// —— 发票抬头
const titles = ref<InvoiceTitle[]>([])
// —— 统计
async function fetchStats(period?: string): Promise<void> {
stats.value = await getFinanceStats(period)
}
// —— 账单
async function fetchList(): Promise<void> {
const pageData: PageResult<Bill> = await getBillList(query.value)
list.value = pageData.list
@@ -89,13 +78,11 @@ export const useFinanceStore = defineStore('finance', () => {
query.value = next
}
/** 确定筛选(重置页码后取数) */
async function search(): Promise<void> {
query.value = { ...query.value, page: 1 }
await fetchList()
}
/** 重置全部条件 */
async function resetQuery(): Promise<void> {
query.value = createDefaultBillQuery()
await fetchList()
@@ -110,12 +97,10 @@ export const useFinanceStore = defineStore('finance', () => {
currentBill.value = await getBillDetail(id)
}
// —— 支付
async function createPayment(billId: string, method: PayMethod): Promise<void> {
payment.value = await createPaymentApi(billId, method)
}
/** 切换支付方式(刷新二维码) */
async function switchPaymentMethod(billId: string, method: PayMethod): Promise<void> {
payment.value = await switchPaymentMethodApi(billId, method)
}
@@ -126,15 +111,6 @@ export const useFinanceStore = defineStore('finance', () => {
: await getPayResult(billId)
}
// —— 收银台(确认支付)
/**
* 拉取收银台订单明细。
*
* <p>入参是**需求 id**(项目详情路由 `:id`):数据走项目详情那个现成接口
* `GET /web/requirementPool/get/finance/{需求id}` 的 `billPlans`,不另开端点。
* `ids` 为可选的期次 id(`vm_bill_plan.id`),用于精确指定付哪一期;
* 不传则取该需求下状态为「待支付」的期。</p>
*/
async function loadCheckout(requirementId: string, ids: string[] = []): Promise<void> {
checkoutLoading.value = true
try {
@@ -144,27 +120,18 @@ export const useFinanceStore = defineStore('finance', () => {
}
}
/**
* 微信 Native 下单(拿到 codeUrl 后由页面渲染二维码)。
*
* @param billIds 本笔支付覆盖的账单 id。后端据此落 `vm_finance_payment` 并把它写进
* `request_payload`,支付成功回调再为每张账单落 `vm_finance_payment_bill`。
*/
async function payByWechatNative(orderNo: string, amount: number, billIds: string[]): Promise<void> {
payOrder.value = await createWechatNativeOrderApi(orderNo, amount, billIds)
}
/** 支付宝电脑网站支付下单(拿到跳转地址后由页面跳转) */
async function payByAlipayPage(orderNo: string, amount: number, billIds: string[]): Promise<void> {
payOrder.value = await createAlipayPageOrderApi(orderNo, amount, billIds)
}
/** 清空下单响应(关闭二维码弹窗时调用) */
function clearPayOrder(): void {
payOrder.value = null
}
// —— 发票
async function fetchInvoices(): Promise<void> {
const pageData: PageResult<Invoice> = await getInvoiceList(invoiceQuery.value)
invoices.value = pageData.list
@@ -175,7 +142,6 @@ export const useFinanceStore = defineStore('finance', () => {
invoiceQuery.value = next
}
/** 发票确定筛选(重置页码后取数) */
async function searchInvoices(): Promise<void> {
invoiceQuery.value = { ...invoiceQuery.value, page: 1 }
await fetchInvoices()
@@ -186,14 +152,12 @@ export const useFinanceStore = defineStore('finance', () => {
await fetchInvoices()
}
/** 申请开票(状态 → 开票中) */
async function applyInvoice(id: string): Promise<void> {
const updated = await applyInvoiceApi(id)
const index = invoices.value.findIndex((item) => item.id === id)
if (index >= 0) invoices.value[index] = updated
}
// —— 发票抬头
async function fetchTitles(): Promise<void> {
titles.value = await getInvoiceTitles()
}
@@ -217,7 +181,6 @@ export const useFinanceStore = defineStore('finance', () => {
titles.value = await setDefaultTitleApi(id)
}
// —— 报表导出
async function exportReport(): Promise<void> {
await exportReportApi()
}