根据已更新的原型调整系统

This commit is contained in:
Weiming committed 2026-12-03 16:45:55 +08:00
1 parent bc29abfc89
commit eadd7a685c
43 files changed
+2743 -815

No files matched your search

+2 -3
View File
@@ -1,12 +1,11 @@
# dependencies # dependencies
node_modules/ node_modules/
# generated build output (dist is intentionally versioned for deployment) # generated build output
build/ build/
.next/ .next/
out/ out/
!dist/ dist/
!dist/**
# local env files # local env files
.env .env
+11 -1
View File
@@ -1,7 +1,8 @@
import request from './request' import request from './request'
export type PayeeAccountStatus = 'ACTIVE' | 'INACTIVE' export type PayeeAccountStatus = 'ACTIVE' | 'INACTIVE'
export type PayeeSubjectType = 'EMPLOYEE' | 'SUPPLIER' export type PayeeSubjectType = 'EMPLOYEE' | 'SUPPLIER' | 'GOVERNMENT'
export type PayeeRelationType = 'INTERNAL' | 'EXTERNAL'
export interface PayeeAccount { export interface PayeeAccount {
id: number id: number
@@ -43,8 +44,13 @@ export interface PayeeAccountPayload {
export interface PayeeSubject { export interface PayeeSubject {
id: number id: number
payeeCode?: string | null
payeeType: PayeeSubjectType payeeType: PayeeSubjectType
displayName: string displayName: string
relationType: PayeeRelationType
countryRegion: string
identityType?: string | null
identityValueMaintained?: boolean
employeeOpenId?: string | null employeeOpenId?: string | null
identityNumber?: string | null identityNumber?: string | null
supplierCreditCode?: string | null supplierCreditCode?: string | null
@@ -56,6 +62,10 @@ export interface PayeeSubject {
export interface PayeeSubjectPayload { export interface PayeeSubjectPayload {
payeeType: PayeeSubjectType payeeType: PayeeSubjectType
relationType?: PayeeRelationType
countryRegion?: string
identityType?: string
identityValue?: string
employeeOpenId?: string | null employeeOpenId?: string | null
identityNumber?: string | null identityNumber?: string | null
displayName: string displayName: string
+116 -45
View File
@@ -8,19 +8,42 @@ export interface PageResponse<T> {
pageSize: number pageSize: number
} }
export interface ReimApplicationSummary { export interface PaymentApplicationFacts {
paymentScenarioId?: number
requestedAmount?: number
paymentScenario?: string
expenseItemCategory?: string
payerEntityName?: string
costCenterName?: string
currencyCode?: string
paymentReason?: string
plannedPaymentDate?: string
linkedTravelApplicationId?: number
approvedAmount?: number
actualPaymentAmount?: number
}
export interface ReimApplicationSummary extends PaymentApplicationFacts {
id: number | string id: number | string
applicationNo: string applicationNo: string
title: string title: string
applicantName: string applicantName: string
departmentName: string departmentName: string
expenseTypeName: string paymentScenario: string
category: string expenseItemCategory: string
totalAmount: number requestedAmount: number
/** @deprecated 仅用于接收旧接口数据。 */
expenseTypeName?: string
/** @deprecated 仅用于接收旧接口数据。 */
category?: string
/** @deprecated 仅用于接收旧接口数据。 */
totalAmount?: number
applicationStatus: string applicationStatus: string
approvalStatus: string approvalStatus: string
currentApprovalNode: string currentApprovalNode: string
receiptStatus: string financeCheckStatus: string
/** @deprecated 仅用于接收旧接口数据。 */
receiptStatus?: string
paymentStatus: string paymentStatus: string
budgetStatus: string budgetStatus: string
submitTime: string submitTime: string
@@ -30,26 +53,38 @@ export interface ReimApplicationSummary {
remainingAmount?: number remainingAmount?: number
} }
export interface ReimApplicationDetail { export interface ReimApplicationDetail extends PaymentApplicationFacts {
id: number | string id: number | string
applicationNo: string applicationNo: string
title: string title: string
applicantName: string applicantName: string
applicantEmployeeNo: string applicantEmployeeNo: string
departmentName: string departmentName: string
expenseTypeId: number paymentScenarioId: number
expenseTypeName: string paymentScenario: string
category: string expenseItemCategory: string
totalAmount: number requestedAmount: number
/** @deprecated 仅用于接收旧接口数据。 */
expenseTypeId?: number
/** @deprecated 仅用于接收旧接口数据。 */
expenseTypeName?: string
/** @deprecated 仅用于接收旧接口数据。 */
category?: string
/** @deprecated 仅用于接收旧接口数据。 */
totalAmount?: number
description: string description: string
applicationStatus: string applicationStatus: string
approvalStatus: string approvalStatus: string
currentApprovalNode: string currentApprovalNode: string
receiptStatus: string financeCheckStatus: string
/** @deprecated 仅用于接收旧接口数据。 */
receiptStatus?: string
paymentStatus: string paymentStatus: string
budgetStatus: string budgetStatus: string
sourceDocNo: string sourceDocNo: string
sourceStatus: string syncStatus: string
/** @deprecated 仅用于接收旧接口数据。 */
sourceStatus?: string
payeeName: string payeeName: string
payeeBankId: number payeeBankId: number
bankName: string bankName: string
@@ -106,10 +141,11 @@ export interface ReimbursementFormDefinition {
export interface ExpenseTypeMetadata { export interface ExpenseTypeMetadata {
id: number id: number
code: string scenarioCode: string
name: string scenarioName: string
category: string scenarioGroup: string
description: string status?: string
description?: string
} }
export interface ReimbursementFormSnapshot { export interface ReimbursementFormSnapshot {
@@ -123,7 +159,9 @@ export interface ExpenseItem {
id?: number | string id?: number | string
seqNo?: number seqNo?: number
expenseDate: string expenseDate: string
category: string expenseItemName: string
/** @deprecated 仅用于接收旧接口数据。 */
category?: string
description?: string description?: string
amount: number amount: number
attachmentIds: Array<number | string> attachmentIds: Array<number | string>
@@ -138,15 +176,23 @@ export interface ReimbursementFormAttachment {
fileSize: number fileSize: number
} }
export interface CreateApplicationRequest { export interface CreateApplicationRequest extends PaymentApplicationFacts {
title: string title: string
expenseTypeId: number paymentScenarioId: number
category: string expenseItemCategory: string
totalAmount: number requestedAmount: number
description: string description: string
payeeName: string payeeName: string
payeeBankId: number payeeBankId: number
items: ExpenseItem[] expenseItems: ExpenseItem[]
/** @deprecated 仅用于旧客户端过渡。 */
expenseTypeId?: number
/** @deprecated 仅用于旧客户端过渡。 */
category?: string
/** @deprecated 仅用于旧客户端过渡。 */
totalAmount?: number
/** @deprecated 仅用于旧客户端过渡。 */
items?: ExpenseItem[]
formFingerprint?: string formFingerprint?: string
formValues?: Record<string, unknown> formValues?: Record<string, unknown>
} }
@@ -210,7 +256,16 @@ export interface ApprovalRecord {
actionTime: string actionTime: string
} }
export interface PaymentRecord { export interface ExternalPaymentFacts {
actualPaymentAmount?: number
actualPaymentDate?: string
actualPaymentMethod?: string
bankTransactionNo?: string
paymentReceipt?: string
source?: string
}
export interface PaymentRecord extends ExternalPaymentFacts {
id: number | string id: number | string
paymentNo: string paymentNo: string
applicationId?: number | string applicationId?: number | string
@@ -218,7 +273,11 @@ export interface PaymentRecord {
totalAmount?: number totalAmount?: number
paidAmount?: number paidAmount?: number
remainingAmount?: number remainingAmount?: number
paymentMethod: string actualPaymentAmount: number
approvedAmount?: number
actualPaymentMethod: string
resultRecordedAt?: string
paymentMethod?: string
referenceNo?: string referenceNo?: string
paymentStatus: string paymentStatus: string
operatorName?: string operatorName?: string
@@ -234,8 +293,9 @@ export interface PaymentReviewRequest {
rejectionCode?: string rejectionCode?: string
} }
export interface PaymentResult { export interface PaymentResult extends ExternalPaymentFacts {
paymentNo?: string paymentNo?: string
amount?: number
paymentAmount?: number paymentAmount?: number
paymentStatus: string paymentStatus: string
message?: string message?: string
@@ -247,61 +307,69 @@ export interface TransferApprovalRequest {
comment?: string comment?: string
} }
export interface ReimbursementWorkbenchResponse { export interface PaymentApplicationWorkbenchResponse {
paymentApplications?: ReimApplicationDetail[]
reimbursements?: ReimApplicationDetail[] reimbursements?: ReimApplicationDetail[]
content?: ReimApplicationDetail[] content?: ReimApplicationDetail[]
payments?: PaymentRecord[] payments?: PaymentRecord[]
notifications?: number notifications?: number
user?: unknown user?: unknown
financeCheckEnabled?: boolean
independentPaymentReviewEnabled?: boolean
} }
/** @deprecated 仅供旧调用方过渡,请使用 PaymentApplicationWorkbenchResponse。 */
export type ReimbursementWorkbenchResponse = PaymentApplicationWorkbenchResponse
const paymentApplicationBase = '/v1/payment-applications'
export const reimbursementApi = { export const reimbursementApi = {
getFormDefinition: (): Promise<ReimbursementFormDefinition> => getFormDefinition: (): Promise<ReimbursementFormDefinition> =>
request.get('/v1/reimbursements/form-definition', { suppressErrorNotification: true }), request.get(`${paymentApplicationBase}/form-definition`, { suppressErrorNotification: true }),
getExpenseTypes: (): Promise<ExpenseTypeMetadata[]> => getExpenseTypes: (): Promise<ExpenseTypeMetadata[]> =>
request.get('/metadata/expense-types', { suppressErrorNotification: true }), request.get('/metadata/payment-scenarios', { suppressErrorNotification: true }),
uploadFormAttachment: (file: File, formFingerprint: string, controlId: string): Promise<ReimbursementFormAttachment> => { uploadFormAttachment: (file: File, formFingerprint: string, controlId: string): Promise<ReimbursementFormAttachment> => {
const data = new FormData() const data = new FormData()
data.append('file', file) data.append('file', file)
data.append('formFingerprint', formFingerprint) data.append('formFingerprint', formFingerprint)
data.append('controlId', controlId) data.append('controlId', controlId)
return request.post('/v1/reimbursements/form-attachments', data, { headers: { 'Content-Type': 'multipart/form-data' }, suppressErrorNotification: true }) return request.post(`${paymentApplicationBase}/form-attachments`, data, { headers: { 'Content-Type': 'multipart/form-data' }, suppressErrorNotification: true })
}, },
deleteFormAttachment: (id: number | string): Promise<void> => deleteFormAttachment: (id: number | string): Promise<void> =>
request.delete(`/v1/reimbursements/form-attachments/${encodeURIComponent(String(id))}`, { suppressErrorNotification: true }), request.delete(`${paymentApplicationBase}/form-attachments/${encodeURIComponent(String(id))}`, { suppressErrorNotification: true }),
getWorkbench: (): Promise<ReimbursementWorkbenchResponse> => getWorkbench: (): Promise<PaymentApplicationWorkbenchResponse> =>
request.get('/v1/reimbursements/workbench'), request.get(`${paymentApplicationBase}/workbench`),
getMyApplications: (params?: { status?: string; page?: number; size?: number }): Promise<PageResponse<ReimApplicationSummary>> => getMyApplications: (params?: { status?: string; page?: number; size?: number }): Promise<PageResponse<ReimApplicationSummary>> =>
request.get('/v1/reimbursements/my', { params }), request.get(`${paymentApplicationBase}/my`, { params }),
getDetail: (id: number | string): Promise<ReimApplicationDetail> => getDetail: (id: number | string): Promise<ReimApplicationDetail> =>
request.get(`/v1/reimbursements/${id}`), request.get(`${paymentApplicationBase}/${id}`),
getByApplicationNo: (no: string): Promise<ReimApplicationDetail> => getByApplicationNo: (no: string): Promise<ReimApplicationDetail> =>
request.get(`/v1/reimbursements/no/${no}`), request.get(`${paymentApplicationBase}/no/${no}`),
create: (data: Partial<CreateApplicationRequest>): Promise<ReimApplicationDetail> => create: (data: Partial<CreateApplicationRequest>): Promise<ReimApplicationDetail> =>
request.post('/v1/reimbursements', data), request.post(paymentApplicationBase, data),
update: (id: number | string, data: Partial<CreateApplicationRequest>): Promise<ReimApplicationDetail> => update: (id: number | string, data: Partial<CreateApplicationRequest>): Promise<ReimApplicationDetail> =>
request.put(`/v1/reimbursements/${id}`, data), request.put(`${paymentApplicationBase}/${id}`, data),
getRoutePreview: (id: number | string): Promise<ApprovalRoutePreview> => getRoutePreview: (id: number | string): Promise<ApprovalRoutePreview> =>
request.get(`/v1/reimbursements/${id}/route-preview`), request.get(`${paymentApplicationBase}/${id}/route-preview`),
submit: (id: number | string, data: SubmitReimbursementRequest): Promise<ReimApplicationDetail> => submit: (id: number | string, data: SubmitReimbursementRequest): Promise<ReimApplicationDetail> =>
request.post(`/v1/reimbursements/${id}/submit`, data), request.post(`${paymentApplicationBase}/${id}/submit`, data),
receive: (id: number | string): Promise<ReimApplicationDetail> => receive: (id: number | string): Promise<ReimApplicationDetail> =>
request.post(`/v1/reimbursements/${id}/receive`), request.post(`${paymentApplicationBase}/${id}/receive`),
delete: (id: number | string): Promise<void> => delete: (id: number | string): Promise<void> =>
request.delete(`/v1/reimbursements/${id}`), request.delete(`${paymentApplicationBase}/${id}`),
} }
export const accountsPayableApi = { export const accountsPayableApi = {
@@ -331,11 +399,11 @@ export const cashierApi = {
getTaskDetail: (id: number | string): Promise<any> => getTaskDetail: (id: number | string): Promise<any> =>
request.get(`/v1/cashier/tasks/${id}`), request.get(`/v1/cashier/tasks/${id}`),
executePayment: (applicationId: number | string, paymentAmount: number, remark?: string, idempotencyKey?: string): Promise<PaymentResult> => executePayment: (applicationId: number | string, actualPaymentAmount: number, remark?: string, idempotencyKey?: string, facts?: ExternalPaymentFacts): Promise<PaymentResult> =>
request.post('/v1/cashier/pay', { applicationId, paymentAmount, remark }, idempotencyKey ? { headers: { 'Idempotency-Key': idempotencyKey } } : undefined), request.post('/v1/cashier/pay', { applicationId, actualPaymentAmount, remark, ...facts }, idempotencyKey ? { headers: { 'Idempotency-Key': idempotencyKey } } : undefined),
partialPayment: (applicationId: number | string, paymentAmount: number, remark?: string, idempotencyKey?: string): Promise<PaymentResult> => partialPayment: (applicationId: number | string, actualPaymentAmount: number, remark?: string, idempotencyKey?: string, facts?: ExternalPaymentFacts): Promise<PaymentResult> =>
request.post('/v1/cashier/partial-pay', { applicationId, paymentAmount, remark }, idempotencyKey ? { headers: { 'Idempotency-Key': idempotencyKey } } : undefined), request.post('/v1/cashier/partial-pay', { applicationId, actualPaymentAmount, remark, ...facts }, idempotencyKey ? { headers: { 'Idempotency-Key': idempotencyKey } } : undefined),
getHistory: (): Promise<PaymentRecord[]> => getHistory: (): Promise<PaymentRecord[]> =>
request.get('/v1/cashier/history'), request.get('/v1/cashier/history'),
@@ -345,6 +413,9 @@ export const cashierApi = {
reject: (data: PaymentReviewRequest): Promise<PaymentResult> => reject: (data: PaymentReviewRequest): Promise<PaymentResult> =>
request.post('/v1/cashier/payments/reject', data), request.post('/v1/cashier/payments/reject', data),
attachReceipt: (paymentId: number | string, paymentReceipt: string): Promise<PaymentResult> =>
request.patch(`/v1/cashier/payments/${paymentId}/receipt`, { paymentReceipt }),
} }
export const dashboardApi = { export const dashboardApi = {
+2
View File
@@ -18,8 +18,10 @@ export interface TravelApplication {
status: string status: string
approvalSystem: string approvalSystem: string
syncedAt: string syncedAt: string
linkedPaymentApplicationCount: number
} }
export const travelApplicationsApi = { export const travelApplicationsApi = {
mine: (): Promise<TravelApplication[]> => request.get('/v1/travel-applications/mine'), mine: (): Promise<TravelApplication[]> => request.get('/v1/travel-applications/mine'),
detail: (id: number): Promise<TravelApplication> => request.get(`/v1/travel-applications/${id}`),
} }
+922
View File
@@ -0,0 +1,922 @@
/*
* Unified UI system
* Apple-family clarity with a restrained ZeroErr blue accent.
* This layer intentionally contains no business-specific rules.
*/
:root {
--navy: #1d1d1f;
--deep: #111113;
--blue: #0071e3;
--blue-hover: #0077ed;
--blue-soft: #e8f2ff;
--white: #ffffff;
--surface: #f5f5f7;
--surface-2: #ececf0;
--line: rgba(60, 60, 67, 0.16);
--line-strong: rgba(60, 60, 67, 0.28);
--text: #1d1d1f;
--body: #3a3a3c;
--muted: #6e6e73;
--quiet: #86868b;
--info: #0071e3;
--info-soft: #e8f2ff;
--success: #248a3d;
--success-soft: #edf8ef;
--warning: #9a6700;
--warning-soft: #fff8e8;
--danger: #d70015;
--danger-hover: #b50012;
--danger-soft: #fff0f1;
--disabled: #8e8e93;
--disabled-soft: #f0f0f2;
--focus: rgba(0, 113, 227, 0.38);
--control-height: 40px;
--control-height-small: 34px;
--sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
--mono: "SFMono-Regular", "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
--shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
--shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 24px rgba(0, 0, 0, 0.04);
--radius-control: 10px;
--radius-panel: 14px;
--radius-modal: 18px;
--side: 240px;
}
html {
background: var(--surface);
color-scheme: light;
}
body {
color: var(--text);
background: var(--surface);
font: 14px/1.55 var(--sans);
letter-spacing: -0.006em;
text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
letter-spacing: inherit;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
outline: 3px solid var(--focus);
outline-offset: 2px;
}
::selection {
background: rgba(0, 113, 227, 0.18);
}
/* Application shell */
.sidebar {
width: var(--side);
padding: 20px 14px 16px;
border-right: 1px solid var(--line);
background: rgba(247, 247, 249, 0.96);
color: var(--text);
box-shadow: none;
backdrop-filter: saturate(180%) blur(24px);
}
.brand {
gap: 10px;
padding: 0 10px;
}
.brand strong {
color: var(--text);
font-size: 15px;
letter-spacing: -0.01em;
}
.brand small {
margin-top: 0;
color: var(--quiet);
font: 10px/1.2 var(--sans);
letter-spacing: 0.16em;
}
.sidebar .brand strong {
color: var(--text);
}
.sidebar .brand small {
color: var(--quiet);
}
.brand-mark {
width: 30px;
height: 30px;
border: 1px solid var(--line);
border-radius: 9px;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.product-name {
margin: 16px 10px 20px;
padding-top: 14px;
border-top-color: var(--line);
color: var(--muted);
font-size: 12px;
}
.main-nav {
margin-right: -2px;
padding-right: 2px;
}
.nav-group {
margin-bottom: 18px;
}
.nav-group > span {
margin: 0 10px 7px;
color: var(--quiet);
font: 600 11px/1.3 var(--sans);
letter-spacing: 0;
}
.main-nav a {
min-height: 38px;
gap: 10px;
margin: 2px 0;
padding: 8px 10px;
border: 0;
border-radius: 10px;
color: var(--body);
font-size: 13px;
transition: background-color 140ms ease, color 140ms ease;
}
.main-nav a b,
.main-nav a .nav-icon {
color: var(--muted);
}
.main-nav a:hover {
background: rgba(0, 0, 0, 0.045);
color: var(--text);
}
.main-nav a.active {
border: 0;
background: rgba(0, 113, 227, 0.1);
color: var(--blue);
font-weight: 650;
}
.main-nav a.active b,
.main-nav a.active .nav-icon {
color: var(--blue);
}
.nav-subgroup {
border-left: 0;
}
.nav-subgroup summary {
padding: 7px 10px;
color: var(--muted);
font-size: 12px;
}
.nav-subgroup summary::before {
color: var(--quiet);
}
.sidebar-foot {
margin: 12px 4px 0;
padding: 11px 10px;
border-color: var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.68);
}
.sidebar-foot strong {
color: var(--body);
}
.sidebar-foot small {
color: var(--quiet);
}
.main-area {
margin-left: var(--side);
}
.topbar {
height: 64px;
padding: 0 32px;
border-bottom: 1px solid var(--line);
background: rgba(255, 255, 255, 0.82);
backdrop-filter: saturate(180%) blur(24px);
}
.breadcrumb {
color: var(--muted);
font-size: 13px;
}
.breadcrumb i {
color: var(--line-strong);
}
.breadcrumb strong {
color: var(--text);
font-weight: 600;
}
.search-box {
width: min(360px, 32vw);
height: 38px;
border-color: transparent;
border-radius: 11px;
background: rgba(118, 118, 128, 0.09);
}
.search-box:focus-within {
border-color: rgba(0, 113, 227, 0.34);
background: #fff;
box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}
.icon-button,
.role-switch {
border-radius: 10px;
}
.icon-button {
border-color: transparent;
background: transparent;
}
.icon-button:hover,
.role-switch:hover {
border-color: var(--line);
background: rgba(118, 118, 128, 0.08);
}
.role-switch {
padding: 4px 8px 4px 4px;
}
.avatar {
border-radius: 9px;
background: var(--text);
}
.page-stage {
width: min(1480px, 100%);
padding: 30px 40px 64px;
}
.page-head {
align-items: flex-end;
margin-bottom: 24px;
}
.page-head h1 {
color: var(--text);
font-size: clamp(26px, 2.2vw, 32px);
font-weight: 700;
letter-spacing: -0.035em;
}
.page-head p {
max-width: 760px;
margin-top: 6px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.head-actions {
gap: 8px;
}
/* Controls */
.btn {
min-height: var(--control-height);
padding: 8px 16px;
border: 1px solid var(--line-strong);
border-radius: var(--radius-control);
background: rgba(255, 255, 255, 0.9);
color: var(--text);
font-size: 13px;
font-weight: 600;
line-height: 1.2;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02);
transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.btn:hover:not(:disabled) {
border-color: rgba(60, 60, 67, 0.36);
background: #fff;
}
.btn:active:not(:disabled) {
transform: scale(0.98);
}
.btn.primary {
border-color: var(--blue);
background: var(--blue);
color: #fff;
box-shadow: none;
}
.btn.primary:hover:not(:disabled) {
border-color: var(--blue-hover);
background: var(--blue-hover);
}
.btn.ghost {
border-color: transparent;
background: transparent;
color: var(--blue);
box-shadow: none;
}
.btn.ghost:hover:not(:disabled) {
border-color: transparent;
background: rgba(0, 113, 227, 0.08);
}
.btn.small {
min-height: var(--control-height-small);
padding: 6px 12px;
border-radius: 9px;
font-size: 12px;
}
.field input,
.field select,
.field textarea,
.filter-input,
.filter-select,
.table-input,
.inline-select,
.field-filter-grid input,
.field-filter-grid select {
border: 1px solid var(--line-strong);
border-radius: var(--radius-control);
background: #fff;
color: var(--text);
font-size: 14px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.015);
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-input:focus,
.filter-select:focus,
.table-input:focus,
.inline-select:focus {
border-color: rgba(0, 113, 227, 0.58);
box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
outline: 0;
}
.field label,
.field-filter-grid label > span {
color: var(--muted);
font-size: 12px;
font-weight: 600;
}
.field-hint {
color: var(--quiet);
}
/* Panels and information hierarchy */
.card,
.section-card,
.payment-start-panel,
.workspace-focus,
.business-document-gate,
.approval-preview,
.role-permission-detail,
.role-directory {
border: 1px solid var(--line);
border-radius: var(--radius-panel);
background: rgba(255, 255, 255, 0.94);
box-shadow: var(--shadow-soft);
}
.card-head,
.section-title {
border-bottom-color: var(--line);
}
.card-head {
padding: 17px 19px;
}
.card-head h2,
.section-title h2 {
color: var(--text);
font-size: 15px;
font-weight: 650;
letter-spacing: -0.015em;
}
.card-head p,
.section-title span {
color: var(--quiet);
}
.card-body {
padding: 19px;
}
.section-card {
margin-bottom: 16px;
box-shadow: none;
}
.section-title {
min-height: 58px;
padding: 15px 18px;
}
.inline-note,
.discussion-note {
border: 0;
border-radius: 12px;
background: var(--blue-soft);
color: var(--body);
box-shadow: inset 3px 0 0 rgba(0, 113, 227, 0.72);
}
.metric {
border-color: var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.9);
box-shadow: none;
}
.metric::before {
width: 2px;
}
.metric strong {
color: var(--text);
font-family: var(--sans);
font-weight: 700;
}
.attention-card,
.featured-start-card,
.workspace-focus,
.payment-start-panel,
.business-document-gate {
border-color: var(--line);
background: linear-gradient(135deg, #fff, #fafafd);
box-shadow: var(--shadow-soft);
}
.type-card,
.quick-type,
.task-item,
.approval-item {
border-color: var(--line);
}
.type-card,
.quick-type {
border-radius: 12px;
background: #fff;
}
.type-card:hover,
.type-card.selected,
.quick-type:hover {
border-color: rgba(0, 113, 227, 0.36);
background: #fff;
box-shadow: 0 10px 30px rgba(0, 113, 227, 0.08);
transform: translateY(-1px);
}
.empty-state {
min-height: 120px;
color: var(--quiet);
}
/* Tables, filters and segmented navigation */
.table-wrap {
border-radius: 0 0 var(--radius-panel) var(--radius-panel);
}
.data-table {
font-size: 13px;
}
.data-table th {
padding: 11px 13px;
border-bottom-color: var(--line);
background: #f7f7f9;
color: var(--muted);
font-size: 12px;
font-weight: 600;
}
.data-table td {
padding: 13px;
border-bottom-color: var(--line);
color: var(--body);
}
.data-table tbody tr:hover {
background: rgba(0, 113, 227, 0.035);
}
.data-table td strong {
color: var(--text);
font-size: 13px;
}
.data-table td small {
color: var(--quiet);
font-size: 12px;
}
.amount {
color: var(--text);
font-size: 13px;
font-weight: 650;
}
.table-action,
.card-link,
.info-link {
color: var(--blue);
font-weight: 600;
}
.filter-bar,
.field-filter-panel {
gap: 9px;
padding: 13px 15px;
border-bottom-color: var(--line);
background: rgba(247, 247, 249, 0.78);
}
.tabs {
gap: 4px;
padding: 5px;
border-bottom: 0;
border-radius: 11px 11px 0 0;
background: rgba(118, 118, 128, 0.08);
}
.tab {
min-height: 34px;
padding: 7px 13px;
border: 0;
border-radius: 8px;
color: var(--muted);
}
.tab:hover {
background: rgba(255, 255, 255, 0.62);
color: var(--text);
}
.tab.active {
border: 0;
background: #fff;
color: var(--text);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.tag {
gap: 0;
padding: 4px 8px;
border-radius: 999px;
font-size: 11px;
font-weight: 600;
}
.tag::before {
display: none;
}
/* Modal and feedback */
.modal-layer {
background: rgba(0, 0, 0, 0.28);
backdrop-filter: blur(10px);
}
.modal {
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: var(--radius-modal);
background: rgba(255, 255, 255, 0.98);
box-shadow: 0 28px 80px rgba(0, 0, 0, 0.2);
}
.modal-head,
.modal-actions {
border-color: var(--line);
}
.modal-head {
padding: 20px 22px 17px;
}
.modal-head h2 {
font-size: 18px;
letter-spacing: -0.02em;
}
.modal-body {
padding: 22px;
}
.modal-actions {
padding: 14px 22px;
background: rgba(247, 247, 249, 0.88);
}
.toast {
border-radius: 12px;
background: rgba(29, 29, 31, 0.94);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(18px);
}
/* Role selection */
.login-screen {
min-height: 100vh;
padding: 40px;
background: radial-gradient(circle at 80% 5%, rgba(0, 113, 227, 0.1), transparent 30%), var(--surface);
color: var(--text);
}
.login-panel {
width: min(1180px, 100%);
}
.login-brand {
margin-bottom: 72px;
}
.login-brand strong {
color: var(--text);
}
.login-brand small {
color: var(--quiet);
}
.login-copy {
margin-bottom: 38px;
}
.login-copy h1 {
margin: 12px 0 8px;
color: var(--text);
font-size: clamp(36px, 5vw, 56px);
font-weight: 700;
letter-spacing: -0.045em;
}
.login-copy p {
color: var(--muted);
font-size: 14px;
}
.environment-pill {
border: 0;
background: var(--blue-soft);
color: var(--blue);
}
.role-login-grid {
gap: 30px;
}
.role-category {
padding: 0;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
}
.role-category-head {
margin-bottom: 12px;
padding: 0 2px;
}
.role-category-head strong {
color: var(--text);
font-size: 14px;
font-weight: 650;
}
.role-category-head small {
display: none;
}
.role-category-grid {
gap: 10px;
}
.role-login-card {
min-height: 108px;
padding: 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(255, 255, 255, 0.88);
color: var(--text);
box-shadow: none;
backdrop-filter: blur(18px);
}
.role-login-card:hover,
.role-login-card:focus-visible {
border-color: rgba(0, 113, 227, 0.34);
background: #fff;
box-shadow: 0 12px 32px rgba(0, 113, 227, 0.08);
transform: translateY(-1px);
}
.role-login-avatar {
border-radius: 10px;
background: var(--blue-soft);
color: var(--blue);
}
.role-login-card strong {
color: var(--text);
font-size: 13px;
}
.role-login-card small {
color: var(--muted);
font-size: 12px;
}
.role-login-card i {
color: var(--blue);
font-size: 12px;
}
.role-login-card.is-disabled {
background: rgba(238, 238, 240, 0.72);
opacity: 0.7;
}
/* Domain patterns */
.approval-preview {
overflow: hidden;
border-color: var(--line);
background: #fff;
box-shadow: none;
}
.approval-preview-head {
border-bottom-color: var(--line);
background: #f7f7f9;
}
.approval-node > span {
background: var(--blue);
}
.step-rail {
border-color: var(--line);
border-radius: 12px;
background: #fff;
}
.step.active .step-num,
.flow-step.done i {
border-color: var(--blue);
background: var(--blue);
}
.flow-step.current i {
box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}
.progress-bar {
background: var(--surface-2);
}
.role-detail-hero,
.expense-type-detail-hero {
background: linear-gradient(135deg, #fff, #f7f7f9);
}
.ui-tip summary,
.info-entry,
.info-link > span {
border-radius: 50%;
}
/* Responsive behavior */
@media (max-width: 1180px) {
.page-stage {
padding-right: 28px;
padding-left: 28px;
}
}
@media (max-width: 920px) {
:root {
--side: 0px;
}
.sidebar {
width: 250px;
box-shadow: 18px 0 48px rgba(0, 0, 0, 0.14);
}
.main-area {
margin-left: 0;
}
.topbar {
padding: 0 20px;
}
}
@media (max-width: 680px) {
.login-screen {
padding: 24px 16px 40px;
}
.login-brand {
margin-bottom: 48px;
}
.login-copy h1 {
font-size: 38px;
}
.page-stage {
padding: 22px 16px 48px;
}
.page-head {
align-items: flex-start;
margin-bottom: 20px;
}
.page-head h1 {
font-size: 27px;
}
.head-actions {
width: 100%;
}
.head-actions .btn {
flex: 1 1 auto;
}
.card,
.section-card,
.payment-start-panel,
.workspace-focus,
.business-document-gate,
.approval-preview {
border-radius: 12px;
}
.tabs {
overflow-x: auto;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
+1 -1
View File
@@ -159,7 +159,7 @@ const landingCandidates: ReadonlyArray<{ key: PageAccessKey; target: PageLanding
{ key: 'financeOperations', target: { path: '/finance-receipt' } }, { key: 'financeOperations', target: { path: '/finance-receipt' } },
{ key: 'sources', target: { path: '/sources' } }, { key: 'sources', target: { path: '/sources' } },
{ key: 'logs', target: { path: '/logs' } }, { key: 'logs', target: { path: '/logs' } },
{ key: 'expenseTypes', target: { path: '/expense-types' } }, { key: 'expenseTypes', target: { path: '/payment-scenarios' } },
{ key: 'payees', target: { path: '/payees' } }, { key: 'payees', target: { path: '/payees' } },
{ key: 'legalEntities', target: { path: '/legal-entities' } }, { key: 'legalEntities', target: { path: '/legal-entities' } },
{ key: 'costCenters', target: { path: '/cost-centers' } }, { key: 'costCenters', target: { path: '/cost-centers' } },
+7
View File
@@ -0,0 +1,7 @@
export {}
declare module 'vue' {
export interface GlobalComponents {
SearchableSelect: typeof import('./components/SearchableSelect.vue')['default']
}
}
+6 -6
View File
@@ -6,12 +6,12 @@
<button class="btn small employee-filter__toggle" type="button" :aria-expanded="advancedOpen" aria-controls="employee-filter-advanced" :disabled="disabled || loading" @click="advancedOpen = !advancedOpen">{{ advancedOpen ? '收起高级筛选' : '展开高级筛选' }}</button> <button class="btn small employee-filter__toggle" type="button" :aria-expanded="advancedOpen" aria-controls="employee-filter-advanced" :disabled="disabled || loading" @click="advancedOpen = !advancedOpen">{{ advancedOpen ? '收起高级筛选' : '展开高级筛选' }}</button>
</div> </div>
<div v-show="advancedOpen" id="employee-filter-advanced" class="employee-filter__advanced"> <div v-show="advancedOpen" id="employee-filter-advanced" class="employee-filter__advanced">
<label v-if="allows('name')">姓名<input v-model="draft.name" type="search" autocomplete="off" :disabled="disabled || loading"></label> <label v-if="allows('name')">姓名<input v-model="draft.name" type="search" autocomplete="off" placeholder="请输入员工姓名" :disabled="disabled || loading"></label>
<label v-if="allows('employeeNo')">工号<input v-model="draft.employeeNo" type="search" autocomplete="off" :disabled="disabled || loading"></label> <label v-if="allows('employeeNo')">工号<input v-model="draft.employeeNo" type="search" autocomplete="off" placeholder="请输入员工工号" :disabled="disabled || loading"></label>
<label v-if="allows('jobTitle')">职位<input v-model="draft.jobTitle" type="search" autocomplete="off" :disabled="disabled || loading"></label> <label v-if="allows('jobTitle')">职位<input v-model="draft.jobTitle" type="search" autocomplete="off" placeholder="请输入职位名称" :disabled="disabled || loading"></label>
<label v-if="allows('email')">邮箱<input v-model="draft.email" type="search" autocomplete="off" inputmode="email" :disabled="disabled || loading"></label> <label v-if="allows('email')">邮箱<input v-model="draft.email" type="search" autocomplete="off" inputmode="email" placeholder="请输入员工邮箱" :disabled="disabled || loading"></label>
<label v-if="allows('mobile')">手机号<input v-model="draft.mobile" type="search" autocomplete="off" inputmode="tel" :disabled="disabled || loading"></label> <label v-if="allows('mobile')">手机号<input v-model="draft.mobile" type="search" autocomplete="off" inputmode="tel" placeholder="请输入员工手机号" :disabled="disabled || loading"></label>
<label v-if="allows('accountId')">账号标识<input v-model="draft.accountId" type="search" autocomplete="off" placeholder="userId 或 openId" :disabled="disabled || loading"></label> <label v-if="allows('accountId')">账号标识<input v-model="draft.accountId" type="search" autocomplete="off" placeholder="请输入 userId 或 openId" :disabled="disabled || loading"></label>
<label v-if="allows('employmentStatus')">在职状态<select v-model="draft.employmentStatus" :disabled="disabled || loading"><option value="">全部状态</option><option value="ACTIVE">在职</option><option value="RESIGNED">已离职</option></select></label> <label v-if="allows('employmentStatus')">在职状态<select v-model="draft.employmentStatus" :disabled="disabled || loading"><option value="">全部状态</option><option value="ACTIVE">在职</option><option value="RESIGNED">已离职</option></select></label>
</div> </div>
<div class="employee-filter__footer"> <div class="employee-filter__footer">
@@ -31,7 +31,7 @@
<div v-if="loading" class="load-wrap" role="status"> <div v-if="loading" class="load-wrap" role="status">
<span class="loader" aria-hidden="true"></span><span>正在加载绑定列表…</span> <span class="loader" aria-hidden="true"></span><span>正在加载绑定列表…</span>
</div> </div>
<div v-else-if="!loadError && filtered.length" class="table-wrap" tabindex="0" role="region" aria-label="金蝶账号绑定列表"> <div v-else-if="!loadError" class="table-wrap" tabindex="0" role="region" aria-label="金蝶账号绑定列表">
<table class="data-table responsive-table"> <table class="data-table responsive-table">
<thead> <thead>
<tr> <tr>
@@ -41,6 +41,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-if="!filtered.length"><td colspan="4"><div class="empty-state"><strong>{{ canViewAll ? '暂无财务人员' : '暂无本人记录' }}</strong><span>{{ canViewAll ? '请先为用户分配「财务」角色,或授予「变更金蝶财务单据」权限。' : '当前账号不在可绑定范围内,或尚无权限。' }}</span></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.employeeOpenId"> <tr v-for="item in paginatedItems" :key="item.employeeOpenId">
<td v-if="uiRead('ui.kingdee.binding.column.employee')" data-label="财务人员"> <td v-if="uiRead('ui.kingdee.binding.column.employee')" data-label="财务人员">
<strong>{{ item.realName }}</strong> <strong>{{ item.realName }}</strong>
@@ -62,10 +63,6 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!loading && !loadError" class="empty-state">
<strong>{{ canViewAll ? '暂无财务人员' : '暂无本人记录' }}</strong>
<span>{{ canViewAll ? '请先为用户分配「财务」角色,或授予「变更金蝶财务单据」权限。' : '当前账号不在可绑定范围内,或尚无权限。' }}</span>
</div>
<AppListPagination <AppListPagination
v-if="!loading && !loadError && filtered.length && canViewAll" v-if="!loading && !loadError && filtered.length && canViewAll"
v-model:page="page" v-model:page="page"
@@ -89,10 +86,10 @@
<div class="form-grid"> <div class="form-grid">
<div v-if="adding" class="field full"> <div v-if="adding" class="field full">
<label for="kingdee-binding-user">绑定人员 <em>*</em></label> <label for="kingdee-binding-user">绑定人员 <em>*</em></label>
<select id="kingdee-binding-user" v-model="selectedEmployeeOpenId" class="select" required :disabled="saving"> <SearchableSelect id="kingdee-binding-user" v-model="selectedEmployeeOpenId" class="select" required :disabled="saving">
<option :value="null" disabled>请选择未绑定人员</option> <option :value="null" disabled>请选择未绑定人员</option>
<option v-for="item in addCandidates" :key="item.employeeOpenId" :value="item.employeeOpenId">{{ addCandidateLabel(item) }}</option> <option v-for="item in addCandidates" :key="item.employeeOpenId" :value="item.employeeOpenId">{{ addCandidateLabel(item) }}</option>
</select> </SearchableSelect>
</div> </div>
<div v-if="uiRead('dialog.kingdee.account.username')" class="field"> <div v-if="uiRead('dialog.kingdee.account.username')" class="field">
<label for="kingdee-username">金蝶用户名 <em>*</em></label> <label for="kingdee-username">金蝶用户名 <em>*</em></label>
+10 -8
View File
@@ -15,8 +15,7 @@
<div v-else-if="loading" class="sync-loading" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span>正在加载同步规则…</div> <div v-else-if="loading" class="sync-loading" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span>正在加载同步规则…</div>
<div v-else-if="loadError" class="inline-alert danger sync-alert" role="alert"><span>{{ loadError }}</span><button class="btn small" type="button" @click="loadConfigs">重试</button></div> <div v-else-if="loadError" class="inline-alert danger sync-alert" role="alert"><span>{{ loadError }}</span><button class="btn small" type="button" @click="loadConfigs">重试</button></div>
<template v-else> <template v-else>
<div v-if="!configs.length" class="sync-empty"><strong>暂无同步规则</strong><span>新建规则后,可以创建目标表并执行单据同步。</span></div> <div class="table-scroll" role="region" aria-label="金蝶同步规则列表" tabindex="0">
<div v-else class="table-scroll" role="region" aria-label="金蝶同步规则列表" tabindex="0">
<el-table :data="pagedConfigs" row-key="id" size="small" empty-text="暂无同步规则"> <el-table :data="pagedConfigs" row-key="id" size="small" empty-text="暂无同步规则">
<el-table-column v-if="uiRead('ui.kingdee.rules.column.name')" prop="configName" label="配置名称" min-width="150" /> <el-table-column v-if="uiRead('ui.kingdee.rules.column.name')" prop="configName" label="配置名称" min-width="150" />
<el-table-column v-if="uiRead('ui.kingdee.rules.column.form')" prop="formId" label="formId" min-width="140" /> <el-table-column v-if="uiRead('ui.kingdee.rules.column.form')" prop="formId" label="formId" min-width="140" />
@@ -66,7 +65,7 @@
<el-form-item label="源字段标识" required><el-input v-model="field.sourceFieldKey" :disabled="!canManageFields" placeholder="如:FMaterialId" /></el-form-item> <el-form-item label="源字段标识" required><el-input v-model="field.sourceFieldKey" :disabled="!canManageFields" placeholder="如:FMaterialId" /></el-form-item>
<el-form-item label="数据库字段名" required><el-input v-model="field.targetColumnName" :disabled="!canManageFields" placeholder="如:material_id" /></el-form-item> <el-form-item label="数据库字段名" required><el-input v-model="field.targetColumnName" :disabled="!canManageFields" placeholder="如:material_id" /></el-form-item>
<el-form-item label="字段注释"><el-input v-model="field.fieldComment" :disabled="!canManageFields" placeholder="可选" /></el-form-item> <el-form-item label="字段注释"><el-input v-model="field.fieldComment" :disabled="!canManageFields" placeholder="可选" /></el-form-item>
<el-form-item label="类型" required><el-select v-model="field.dataType" :disabled="!canManageFields" placeholder="选择类型" @change="onDataTypeChange(field)"><el-option v-for="type in dataTypes" :key="type" :label="type" :value="type" /></el-select></el-form-item> <el-form-item label="类型" required><el-select v-model="field.dataType" filterable :disabled="!canManageFields" placeholder="选择或搜索类型" @change="onDataTypeChange(field)"><el-option v-for="type in dataTypes" :key="type" :label="type" :value="type" /></el-select></el-form-item>
<el-form-item label="长度"><el-input-number v-model="field.fieldLength" :disabled="!canManageFields || field.dataType !== 'STRING'" :min="1" :max="10000" controls-position="right" placeholder="可选" /></el-form-item> <el-form-item label="长度"><el-input-number v-model="field.fieldLength" :disabled="!canManageFields || field.dataType !== 'STRING'" :min="1" :max="10000" controls-position="right" placeholder="可选" /></el-form-item>
<el-button v-if="canManageFields" class="remove-row" link type="danger" :disabled="draft.fields.length <= 1" :aria-label="`删除第${index + 1}条字段`" @click="removeField(index)">删除</el-button> <el-button v-if="canManageFields" class="remove-row" link type="danger" :disabled="draft.fields.length <= 1" :aria-label="`删除第${index + 1}条字段`" @click="removeField(index)">删除</el-button>
</div> </div>
@@ -76,7 +75,7 @@
<div v-if="uiRead('dialog.kingdee.rule.filters')" class="filter-list"> <div v-if="uiRead('dialog.kingdee.rule.filters')" class="filter-list">
<div v-for="(filter, index) in draft.filters" :key="filter._key" class="filter-row"> <div v-for="(filter, index) in draft.filters" :key="filter._key" class="filter-row">
<el-form-item label="源字段标识"><el-input v-model="filter.sourceFieldKey" :disabled="!canManageFilters" placeholder="如:FDocumentStatus" /></el-form-item> <el-form-item label="源字段标识"><el-input v-model="filter.sourceFieldKey" :disabled="!canManageFilters" placeholder="如:FDocumentStatus" /></el-form-item>
<el-form-item label="操作符"><el-select v-model="filter.operator" :disabled="!canManageFilters"><el-option v-for="operator in operators" :key="operator.value" :label="operator.label" :value="operator.value" /></el-select></el-form-item> <el-form-item label="操作符"><el-select v-model="filter.operator" filterable :disabled="!canManageFilters" placeholder="选择或搜索操作符"><el-option v-for="operator in operators" :key="operator.value" :label="operator.label" :value="operator.value" /></el-select></el-form-item>
<el-form-item label="过滤值"><el-input v-model="filter.filterValue" :disabled="!canManageFilters" placeholder="结构化值,如:A,B" /></el-form-item> <el-form-item label="过滤值"><el-input v-model="filter.filterValue" :disabled="!canManageFilters" placeholder="结构化值,如:A,B" /></el-form-item>
<el-button v-if="canManageFilters" class="remove-row" link type="danger" :aria-label="`删除第${index + 1}条过滤条件`" @click="removeFilter(index)">删除</el-button> <el-button v-if="canManageFilters" class="remove-row" link type="danger" :aria-label="`删除第${index + 1}条过滤条件`" @click="removeFilter(index)">删除</el-button>
</div> </div>
@@ -95,16 +94,15 @@
<section v-if="previewResult" class="result-section" aria-labelledby="preview-result-title"> <section v-if="previewResult" class="result-section" aria-labelledby="preview-result-title">
<div class="result-title"><h4 id="preview-result-title">预览结果</h4><el-tag v-if="previewResult.truncated" type="warning" size="small">结果已截断</el-tag></div> <div class="result-title"><h4 id="preview-result-title">预览结果</h4><el-tag v-if="previewResult.truncated" type="warning" size="small">结果已截断</el-tag></div>
<p class="result-meta">过滤条件:{{ previewResult.filterString || '无' }} · 返回 {{ previewResult.rows.length }} 行</p> <p class="result-meta">过滤条件:{{ previewResult.filterString || '无' }} · 返回 {{ previewResult.rows.length }} 行</p>
<div v-if="!previewResult.rows.length" class="muted-copy">暂无符合条件的数据。</div> <div class="table-scroll preview-table" role="region" aria-label="同步数据预览" tabindex="0"><el-table :data="previewResult.rows" size="small" empty-text="暂无符合条件的数据"><el-table-column v-for="column in previewColumns" :key="column" :prop="column" :label="column" min-width="140"><template #default="scope">{{ formatCell(scope.row[column]) }}</template></el-table-column></el-table></div>
<div v-else class="table-scroll preview-table" role="region" aria-label="同步数据预览" tabindex="0"><el-table :data="previewResult.rows" size="small"><el-table-column v-for="column in previewColumns" :key="column" :prop="column" :label="column" min-width="140"><template #default="scope">{{ formatCell(scope.row[column]) }}</template></el-table-column></el-table></div>
</section> </section>
<div v-if="runNotice" class="result-note" :class="runNoticeDanger ? 'result-danger' : 'result-pending'" :role="runNoticeDanger ? 'alert' : 'status'" aria-live="polite"> <div v-if="runNotice" class="result-note" :class="runNoticeDanger ? 'result-danger' : 'result-pending'" :role="runNoticeDanger ? 'alert' : 'status'" aria-live="polite">
<span>{{ runNotice }}</span><el-button v-if="pollingTimedOut" link type="primary" size="small" :loading="runLoading" @click="refreshRunStatus">刷新运行状态</el-button> <span>{{ runNotice }}</span><el-button v-if="pollingTimedOut" link type="primary" size="small" :loading="runLoading" @click="refreshRunStatus">刷新运行状态</el-button>
</div> </div>
<section v-if="latestRun || runs.length" class="result-section" aria-labelledby="run-result-title"> <section v-if="editingId !== null" class="result-section" aria-labelledby="run-result-title">
<div class="result-title"><h4 id="run-result-title">运行结果</h4><span v-if="runLoading" class="muted-copy" role="status">正在查询状态…</span></div> <div class="result-title"><h4 id="run-result-title">运行结果</h4><span v-if="runLoading" class="muted-copy" role="status">正在查询状态…</span></div>
<div v-if="latestRun" class="run-summary" role="status" aria-live="polite"><span>状态:{{ latestRun.status }}</span><span>fetched:{{ latestRun.fetchedCount ?? 0 }}</span><span>inserted:{{ latestRun.insertedCount ?? 0 }}</span><span>updated:{{ latestRun.updatedCount ?? 0 }}</span><span>failed:{{ latestRun.failedCount ?? 0 }}</span><span v-if="latestRun.errorMessage" class="run-error">{{ latestRun.errorMessage }}</span></div> <div v-if="latestRun" class="run-summary" role="status" aria-live="polite"><span>状态:{{ latestRun.status }}</span><span>fetched:{{ latestRun.fetchedCount ?? 0 }}</span><span>inserted:{{ latestRun.insertedCount ?? 0 }}</span><span>updated:{{ latestRun.updatedCount ?? 0 }}</span><span>failed:{{ latestRun.failedCount ?? 0 }}</span><span v-if="latestRun.errorMessage" class="run-error">{{ latestRun.errorMessage }}</span></div>
<div v-if="runs.length" class="table-scroll run-table" role="region" aria-label="历史运行结果" tabindex="0"><el-table :data="runs" size="small"><el-table-column prop="status" label="status" width="110" /><el-table-column prop="fetchedCount" label="fetched" width="95" /><el-table-column prop="insertedCount" label="inserted" width="95" /><el-table-column prop="updatedCount" label="updated" width="95" /><el-table-column prop="failedCount" label="failed" width="85" /><el-table-column label="运行时间" min-width="180"><template #default="scope">{{ formatDate(scope.row.startedAt) }}</template></el-table-column></el-table></div> <div class="table-scroll run-table" role="region" aria-label="历史运行结果" tabindex="0"><el-table :data="runs" size="small" empty-text="暂无运行记录"><el-table-column prop="status" label="status" width="110" /><el-table-column prop="fetchedCount" label="fetched" width="95" /><el-table-column prop="insertedCount" label="inserted" width="95" /><el-table-column prop="updatedCount" label="updated" width="95" /><el-table-column prop="failedCount" label="failed" width="85" /><el-table-column label="运行时间" min-width="180"><template #default="scope">{{ formatDate(scope.row.startedAt) }}</template></el-table-column></el-table></div>
</section> </section>
</div> </div>
<template #footer><el-button :disabled="dialogBusy" @click="requestKingdeeDialogClose">关闭</el-button></template> <template #footer><el-button :disabled="dialogBusy" @click="requestKingdeeDialogClose">关闭</el-button></template>
@@ -189,6 +187,10 @@ let configLoadPromise: Promise<void> | null = null
const { page: currentPage, pageSize, paginatedItems: pagedConfigs } = useListPagination(configs) const { page: currentPage, pageSize, paginatedItems: pagedConfigs } = useListPagination(configs)
const previewColumns = computed(() => { const previewColumns = computed(() => {
const columns = new Set<string>() const columns = new Set<string>()
draft.value.fields.forEach(field => {
const column = field.targetColumnName?.trim()
if (column) columns.add(column)
})
previewResult.value?.rows.forEach(row => Object.keys(row).forEach(key => columns.add(key))) previewResult.value?.rows.forEach(row => Object.keys(row).forEach(key => columns.add(key)))
return Array.from(columns) return Array.from(columns)
}) })
+81 -51
View File
@@ -2,40 +2,51 @@
<div class="application-form"> <div class="application-form">
<div class="page-head"> <div class="page-head">
<div> <div>
<span class="eyebrow">{{ id ? 'EDIT DRAFT' : 'NEW REIMBURSEMENT' }}</span> <span class="eyebrow">{{ id ? 'EDIT DRAFT' : 'NEW PAYMENT APPLICATION' }}</span>
<h1>{{ id && existing?.approvalStatus === '退回' ? '补充退回报销' : id ? '编辑报销草稿' : '发起员工报销' }}</h1> <h1>{{ id && existing?.approvalStatus === '退回' ? '补充退回付款申请' : id ? '编辑付款申请草稿' : '发起付款申请' }}</h1>
<p>{{ id ? '沿用原报销单号,核对表单内容后重新提交。' : '按当前审批模板填写个人垫付费用。' }}</p> <p>{{ id ? '沿用原付款申请单号,核对表单内容后重新提交。' : '按当前审批模板填写付款事由、金额与申请附件。' }}</p>
</div> </div>
<router-link class="btn" to="/applications">取消</router-link> <router-link class="btn" to="/applications">取消</router-link>
</div> </div>
<div v-if="loadError && !definitionError" class="inline-alert danger" role="alert"><b>!</b><span>{{ loadError }}</span></div> <div v-if="loadError && !definitionError" class="inline-alert danger" role="alert"><b>!</b><span>{{ loadError }}</span></div>
<div v-if="linkedTravelApplicationId" class="inline-alert" role="status"><b>↗</b><span>已关联飞书出差申请(系统记录 #{{ linkedTravelApplicationId }}),保存后将作为本付款申请的只读业务依据。</span></div>
<div v-if="!loading && attachmentIntegrityError" class="inline-alert danger" role="alert"><b>!</b><span>{{ attachmentIntegrityError }}</span></div> <div v-if="!loading && attachmentIntegrityError" class="inline-alert danger" role="alert"><b>!</b><span>{{ attachmentIntegrityError }}</span></div>
<div v-if="staleDefinition" class="inline-alert danger conflict-alert" role="alert"><b>409</b><span><strong>审批模板已更新,当前内容不能保存或提交</strong><br>当前页面仍保留原模板及全部输入。升级前不会删除或改写任何值。</span><button v-if="definition?.mode === 'FEISHU'" class="btn small" type="button" :disabled="migratingDefinition" :aria-busy="migratingDefinition" @click="migrateStaleDefinition">{{ migratingDefinition ? '正在读取最新模板…' : '升级到最新模板并核对' }}</button></div> <div v-if="staleDefinition" class="inline-alert danger conflict-alert" role="alert"><b>409</b><span><strong>审批模板已更新,当前内容不能保存或提交</strong><br>当前页面仍保留原模板及全部输入。升级前不会删除或改写任何值。</span><button v-if="definition?.mode === 'FEISHU'" class="btn small" type="button" :disabled="migratingDefinition" :aria-busy="migratingDefinition" @click="migrateStaleDefinition">{{ migratingDefinition ? '正在读取最新模板…' : '升级到最新模板并核对' }}</button></div>
<div v-if="migrationNotice" class="inline-alert migration-alert" role="status"><b>↑</b><span><strong>草稿已升级到当前飞书审批模板</strong><br>{{ migrationNotice }}</span></div> <div v-if="migrationNotice" class="inline-alert migration-alert" role="status"><b>↑</b><span><strong>草稿已升级到当前飞书审批模板</strong><br>{{ migrationNotice }}</span></div>
<div class="step-rail"><div class="step done"><span>1</span><strong>填写报销</strong></div><div class="step active"><span>2</span><strong>材料校验</strong></div><div class="step"><span>3</span><strong>飞书审批</strong></div><div class="step"><span>4</span><strong>财务付款</strong></div></div> <div class="step-rail"><div class="step done"><span>1</span><strong>填写申请</strong></div><div class="step active"><span>2</span><strong>材料校验</strong></div><div class="step"><span>3</span><strong>飞书审批</strong></div><div class="step"><span>4</span><strong>付款结果登记</strong></div></div>
<div v-if="loading" class="card load-wrap" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span><span>正在读取飞书报销模板…</span></div> <div v-if="loading" class="card load-wrap" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span><span>正在读取飞书审批模板…</span></div>
<div v-else-if="definitionError" class="card definition-state" role="alert"><strong>模板暂时无法加载</strong><span>{{ definitionError }}</span><div><button class="btn" type="button" @click="loadPage">重新检查</button><router-link class="btn" to="/applications">返回我的报销</router-link></div></div> <div v-else-if="definitionError" class="card definition-state" role="alert"><strong>模板暂时无法加载</strong><span>{{ definitionError }}</span><div><button class="btn" type="button" @click="loadPage">重新检查</button><router-link class="btn" to="/applications">返回申请中心</router-link></div></div>
<form v-else class="form-page" @submit.prevent="save(true)"> <form v-else class="form-page" @submit.prevent="save(true)">
<section v-if="uiRead('ui.application.form.description')" class="section-card" aria-labelledby="payment-facts-title">
<div class="section-title"><h2 id="payment-facts-title">1. 基本信息</h2><span>组织同步+付款安排</span></div>
<div class="form-grid">
<div class="field"><label>申请人/部门</label><input :value="`${userName}/${department}`" readonly></div>
<div v-if="!id || hasOwnField(existing, 'payerEntityName')" class="field"><label for="payer-entity">付款单位 <em>*</em></label><input id="payer-entity" v-model.trim="form.payerEntityName" maxlength="200" required :readonly="!canWriteApplication || !uiEdit('ui.application.form.description')" placeholder="填写实际承担付款的单位"></div>
<div class="field"><label for="cost-center">成本中心 <em>*</em></label><input id="cost-center" v-model.trim="form.costCenterName" maxlength="200" required readonly><small class="form-help">按申请人所在部门映射并作为提交快照保存。</small></div>
<div class="field"><label for="currency-code">币种 <em>*</em></label><SearchableSelect id="currency-code" v-model="form.currencyCode" required :disabled="!canWriteApplication || !uiEdit('ui.application.form.description')"><option value="CNY">CNY · 人民币</option></SearchableSelect><small class="form-help">外币金额、汇率和折算日期口径待确认,当前仅开放人民币。</small></div>
<div v-if="!id || hasOwnField(existing, 'plannedPaymentDate')" class="field"><label for="planned-payment-date">计划付款日期 <em>*</em></label><input id="planned-payment-date" v-model="form.plannedPaymentDate" type="date" required :readonly="!canWriteApplication || !uiEdit('ui.application.form.description')"></div>
</div>
</section>
<div v-if="isFeishu" class="definition-bar" aria-label="飞书表单模板信息"><strong>飞书审批表单</strong><span>版本 {{ shortFingerprint }}</span><span v-if="definition?.fetchedAt">同步于 {{ formatDateTime(definition.fetchedAt) }}</span></div> <div v-if="isFeishu" class="definition-bar" aria-label="飞书表单模板信息"><strong>飞书审批表单</strong><span>版本 {{ shortFingerprint }}</span><span v-if="definition?.fetchedAt">同步于 {{ formatDateTime(definition.fetchedAt) }}</span></div>
<section v-if="isFeishu && uiRead('ui.application.form.dynamic')" class="section-card" aria-labelledby="feishu-form-title"> <section v-if="isFeishu && uiRead('ui.application.form.dynamic')" class="section-card" aria-labelledby="feishu-form-title">
<div class="section-title"><div class="section-heading"><span class="section-marker">审批</span><div><h2 id="feishu-form-title">飞书审批信息</h2><p>填写本次报销的基础资料与飞书审批字段</p></div></div><span>按模板顺序 · * 为必填项</span></div> <div class="section-title"><div class="section-heading"><span class="section-marker">审批</span><div><h2 id="feishu-form-title">飞书审批信息</h2><p>填写本次付款申请的基础资料与飞书审批字段</p></div></div><span>按模板顺序 · * 为必填项</span></div>
<fieldset class="permission-fieldset" :disabled="!uiEdit('ui.application.form.dynamic')"> <fieldset class="permission-fieldset" :disabled="!uiEdit('ui.application.form.dynamic')">
<FeishuFormFields :fields="activeFields" :form-values="formValues" :form="form" :derived="derivedValues" :show-errors="showValidationErrors" :items-total="itemsTotal" :amount-matches="amountMatches" :expense-types="expenseTypes" :form-fingerprint="pinnedFingerprint" @add-item="addItem" @remove-item="removeItem" @upload-state-change="attachmentRevision++" /> <FeishuFormFields :fields="activeFields" :form-values="formValues" :form="form" :derived="derivedValues" :show-errors="showValidationErrors" :items-total="itemsTotal" :amount-matches="amountMatches" :expense-types="expenseTypes" :form-fingerprint="pinnedFingerprint" @add-item="addItem" @remove-item="removeItem" @upload-state-change="attachmentRevision++" />
</fieldset> </fieldset>
</section> </section>
<section v-if="hasSupplementFields" class="section-card" :class="{ 'section-gap': isFeishu }" aria-labelledby="finance-supplement-title"> <section v-if="hasSupplementFields" class="section-card" :class="{ 'section-gap': isFeishu }" aria-labelledby="finance-supplement-title">
<div class="section-title"><div class="section-heading"><span class="section-marker finance-marker">财务</span><div><h2 id="finance-supplement-title">财务补充信息</h2><p>核对费用归类、收款人及付款账户</p></div></div><span>审批与付款必需 · * 为必填项</span></div> <div class="section-title"><div class="section-heading"><span class="section-marker finance-marker">财务</span><div><h2 id="finance-supplement-title">付款补充信息</h2><p>核对费用项目、收款方及付款账户</p></div></div><span>按付款情形填写 · * 为必填项</span></div>
<div class="form-grid"> <div class="form-grid">
<div v-if="missingBinding('TITLE') && showProjectedField('title')" class="field semantic-title"><label for="title">报销事项 <em>*</em></label><input id="title" v-model.trim="form.title" :readonly="readonlyProjectedField('title')" required maxlength="100"></div> <div v-if="missingBinding('TITLE') && showProjectedField('title')" class="field semantic-title"><label for="title">付款事由 <em>*</em></label><input id="title" v-model.trim="form.title" :readonly="readonlyProjectedField('title')" required maxlength="100"></div>
<div v-if="missingBinding('EXPENSE_TYPE') && showProjectedField('expenseTypeId')" class="field semantic-expense-type"><label for="expense-type">费用类型 <em>*</em></label><select id="expense-type" v-model.number="form.expenseTypeId" :disabled="readonlyProjectedField('expenseTypeId')" required @change="syncExpenseType"><option value="" disabled>请选择</option><option v-for="type in expenseTypes" :key="type.id" :value="type.id">{{ type.name }}</option></select></div> <div v-if="missingBinding('EXPENSE_TYPE') && showProjectedField('paymentScenarioId')" class="field semantic-expense-type"><label for="expense-type">付款情形 <em>*</em></label><SearchableSelect id="expense-type" v-model.number="form.paymentScenarioId" :disabled="readonlyProjectedField('paymentScenarioId')" required @change="syncExpenseType"><option value="" disabled>请选择</option><option v-for="type in expenseTypes" :key="type.id" :value="type.id">{{ type.scenarioName }}</option></SearchableSelect></div>
<div v-if="missingBinding('TOTAL_AMOUNT') && showField('application:amount')" class="field semantic-amount"><label for="amount">报销金额(元) <em>*</em></label><input id="amount" v-model.number="form.totalAmount" type="number" min="0.01" step="0.01" :readonly="readonlyField('application:amount')" required><small v-if="readonlyField('application:amount')" class="form-help">当前字段只读</small></div> <div v-if="missingBinding('TOTAL_AMOUNT') && showField('application:amount')" class="field semantic-amount"><label for="amount">申请付款金额(元) <em>*</em></label><input id="amount" v-model.number="form.requestedAmount" type="number" min="0.01" step="0.01" :readonly="readonlyField('application:amount')" required><small v-if="readonlyField('application:amount')" class="form-help">当前字段只读</small></div>
<div v-if="missingBinding('DESCRIPTION') && showProjectedField('description')" class="field full semantic-description"><label for="description">费用说明 <em>*</em></label><textarea id="description" v-model.trim="form.description" :readonly="readonlyProjectedField('description')" required maxlength="500" rows="3"></textarea></div> <div v-if="missingBinding('DESCRIPTION') && showProjectedField('description')" class="field full semantic-description"><label for="description">付款事由补充说明 <em>*</em></label><textarea id="description" v-model.trim="form.description" :readonly="readonlyProjectedField('description')" required maxlength="500" rows="3"></textarea></div>
<div v-if="showField('application:payeeName')" class="field semantic-payee"><label for="payee">收款人 <em>*</em></label><input id="payee" v-model.trim="form.payeeName" :readonly="readonlyField('application:payeeName')" maxlength="100" required><small v-if="readonlyField('application:payeeName')" class="form-help">当前字段只读</small></div> <div v-if="showField('application:payeeName')" class="field semantic-payee"><label for="payee">收款方 <em>*</em></label><input id="payee" v-model.trim="form.payeeName" :readonly="readonlyField('application:payeeName')" maxlength="100" required><small v-if="readonlyField('application:payeeName')" class="form-help">当前字段只读</small></div>
<div v-if="showField('application:bankAccount')" class="field semantic-bank-account"><label for="bank">收款账户 <em>*</em></label><select id="bank" v-model.number="form.payeeBankId" :disabled="readonlyField('application:bankAccount')" required><option value="" disabled>{{ activePayees.length ? '请选择本人启用账户' : '暂无可用账户' }}</option><option v-for="payee in activePayees" :key="payee.id" :value="payee.id">{{ payee.bankName }} · {{ payee.bankAccountMask }}{{ payee.isDefault ? ' · 默认' : '' }}</option></select><small class="form-help">{{ readonlyField('application:bankAccount') ? '当前字段只读;账户信息不会明文展示。' : activePayees.length ? '仅可选择本人启用的账户,详情页只显示脱敏账号。' : '当前没有启用的付款账户,请联系管理员维护。' }}</small></div> <div v-if="showField('application:bankAccount')" class="field semantic-bank-account"><label for="bank">收款账户 <em>*</em></label><SearchableSelect id="bank" v-model.number="form.payeeBankId" :disabled="readonlyField('application:bankAccount')" required><option value="" disabled>{{ activePayees.length ? '请选择本人启用账户' : '暂无可用账户' }}</option><option v-for="payee in activePayees" :key="payee.id" :value="payee.id">{{ payee.bankName }} · {{ payee.bankAccountMask }}{{ payee.isDefault ? ' · 默认' : '' }}</option></SearchableSelect><small class="form-help">{{ readonlyField('application:bankAccount') ? '当前字段只读;账户信息不会明文展示。' : activePayees.length ? '仅可选择本人启用的账户,详情页只显示脱敏账号。' : '当前没有启用的付款账户,请联系管理员维护。' }}</small></div>
</div> </div>
</section> </section>
@@ -46,7 +57,7 @@
<div v-for="(item, index) in form.items" :key="item.key" class="expense-item"> <div v-for="(item, index) in form.items" :key="item.key" class="expense-item">
<div class="expense-item-heading"><div><span>费用明细</span><strong>第 {{ index + 1 }} 笔</strong></div><button v-if="form.items.length > 1" class="remove-item" type="button" :aria-label="`删除第 ${index + 1} 条费用明细`" @click="removeItem(index)">删除</button></div> <div class="expense-item-heading"><div><span>费用明细</span><strong>第 {{ index + 1 }} 笔</strong></div><button v-if="form.items.length > 1" class="remove-item" type="button" :aria-label="`删除第 ${index + 1} 条费用明细`" @click="removeItem(index)">删除</button></div>
<div class="field expense-date"><label :for="`expense-date-${item.key}`">日期 <em>*</em></label><input :id="`expense-date-${item.key}`" v-model="item.expenseDate" type="date" required></div> <div class="field expense-date"><label :for="`expense-date-${item.key}`">日期 <em>*</em></label><input :id="`expense-date-${item.key}`" v-model="item.expenseDate" type="date" required></div>
<div class="field expense-category"><label :for="`expense-category-${item.key}`">类别 <em>*</em></label><input :id="`expense-category-${item.key}`" v-model.trim="item.category" required maxlength="50"></div> <div class="field expense-category"><label :for="`expense-category-${item.key}`">费用项目 <em>*</em></label><input :id="`expense-category-${item.key}`" v-model.trim="item.expenseItemName" required maxlength="50"></div>
<div class="field expense-amount"> <div class="field expense-amount">
<label :for="`expense-amount-${item.key}`">金额 <em>*</em></label> <label :for="`expense-amount-${item.key}`">金额 <em>*</em></label>
<input <input
@@ -67,12 +78,12 @@
<div class="field expense-description"><label :for="`expense-description-${item.key}`">说明 <em>*</em></label><input :id="`expense-description-${item.key}`" v-model.trim="item.description" required maxlength="200"></div> <div class="field expense-description"><label :for="`expense-description-${item.key}`">说明 <em>*</em></label><input :id="`expense-description-${item.key}`" v-model.trim="item.description" required maxlength="200"></div>
</div> </div>
</div> </div>
<div class="amount-summary" :class="{ 'amount-mismatch': form.totalAmount > 0 && !amountMatches }"><span>明细合计</span><strong>{{ money(itemsTotal) }}</strong><span>申请金额 {{ money(form.totalAmount) }}</span></div> <div class="amount-summary" :class="{ 'amount-mismatch': form.requestedAmount > 0 && !amountMatches }"><span>明细合计</span><strong>{{ money(itemsTotal) }}</strong><span>申请金额 {{ money(form.requestedAmount) }}</span></div>
<small v-if="form.totalAmount > 0 && !amountMatches" class="field-error" role="status">明细合计须与申请金额一致,请核对各行金额。</small> <small v-if="form.requestedAmount > 0 && !amountMatches" class="field-error" role="status">明细合计须与申请金额一致,请核对各行金额。</small>
</fieldset> </fieldset>
</section> </section>
<div v-if="canWriteApplication" class="form-actions"><button class="btn" type="button" :disabled="saving || staleDefinition || hasAttachmentBlocks" :title="hasAttachmentBlocks ? attachmentBlockMessage : undefined" @click="save(false)">{{ saving ? '保存中…' : '保存草稿' }}</button><button v-if="canSubmit" class="btn primary" type="submit" :disabled="saving || staleDefinition || hasUnsupported || hasAttachmentBlocks" :title="hasAttachmentBlocks ? attachmentBlockMessage : undefined" :aria-busy="saving">{{ saving ? '处理中…' : '提交报销' }}</button></div> <div v-if="canWriteApplication" class="form-actions"><button class="btn" type="button" :disabled="saving || staleDefinition || hasAttachmentBlocks" :title="hasAttachmentBlocks ? attachmentBlockMessage : undefined" @click="save(false)">{{ saving ? '保存中…' : '保存草稿' }}</button><button v-if="canSubmit" class="btn primary" type="submit" :disabled="saving || staleDefinition || hasUnsupported || hasAttachmentBlocks" :title="hasAttachmentBlocks ? attachmentBlockMessage : undefined" :aria-busy="saving">{{ saving ? '处理中…' : '提交付款申请' }}</button></div>
</form> </form>
<dialog v-if="canPreviewRoute" ref="previewDialog" v-dialog-drag class="app-dialog route-dialog" aria-modal="true" aria-labelledby="route-dialog-title" aria-describedby="route-dialog-description" @cancel="handleDialogCancel" @click="handleBackdropClick"> <dialog v-if="canPreviewRoute" ref="previewDialog" v-dialog-drag class="app-dialog route-dialog" aria-modal="true" aria-labelledby="route-dialog-title" aria-describedby="route-dialog-description" @cancel="handleDialogCancel" @click="handleBackdropClick">
@@ -83,7 +94,7 @@
</header> </header>
<div class="route-dialog-body"> <div class="route-dialog-body">
<dl class="route-summary" aria-label="报销摘要"><div><dt>报销事项</dt><dd>{{ form.title }}</dd></div><div><dt>费用类型</dt><dd>{{ form.category }}</dd></div><div><dt>报销金额</dt><dd>{{ money(form.totalAmount) }}</dd></div></dl> <dl class="route-summary" aria-label="付款申请摘要"><div><dt>付款事由</dt><dd>{{ form.title }}</dd></div><div><dt>付款情形</dt><dd>{{ form.paymentScenario }}</dd></div><div><dt>申请付款金额</dt><dd>{{ money(form.requestedAmount) }}</dd></div></dl>
<div v-if="previewLoading" class="route-state" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span><span>正在获取预计审批路径…</span></div> <div v-if="previewLoading" class="route-state" role="status" aria-live="polite"><span class="loader" aria-hidden="true"></span><span>正在获取预计审批路径…</span></div>
<div v-else-if="previewError" class="route-state route-error" role="alert"><strong>审批路线预览失败</strong><span>{{ previewError }}</span><button ref="retryButton" class="btn small" type="button" :disabled="previewLoading || submitting" @click="requestPreview">重新预览</button></div> <div v-else-if="previewError" class="route-state route-error" role="alert"><strong>审批路线预览失败</strong><span>{{ previewError }}</span><button ref="retryButton" class="btn small" type="button" :disabled="previewLoading || submitting" @click="requestPreview">重新预览</button></div>
@@ -128,6 +139,10 @@ interface FormItem extends ExpenseItem { key: number; description: string; attac
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const linkedTravelApplicationId = computed(() => {
const value = existing.value?.linkedTravelApplicationId ?? Number(route.query.travelApplicationId)
return Number.isInteger(Number(value)) && Number(value) > 0 ? Number(value) : undefined
})
const userStore = useUserStore() const userStore = useUserStore()
const authorization = useAuthorizationStore() const authorization = useAuthorizationStore()
const store = useWorkbenchStore() const store = useWorkbenchStore()
@@ -164,9 +179,9 @@ const department = computed(() => userStore.userInfo?.departmentName || store.us
const newItem = (value?: Partial<ExpenseItem>, applicationAttachments: Parameters<typeof expenseItemAttachmentMetadata>[1] = []): FormItem => { const newItem = (value?: Partial<ExpenseItem>, applicationAttachments: Parameters<typeof expenseItemAttachmentMetadata>[1] = []): FormItem => {
const files = expenseItemAttachmentMetadata(value, applicationAttachments) const files = expenseItemAttachmentMetadata(value, applicationAttachments)
const attachmentIds = hydratedAttachmentIds(value, files) const attachmentIds = hydratedAttachmentIds(value, files)
return { key: nextKey++, expenseDate: value?.expenseDate || new Date().toISOString().slice(0, 10), category: value?.category || '', description: value?.description || '', amount: Number(value?.amount || 0), seqNo: value?.seqNo, attachmentIds, attachmentFiles: files.map(file => ({ ...file, localKey: `saved-${file.id}`, status: 'uploaded' })) } return { key: nextKey++, expenseDate: value?.expenseDate || new Date().toISOString().slice(0, 10), expenseItemName: value?.expenseItemName || value?.category || '', description: value?.description || '', amount: Number(value?.amount || 0), seqNo: value?.seqNo, attachmentIds, attachmentFiles: files.map(file => ({ ...file, localKey: `saved-${file.id}`, status: 'uploaded' })) }
} }
const form = reactive({ title: '', expenseTypeId: undefined as number | undefined, category: '', totalAmount: 0, description: '', payeeName: '', payeeBankId: undefined as number | undefined, items: [newItem()] }) const form = reactive({ title: '', paymentScenarioId: undefined as number | undefined, paymentScenario: '', requestedAmount: 0, description: '', payeeName: '', payeeBankId: undefined as number | undefined, payerEntityName: '', costCenterName: '', currencyCode: 'CNY', plannedPaymentDate: '', items: [newItem()] })
const fieldLevel = (code: string): FieldLevel => userStore.access(code) const fieldLevel = (code: string): FieldLevel => userStore.access(code)
const uiRead = (code: string) => fieldLevel(code) !== 'HIDDEN' const uiRead = (code: string) => fieldLevel(code) !== 'HIDDEN'
@@ -175,10 +190,10 @@ const writeActionCode = computed(() => id.value ? 'reimbursement.application.edi
const canWriteApplication = computed(() => authorization.can(id.value ? 'reimbursement.application:edit' : 'reimbursement.application:create') && uiEdit(writeActionCode.value)) const canWriteApplication = computed(() => authorization.can(id.value ? 'reimbursement.application:edit' : 'reimbursement.application:create') && uiEdit(writeActionCode.value))
const canPreviewRoute = computed(() => uiRead('dialog.application.route-preview') && uiRead('dialog.application.route-preview.nodes')) const canPreviewRoute = computed(() => uiRead('dialog.application.route-preview') && uiRead('dialog.application.route-preview.nodes'))
const canSubmit = computed(() => authorization.can('reimbursement.application:submit') && canPreviewRoute.value && uiEdit('dialog.application.submit')) const canSubmit = computed(() => authorization.can('reimbursement.application:submit') && canPreviewRoute.value && uiEdit('dialog.application.submit'))
const fieldKeys: Record<string, keyof ReimApplicationDetail> = { 'application:amount': 'totalAmount', 'application:payeeName': 'payeeName', 'application:bankAccount': 'payeeBankId' } const fieldKeys: Record<string, keyof ReimApplicationDetail> = { 'application:amount': 'requestedAmount', 'application:payeeName': 'payeeName', 'application:bankAccount': 'payeeBankId' }
const projectedFieldCodes: Partial<Record<keyof ReimApplicationDetail, string>> = { const projectedFieldCodes: Partial<Record<keyof ReimApplicationDetail, string>> = {
title: 'ui.application.form.title', title: 'ui.application.form.title',
expenseTypeId: 'ui.application.form.expense-type', paymentScenarioId: 'ui.application.form.expense-type',
description: 'ui.application.form.description', description: 'ui.application.form.description',
expenseItems: 'ui.application.form.expense-items', expenseItems: 'ui.application.form.expense-items',
} }
@@ -195,7 +210,7 @@ const readonlyProjectedField = (key: keyof ReimApplicationDetail) => {
return !code || !uiEdit(code) return !code || !uiEdit(code)
} }
const itemsTotal = computed(() => form.items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0)) const itemsTotal = computed(() => form.items.reduce((sum, item) => sum + (Number(item.amount) || 0), 0))
const amountMatches = computed(() => form.items.length > 0 && form.totalAmount > 0 && Math.abs(itemsTotal.value - form.totalAmount) < 0.005) const amountMatches = computed(() => form.items.length > 0 && form.requestedAmount > 0 && Math.abs(itemsTotal.value - form.requestedAmount) < 0.005)
const localAmountDrafts = reactive<Record<number, string>>({}) const localAmountDrafts = reactive<Record<number, string>>({})
const localAmountSource = (item: FormItem) => (localAmountDrafts[item.key] != null ? localAmountDrafts[item.key] : (item.amount > 0 ? item.amount : '')) const localAmountSource = (item: FormItem) => (localAmountDrafts[item.key] != null ? localAmountDrafts[item.key] : (item.amount > 0 ? item.amount : ''))
const localAmountText = (item: FormItem) => (localAmountDrafts[item.key] != null ? localAmountDrafts[item.key] : (item.amount > 0 ? String(item.amount) : '')) const localAmountText = (item: FormItem) => (localAmountDrafts[item.key] != null ? localAmountDrafts[item.key] : (item.amount > 0 ? String(item.amount) : ''))
@@ -250,7 +265,7 @@ const rowReasonCaptured = computed(() => activeFields.value.some(field => field.
const missingBinding = (binding: string) => !isFeishu.value || (!(['TITLE', 'DESCRIPTION'].includes(binding) && rowReasonCaptured.value) && !renderedBindings.value.has(binding as ReimbursementFormField['binding'])) const missingBinding = (binding: string) => !isFeishu.value || (!(['TITLE', 'DESCRIPTION'].includes(binding) && rowReasonCaptured.value) && !renderedBindings.value.has(binding as ReimbursementFormField['binding']))
const hasSupplementFields = computed(() => ( const hasSupplementFields = computed(() => (
(missingBinding('TITLE') && showProjectedField('title')) (missingBinding('TITLE') && showProjectedField('title'))
|| (missingBinding('EXPENSE_TYPE') && showProjectedField('expenseTypeId')) || (missingBinding('EXPENSE_TYPE') && showProjectedField('paymentScenarioId'))
|| (missingBinding('TOTAL_AMOUNT') && showField('application:amount')) || (missingBinding('TOTAL_AMOUNT') && showField('application:amount'))
|| (missingBinding('DESCRIPTION') && showProjectedField('description')) || (missingBinding('DESCRIPTION') && showProjectedField('description'))
|| showField('application:payeeName') || showField('application:payeeName')
@@ -282,16 +297,16 @@ const formatDateTime = (value: string) => { const date = new Date(value); return
const hydrate = () => { const hydrate = () => {
const item = existing.value const item = existing.value
if (!item) { form.payeeName = userName.value; return } if (!item) { form.payeeName = userName.value; form.costCenterName = department.value; return }
persistedApplicationId.value = item.id persistedApplicationId.value = item.id
if (hasOwnField(item, 'title')) form.title = item.title if (hasOwnField(item, 'title')) form.title = item.title
if (hasOwnField(item, 'expenseTypeId')) form.expenseTypeId = item.expenseTypeId || undefined if (hasOwnField(item, 'paymentScenarioId')) form.paymentScenarioId = item.paymentScenarioId || undefined
if (hasOwnField(item, 'category')) form.category = item.expenseTypeName || item.category if (hasOwnField(item, 'paymentScenario')) form.paymentScenario = item.paymentScenario || item.expenseItemCategory
if (hasOwnField(item, 'totalAmount')) form.totalAmount = item.totalAmount if (hasOwnField(item, 'requestedAmount')) form.requestedAmount = item.requestedAmount
if (hasOwnField(item, 'description')) form.description = item.description if (hasOwnField(item, 'description')) form.description = item.description
if (hasOwnField(item, 'payeeName')) form.payeeName = item.payeeName if (hasOwnField(item, 'payeeName')) form.payeeName = item.payeeName
if (hasOwnField(item, 'payeeBankId')) form.payeeBankId = item.payeeBankId || undefined if (hasOwnField(item, 'payeeBankId')) form.payeeBankId = item.payeeBankId || undefined
form.items = item.expenseItems.length ? item.expenseItems.map(expense => newItem(expense, item.attachments)) : [newItem({ amount: item.totalAmount, category: item.category, description: item.title })] form.items = item.expenseItems.length ? item.expenseItems.map(expense => newItem(expense, item.attachments)) : [newItem({ amount: item.requestedAmount, expenseItemName: item.expenseItemCategory, description: item.title })]
if (item.formSnapshot?.mode === 'FEISHU') { if (item.formSnapshot?.mode === 'FEISHU') {
activeMode.value = 'FEISHU' activeMode.value = 'FEISHU'
pinnedFingerprint.value = item.formSnapshot.fingerprint pinnedFingerprint.value = item.formSnapshot.fingerprint
@@ -324,11 +339,11 @@ const loadPage = async () => {
try { try {
if (id.value) { if (id.value) {
const detail = await store.loadDetail(id.value, { strict: true }) const detail = await store.loadDetail(id.value, { strict: true })
if (store.source === 'api' && !detail?.formSnapshot) throw new Error('报销详情缺少表单快照,无法安全编辑,请刷新或联系管理员。') if (store.source === 'api' && !detail?.formSnapshot) throw new Error('付款申请详情缺少表单快照,无法安全编辑,请刷新或联系管理员。')
if (store.source === 'api' && detail?.formSnapshot && !['FEISHU', 'LOCAL', 'LEGACY'].includes(detail.formSnapshot.mode)) throw new Error('报销详情的表单快照模式无效,无法安全编辑。') if (store.source === 'api' && detail?.formSnapshot && !['FEISHU', 'LOCAL', 'LEGACY'].includes(detail.formSnapshot.mode)) throw new Error('付款申请详情的表单快照模式无效,无法安全编辑。')
} else if (!store.reimbursements.length) await store.load() } else if (!store.paymentApplications.length) await store.load()
hydrate() hydrate()
if (id.value && !existing.value) throw new Error('未找到该报销单,无法编辑') if (id.value && !existing.value) throw new Error('未找到该付款申请,无法编辑')
const [definitionResult, expenseTypesResult, payeesResult] = await Promise.allSettled([loadFormDefinitionWithRetry(), reimbursementApi.getExpenseTypes(), payeesApi.ownActive()]) const [definitionResult, expenseTypesResult, payeesResult] = await Promise.allSettled([loadFormDefinitionWithRetry(), reimbursementApi.getExpenseTypes(), payeesApi.ownActive()])
if (expenseTypesResult.status === 'rejected') throw expenseTypesResult.reason if (expenseTypesResult.status === 'rejected') throw expenseTypesResult.reason
if (payeesResult.status === 'rejected') { if (payeesResult.status === 'rejected') {
@@ -341,6 +356,10 @@ const loadPage = async () => {
throw payeesResult.reason throw payeesResult.reason
} }
} }
form.payerEntityName = existing.value?.payerEntityName || ''
form.costCenterName = existing.value?.costCenterName || department.value
form.currencyCode = existing.value?.currencyCode || 'CNY'
form.plannedPaymentDate = existing.value?.plannedPaymentDate || ''
expenseTypes.value = expenseTypesResult.value expenseTypes.value = expenseTypesResult.value
if (payeesResult.status === 'fulfilled') { if (payeesResult.status === 'fulfilled') {
activePayees.value = Array.isArray(payeesResult.value) ? payeesResult.value : [] activePayees.value = Array.isArray(payeesResult.value) ? payeesResult.value : []
@@ -353,7 +372,7 @@ const loadPage = async () => {
if (definitionResult.status === 'fulfilled') definition.value = definitionResult.value if (definitionResult.status === 'fulfilled') definition.value = definitionResult.value
else throw definitionResult.reason else throw definitionResult.reason
if (!definition.value || !Array.isArray(definition.value.fields)) throw new Error('审批模板响应格式无效,请联系管理员重新同步') if (!definition.value || !Array.isArray(definition.value.fields)) throw new Error('审批模板响应格式无效,请联系管理员重新同步')
if (!Array.isArray(expenseTypes.value) || !expenseTypes.value.length) throw new Error('没有可用费用类型,无法填写报销。') if (!Array.isArray(expenseTypes.value) || !expenseTypes.value.length) throw new Error('没有可用付款情形,无法填写申请。')
const snapshot = existing.value?.formSnapshot const snapshot = existing.value?.formSnapshot
if (definition.value.mode === 'FEISHU' && (!definition.value.fields.length || !definition.value.formFingerprint)) { if (definition.value.mode === 'FEISHU' && (!definition.value.fields.length || !definition.value.formFingerprint)) {
if (!definition.value.fields.length) throw new Error('审批模板没有可用字段,请联系管理员重新同步') if (!definition.value.fields.length) throw new Error('审批模板没有可用字段,请联系管理员重新同步')
@@ -371,7 +390,7 @@ const loadPage = async () => {
activeMode.value = 'FEISHU' activeMode.value = 'FEISHU'
pinnedFingerprint.value = definition.value.formFingerprint pinnedFingerprint.value = definition.value.formFingerprint
Object.keys(formValues).forEach(key => delete formValues[key]) Object.keys(formValues).forEach(key => delete formValues[key])
migrationNotice.value = '原有报销、付款和费用明细已保留;新模板自定义字段从空值开始,请逐项核对并填写后再保存。' migrationNotice.value = '原有付款申请、付款结果和费用项目已保留;新模板自定义字段从空值开始,请逐项核对并填写后再保存。'
} else { } else {
activeFields.value = [] activeFields.value = []
activeMode.value = 'LOCAL' activeMode.value = 'LOCAL'
@@ -383,7 +402,7 @@ const loadPage = async () => {
loading.value = false loading.value = false
} }
} }
const addItem = () => form.items.push(newItem({ category: form.category })) const addItem = () => form.items.push(newItem({ expenseItemName: form.paymentScenario }))
const removeItem = async (index: number) => { const removeItem = async (index: number) => {
const item = form.items[index] const item = form.items[index]
if (!item || item.attachmentFiles.some(file => file.status === 'pending' || file.status === 'deleting')) return if (!item || item.attachmentFiles.some(file => file.status === 'pending' || file.status === 'deleting')) return
@@ -412,7 +431,7 @@ const removeItem = async (index: number) => {
} }
form.items.splice(index, 1) form.items.splice(index, 1)
} }
const syncExpenseType = () => { const type = expenseTypes.value.find(entry => entry.id === form.expenseTypeId); form.category = type?.category || type?.name || ''; form.items.forEach(item => { item.category = form.category }) } const syncExpenseType = () => { const type = expenseTypes.value.find(entry => entry.id === form.paymentScenarioId); form.paymentScenario = type?.scenarioName || ''; form.items.forEach(item => { item.expenseItemName = form.paymentScenario }) }
const permissionBlock = (code: string, label: string, value: unknown) => { const level = fieldLevel(code); const missing = value === undefined || value === null || value === '' || Number(value) === 0; return level !== 'EDIT' && missing ? `当前字段“${label}”为${level === 'HIDDEN' ? '隐藏' : '只读'},但业务接口仍要求该字段,请联系管理员开放字段权限后再提交。` : '' } const permissionBlock = (code: string, label: string, value: unknown) => { const level = fieldLevel(code); const missing = value === undefined || value === null || value === '' || Number(value) === 0; return level !== 'EDIT' && missing ? `当前字段“${label}”为${level === 'HIDDEN' ? '隐藏' : '只读'},但业务接口仍要求该字段,请联系管理员开放字段权限后再提交。` : '' }
const errorMessage = reimbursementErrorMessage const errorMessage = reimbursementErrorMessage
const isConflict = isReimbursementConflict const isConflict = isReimbursementConflict
@@ -444,7 +463,7 @@ const migrateStaleDefinition = async () => {
pinnedFingerprint.value = latest.formFingerprint pinnedFingerprint.value = latest.formFingerprint
staleDefinition.value = false staleDefinition.value = false
showValidationErrors.value = false showValidationErrors.value = false
migrationNotice.value = '报销、付款和费用明细保持不变;仅保留了键与类型兼容的自定义值,已移除或类型变化的字段未迁移。请核对全部字段后再手动保存。' migrationNotice.value = '付款申请、付款结果和费用项目保持不变;仅保留了键与类型兼容的自定义值,已移除或类型变化的字段未迁移。请核对全部字段后再手动保存。'
} catch (error) { } catch (error) {
loadError.value = errorMessage(error, '无法读取最新审批模板,原模板和值未发生变化。') loadError.value = errorMessage(error, '无法读取最新审批模板,原模板和值未发生变化。')
} finally { } finally {
@@ -508,14 +527,21 @@ const writableProjectedField = (key: keyof ReimApplicationDetail, code?: string)
} }
const payload = (): Partial<CreateApplicationRequest> => { const payload = (): Partial<CreateApplicationRequest> => {
const result: Partial<CreateApplicationRequest> = {} const result: Partial<CreateApplicationRequest> = {}
if (writableProjectedField('title')) result.title = form.title if (linkedTravelApplicationId.value) result.linkedTravelApplicationId = linkedTravelApplicationId.value
if (writableProjectedField('expenseTypeId')) result.expenseTypeId = form.expenseTypeId! if (canWriteApplication.value && uiEdit('ui.application.form.description')) {
if (writableProjectedField('category')) result.category = form.category if (!id.value || hasOwnField(existing.value, 'payerEntityName')) result.payerEntityName = form.payerEntityName
if (writableProjectedField('totalAmount', 'application:amount')) result.totalAmount = Number(form.totalAmount.toFixed(2)) result.costCenterName = form.costCenterName
result.currencyCode = form.currencyCode
if (!id.value || hasOwnField(existing.value, 'plannedPaymentDate')) result.plannedPaymentDate = form.plannedPaymentDate || undefined
}
if (writableProjectedField('title')) { result.title = form.title; result.paymentReason = form.title }
if (writableProjectedField('paymentScenarioId')) result.paymentScenarioId = form.paymentScenarioId!
if (writableProjectedField('expenseItemCategory')) result.expenseItemCategory = form.paymentScenario
if (writableProjectedField('requestedAmount', 'application:amount')) result.requestedAmount = Number(form.requestedAmount.toFixed(2))
if (writableProjectedField('description')) result.description = form.description if (writableProjectedField('description')) result.description = form.description
if (writableProjectedField('payeeName', 'application:payeeName')) result.payeeName = form.payeeName if (writableProjectedField('payeeName', 'application:payeeName')) result.payeeName = form.payeeName
if (writableProjectedField('payeeBankId', 'application:bankAccount')) result.payeeBankId = form.payeeBankId! if (writableProjectedField('payeeBankId', 'application:bankAccount')) result.payeeBankId = form.payeeBankId!
if (writableProjectedField('expenseItems')) result.items = form.items.map((item, index) => ({ seqNo: index + 1, expenseDate: item.expenseDate, category: item.category, description: item.description, amount: normalizeMoneyAmount(item.amount), attachmentIds: [...item.attachmentIds] })) if (writableProjectedField('expenseItems')) result.expenseItems = form.items.map((item, index) => ({ seqNo: index + 1, expenseDate: item.expenseDate, expenseItemName: item.expenseItemName, description: item.description, amount: normalizeMoneyAmount(item.amount), attachmentIds: [...item.attachmentIds] }))
if (isFeishu.value && uiEdit('ui.application.form.dynamic') && (!id.value || hasOwnField(existing.value, 'formSnapshot'))) { if (isFeishu.value && uiEdit('ui.application.form.dynamic') && (!id.value || hasOwnField(existing.value, 'formSnapshot'))) {
result.formFingerprint = pinnedFingerprint.value result.formFingerprint = pinnedFingerprint.value
result.formValues = submittedCustomValues() result.formValues = submittedCustomValues()
@@ -527,6 +553,10 @@ const validate = () => {
if (hasUnsupported.value) return '审批模板包含当前系统不支持的控件,无法保存或提交,请联系管理员。' if (hasUnsupported.value) return '审批模板包含当前系统不支持的控件,无法保存或提交,请联系管理员。'
if (attachmentIntegrityError.value) return attachmentIntegrityError.value if (attachmentIntegrityError.value) return attachmentIntegrityError.value
if (hasAttachmentBlocks.value) return '请等待附件上传或移除完成,并处理上传失败的文件。' if (hasAttachmentBlocks.value) return '请等待附件上传或移除完成,并处理上传失败的文件。'
if (!form.payerEntityName.trim()) return '请填写付款单位'
if (!form.costCenterName.trim()) return '请确认成本中心'
if (!/^[A-Z]{3}$/.test(form.currencyCode)) return '币种必须使用三位英文代码'
if (!form.plannedPaymentDate) return '请填写计划付款日期'
if (attachmentRequired.value && form.items.some(item => !item.attachmentIds.length)) return '请为每条费用明细上传必填附件。' if (attachmentRequired.value && form.items.some(item => !item.attachmentIds.length)) return '请为每条费用明细上传必填附件。'
const missingCustom = activeFields.value.find(field => field.binding === 'CUSTOM' && field.required && !field.readOnly && (formValues[field.valueKey] == null || formValues[field.valueKey] === '' || (Array.isArray(formValues[field.valueKey]) && !(formValues[field.valueKey] as unknown[]).length))) const missingCustom = activeFields.value.find(field => field.binding === 'CUSTOM' && field.required && !field.readOnly && (formValues[field.valueKey] == null || formValues[field.valueKey] === '' || (Array.isArray(formValues[field.valueKey]) && !(formValues[field.valueKey] as unknown[]).length)))
if (missingCustom) return `请填写飞书表单必填项“${missingCustom.label}”` if (missingCustom) return `请填写飞书表单必填项“${missingCustom.label}”`
@@ -538,10 +568,10 @@ const validate = () => {
const issue = inspectMoneyAmount(localAmountSource(item) || item.amount)! const issue = inspectMoneyAmount(localAmountSource(item) || item.amount)!
return `第 ${badAmountIndex + 1} 条费用明细:${moneyAmountMessage(issue, '金额')}` return `第 ${badAmountIndex + 1} 条费用明细:${moneyAmountMessage(issue, '金额')}`
} }
if (writableProjectedField('totalAmount', 'application:amount')) { const totalIssue = inspectMoneyAmount(form.totalAmount > 0 ? form.totalAmount : ''); if (totalIssue) return moneyAmountMessage(totalIssue, '申请金额') } if (writableProjectedField('requestedAmount', 'application:amount')) { const totalIssue = inspectMoneyAmount(form.requestedAmount > 0 ? form.requestedAmount : ''); if (totalIssue) return moneyAmountMessage(totalIssue, '申请金额') }
if ((writableProjectedField('title') && !form.title) || (writableProjectedField('description') && !form.description) || (writableProjectedField('expenseTypeId') && !form.expenseTypeId) || (writableProjectedField('category') && !form.category) || (writableProjectedField('payeeName', 'application:payeeName') && !form.payeeName) || (writableProjectedField('payeeBankId', 'application:bankAccount') && !form.payeeBankId) || (writableProjectedField('expenseItems') && !form.items.length)) return '请完善可编辑的必填信息后再保存' if ((writableProjectedField('title') && !form.title) || (writableProjectedField('description') && !form.description) || (writableProjectedField('paymentScenarioId') && !form.paymentScenarioId) || (writableProjectedField('expenseItemCategory') && !form.paymentScenario) || (writableProjectedField('payeeName', 'application:payeeName') && !form.payeeName) || (writableProjectedField('payeeBankId', 'application:bankAccount') && !form.payeeBankId) || (writableProjectedField('expenseItems') && !form.items.length)) return '请完善可编辑的必填信息后再保存'
if (writableProjectedField('expenseItems') && form.items.some(item => !item.expenseDate || !item.category || !item.description)) return '请完善费用明细的日期、类别和说明' if (writableProjectedField('expenseItems') && form.items.some(item => !item.expenseDate || !item.expenseItemName || !item.description)) return '请完善费用项目的日期、项目名称和说明'
if (writableProjectedField('expenseItems') && writableProjectedField('totalAmount', 'application:amount') && !amountMatches.value) return '明细合计须与申请金额一致,请核对各行金额' if (writableProjectedField('expenseItems') && writableProjectedField('requestedAmount', 'application:amount') && !amountMatches.value) return '明细合计须与申请金额一致,请核对各行金额'
return '' return ''
} }
const save = async (submit: boolean) => { const save = async (submit: boolean) => {
@@ -570,7 +600,7 @@ const save = async (submit: boolean) => {
if (isFormConflict(error)) { if (isFormConflict(error)) {
staleDefinition.value = true staleDefinition.value = true
loadError.value = '审批模板已更新(409)。已保留当前输入,请点击“升级到最新模板并核对”。' loadError.value = '审批模板已更新(409)。已保留当前输入,请点击“升级到最新模板并核对”。'
} else loadError.value = errorMessage(error, '保存报销草稿失败,请重试。') } else loadError.value = errorMessage(error, '保存付款申请草稿失败,请重试。')
ElMessage.error(loadError.value) ElMessage.error(loadError.value)
} finally { } finally {
saving.value = false saving.value = false
@@ -583,7 +613,7 @@ const confirmSubmit = async () => {
previewError.value = '' previewError.value = ''
try { try {
await store.submit(persistedApplicationId.value, token) await store.submit(persistedApplicationId.value, token)
ElMessage.success('报销已提交') ElMessage.success('付款申请已提交')
previewDialog.value?.close() previewDialog.value?.close()
await router.replace(`/applications/${persistedApplicationId.value}`) await router.replace(`/applications/${persistedApplicationId.value}`)
} catch (error) { } catch (error) {
@@ -608,7 +638,7 @@ watch(() => JSON.stringify({ form, formValues }), () => {
if (preview.value && !submitting.value) invalidatePreview(false) if (preview.value && !submitting.value) invalidatePreview(false)
}) })
watch([itemsTotal, () => activeFields.value], () => { watch([itemsTotal, () => activeFields.value], () => {
if (activeFields.value.some(field => field.binding === 'TOTAL_AMOUNT' && field.type === 'FORMULA')) form.totalAmount = Number(itemsTotal.value.toFixed(2)) if (activeFields.value.some(field => field.binding === 'TOTAL_AMOUNT' && field.type === 'FORMULA')) form.requestedAmount = Number(itemsTotal.value.toFixed(2))
}, { deep: true, immediate: true }) }, { deep: true, immediate: true })
watch([rowReasonCaptured, () => form.items.map(item => item.description).join('\u0000')], () => { watch([rowReasonCaptured, () => form.items.map(item => item.description).join('\u0000')], () => {
if (!rowReasonCaptured.value) return if (!rowReasonCaptured.value) return
+515
View File
@@ -0,0 +1,515 @@
<template>
<span
ref="root"
class="searchable-select"
:class="{ 'is-open': open, 'is-disabled': disabled, 'is-multiple': multiple }"
:style="rootStyle"
>
<select
ref="nativeSelect"
class="searchable-select__native"
:name="name"
:required="required"
:disabled="disabled"
:multiple="multiple"
tabindex="-1"
aria-hidden="true"
@invalid="handleInvalid"
>
<slot />
</select>
<input
:id="id"
ref="input"
v-bind="inputAttrs"
:class="attrs.class"
:value="query"
type="text"
role="combobox"
aria-autocomplete="list"
:aria-controls="listboxId"
:aria-expanded="open"
:aria-multiselectable="multiple || undefined"
:disabled="disabled"
:required="required"
:placeholder="placeholder || '输入关键字搜索'"
autocomplete="off"
@focus="openOptions"
@input="searchOptions"
@blur="handleBlur"
@keydown="handleKeydown"
>
<button
class="searchable-select__toggle"
type="button"
tabindex="-1"
:disabled="disabled"
aria-label="展开选项"
@mousedown.prevent
@click="toggleOptions"
>
<span aria-hidden="true">⌄</span>
</button>
<ul
v-if="open"
:id="listboxId"
ref="listbox"
class="searchable-select__options"
:style="dropdownStyle"
role="listbox"
:aria-multiselectable="multiple || undefined"
>
<li v-for="option in filteredOptions" :key="option.key">
<button
type="button"
role="option"
:aria-selected="isSelected(option.value)"
:disabled="option.disabled"
@mousedown.prevent
@click="chooseOption(option)"
>
<span class="searchable-select__option-label">{{ option.label }}</span>
<small v-if="option.group">{{ option.group }}</small>
<b v-if="isSelected(option.value)" aria-label="已选择">✓</b>
</button>
</li>
<li v-if="!filteredOptions.length" class="searchable-select__empty">没有匹配选项</li>
</ul>
</span>
</template>
<script setup lang="ts">
import {
computed,
getCurrentInstance,
nextTick,
onBeforeUnmount,
onMounted,
onUpdated,
ref,
useAttrs,
watch,
} from 'vue'
defineOptions({ inheritAttrs: false })
type SelectValue = string | number | null | undefined
type SearchableOption = {
key: string
value: string
label: string
group: string
disabled: boolean
}
const props = withDefaults(defineProps<{
modelValue?: SelectValue | SelectValue[]
modelModifiers?: { number?: boolean }
value?: SelectValue | SelectValue[]
id?: string
name?: string
placeholder?: string
disabled?: boolean
required?: boolean
multiple?: boolean
}>(), {
disabled: false,
required: false,
multiple: false,
})
const emit = defineEmits<{
'update:modelValue': [value: SelectValue | SelectValue[]]
change: [event: Event]
input: [event: Event]
}>()
const attrs = useAttrs()
const root = ref<HTMLElement | null>(null)
const input = ref<HTMLInputElement | null>(null)
const listbox = ref<HTMLElement | null>(null)
const nativeSelect = ref<HTMLSelectElement | null>(null)
const options = ref<SearchableOption[]>([])
const optionsSignature = ref('')
const query = ref('')
const open = ref(false)
const searching = ref(false)
const dropdownStyle = ref<Record<string, string>>({})
const listboxId = `searchable-select-${getCurrentInstance()?.uid ?? Math.random().toString(36).slice(2)}`
const inputAttrs = computed(() => {
const { class: _class, style: _style, ...rest } = attrs
return rest
})
const rootStyle = computed(() => attrs.style as string | Record<string, string> | undefined)
const controlledValue = computed(() => props.modelValue !== undefined ? props.modelValue : props.value)
const selectedValues = computed(() => {
const value = controlledValue.value
if (props.multiple) return (Array.isArray(value) ? value : value == null ? [] : [value]).map(item => String(item))
return [value == null ? '' : String(value)]
})
const selectedLabels = computed(() => options.value
.filter(option => selectedValues.value.includes(option.value))
.map(option => option.label))
const displayValue = computed(() => selectedLabels.value.join('、'))
const normalizedTerms = computed(() => query.value.toLocaleLowerCase().split(/\s+/).filter(Boolean))
const filteredOptions = computed(() => options.value.filter(option => {
if (!searching.value || !normalizedTerms.value.length) return true
const source = `${option.label} ${option.value} ${option.group}`.toLocaleLowerCase()
return normalizedTerms.value.every(term => source.includes(term))
}))
const syncNativeSelection = (values: string[]) => {
if (!nativeSelect.value) return
Array.from(nativeSelect.value.options).forEach(option => { option.selected = values.includes(option.value) })
}
const refreshOptions = () => {
const select = nativeSelect.value
if (!select) return
const next = Array.from(select.options).map((option, index) => ({
key: `${index}-${option.value}`,
value: option.value,
label: option.label || option.textContent?.trim() || option.value,
group: option.parentElement instanceof HTMLOptGroupElement ? option.parentElement.label : '',
disabled: option.disabled || (option.parentElement instanceof HTMLOptGroupElement && option.parentElement.disabled),
}))
const signature = JSON.stringify(next)
if (signature !== optionsSignature.value) {
optionsSignature.value = signature
options.value = next
}
syncNativeSelection(selectedValues.value)
}
const convertValue = (value: string): SelectValue => {
if (!props.modelModifiers?.number || value === '') return value
const numberValue = Number(value)
return Number.isNaN(numberValue) ? value : numberValue
}
const positionDropdown = () => {
const field = input.value
if (!field) return
const rect = field.getBoundingClientRect()
const viewportGap = 8
const width = Math.min(Math.max(rect.width, 180), window.innerWidth - viewportGap * 2)
const left = Math.min(Math.max(viewportGap, rect.left), window.innerWidth - width - viewportGap)
const below = window.innerHeight - rect.bottom - viewportGap
const above = rect.top - viewportGap
const maxHeight = Math.max(120, Math.min(280, Math.max(below, above) - 6))
const top = below >= Math.min(180, maxHeight)
? rect.bottom + 4
: Math.max(viewportGap, rect.top - maxHeight - 4)
dropdownStyle.value = {
top: `${Math.round(top)}px`,
left: `${Math.round(left)}px`,
width: `${Math.round(width)}px`,
maxHeight: `${Math.round(maxHeight)}px`,
}
}
const handleOutsidePointer = (event: PointerEvent) => {
if (root.value?.contains(event.target as Node)) return
closeOptions()
}
const handleBlur = () => {
window.setTimeout(() => {
if (!root.value?.contains(document.activeElement)) closeOptions()
}, 0)
}
const addOpenListeners = () => {
window.addEventListener('resize', positionDropdown)
window.addEventListener('scroll', positionDropdown, true)
document.addEventListener('pointerdown', handleOutsidePointer, true)
}
const removeOpenListeners = () => {
window.removeEventListener('resize', positionDropdown)
window.removeEventListener('scroll', positionDropdown, true)
document.removeEventListener('pointerdown', handleOutsidePointer, true)
}
const openOptions = async () => {
if (props.disabled) return
refreshOptions()
searching.value = false
query.value = displayValue.value
if (!open.value) {
open.value = true
addOpenListeners()
}
await nextTick()
positionDropdown()
input.value?.select()
}
const closeOptions = (restoreDisplay = true) => {
if (!open.value) return
open.value = false
searching.value = false
removeOpenListeners()
if (restoreDisplay) query.value = displayValue.value
}
const toggleOptions = () => {
if (open.value) {
closeOptions()
return
}
input.value?.focus()
void openOptions()
}
const searchOptions = (event: Event) => {
query.value = (event.target as HTMLInputElement).value
searching.value = true
if (!open.value) {
open.value = true
addOpenListeners()
}
void nextTick(positionDropdown)
}
const dispatchSelectionEvents = () => {
const select = nativeSelect.value
if (!select) return
const inputEvent = new Event('input', { bubbles: true })
select.dispatchEvent(inputEvent)
emit('input', inputEvent)
const changeEvent = new Event('change', { bubbles: true })
select.dispatchEvent(changeEvent)
emit('change', changeEvent)
}
const isSelected = (value: string) => selectedValues.value.includes(value)
const chooseOption = (option: SearchableOption) => {
if (option.disabled) return
let values: string[]
if (props.multiple) {
values = isSelected(option.value)
? selectedValues.value.filter(value => value !== option.value)
: [...selectedValues.value, option.value]
} else {
values = [option.value]
}
syncNativeSelection(values)
emit('update:modelValue', props.multiple ? values.map(convertValue) : convertValue(option.value))
dispatchSelectionEvents()
if (props.multiple) {
searching.value = false
query.value = ''
void nextTick(positionDropdown)
} else {
query.value = option.label
closeOptions(false)
input.value?.focus()
}
}
const handleKeydown = (event: KeyboardEvent) => {
if (event.key === 'Escape') {
event.preventDefault()
closeOptions()
input.value?.select()
return
}
if (event.key === 'ArrowDown') {
event.preventDefault()
if (!open.value) void openOptions()
else listbox.value?.querySelector<HTMLButtonElement>('button:not(:disabled)')?.focus()
return
}
if (event.key === 'Enter' && open.value) {
const first = filteredOptions.value.find(option => !option.disabled)
if (first) {
event.preventDefault()
chooseOption(first)
}
}
}
const handleInvalid = (event: Event) => {
event.preventDefault()
input.value?.focus()
void openOptions()
}
watch([() => controlledValue.value, optionsSignature], () => {
syncNativeSelection(selectedValues.value)
if (!open.value || !searching.value) query.value = displayValue.value
}, { deep: true, flush: 'post' })
watch(() => props.disabled, disabled => {
if (disabled) closeOptions()
})
onMounted(() => {
refreshOptions()
query.value = displayValue.value
})
onUpdated(refreshOptions)
onBeforeUnmount(removeOpenListeners)
</script>
<style scoped>
.searchable-select {
position: relative;
display: inline-block;
width: 100%;
min-width: 0;
max-width: 100%;
vertical-align: middle;
}
.searchable-select__native {
position: absolute;
width: 1px;
height: 1px;
margin: 0;
padding: 0;
border: 0;
opacity: 0;
pointer-events: none;
}
.searchable-select > input {
width: 100%;
min-width: 0;
min-height: var(--control-height, 40px);
box-sizing: border-box;
padding: 8px 34px 8px 12px;
border: 1px solid var(--line-strong, #cfd7e3);
border-radius: 6px;
background: #fff;
color: var(--text, #172033);
font: inherit;
cursor: text;
}
.searchable-select > input:focus {
border-color: var(--blue, #0057d9);
outline: none;
box-shadow: 0 0 0 3px rgba(0, 87, 217, 0.12);
}
.searchable-select > input:disabled {
cursor: not-allowed;
border-color: #d3dae2;
background: var(--disabled-soft, #f3f5f7);
color: var(--disabled, #8994a3);
}
.searchable-select__toggle {
position: absolute;
top: 50%;
right: 4px;
display: grid;
width: 30px;
height: calc(100% - 8px);
padding: 0;
transform: translateY(-50%);
place-items: center;
border: 0;
background: transparent;
color: var(--muted, #667085);
cursor: pointer;
}
.is-open .searchable-select__toggle span {
transform: rotate(180deg);
}
.searchable-select__options {
position: fixed;
z-index: 2147483000;
display: grid;
gap: 3px;
margin: 0;
padding: 6px;
overflow: auto;
border: 1px solid var(--line-strong, #cfd7e3);
border-radius: 8px;
background: #fff;
box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
list-style: none;
}
.searchable-select__options li {
margin: 0;
padding: 0;
}
.searchable-select__options button {
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
width: 100%;
min-height: 36px;
gap: 8px;
padding: 7px 9px;
border: 0;
border-radius: 6px;
background: transparent;
color: var(--text, #172033);
text-align: left;
cursor: pointer;
}
.searchable-select__options button:hover:not(:disabled),
.searchable-select__options button:focus-visible,
.searchable-select__options button[aria-selected="true"] {
outline: 0;
background: var(--blue-soft, #edf4ff);
}
.searchable-select__options button:disabled {
opacity: 0.48;
cursor: not-allowed;
}
.searchable-select__option-label {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.searchable-select__options small {
color: var(--muted, #667085);
}
.searchable-select__options b {
color: var(--blue, #0057d9);
}
.searchable-select__empty {
padding: 18px 12px !important;
color: var(--muted, #667085);
text-align: center;
}
:global(.compatibility-card) .searchable-select {
width: 132px;
min-width: 112px;
flex: 0 0 132px;
}
:global(.amount-control.has-currency) > .searchable-select {
width: 96px;
min-width: 0;
}
:global(.amount-control.has-currency) > .searchable-select > input {
min-height: 40px;
padding-inline: 9px 28px;
border: 0;
border-left: 1px solid var(--line, #d9dee8);
border-radius: 0;
background: var(--surface, #f7f9fb);
box-shadow: none;
}
</style>
+291
View File
@@ -0,0 +1,291 @@
<template>
<dialog
ref="dialog"
class="app-dialog searchable-select-dialog"
aria-labelledby="searchable-select-title"
@cancel.prevent="closePicker"
@click="handleBackdropClick"
>
<section class="app-dialog__panel searchable-select-panel">
<header class="modal-head">
<div>
<span class="eyebrow">QUICK SELECT</span>
<h2 id="searchable-select-title">搜索并选择</h2>
<p v-if="selectedLabel">当前选择:{{ selectedLabel }}</p>
<p v-else>输入关键字可快速筛选下拉选项。</p>
</div>
<button class="modal-close" type="button" aria-label="关闭选择窗口" @click="closePicker">×</button>
</header>
<div class="modal-body searchable-select-body">
<label class="searchable-select-search">
<span>搜索选项</span>
<input
ref="searchInput"
v-model.trim="query"
type="search"
autocomplete="off"
placeholder="输入名称或值进行搜索"
@keydown.down.prevent="focusFirstOption"
@keydown.enter.prevent="chooseFirstOption"
>
</label>
<div class="searchable-select-summary" role="status">
找到 {{ filteredOptions.length }} 个选项
</div>
<ul v-if="filteredOptions.length" class="searchable-select-options" role="listbox">
<li v-for="option in filteredOptions" :key="option.key">
<button
type="button"
role="option"
:aria-selected="option.value === selectedValue"
:disabled="option.disabled"
@click="chooseOption(option)"
>
<span>{{ option.label }}</span>
<small v-if="option.group">{{ option.group }}</small>
<b v-if="option.value === selectedValue" aria-label="当前选项">✓</b>
</button>
</li>
</ul>
<div v-else class="searchable-select-empty">
<strong>未找到匹配选项</strong>
<span>请尝试更短的名称或其他关键字。</span>
</div>
</div>
<footer class="modal-actions">
<button class="btn" type="button" @click="closePicker">取消</button>
</footer>
</section>
</dialog>
</template>
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
type SearchableOption = {
key: string
value: string
label: string
group: string
disabled: boolean
}
const dialog = ref<HTMLDialogElement | null>(null)
const searchInput = ref<HTMLInputElement | null>(null)
const activeSelect = ref<HTMLSelectElement | null>(null)
const options = ref<SearchableOption[]>([])
const query = ref('')
const selectedValue = ref('')
const normalizedTerms = computed(() => query.value.toLocaleLowerCase().split(/\s+/).filter(Boolean))
const filteredOptions = computed(() => options.value.filter(option => {
if (!normalizedTerms.value.length) return true
const source = `${option.label} ${option.value} ${option.group}`.toLocaleLowerCase()
return normalizedTerms.value.every(term => source.includes(term))
}))
const selectedLabel = computed(() => options.value.find(option => option.value === selectedValue.value)?.label || '')
const nativeSelectFromTarget = (target: EventTarget | null) => {
if (!(target instanceof Element)) return null
const select = target.closest('select')
if (!(select instanceof HTMLSelectElement) || select.disabled || select.multiple || select.size > 1) return null
return select
}
const extractOptions = (select: HTMLSelectElement): SearchableOption[] => Array.from(select.options).map((option, index) => ({
key: `${index}-${option.value}`,
value: option.value,
label: option.label || option.textContent?.trim() || option.value,
group: option.parentElement instanceof HTMLOptGroupElement ? option.parentElement.label : '',
disabled: option.disabled || (option.parentElement instanceof HTMLOptGroupElement && option.parentElement.disabled),
}))
const openPicker = async (select: HTMLSelectElement) => {
activeSelect.value = select
options.value = extractOptions(select)
selectedValue.value = select.value
query.value = ''
select.focus({ preventScroll: true })
if (!dialog.value?.open) dialog.value?.showModal()
await nextTick()
searchInput.value?.focus()
}
const closePicker = () => {
const select = activeSelect.value
if (dialog.value?.open) dialog.value.close()
activeSelect.value = null
options.value = []
query.value = ''
if (select?.isConnected) requestAnimationFrame(() => select.focus({ preventScroll: true }))
}
const chooseOption = (option: SearchableOption) => {
const select = activeSelect.value
if (!select || option.disabled) return
select.value = option.value
selectedValue.value = option.value
select.dispatchEvent(new Event('input', { bubbles: true }))
select.dispatchEvent(new Event('change', { bubbles: true }))
closePicker()
}
const firstEnabledOption = () => filteredOptions.value.find(option => !option.disabled)
const chooseFirstOption = () => {
const option = firstEnabledOption()
if (option) chooseOption(option)
}
const focusFirstOption = () => {
const firstButton = dialog.value?.querySelector<HTMLButtonElement>('.searchable-select-options button:not(:disabled)')
firstButton?.focus()
}
const handleBackdropClick = (event: MouseEvent) => {
if (event.target === dialog.value) closePicker()
}
const handlePointerDown = (event: PointerEvent) => {
if (event.button !== 0 || event.defaultPrevented) return
const select = nativeSelectFromTarget(event.target)
if (!select) return
event.preventDefault()
event.stopImmediatePropagation()
void openPicker(select)
}
const handleClick = (event: MouseEvent) => {
const select = nativeSelectFromTarget(event.target)
if (!select) return
event.preventDefault()
event.stopImmediatePropagation()
if (!dialog.value?.open) void openPicker(select)
}
const handleKeyDown = (event: KeyboardEvent) => {
const select = nativeSelectFromTarget(event.target)
if (!select || !['Enter', ' ', 'ArrowDown'].includes(event.key)) return
if (event.key === 'ArrowDown' && !event.altKey && event.target !== document.activeElement) return
event.preventDefault()
event.stopImmediatePropagation()
void openPicker(select)
}
onMounted(() => {
document.addEventListener('pointerdown', handlePointerDown, true)
document.addEventListener('click', handleClick, true)
document.addEventListener('keydown', handleKeyDown, true)
})
onBeforeUnmount(() => {
document.removeEventListener('pointerdown', handlePointerDown, true)
document.removeEventListener('click', handleClick, true)
document.removeEventListener('keydown', handleKeyDown, true)
})
</script>
<style scoped>
.searchable-select-dialog {
--dialog-inline-size: min(620px, calc(100vw - 24px));
}
.searchable-select-panel {
min-height: min(560px, calc(100dvh - 32px));
}
.searchable-select-body {
display: flex;
flex-direction: column;
gap: 12px;
}
.searchable-select-search {
display: grid;
gap: 7px;
color: var(--text, #172033);
font-size: 13px;
font-weight: 700;
}
.searchable-select-search input {
width: 100%;
}
.searchable-select-summary {
color: var(--muted, #667085);
font-size: 12px;
}
.searchable-select-options {
display: grid;
gap: 6px;
max-height: min(360px, 48vh);
margin: 0;
padding: 0;
overflow: auto;
list-style: none;
}
.searchable-select-options button {
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
width: 100%;
min-height: 42px;
padding: 9px 12px;
border: 1px solid var(--line, #d9dee8);
border-radius: 8px;
background: #fff;
color: var(--text, #172033);
text-align: left;
cursor: pointer;
}
.searchable-select-options button:hover:not(:disabled),
.searchable-select-options button:focus-visible,
.searchable-select-options button[aria-selected="true"] {
border-color: var(--primary, #315efb);
background: color-mix(in srgb, var(--primary, #315efb) 7%, #fff);
}
.searchable-select-options button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.searchable-select-options button span {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.searchable-select-options button small {
color: var(--muted, #667085);
font-weight: 500;
}
.searchable-select-options button b {
color: var(--primary, #315efb);
}
.searchable-select-empty {
display: grid;
place-items: center;
min-height: 180px;
color: var(--muted, #667085);
text-align: center;
}
.searchable-select-empty strong {
color: var(--text, #172033);
}
@media (max-width: 640px) {
.searchable-select-panel {
min-height: calc(100dvh - 16px);
}
}
</style>
@@ -2,7 +2,7 @@
<section class="permission-editor" aria-labelledby="permission-editor-title"> <section class="permission-editor" aria-labelledby="permission-editor-title">
<header class="editor-head"> <header class="editor-head">
<div><h3 id="permission-editor-title">系统导航权限</h3><p>目录与系统导航保持同一层级;右侧只配置当前页面的字段、按钮和弹窗。</p></div> <div><h3 id="permission-editor-title">系统导航权限</h3><p>目录与系统导航保持同一层级;右侧只配置当前页面的字段、按钮和弹窗。</p></div>
<label class="permission-search"><span class="sr-only">搜索导航或权限</span><input v-model="query" type="search" placeholder="搜索菜单、页面或功能"></label> <label class="permission-search"><span class="sr-only">搜索导航或权限</span><input v-model="query" type="search" placeholder="搜索菜单、页面或功能" aria-label="搜索菜单、页面或功能"></label>
</header> </header>
<div class="tree-toolbar"> <div class="tree-toolbar">
<button class="btn small" type="button" @click="expandAll">展开全部</button><button class="btn small" type="button" @click="collapseAll">折叠全部</button> <button class="btn small" type="button" @click="expandAll">展开全部</button><button class="btn small" type="button" @click="collapseAll">折叠全部</button>
@@ -38,7 +38,7 @@
<div v-if="!visibleMenuNodes.length" class="empty-state compact-empty"><strong>未找到匹配权限</strong></div> <div v-if="!visibleMenuNodes.length" class="empty-state compact-empty"><strong>未找到匹配权限</strong></div>
</div> </div>
<section v-if="compatibility.length" class="compatibility-card" aria-labelledby="compat-title"><h4 id="compat-title">兼容权限</h4><p>这些旧权限不属于当前菜单目录,保存时原样保留,避免静默丢失。</p><ul><li v-for="item in compatibility" :key="item.code"><code>{{ item.code }}</code><select :value="item.level" :aria-label="`${item.code}兼容权限`" :disabled="disabled || !mayConfigure || Boolean(catalogError)" @change="setAccess(item.code, ($event.target as HTMLSelectElement).value as PermissionAccess)"><option value="HIDDEN">隐藏</option><option value="READ">只读</option><option value="EDIT">编辑</option></select></li></ul></section> <section v-if="compatibility.length" class="compatibility-card" aria-labelledby="compat-title"><h4 id="compat-title">兼容权限</h4><p>这些旧权限不属于当前菜单目录,保存时原样保留,避免静默丢失。</p><ul><li v-for="item in compatibility" :key="item.code"><code>{{ item.code }}</code><SearchableSelect :value="item.level" :aria-label="`${item.code}兼容权限`" :disabled="disabled || !mayConfigure || Boolean(catalogError)" @change="setAccess(item.code, ($event.target as HTMLSelectElement).value as PermissionAccess)"><option value="HIDDEN">隐藏</option><option value="READ">只读</option><option value="EDIT">编辑</option></SearchableSelect></li></ul></section>
</section> </section>
</template> </template>
@@ -33,14 +33,14 @@
</ul> </ul>
<small v-if="attachmentError(item, column.required)" :id="`${controlId(field)}-${item.key}-attachment-error`" class="field-error" role="alert">! {{ attachmentError(item, column.required) }}</small> <small v-if="attachmentError(item, column.required)" :id="`${controlId(field)}-${item.key}-attachment-error`" class="field-error" role="alert">! {{ attachmentError(item, column.required) }}</small>
</template> </template>
<select <SearchableSelect
v-else-if="column.type === 'SINGLE_SELECT'" v-else-if="column.type === 'SINGLE_SELECT'"
:id="`${controlId(field)}-${item.key}-${column.key}`" :id="`${controlId(field)}-${item.key}-${column.key}`"
:value="item[column.key]" :value="item[column.key]"
:required="column.required && !field.readOnly" :required="column.required && !field.readOnly"
:disabled="field.readOnly || column.readOnly" :disabled="field.readOnly || column.readOnly"
@change="setItemValue(item, column.key, $event)" @change="setItemValue(item, column.key, $event)"
><option value="">请选择</option><option v-for="option in column.options" :key="option.value" :value="option.label">{{ option.label }}</option></select> ><option value="">请选择</option><option v-for="option in column.options" :key="option.value" :value="option.label">{{ option.label }}</option></SearchableSelect>
<textarea <textarea
v-else-if="column.type === 'TEXTAREA'" v-else-if="column.type === 'TEXTAREA'"
:id="`${controlId(field)}-${item.key}-${column.key}`" :value="String(item[column.key] ?? '')" rows="2" :id="`${controlId(field)}-${item.key}-${column.key}`" :value="String(item[column.key] ?? '')" rows="2"
@@ -63,7 +63,7 @@
@input="setItemAmount(item, $event)" @input="setItemAmount(item, $event)"
@blur="normalizeItemAmount(item)" @blur="normalizeItemAmount(item)"
> >
<select <SearchableSelect
v-if="currencyOptions(column.child).length" v-if="currencyOptions(column.child).length"
:aria-label="`${column.label}币种`" :aria-label="`${column.label}币种`"
:value="rowCurrency(column.child, index)" :value="rowCurrency(column.child, index)"
@@ -71,7 +71,7 @@
@change="setRowCurrency(column.child, index, $event)" @change="setRowCurrency(column.child, index, $event)"
> >
<option v-for="option in currencyOptions(column.child)" :key="option.value" :value="option.value">{{ option.label }}</option> <option v-for="option in currencyOptions(column.child)" :key="option.value" :value="option.value">{{ option.label }}</option>
</select> </SearchableSelect>
</div> </div>
<small v-if="amountHasError(item, column.required)" :id="`${controlId(field)}-${item.key}-amount-error`" class="field-error" role="alert">! {{ amountError(item, column.label, column.required) }}</small> <small v-if="amountHasError(item, column.required)" :id="`${controlId(field)}-${item.key}-amount-error`" class="field-error" role="alert">! {{ amountError(item, column.label, column.required) }}</small>
<small v-else :id="`${controlId(field)}-${item.key}-amount-help`" class="form-help">请填写大于 0 的金额,最多两位小数,上限 99,999,999.99 元</small> <small v-else :id="`${controlId(field)}-${item.key}-amount-help`" class="form-help">请填写大于 0 的金额,最多两位小数,上限 99,999,999.99 元</small>
@@ -84,10 +84,10 @@
</div> </div>
</fieldset> </fieldset>
</div> </div>
<div class="amount-summary" :class="{ 'amount-mismatch': form.totalAmount > 0 && !amountMatches }"> <div class="amount-summary" :class="{ 'amount-mismatch': form.requestedAmount > 0 && !amountMatches }">
<span>明细合计</span><strong>{{ money(itemsTotal) }}</strong><span>申请金额 {{ money(form.totalAmount) }}</span> <span>明细合计</span><strong>{{ money(itemsTotal) }}</strong><span>申请金额 {{ money(form.requestedAmount) }}</span>
</div> </div>
<small v-if="form.totalAmount > 0 && !amountMatches" class="field-error amount-mismatch-tip" role="status">明细合计须与申请金额一致,请核对各行金额。</small> <small v-if="form.requestedAmount > 0 && !amountMatches" class="field-error amount-mismatch-tip" role="status">明细合计须与申请金额一致,请核对各行金额。</small>
</section> </section>
<div v-else-if="field.type === 'DISPLAY'" class="dynamic-field display-field" role="note"> <div v-else-if="field.type === 'DISPLAY'" class="dynamic-field display-field" role="note">
@@ -141,22 +141,22 @@
:aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : undefined" :aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : undefined"
@input="setFieldValue(field, ($event.target as HTMLTextAreaElement).value)" @input="setFieldValue(field, ($event.target as HTMLTextAreaElement).value)"
></textarea> ></textarea>
<select <SearchableSelect
v-else-if="field.type === 'SINGLE_SELECT'" v-else-if="field.type === 'SINGLE_SELECT'"
:id="controlId(field)" :value="String(fieldValue(field) ?? '')" :required="field.required" :aria-required="field.required" :id="controlId(field)" :value="String(fieldValue(field) ?? '')" :required="field.required" :aria-required="field.required"
:aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : undefined" :aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : undefined"
@change="setFieldValue(field, ($event.target as HTMLSelectElement).value)" @change="setFieldValue(field, ($event.target as HTMLSelectElement).value)"
> >
<option value="">请选择</option><option v-for="option in field.options" :key="option.value" :value="option.value">{{ option.label }}</option> <option value="">请选择</option><option v-for="option in field.options" :key="option.value" :value="option.value">{{ option.label }}</option>
</select> </SearchableSelect>
<select <SearchableSelect
v-else-if="field.type === 'MULTI_SELECT'" v-else-if="field.type === 'MULTI_SELECT'"
:id="controlId(field)" :value="arrayValue(field)" multiple :required="field.required" :aria-required="field.required" :id="controlId(field)" :value="arrayValue(field)" multiple :required="field.required" :aria-required="field.required"
:aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : `${controlId(field)}-help`" :aria-invalid="hasError(field)" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : `${controlId(field)}-help`"
@change="setMultiValue(field, $event)" @change="setMultiValue(field, $event)"
> >
<option v-for="option in field.options" :key="option.value" :value="option.value">{{ option.label }}</option> <option v-for="option in field.options" :key="option.value" :value="option.value">{{ option.label }}</option>
</select> </SearchableSelect>
<div v-else-if="field.type === 'DECIMAL'" class="amount-control" :class="{ 'has-currency': currencyOptions(field).length > 0 }"> <div v-else-if="field.type === 'DECIMAL'" class="amount-control" :class="{ 'has-currency': currencyOptions(field).length > 0 }">
<input <input
:id="controlId(field)" :value="fieldValue(field) as string | number | undefined" :id="controlId(field)" :value="fieldValue(field) as string | number | undefined"
@@ -165,14 +165,14 @@
:aria-describedby="hasError(field) ? `${controlId(field)}-error` : `${controlId(field)}-help`" :aria-describedby="hasError(field) ? `${controlId(field)}-error` : `${controlId(field)}-help`"
@input="setFieldValue(field, ($event.target as HTMLInputElement).value)" @input="setFieldValue(field, ($event.target as HTMLInputElement).value)"
> >
<select <SearchableSelect
v-if="currencyOptions(field).length" v-if="currencyOptions(field).length"
:aria-label="`${field.label}币种`" :aria-label="`${field.label}币种`"
:value="fieldCurrency(field)" :value="fieldCurrency(field)"
@change="setFieldCurrency(field, $event)" @change="setFieldCurrency(field, $event)"
> >
<option v-for="option in currencyOptions(field)" :key="option.value" :value="option.value">{{ option.label }}</option> <option v-for="option in currencyOptions(field)" :key="option.value" :value="option.value">{{ option.label }}</option>
</select> </SearchableSelect>
</div> </div>
<input <input
v-else v-else
@@ -200,11 +200,11 @@ import { ATTACHMENT_ACCEPT, attachmentFileValidationError, attachmentIdsMissingM
import { inspectMoneyAmount, moneyAmountMessage, normalizeMoneyAmount } from '@/utils/moneyAmount' import { inspectMoneyAmount, moneyAmountMessage, normalizeMoneyAmount } from '@/utils/moneyAmount'
import { expenseColumnClass, semanticFieldClass } from './formLayout' import { expenseColumnClass, semanticFieldClass } from './formLayout'
type ItemKey = 'expenseDate' | 'category' | 'description' | 'amount' | 'attachmentIds' type ItemKey = 'expenseDate' | 'expenseItemName' | 'description' | 'amount' | 'attachmentIds'
type AttachmentStatus = 'uploaded' | 'pending' | 'failed' | 'deleting' type AttachmentStatus = 'uploaded' | 'pending' | 'failed' | 'deleting'
interface AttachmentEntry extends Partial<ReimbursementFormAttachment> { localKey: string; fileName: string; status: AttachmentStatus; error?: string } interface AttachmentEntry extends Partial<ReimbursementFormAttachment> { localKey: string; fileName: string; status: AttachmentStatus; error?: string }
interface FormItem extends ExpenseItem { key: number; description: string; attachmentFiles: AttachmentEntry[] } interface FormItem extends ExpenseItem { key: number; description: string; attachmentFiles: AttachmentEntry[] }
interface FormModel { title: string; expenseTypeId?: number; category: string; totalAmount: number; description: string; items: FormItem[] } interface FormModel { title: string; paymentScenarioId?: number; paymentScenario: string; requestedAmount: number; description: string; items: FormItem[] }
const props = defineProps<{ const props = defineProps<{
fields: ReimbursementFormField[] fields: ReimbursementFormField[]
@@ -242,7 +242,7 @@ const canEditField = (field: ReimbursementFormField) => {
} }
const isEmpty = (value: unknown) => value == null || value === '' || (Array.isArray(value) && value.length === 0) const isEmpty = (value: unknown) => value == null || value === '' || (Array.isArray(value) && value.length === 0)
const fieldError = (field: ReimbursementFormField) => { const fieldError = (field: ReimbursementFormField) => {
if (field.binding === 'EXPENSE_TYPE' && props.form.category && !props.form.expenseTypeId) return `${field.label}无法与系统费用类型唯一匹配,请联系管理员检查模板选项` if (field.binding === 'EXPENSE_TYPE' && props.form.paymentScenario && !props.form.paymentScenarioId) return `${field.label}无法与系统付款情形唯一匹配,请联系管理员检查模板选项`
if (field.required && isEmpty(fieldValue(field))) return `${field.label}为必填项` if (field.required && isEmpty(fieldValue(field))) return `${field.label}为必填项`
if (field.type === 'DECIMAL' && !isEmpty(fieldValue(field))) { if (field.type === 'DECIMAL' && !isEmpty(fieldValue(field))) {
if (field.binding === 'TOTAL_AMOUNT') { if (field.binding === 'TOTAL_AMOUNT') {
@@ -264,9 +264,9 @@ const matchExpenseType = (option: ReimbursementFormOption | undefined): ExpenseT
const byId = unique(props.expenseTypes.filter(type => type.id === Number(option.value))) const byId = unique(props.expenseTypes.filter(type => type.id === Number(option.value)))
if (byId) return byId if (byId) return byId
} }
const byCode = unique(props.expenseTypes.filter(type => type.code === option.value)) const byCode = unique(props.expenseTypes.filter(type => type.scenarioCode === option.value))
if (byCode) return byCode if (byCode) return byCode
return unique(props.expenseTypes.filter(type => type.name === option.label)) return unique(props.expenseTypes.filter(type => type.scenarioName === option.label))
} }
const fieldValue = (field: ReimbursementFormField): unknown => { const fieldValue = (field: ReimbursementFormField): unknown => {
@@ -275,8 +275,8 @@ const fieldValue = (field: ReimbursementFormField): unknown => {
if (field.binding === 'CUSTOM') return props.formValues[field.valueKey] if (field.binding === 'CUSTOM') return props.formValues[field.valueKey]
if (field.binding === 'TITLE') return props.form.title if (field.binding === 'TITLE') return props.form.title
if (field.binding === 'EXPENSE_TYPE') { if (field.binding === 'EXPENSE_TYPE') {
if (field.type !== 'SINGLE_SELECT') return props.form.category if (field.type !== 'SINGLE_SELECT') return props.form.paymentScenario
return field.options.find(option => matchExpenseType(option)?.id === props.form.expenseTypeId)?.value return field.options.find(option => matchExpenseType(option)?.id === props.form.paymentScenarioId)?.value
|| '' || ''
} }
if (field.binding === 'TOTAL_AMOUNT') return props.itemsTotal if (field.binding === 'TOTAL_AMOUNT') return props.itemsTotal
@@ -297,9 +297,9 @@ const setFieldValue = (field: ReimbursementFormField, value: string) => {
else if (field.binding === 'EXPENSE_TYPE') { else if (field.binding === 'EXPENSE_TYPE') {
const option = field.options.find(entry => entry.value === value) const option = field.options.find(entry => entry.value === value)
const matched = matchExpenseType(option) const matched = matchExpenseType(option)
props.form.expenseTypeId = matched?.id props.form.paymentScenarioId = matched?.id
props.form.category = matched?.category || option?.label || '' props.form.paymentScenario = matched?.scenarioName || option?.label || ''
} else if (field.binding === 'TOTAL_AMOUNT') props.form.totalAmount = Number(value) || 0 } else if (field.binding === 'TOTAL_AMOUNT') props.form.requestedAmount = Number(value) || 0
else if (field.binding === 'DESCRIPTION') props.form.description = value else if (field.binding === 'DESCRIPTION') props.form.description = value
} }
const setMultiValue = (field: ReimbursementFormField, event: Event) => { const setMultiValue = (field: ReimbursementFormField, event: Event) => {
@@ -307,10 +307,10 @@ const setMultiValue = (field: ReimbursementFormField, event: Event) => {
props.formValues[field.valueKey] = [...(event.target as HTMLSelectElement).selectedOptions].map(option => option.value) props.formValues[field.valueKey] = [...(event.target as HTMLSelectElement).selectedOptions].map(option => option.value)
} }
const childBindingKeys: Partial<Record<ReimbursementFormField['binding'], ItemKey>> = { const childBindingKeys: Partial<Record<ReimbursementFormField['binding'], ItemKey>> = {
EXPENSE_DATE: 'expenseDate', EXPENSE_CATEGORY: 'category', EXPENSE_DESCRIPTION: 'description', EXPENSE_AMOUNT: 'amount', EXPENSE_ATTACHMENT: 'attachmentIds', EXPENSE_DATE: 'expenseDate', EXPENSE_CATEGORY: 'expenseItemName', EXPENSE_DESCRIPTION: 'description', EXPENSE_AMOUNT: 'amount', EXPENSE_ATTACHMENT: 'attachmentIds',
} }
const supportedChildTypes: Record<ItemKey, Set<ReimbursementFormField['type']>> = { const supportedChildTypes: Record<ItemKey, Set<ReimbursementFormField['type']>> = {
expenseDate: new Set(['DATE']), category: new Set(['TEXT', 'SINGLE_SELECT']), description: new Set(['TEXT', 'TEXTAREA']), amount: new Set(['DECIMAL']), attachmentIds: new Set(['ATTACHMENT']), expenseDate: new Set(['DATE']), expenseItemName: new Set(['TEXT', 'SINGLE_SELECT']), description: new Set(['TEXT', 'TEXTAREA']), amount: new Set(['DECIMAL']), attachmentIds: new Set(['ATTACHMENT']),
} }
const expenseFieldUnsupported = (field: ReimbursementFormField) => field.children.some(child => { const expenseFieldUnsupported = (field: ReimbursementFormField) => field.children.some(child => {
if (child.type === 'DISPLAY' && !child.required) return false if (child.type === 'DISPLAY' && !child.required) return false
+3 -2
View File
@@ -17,9 +17,10 @@ export const copyAvailableFields = <T extends Record<string, unknown>, K extends
export const paymentStatusLabel = (status: unknown) => ({ export const paymentStatusLabel = (status: unknown) => ({
PENDING_REVIEW: '待复核', PENDING_REVIEW: '待复核',
COMPLETED: '复核通过', PENDING_RECEIPT: '待补付款回单',
COMPLETED: '已登记',
REJECTED: '已拒绝', REJECTED: '已拒绝',
ACTIVE: '复核通过', ACTIVE: '已登记',
}[String(status ?? '')] || String(status ?? '')) }[String(status ?? '')] || String(status ?? ''))
/** /**
+3
View File
@@ -5,11 +5,14 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css' import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue' import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue' import App from './App.vue'
import SearchableSelect from './components/SearchableSelect.vue'
import router from './router' import router from './router'
import { dialogDrag } from './directives/dialogDrag' import { dialogDrag } from './directives/dialogDrag'
import './assets/main.css' import './assets/main.css'
import './assets/ui-system.css'
const app = createApp(App) const app = createApp(App)
app.component('SearchableSelect', SearchableSelect)
// Register Element Plus icons // Register Element Plus icons
for (const [key, component] of Object.entries(ElementPlusIconsVue)) { for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
+1 -1
View File
@@ -13,7 +13,7 @@ export const reimbursementErrorMessage = (error: unknown, fallback: string) => {
export const reimbursementPayeeSelectorErrorMessage = (error: unknown, fallback: string) => export const reimbursementPayeeSelectorErrorMessage = (error: unknown, fallback: string) =>
(error as HttpError | null)?.response?.status === 403 (error as HttpError | null)?.response?.status === 403
? '当前账号没有发起或编辑报销权限' ? '当前账号没有发起或编辑付款申请权限'
: reimbursementErrorMessage(error, fallback) : reimbursementErrorMessage(error, fallback)
export const isReimbursementConflict = (error: unknown) => export const isReimbursementConflict = (error: unknown) =>
+18 -13
View File
@@ -1,5 +1,5 @@
export type SettingsCategoryKey = 'business' | 'system' export type SettingsCategoryKey = 'business' | 'system'
export type SettingsChildKey = 'legal-entities' | 'cost-centers' | 'currencies' | 'expense-types' | 'budgets' | 'payees' | 'payment-methods' | 'payment-accounts' | 'integration' | 'people' | 'tasks' | 'logs' export type SettingsChildKey = 'legal-entities' | 'cost-centers' | 'currencies' | 'expense-types' | 'budgets' | 'payees' | 'payment-methods' | 'payment-accounts' | 'integration' | 'people' | 'permission-groups' | 'roles' | 'tasks' | 'logs'
export type SettingsIconKey = 'expense' | 'payee' | 'integration' | 'people' | 'tasks' | 'logs' export type SettingsIconKey = 'expense' | 'payee' | 'integration' | 'people' | 'tasks' | 'logs'
export type SettingsRouteTarget = { export type SettingsRouteTarget = {
@@ -51,11 +51,12 @@ export type SettingsNavigationCategory = {
} }
export type SettingsNavigationGroup = { key: string; label: string; children: SettingsNavigationChild[]; active: boolean; openByDefault?: boolean } export type SettingsNavigationGroup = { key: string; label: string; children: SettingsNavigationChild[]; active: boolean; openByDefault?: boolean }
const activeFor = (key: SettingsChildKey, path: string) => { const activeFor = (key: SettingsChildKey, location: SettingsNavigationLocation) => {
const { path, tab } = location
if (key === 'legal-entities') return path.startsWith('/legal-entities') if (key === 'legal-entities') return path.startsWith('/legal-entities')
if (key === 'cost-centers') return path.startsWith('/cost-centers') if (key === 'cost-centers') return path.startsWith('/cost-centers')
if (key === 'currencies') return path.startsWith('/currencies') if (key === 'currencies') return path.startsWith('/currencies')
if (key === 'expense-types') return path.startsWith('/expense-types') if (key === 'expense-types') return path.startsWith('/payment-scenarios') || path.startsWith('/expense-types')
if (key === 'budgets') return path.startsWith('/budgets') if (key === 'budgets') return path.startsWith('/budgets')
if (key === 'payees') return path.startsWith('/payees') if (key === 'payees') return path.startsWith('/payees')
if (key === 'payment-methods') return path.startsWith('/payment-methods') if (key === 'payment-methods') return path.startsWith('/payment-methods')
@@ -63,7 +64,9 @@ const activeFor = (key: SettingsChildKey, path: string) => {
if (key === 'integration') { if (key === 'integration') {
return ['/integration-config', '/kingdee-accounts'].some(prefix => path.startsWith(prefix)) return ['/integration-config', '/kingdee-accounts'].some(prefix => path.startsWith(prefix))
} }
if (key === 'people') return path.startsWith('/users') || path.startsWith('/feishu-directory') if (key === 'people') return path.startsWith('/feishu-directory') || (path.startsWith('/users') && tab === 'directory')
if (key === 'permission-groups') return path.startsWith('/users') && tab === 'groups'
if (key === 'roles') return path.startsWith('/users') && tab === 'roles'
if (key === 'tasks') return path.startsWith('/scheduled-tasks') if (key === 'tasks') return path.startsWith('/scheduled-tasks')
return path.startsWith('/logs') return path.startsWith('/logs')
} }
@@ -74,7 +77,7 @@ const child = (
icon: SettingsIconKey, icon: SettingsIconKey,
to: SettingsRouteTarget, to: SettingsRouteTarget,
location: SettingsNavigationLocation, location: SettingsNavigationLocation,
): SettingsNavigationChild => ({ key, label, icon, to, active: activeFor(key, location.path) }) ): SettingsNavigationChild => ({ key, label, icon, to, active: activeFor(key, location) })
export const buildSystemSettingsNavigation = ( export const buildSystemSettingsNavigation = (
access: SettingsNavigationAccess, access: SettingsNavigationAccess,
@@ -89,12 +92,12 @@ export const buildSystemSettingsNavigation = (
].filter((item): item is SettingsNavigationChild => Boolean(item)) ].filter((item): item is SettingsNavigationChild => Boolean(item))
if (masterData.length) business.push(group('master-data', '财务主数据', masterData, true)) if (masterData.length) business.push(group('master-data', '财务主数据', masterData, true))
const expenseBudget = [ const expenseBudget = [
access.expenseTypes ? child('expense-types', '费用类型', 'expense', { path: '/expense-types' }, location) : null, access.expenseTypes ? child('expense-types', '付款情形', 'expense', { path: '/payment-scenarios' }, location) : null,
access.budgets ? child('budgets', '预算管理', 'expense', { path: '/budgets' }, location) : null, access.budgets ? child('budgets', '预算管理', 'expense', { path: '/budgets' }, location) : null,
].filter((item): item is SettingsNavigationChild => Boolean(item)) ].filter((item): item is SettingsNavigationChild => Boolean(item))
if (expenseBudget.length) business.push(group('expense-budget', '费用与预算', expenseBudget)) if (expenseBudget.length) business.push(group('expense-budget', '付款与预算', expenseBudget))
const paymentConfig = [ const paymentConfig = [
access.payees ? child('payees', '付款对象与收款账户', 'payee', { path: '/payees' }, location) : null, access.payees ? child('payees', '收款方与收款账户', 'payee', { path: '/payees' }, location) : null,
access.paymentMethods ? child('payment-methods', '付款方式', 'expense', { path: '/payment-methods' }, location) : null, access.paymentMethods ? child('payment-methods', '付款方式', 'expense', { path: '/payment-methods' }, location) : null,
access.paymentAccounts ? child('payment-accounts', '公司付款账户', 'people', { path: '/payment-accounts' }, location) : null, access.paymentAccounts ? child('payment-accounts', '公司付款账户', 'people', { path: '/payment-accounts' }, location) : null,
].filter((item): item is SettingsNavigationChild => Boolean(item)) ].filter((item): item is SettingsNavigationChild => Boolean(item))
@@ -102,10 +105,12 @@ export const buildSystemSettingsNavigation = (
const system: SettingsNavigationGroup[] = [] const system: SettingsNavigationGroup[] = []
if (access.iam || access.directory) { if (access.iam || access.directory) {
const to = access.iam const organizationAccess = [
? { path: '/users' } access.directory || access.iam ? child('people', '人员与组织', 'people', { path: '/users', query: { tab: 'directory' } }, location) : null,
: { path: '/users', query: { tab: 'directory' } } access.iam ? child('permission-groups', '权限组', 'people', { path: '/users', query: { tab: 'groups' } }, location) : null,
system.push(group('organization-access', '组织与权限', [child('people', '人员与权限', 'people', to, location)], true)) access.iam ? child('roles', '角色', 'people', { path: '/users', query: { tab: 'roles' } }, location) : null,
].filter((item): item is SettingsNavigationChild => Boolean(item))
system.push(group('organization-access', '组织与权限', organizationAccess, true))
} }
const runtime: SettingsNavigationChild[] = [] const runtime: SettingsNavigationChild[] = []
if (access.integration || access.kingdee) runtime.push(child('integration', '集成管理', 'integration', access.integration ? { path: '/integration-config' } : { path: '/integration-config', query: { tab: 'kingdee' } }, location)) if (access.integration || access.kingdee) runtime.push(child('integration', '集成管理', 'integration', access.integration ? { path: '/integration-config' } : { path: '/integration-config', query: { tab: 'kingdee' } }, location))
@@ -115,7 +120,7 @@ export const buildSystemSettingsNavigation = (
return [ return [
{ key: 'business' as const, label: '业务配置', groups: business }, { key: 'business' as const, label: '业务配置', groups: business },
{ key: 'system' as const, label: '系统管理', groups: system }, { key: 'system' as const, label: '系统配置', groups: system },
].filter(category => category.groups.length > 0) ].filter(category => category.groups.length > 0)
} }
+9 -8
View File
@@ -48,19 +48,19 @@ const routes: RouteRecordRaw[] = [
path: 'applications/new', path: 'applications/new',
name: 'ApplicationNew', name: 'ApplicationNew',
component: () => import('@/components/ReimbursementForm.vue'), component: () => import('@/components/ReimbursementForm.vue'),
meta: { title: '发起报销', pageAccess: 'applicationCreate' }, meta: { title: '发起付款申请', pageAccess: 'applicationCreate' },
}, },
{ {
path: 'applications/:id', path: 'applications/:id',
name: 'ApplicationDetail', name: 'ApplicationDetail',
component: () => import('@/views/ApplicationDetail.vue'), component: () => import('@/views/ApplicationDetail.vue'),
meta: { title: '报销单详情', hidden: true, pageAccess: 'applicationDetail' }, meta: { title: '付款申请详情', hidden: true, pageAccess: 'applicationDetail' },
}, },
{ {
path: 'applications/:id/edit', path: 'applications/:id/edit',
name: 'ApplicationEdit', name: 'ApplicationEdit',
component: () => import('@/components/ReimbursementForm.vue'), component: () => import('@/components/ReimbursementForm.vue'),
meta: { title: '编辑报销', hidden: true, pageAccess: 'applicationEdit' }, meta: { title: '编辑付款申请', hidden: true, pageAccess: 'applicationEdit' },
}, },
{ {
path: 'finance-receipt', path: 'finance-receipt',
@@ -89,16 +89,17 @@ const routes: RouteRecordRaw[] = [
meta: { title: '操作日志', pageAccess: 'logs' }, meta: { title: '操作日志', pageAccess: 'logs' },
}, },
{ {
path: 'expense-types', path: 'payment-scenarios',
alias: 'expense-types',
name: 'ExpenseTypes', name: 'ExpenseTypes',
component: () => import('@/views/ExpenseTypes.vue'), component: () => import('@/views/ExpenseTypes.vue'),
meta: { title: '费用类型', pageAccess: 'expenseTypes' }, meta: { title: '付款情形', pageAccess: 'expenseTypes' },
}, },
{ {
path: 'payees', path: 'payees',
name: 'Payees', name: 'Payees',
component: () => import('@/views/Payees.vue'), component: () => import('@/views/Payees.vue'),
meta: { title: '付款对象与收款账户', pageAccess: 'payees' }, meta: { title: '收款方与收款账户', pageAccess: 'payees' },
}, },
{ path: 'legal-entities', name: 'LegalEntities', component: () => import('@/views/business-config/LegalEntities.vue'), meta: { title: '法人主体', pageAccess: 'legalEntities' } }, { path: 'legal-entities', name: 'LegalEntities', component: () => import('@/views/business-config/LegalEntities.vue'), meta: { title: '法人主体', pageAccess: 'legalEntities' } },
{ path: 'cost-centers', name: 'CostCenters', component: () => import('@/views/business-config/CostCenters.vue'), meta: { title: '成本中心', pageAccess: 'costCenters' } }, { path: 'cost-centers', name: 'CostCenters', component: () => import('@/views/business-config/CostCenters.vue'), meta: { title: '成本中心', pageAccess: 'costCenters' } },
@@ -111,7 +112,7 @@ const routes: RouteRecordRaw[] = [
name: 'Users', name: 'Users',
component: () => import('@/views/Users.vue'), component: () => import('@/views/Users.vue'),
meta: { meta: {
title: '人员与权限', title: '人员与组织',
pageAccess: 'users', pageAccess: 'users',
}, },
}, },
@@ -123,7 +124,7 @@ const routes: RouteRecordRaw[] = [
path: 'scheduled-tasks', path: 'scheduled-tasks',
name: 'ScheduledTasks', name: 'ScheduledTasks',
component: () => import('@/views/ScheduledTasks.vue'), component: () => import('@/views/ScheduledTasks.vue'),
meta: { title: '自动任务', pageAccess: 'scheduledTasks' }, meta: { title: '定时任务', pageAccess: 'scheduledTasks' },
}, },
{ {
path: 'integration-config', path: 'integration-config',
+40 -37
View File
@@ -6,7 +6,7 @@ import { consumeScopedRows, hasOwnField, paymentStatusLabel } from '@/finance/fi
export type DataSource = 'connecting' | 'api' | 'error' export type DataSource = 'connecting' | 'api' | 'error'
export type StatusTone = 'info' | 'pending' | 'success' | 'danger' | 'draft' | 'neutral' export type StatusTone = 'info' | 'pending' | 'success' | 'danger' | 'draft' | 'neutral'
const labels: Record<string, string> = { DRAFT: '草稿', SUBMITTED: '已提交', PENDING: '审批中', APPROVING: '审批中', APPROVED: '审批通过', REJECTED: '退回', RETURNED: '退回', CANCELLED: '已取消', RECEIPT_PENDING: '待收单', RECEIVED: '已收单', UNRECEIVED: '未触发', UNPAID: '未付款', PARTIAL: '部分付款', PAID: '已付款', OCCUPIED: '已占用', EXECUTED: '已转执行', ACTIVE: '复核通过', COMPLETED: '复核通过', PENDING_REVIEW: '待复核', INACTIVE: '停用' } const labels: Record<string, string> = { DRAFT: '草稿', SUBMITTED: '已提交', PENDING: '审批中', APPROVING: '审批中', APPROVED: '审批通过', REJECTED: '退回', RETURNED: '退回', CANCELLED: '已取消', RECEIPT_PENDING: '待核对', RECEIVED: '已核对', '待收单': '待核对', '已收单': '已核对', UNRECEIVED: '未启用', UNPAID: '未付款', PARTIAL: '部分付款', PAID: '已付款', OCCUPIED: '已占用', EXECUTED: '已转执行', ACTIVE: '已登记', COMPLETED: '已登记', PENDING_RECEIPT: '待补付款回单', PENDING_REVIEW: '待复核', INACTIVE: '停用' }
const text = (value: unknown, fallback = '') => String(value ?? fallback) const text = (value: unknown, fallback = '') => String(value ?? fallback)
const number = (value: unknown) => Number(value || 0) const number = (value: unknown) => Number(value || 0)
const status = (value: unknown, fallback: string) => labels[text(value)] || text(value, fallback) const status = (value: unknown, fallback: string) => labels[text(value)] || text(value, fallback)
@@ -14,13 +14,15 @@ const budgetStatus = (value: unknown) => ({ PENDING: '待处理', OCCUPIED: '已
export const useWorkbenchStore = defineStore('workbench', () => { export const useWorkbenchStore = defineStore('workbench', () => {
const user = ref<UserProfile | null>(null) const user = ref<UserProfile | null>(null)
const reimbursements = ref<ReimApplicationDetail[]>([]) const paymentApplications = ref<ReimApplicationDetail[]>([])
const payments = ref<PaymentRecord[]>([]) const payments = ref<PaymentRecord[]>([])
const source = ref<DataSource>('connecting') const source = ref<DataSource>('connecting')
const loading = ref(false) const loading = ref(false)
const error = ref('') const error = ref('')
const financeQueueError = ref('') const financeQueueError = ref('')
const notifications = ref(0) const notifications = ref(0)
const financeCheckEnabled = ref(false)
const independentPaymentReviewEnabled = ref(false)
let loadPromise: Promise<void> | null = null let loadPromise: Promise<void> | null = null
let sessionVersion = 0 let sessionVersion = 0
const queueVersions: Record<'receipt' | 'payment', number> = { receipt: 0, payment: 0 } const queueVersions: Record<'receipt' | 'payment', number> = { receipt: 0, payment: 0 }
@@ -30,15 +32,15 @@ export const useWorkbenchStore = defineStore('workbench', () => {
id: raw.id ?? raw.paymentNo ?? `payment-${Date.now()}`, id: raw.id ?? raw.paymentNo ?? `payment-${Date.now()}`,
paymentNo: text(raw.paymentNo, raw.reference || raw.id), paymentNo: text(raw.paymentNo, raw.reference || raw.id),
applicationId: raw.applicationId ?? raw.reimbursementId, applicationId: raw.applicationId ?? raw.reimbursementId,
paymentAmount: number(raw.paymentAmount ?? raw.amount), actualPaymentAmount: number(raw.actualPaymentAmount ?? raw.paymentAmount ?? raw.amount),
totalAmount: number(raw.totalAmount), approvedAmount: number(raw.approvedAmount ?? raw.totalAmount),
paidAmount: number(raw.paidAmount ?? raw.amount), paidAmount: number(raw.paidAmount ?? raw.amount),
remainingAmount: number(raw.remainingAmount), remainingAmount: number(raw.remainingAmount),
paymentMethod: text(raw.paymentMethod, raw.method || '银行转账'), actualPaymentMethod: text(raw.actualPaymentMethod ?? raw.paymentMethod, raw.method || ''),
referenceNo: hasOwnField(raw, 'referenceNo') ? raw.referenceNo : raw.reference, referenceNo: hasOwnField(raw, 'referenceNo') ? raw.referenceNo : raw.reference,
paymentStatus: paymentStatusLabel(raw.paymentStatus) || '待复核', paymentStatus: paymentStatusLabel(raw.paymentStatus) || '待复核',
operatorName: hasOwnField(raw, 'operatorName') ? raw.operatorName : undefined, operatorName: hasOwnField(raw, 'operatorName') ? raw.operatorName : undefined,
paymentTime: hasOwnField(raw, 'paymentTime') ? raw.paymentTime : raw.time, resultRecordedAt: raw.resultRecordedAt ?? raw.paymentTime ?? raw.actualPaymentDate ?? raw.time,
remark: hasOwnField(raw, 'remark') ? raw.remark : undefined, remark: hasOwnField(raw, 'remark') ? raw.remark : undefined,
canVerify: raw.canVerify === true, canVerify: raw.canVerify === true,
canReject: raw.canReject === true, canReject: raw.canReject === true,
@@ -52,30 +54,29 @@ export const useWorkbenchStore = defineStore('workbench', () => {
const approval = application === '草稿' && !['退回', 'REJECTED', 'RETURNED', 'CANCELLED', '已取消'].includes(approvalRaw) const approval = application === '草稿' && !['退回', 'REJECTED', 'RETURNED', 'CANCELLED', '已取消'].includes(approvalRaw)
? '未触发' ? '未触发'
: status(approvalRaw, '未触发') : status(approvalRaw, '未触发')
const receiptRaw = text(raw.receiptStatus) const financeCheck = status(raw.financeCheckStatus ?? raw.receiptStatus, '未启用')
const receipt = approval === '审批通过' && (!receiptRaw || ['UNRECEIVED', '未触发'].includes(receiptRaw))
? '待收单'
: status(raw.receiptStatus, '未触发')
const normalized = { const normalized = {
...raw, ...raw,
id: raw.id, id: raw.id,
applicationNo: text(raw.applicationNo, raw.id), applicationNo: text(raw.applicationNo, raw.id),
title: text(raw.title, '未命名报销'), title: text(raw.title, '未命名付款申请'),
departmentName: text(raw.departmentName, raw.department), departmentName: text(raw.departmentName, raw.department),
expenseTypeName: text(raw.expenseTypeName, raw.expenseType || '员工报销'), paymentScenario: text(raw.paymentScenario, raw.expenseTypeName || raw.expenseType || '员工费用报销'),
category: text(raw.category), paymentScenarioId: raw.paymentScenarioId ?? raw.expenseTypeId,
expenseItemCategory: text(raw.expenseItemCategory, raw.category),
requestedAmount: number(raw.requestedAmount ?? raw.totalAmount),
applicationStatus: application, applicationStatus: application,
approvalStatus: approval, approvalStatus: approval,
currentApprovalNode: text(raw.currentApprovalNode, raw.approvalNode || '—'), currentApprovalNode: text(raw.currentApprovalNode, raw.approvalNode || '—'),
receiptStatus: receipt, financeCheckStatus: financeCheck,
paymentStatus: status(raw.paymentStatus, '未付款'), paymentStatus: status(raw.paymentStatus, '未付款'),
budgetStatus: budgetStatus(raw.budgetStatus), budgetStatus: budgetStatus(raw.budgetStatus),
sourceDocNo: text(raw.sourceDocNo), sourceDocNo: text(raw.sourceDocNo),
sourceStatus: text(raw.sourceStatus, '未关联'), syncStatus: text(raw.syncStatus ?? raw.sourceStatus, '未同步'),
submitTime: text(raw.submitTime, raw.date), submitTime: text(raw.submitTime, raw.date),
createdAt: text(raw.createdAt, raw.date), createdAt: text(raw.createdAt, raw.date),
updatedAt: text(raw.updatedAt, raw.lastUpdated), updatedAt: text(raw.updatedAt, raw.lastUpdated),
paidAmountSnapshot: raw.paidAmount == null ? undefined : number(raw.paidAmount), paidAmountSnapshot: raw.paidAmount == null && raw.actualPaymentAmount == null ? undefined : number(raw.paidAmount ?? raw.actualPaymentAmount),
remainingAmountSnapshot: raw.remainingAmount == null ? undefined : number(raw.remainingAmount), remainingAmountSnapshot: raw.remainingAmount == null ? undefined : number(raw.remainingAmount),
availableActions: Array.isArray(raw.availableActions) availableActions: Array.isArray(raw.availableActions)
? raw.availableActions.filter((action: unknown): action is string => typeof action === 'string') ? raw.availableActions.filter((action: unknown): action is string => typeof action === 'string')
@@ -89,14 +90,15 @@ export const useWorkbenchStore = defineStore('workbench', () => {
return normalized return normalized
} }
const linkedPayments = (item: ReimApplicationDetail) => payments.value.filter(payment => String(payment.applicationId) === String(item.id)) const linkedPayments = (item: ReimApplicationDetail) => payments.value.filter(payment => String(payment.applicationId) === String(item.id))
const completedPayment = (payment: PaymentRecord) => ['复核通过', '有效', 'COMPLETED', 'ACTIVE'].includes(payment.paymentStatus) const completedPayment = (payment: PaymentRecord) => ['已登记', '复核通过', '有效', '待补付款回单', 'COMPLETED', 'PENDING_RECEIPT', 'ACTIVE'].includes(payment.paymentStatus)
const reservedPayment = (payment: PaymentRecord) => completedPayment(payment) || ['待复核', 'PENDING_REVIEW'].includes(payment.paymentStatus) const reservedPayment = (payment: PaymentRecord) => completedPayment(payment) || ['待复核', 'PENDING_REVIEW'].includes(payment.paymentStatus)
const paidAmount = (item: ReimApplicationDetail) => { const linked = linkedPayments(item).filter(completedPayment); return linked.length ? linked.reduce((sum, payment) => sum + number(payment.paymentAmount ?? payment.paidAmount), 0) : item.paidAmountSnapshot ?? 0 } const payableAmount = (item: ReimApplicationDetail) => number(item.approvedAmount ?? item.requestedAmount)
const balance = (item: ReimApplicationDetail) => { const reserved = linkedPayments(item).filter(reservedPayment).reduce((sum, payment) => sum + number(payment.paymentAmount), 0); return Math.max(0, number(item.totalAmount) - Math.max(paidAmount(item), reserved)) } const paidAmount = (item: ReimApplicationDetail) => { const linked = linkedPayments(item).filter(completedPayment); return linked.length ? linked.reduce((sum, payment) => sum + number(payment.actualPaymentAmount ?? payment.paidAmount), 0) : item.paidAmountSnapshot ?? 0 }
const refreshPaymentStatuses = () => reimbursements.value.forEach(item => { const linked = linkedPayments(item); if (!linked.length && item.paidAmountSnapshot === undefined) return; if (hasOwnField(item, 'payments')) item.payments = linked; const paid = paidAmount(item); item.paymentStatus = paid <= 0 ? '未付款' : paid >= number(item.totalAmount) ? '已付款' : '部分付款' }) const balance = (item: ReimApplicationDetail) => { const reserved = linkedPayments(item).filter(reservedPayment).reduce((sum, payment) => sum + number(payment.actualPaymentAmount), 0); return Math.max(0, payableAmount(item) - Math.max(paidAmount(item), reserved)) }
const summaries = computed<ReimApplicationSummary[]>(() => reimbursements.value.map(item => ({ ...item } as ReimApplicationSummary))) const refreshPaymentStatuses = () => paymentApplications.value.forEach(item => { const linked = linkedPayments(item); if (!linked.length && item.paidAmountSnapshot === undefined) return; if (hasOwnField(item, 'payments')) item.payments = linked; const paid = paidAmount(item); item.paymentStatus = paid <= 0 ? '未付款' : paid >= payableAmount(item) ? '已付款' : '部分付款' })
const summaries = computed<ReimApplicationSummary[]>(() => paymentApplications.value.map(item => ({ ...item } as ReimApplicationSummary)))
const setSnapshot = (payload: any) => { payments.value = (payload?.payments || []).map(normalizePayment); const rows: ReimApplicationDetail[] = (payload?.reimbursements || payload?.content || []).map(normalize); user.value = payload?.user || user.value; reimbursements.value = consumeScopedRows(rows); notifications.value = number(payload?.notifications); source.value = 'api'; refreshPaymentStatuses() } const setSnapshot = (payload: any) => { payments.value = (payload?.payments || []).map(normalizePayment); const rows: ReimApplicationDetail[] = (payload?.paymentApplications || payload?.reimbursements || payload?.content || []).map(normalize); user.value = payload?.user || user.value; paymentApplications.value = consumeScopedRows(rows); notifications.value = number(payload?.notifications); financeCheckEnabled.value = payload?.financeCheckEnabled === true; independentPaymentReviewEnabled.value = payload?.independentPaymentReviewEnabled === true; source.value = 'api'; refreshPaymentStatuses() }
const load = async () => { const load = async () => {
if (loadPromise) return loadPromise if (loadPromise) return loadPromise
const requestVersion = sessionVersion const requestVersion = sessionVersion
@@ -105,12 +107,12 @@ export const useWorkbenchStore = defineStore('workbench', () => {
error.value = '' error.value = ''
try { try {
const payload = await reimbursementApi.getWorkbench() const payload = await reimbursementApi.getWorkbench()
if (!payload || (!Array.isArray(payload.reimbursements) && !Array.isArray(payload.content))) throw new Error('工作台数据格式不兼容') if (!payload || (!Array.isArray(payload.paymentApplications) && !Array.isArray(payload.reimbursements) && !Array.isArray(payload.content))) throw new Error('工作台数据格式不兼容')
if (requestVersion !== sessionVersion) return if (requestVersion !== sessionVersion) return
setSnapshot(payload) setSnapshot(payload)
} catch { } catch {
if (requestVersion !== sessionVersion) return if (requestVersion !== sessionVersion) return
reimbursements.value = [] paymentApplications.value = []
payments.value = [] payments.value = []
source.value = 'error' source.value = 'error'
error.value = '无法连接财务服务,为避免展示过期数据,业务记录已隐藏。' error.value = '无法连接财务服务,为避免展示过期数据,业务记录已隐藏。'
@@ -125,9 +127,9 @@ export const useWorkbenchStore = defineStore('workbench', () => {
if (loadPromise === currentPromise) loadPromise = null if (loadPromise === currentPromise) loadPromise = null
} }
} }
const loadList = async () => { if (!reimbursements.value.length) await load() } const loadList = async () => { if (!paymentApplications.value.length) await load() }
const getById = (id: string | number) => reimbursements.value.find(item => String(item.id) === String(id)) || null const getById = (id: string | number) => paymentApplications.value.find(item => String(item.id) === String(id)) || null
const replaceApplication = (detail: ReimApplicationDetail) => { const normalized = normalize(detail); reimbursements.value = reimbursements.value.some(item => String(item.id) === String(detail.id)) ? reimbursements.value.map(item => String(item.id) === String(detail.id) ? normalized : item) : [...reimbursements.value, normalized]; return normalized } const replaceApplication = (detail: ReimApplicationDetail) => { const normalized = normalize(detail); paymentApplications.value = paymentApplications.value.some(item => String(item.id) === String(detail.id)) ? paymentApplications.value.map(item => String(item.id) === String(detail.id) ? normalized : item) : [...paymentApplications.value, normalized]; return normalized }
const loadDetail = async (id: string | number, options?: { strict?: boolean }) => { const loadDetail = async (id: string | number, options?: { strict?: boolean }) => {
const requestVersion = sessionVersion const requestVersion = sessionVersion
try { try {
@@ -158,36 +160,37 @@ export const useWorkbenchStore = defineStore('workbench', () => {
if (!rows.length || rows.length < 100 || page >= 1000) break if (!rows.length || rows.length < 100 || page >= 1000) break
} while (allRows.length < total) } while (allRows.length < total)
if (requestVersion !== sessionVersion || queueVersion !== queueVersions[kind]) return if (requestVersion !== sessionVersion || queueVersion !== queueVersions[kind]) return
const byId = new Map(reimbursements.value.map(item => [String(item.id), item])) const byId = new Map(paymentApplications.value.map(item => [String(item.id), item]))
allRows.map(normalize).forEach((item: ReimApplicationDetail) => byId.set(String(item.id), item)) allRows.map(normalize).forEach((item: ReimApplicationDetail) => byId.set(String(item.id), item))
reimbursements.value = consumeScopedRows([...byId.values()]) paymentApplications.value = consumeScopedRows([...byId.values()])
if (kind === 'payment') await loadPaymentHistory() if (kind === 'payment') await loadPaymentHistory()
source.value = 'api' source.value = 'api'
financeQueueError.value = '' financeQueueError.value = ''
} catch { if (requestVersion === sessionVersion && queueVersion === queueVersions[kind]) financeQueueError.value = kind === 'receipt' ? '无法读取财务收单队列,请重试。' : '无法读取付款队列或复核记录,请重试。' } } catch { if (requestVersion === sessionVersion && queueVersion === queueVersions[kind]) financeQueueError.value = kind === 'receipt' ? '无法读取财务核对队列,请重试。' : '无法读取付款结果或复核记录,请重试。' }
finally { if (requestVersion === sessionVersion) loading.value = false } finally { if (requestVersion === sessionVersion) loading.value = false }
} }
const save = async (payload: Partial<CreateApplicationRequest>, id?: string | number) => replaceApplication(id ? await reimbursementApi.update(id, payload) : await reimbursementApi.create(payload)) const save = async (payload: Partial<CreateApplicationRequest>, id?: string | number) => replaceApplication(id ? await reimbursementApi.update(id, payload) : await reimbursementApi.create(payload))
const removeApplication = async (id: string | number) => { const removeApplication = async (id: string | number) => {
await reimbursementApi.delete(id) await reimbursementApi.delete(id)
reimbursements.value = reimbursements.value.filter(item => String(item.id) !== String(id)) paymentApplications.value = paymentApplications.value.filter(item => String(item.id) !== String(id))
payments.value = payments.value.filter(payment => String(payment.applicationId) !== String(id)) payments.value = payments.value.filter(payment => String(payment.applicationId) !== String(id))
} }
const previewRoute = (id: string | number): Promise<ApprovalRoutePreview> => reimbursementApi.getRoutePreview(id) const previewRoute = (id: string | number): Promise<ApprovalRoutePreview> => reimbursementApi.getRoutePreview(id)
const submit = async (id: string | number, previewToken: string) => { if (!previewToken) throw new Error('审批路线预览已失效,请重新预览'); return replaceApplication(await reimbursementApi.submit(id, { previewToken })) } const submit = async (id: string | number, previewToken: string) => { if (!previewToken) throw new Error('审批路线预览已失效,请重新预览'); return replaceApplication(await reimbursementApi.submit(id, { previewToken })) }
const receive = async (id: string | number) => replaceApplication(await reimbursementApi.receive(id)) const receive = async (id: string | number) => replaceApplication(await reimbursementApi.receive(id))
const pay = async (id: string | number, amount: number, remark: string, idempotencyKey: string) => { const pay = async (id: string | number, amount: number, remark: string, idempotencyKey: string, facts?: import('@/api/reimbursement').ExternalPaymentFacts) => {
const item = getById(id) const item = getById(id)
if (!item) throw new Error('报销单不存在') if (!item) throw new Error('付款申请不存在')
if (!(amount > 0) || amount > balance(item) + 0.005) throw new Error(`付款金额须大于 0 且不超过未付余额 ¥ ${balance(item).toFixed(2)}`) if (!(amount > 0) || amount > balance(item) + 0.005) throw new Error(`付款金额须大于 0 且不超过未付余额 ¥ ${balance(item).toFixed(2)}`)
const result = amount < balance(item) ? await cashierApi.partialPayment(id, amount, remark, idempotencyKey) : await cashierApi.executePayment(id, amount, remark, idempotencyKey) const result = amount < balance(item) ? await cashierApi.partialPayment(id, amount, remark, idempotencyKey, facts) : await cashierApi.executePayment(id, amount, remark, idempotencyKey, facts)
payments.value.unshift(normalizePayment({ ...result, applicationId: id, paymentAmount: result.paymentAmount ?? amount, paymentStatus: result.paymentStatus || 'PENDING_REVIEW', totalAmount: item.totalAmount })) payments.value.unshift(normalizePayment({ ...result, applicationId: id, actualPaymentAmount: result.actualPaymentAmount ?? result.paymentAmount ?? amount, paymentStatus: result.paymentStatus || 'COMPLETED', approvedAmount: item.approvedAmount ?? item.requestedAmount }))
refreshPaymentStatuses() refreshPaymentStatuses()
return result return result
} }
const applyPaymentResult = (paymentId: string | number, result: PaymentResult) => { payments.value = payments.value.map(payment => String(payment.id) === String(paymentId) ? normalizePayment({ ...payment, ...result, id: payment.id }) : payment); refreshPaymentStatuses(); return result } const applyPaymentResult = (paymentId: string | number, result: PaymentResult) => { payments.value = payments.value.map(payment => String(payment.id) === String(paymentId) ? normalizePayment({ ...payment, ...result, id: payment.id }) : payment); refreshPaymentStatuses(); return result }
const verifyPayment = async (paymentId: string | number) => applyPaymentResult(paymentId, await cashierApi.verify({ paymentId })) const verifyPayment = async (paymentId: string | number) => applyPaymentResult(paymentId, await cashierApi.verify({ paymentId }))
const rejectPayment = async (paymentId: string | number, rejectionCode: string) => applyPaymentResult(paymentId, await cashierApi.reject({ paymentId, rejectionCode })) const rejectPayment = async (paymentId: string | number, rejectionCode: string) => applyPaymentResult(paymentId, await cashierApi.reject({ paymentId, rejectionCode }))
const reset = () => { sessionVersion += 1; queueVersions.receipt += 1; queueVersions.payment += 1; loadPromise = null; user.value = null; reimbursements.value = []; payments.value = []; source.value = 'connecting'; loading.value = false; error.value = ''; financeQueueError.value = ''; notifications.value = 0 } const attachPaymentReceipt = async (paymentId: string | number, paymentReceipt: string) => applyPaymentResult(paymentId, await cashierApi.attachReceipt(paymentId, paymentReceipt))
return { user, reimbursements, payments, source, loading, error, financeQueueError, notifications, summaries, balance, paidAmount, load, loadList, loadDetail, loadFinanceQueue, loadPaymentHistory, getById, save, removeApplication, previewRoute, submit, receive, pay, verifyPayment, rejectPayment, reset, refreshPaymentStatuses } const reset = () => { sessionVersion += 1; queueVersions.receipt += 1; queueVersions.payment += 1; loadPromise = null; user.value = null; paymentApplications.value = []; payments.value = []; source.value = 'connecting'; loading.value = false; error.value = ''; financeQueueError.value = ''; notifications.value = 0; financeCheckEnabled.value = false; independentPaymentReviewEnabled.value = false }
return { user, paymentApplications, payments, source, loading, error, financeQueueError, notifications, financeCheckEnabled, independentPaymentReviewEnabled, summaries, balance, paidAmount, load, loadList, loadDetail, loadFinanceQueue, loadPaymentHistory, getById, save, removeApplication, previewRoute, submit, receive, pay, verifyPayment, rejectPayment, attachPaymentReceipt, reset, refreshPaymentStatuses }
}) })
+54 -21
View File
@@ -1,14 +1,28 @@
<template> <template>
<div> <div>
<div class="page-head"><div><span class="eyebrow">REIMBURSEMENT DETAIL</span><h1>报销单详情</h1><p>{{ item ? `${item.applicationNo} · ${item.title}` : `单号:${route.params.id}` }}</p></div><div class="head-actions"><button class="btn" @click="router.back()">← 返回</button><button v-if="item && uiEdit('ui.application-detail.print')" class="btn" @click="print">打印详情</button><router-link v-if="canEdit" class="btn primary" :to="editRoute">{{ item?.approvalStatus === '退回' ? '补充信息' : '编辑草稿' }}</router-link></div></div> <div class="page-head"><div><span class="eyebrow">PAYMENT APPLICATION DETAIL</span><h1>付款申请详情</h1><p>{{ item ? `${item.applicationNo} · ${item.title}` : `单号:${route.params.id}` }}</p></div><div class="head-actions"><button class="btn" @click="router.back()">← 返回</button><button v-if="item && uiEdit('ui.application-detail.print')" class="btn" @click="print">打印详情</button><router-link v-if="canEdit" class="btn primary" :to="editRoute">{{ item?.approvalStatus === '退回' ? '补充信息' : '编辑草稿' }}</router-link></div></div>
<div v-if="detailLoading" class="load-wrap" role="status"><span class="loader"></span><p>正在读取报销详情…</p></div> <div v-if="detailLoading" class="load-wrap" role="status"><span class="loader"></span><p>正在读取付款申请详情…</p></div>
<div v-else-if="detailError" class="card empty-state" role="alert"><strong>报销详情加载失败</strong><span>{{ detailError }}</span><button v-if="uiEdit('ui.application-detail.reload')" class="btn" type="button" @click="loadDetail">重新加载</button><router-link class="btn" to="/applications">返回我的报销</router-link></div> <div v-else-if="detailError" class="card empty-state" role="alert"><strong>付款申请详情加载失败</strong><span>{{ detailError }}</span><button v-if="uiEdit('ui.application-detail.reload')" class="btn" type="button" @click="loadDetail">重新加载</button><router-link class="btn" to="/applications">返回申请中心</router-link></div>
<div v-else-if="!item" class="card empty-state"><strong>未找到该报销单</strong><span>单号「{{ route.params.id }}」不存在或已被删除,请返回我的报销重试。</span><router-link class="btn" to="/applications">返回我的报销</router-link></div> <div v-else-if="!item" class="card empty-state"><strong>未找到该付款申请</strong><span>单号「{{ route.params.id }}」不存在或已被删除,请返回申请中心重试。</span><router-link class="btn" to="/applications">返回申请中心</router-link></div>
<template v-else> <template v-else>
<div v-if="item.approvalStatus === '退回'" class="inline-alert danger" role="alert"><b>!</b><span><strong>审批退回,需补充信息</strong><template v-if="hasOwnField(item, 'returnReason')"><br>{{ item.returnReason }}</template></span><router-link v-if="canEdit" class="btn small" :to="`/applications/${item.id}/edit`">去补充</router-link></div> <div v-if="item.approvalStatus === '退回'" class="inline-alert danger" role="alert"><b>!</b><span><strong>审批退回,需补充信息</strong><template v-if="hasOwnField(item, 'returnReason')"><br>{{ item.returnReason }}</template></span><router-link v-if="canEdit" class="btn small" :to="`/applications/${item.id}/edit`">去补充</router-link></div>
<section v-if="uiRead('ui.application-detail.summary')" class="section-card section-gap">
<div class="section-title"><h2>付款申请摘要</h2><span>申请、批准与实际金额分别记录</span></div>
<div class="source-grid card-body">
<div v-if="hasOwnField(item, 'paymentScenario')"><span>付款情形</span><strong>{{ item.paymentScenario || '—' }}</strong></div>
<div v-if="hasOwnField(item, 'payerEntityName')"><span>付款单位</span><strong>{{ item.payerEntityName || '—' }}</strong></div>
<div v-if="hasOwnField(item, 'costCenterName')"><span>成本中心</span><strong>{{ item.costCenterName || '—' }}</strong></div>
<div v-if="hasOwnField(item, 'currencyCode')"><span>币种</span><strong>{{ item.currencyCode || 'CNY' }}</strong></div>
<div v-if="hasOwnField(item, 'paymentReason') || hasOwnField(item, 'title')"><span>付款事由</span><strong>{{ item.paymentReason || item.title || '—' }}</strong></div>
<div v-if="hasOwnField(item, 'plannedPaymentDate')"><span>计划付款日期</span><strong>{{ item.plannedPaymentDate || '—' }}</strong></div>
<div v-if="hasOwnField(item, 'requestedAmount')"><span>申请付款金额</span><strong>{{ money(item.requestedAmount) }}</strong></div>
<div v-if="hasOwnField(item, 'approvedAmount')"><span>批准金额</span><strong>{{ item.approvedAmount == null ? '—' : money(item.approvedAmount) }}</strong></div>
<div v-if="hasOwnField(item, 'requestedAmount')"><span>实际付款金额</span><strong>{{ money(item.actualPaymentAmount ?? store.paidAmount(item)) }}</strong></div>
</div>
</section>
<div class="detail-layout"><div> <div class="detail-layout"><div>
<template v-if="uiRead('ui.application-detail.summary')"><div class="status-strip" aria-label="报销流程独立状态"><div><small>申请状态</small><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></div><div><small>审批状态</small><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></div><div><small>收单状态</small><span class="tag" :class="tone(item.receiptStatus)">{{ item.receiptStatus }}</span></div><div><small>付款状态</small><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></div></div> <template v-if="uiRead('ui.application-detail.summary')"><div class="status-strip" aria-label="付款申请流程独立状态"><div><small>申请状态</small><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></div><div><small>审批状态</small><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></div><div v-if="store.financeCheckEnabled"><small>财务核对</small><span class="tag" :class="tone(item.financeCheckStatus)">{{ item.financeCheckStatus }}</span></div><div><small>付款状态</small><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></div></div>
<div class="workflow" aria-label="报销流程"><div v-for="(step,index) in workflow" :key="step.name" class="workflow-step" :class="step.tone"><span>{{ index + 1 }}</span><div><strong>{{ step.name }}</strong><small>{{ step.value }}</small></div></div></div></template> <div class="workflow" aria-label="付款申请流程"><div v-for="(step,index) in workflow" :key="step.name" class="workflow-step" :class="step.tone"><span>{{ index + 1 }}</span><div><strong>{{ step.name }}</strong><small>{{ step.value }}</small></div></div></div></template>
<section v-if="hasFeishuSnapshot && uiRead('ui.application-detail.form')" class="section-card" aria-labelledby="feishu-snapshot-title"> <section v-if="hasFeishuSnapshot && uiRead('ui.application-detail.form')" class="section-card" aria-labelledby="feishu-snapshot-title">
<div class="section-title"><div><span class="eyebrow">HISTORICAL SNAPSHOT</span><h2 id="feishu-snapshot-title">飞书审批表单</h2></div><span>提交版本 {{ item.formSnapshot?.fingerprint?.slice(0, 8) || '未知' }} · 历史快照</span></div> <div class="section-title"><div><span class="eyebrow">HISTORICAL SNAPSHOT</span><h2 id="feishu-snapshot-title">飞书审批表单</h2></div><span>提交版本 {{ item.formSnapshot?.fingerprint?.slice(0, 8) || '未知' }} · 历史快照</span></div>
@@ -19,21 +33,21 @@
</div> </div>
<div v-else class="snapshot-field full expense-snapshot"> <div v-else class="snapshot-field full expense-snapshot">
<dt>{{ field.label }}</dt> <dt>{{ field.label }}</dt>
<dd><div v-if="hasUnknownExpenseChild(field)" class="snapshot-warning" role="note">该历史明细包含当前版本无法识别的列,仅展示有明确绑定的列。</div><div v-if="expenseRows(field).length && detailColumns(field).length" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th v-for="column in detailColumns(field)" :key="column.valueKey" :class="{ amount: column.binding === 'EXPENSE_AMOUNT' }">{{ column.label }}</th></tr></thead><tbody><tr v-for="(expense, rowIndex) in expenseRows(field)" :key="rowIndex"><td v-for="column in detailColumns(field)" :key="column.valueKey" :data-label="column.label" :class="{ amount: column.binding === 'EXPENSE_AMOUNT' }">{{ expenseCell(expense, column, rowIndex) }}</td></tr></tbody></table></div><span v-else>—</span></dd> <dd><div v-if="hasUnknownExpenseChild(field)" class="snapshot-warning" role="note">该历史明细包含当前版本无法识别的列,仅展示有明确绑定的列。</div><div v-if="detailColumns(field).length" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th v-for="column in detailColumns(field)" :key="column.valueKey" :class="{ amount: column.binding === 'EXPENSE_AMOUNT' }">{{ column.label }}</th></tr></thead><tbody><tr v-if="!expenseRows(field).length"><td :colspan="detailColumns(field).length"><div class="empty-state"><strong>暂无费用明细</strong></div></td></tr><tr v-for="(expense, rowIndex) in expenseRows(field)" :key="rowIndex"><td v-for="column in detailColumns(field)" :key="column.valueKey" :data-label="column.label" :class="{ amount: column.binding === 'EXPENSE_AMOUNT' }">{{ expenseCell(expense, column, rowIndex) }}</td></tr></tbody></table></div><span v-else>—</span></dd>
</div> </div>
</template> </template>
</dl> </dl>
</section> </section>
<section v-if="!hasFeishuSnapshot && uiRead('ui.application-detail.form')" class="section-card"><div class="section-title"><h2>报销信息</h2><span>{{ item.category }}</span></div><div class="form-grid"><div v-if="hasOwnField(item, 'applicantName')" class="field"><label>报销人 / 部门</label><input readonly :value="`${item.applicantName} / ${item.departmentName}`"></div><div class="field"><label>费用类型</label><input readonly :value="`${item.expenseTypeName} · ${item.category}`"></div><div v-if="hasOwnField(item, 'totalAmount')" class="field"><label>申请金额</label><input readonly :value="money(item.totalAmount)"></div><div class="field"><label>申请日期</label><input readonly :value="item.createdAt?.slice(0,10) || '-' "></div><div v-if="hasOwnField(item, 'payeeName') || hasOwnField(item, 'bankAccountMask')" class="field"><label>收款人 / 账户</label><input readonly :value="[hasOwnField(item, 'payeeName') ? item.payeeName : '', hasOwnField(item, 'bankAccountMask') ? item.bankAccountMask : ''].filter(Boolean).join(' · ')"></div><div v-if="hasOwnField(item, 'description')" class="field full"><label>报销说明</label><textarea readonly :value="item.description"></textarea></div></div></section> <section v-if="!hasFeishuSnapshot && uiRead('ui.application-detail.form')" class="section-card"><div class="section-title"><h2>付款申请信息</h2><span>{{ item.paymentScenario }}</span></div><div class="form-grid"><div v-if="hasOwnField(item, 'applicantName')" class="field"><label>申请人 / 部门</label><input readonly :value="`${item.applicantName} / ${item.departmentName}`"></div><div class="field"><label>付款情形</label><input readonly :value="item.paymentScenario"></div><div v-if="hasOwnField(item, 'payerEntityName')" class="field"><label>付款单位</label><input readonly :value="item.payerEntityName || '—'"></div><div v-if="hasOwnField(item, 'costCenterName')" class="field"><label>成本中心</label><input readonly :value="item.costCenterName || '—'"></div><div v-if="hasOwnField(item, 'currencyCode')" class="field"><label>币种</label><input readonly :value="item.currencyCode || 'CNY'"></div><div v-if="hasOwnField(item, 'plannedPaymentDate')" class="field"><label>计划付款日期</label><input readonly :value="item.plannedPaymentDate || '—'"></div><div v-if="hasOwnField(item, 'requestedAmount')" class="field"><label>申请付款金额</label><input readonly :value="money(item.requestedAmount)"></div><div class="field"><label>申请日期</label><input readonly :value="item.createdAt?.slice(0,10) || '-' "></div><div v-if="hasOwnField(item, 'payeeName') || hasOwnField(item, 'bankAccountMask')" class="field"><label>收款方 / 账户</label><input readonly :value="[hasOwnField(item, 'payeeName') ? item.payeeName : '', hasOwnField(item, 'bankAccountMask') ? item.bankAccountMask : ''].filter(Boolean).join(' · ')"></div><div v-if="hasOwnField(item, 'paymentReason') || hasOwnField(item, 'description')" class="field full"><label>付款事由</label><textarea readonly :value="item.paymentReason || item.description"></textarea></div></div></section>
<section v-if="hasFeishuSnapshot && uiRead('ui.application-detail.summary')" class="section-card finance-facts"><div class="section-title"><h2>财务与付款信息</h2><span>系统记录</span></div><div class="source-grid"><div v-if="hasOwnField(item, 'payeeName')"><span>收款人</span><strong>{{ item.payeeName }}</strong></div><div v-if="hasOwnField(item, 'bankAccountMask')"><span>收款账户</span><strong>{{ item.bankAccountMask }}</strong></div><div v-if="hasOwnField(item, 'bankName')"><span>开户银行</span><strong>{{ item.bankName }}</strong></div><div><span>申请日期</span><strong>{{ item.createdAt?.slice(0, 10) || '—' }}</strong></div></div></section> <section v-if="hasFeishuSnapshot && uiRead('ui.application-detail.summary')" class="section-card finance-facts"><div class="section-title"><h2>财务与付款信息</h2><span>系统记录</span></div><div class="source-grid"><div v-if="hasOwnField(item, 'payeeName')"><span>收款方</span><strong>{{ item.payeeName }}</strong></div><div v-if="hasOwnField(item, 'bankAccountMask')"><span>收款账户</span><strong>{{ item.bankAccountMask }}</strong></div><div v-if="hasOwnField(item, 'bankName')"><span>开户银行</span><strong>{{ item.bankName }}</strong></div><div><span>申请日期</span><strong>{{ item.createdAt?.slice(0, 10) || '—' }}</strong></div></div></section>
<section v-if="uiRead('ui.application-detail.source')" class="source-card"><div class="source-card-head"><div><span class="eyebrow">KINGDEE SOURCE · READ ONLY</span><h3>{{ item.sourceDocNo || '未关联源单' }} <small>{{ item.sourceStatus }}</small></h3></div><span class="tag success">只读</span></div><div class="source-grid"><div><span>来源系统</span><strong>{{ item.sourceDocNo ? '金蝶 ERP' : '暂无' }}</strong></div><div><span>源单编号</span><strong>{{ item.sourceDocNo || '—' }}</strong></div><div><span>来源状态</span><strong>{{ item.sourceStatus }}</strong></div><div v-if="hasOwnField(item, 'payeeName')"><span>收款人</span><strong>{{ item.payeeName }}</strong></div><div v-if="hasOwnField(item, 'bankName')"><span>开户银行</span><strong>{{ item.bankName }}</strong></div><div v-if="hasOwnField(item, 'bankAccountMask')"><span>账号</span><strong>{{ item.bankAccountMask }}</strong></div></div><p><b>只读说明</b> 来源单据由外部系统同步,需修改业务事实请回到金蝶维护后重新同步。</p></section> <section v-if="uiRead('ui.application-detail.source')" class="source-card"><div class="source-card-head"><div><span class="eyebrow">KINGDEE SOURCE · READ ONLY</span><h3>{{ item.sourceDocNo || '未关联金蝶单据' }} <small>{{ item.syncStatus }}</small></h3></div><span class="tag success">只读</span></div><div class="source-grid"><div><span>来源系统</span><strong>{{ item.sourceDocNo ? '金蝶 ERP' : '暂无' }}</strong></div><div><span>金蝶单据编号</span><strong>{{ item.sourceDocNo || '—' }}</strong></div><div><span>同步状态</span><strong>{{ item.syncStatus }}</strong></div><div v-if="hasOwnField(item, 'payeeName')"><span>收款方</span><strong>{{ item.payeeName }}</strong></div><div v-if="hasOwnField(item, 'bankName')"><span>开户银行</span><strong>{{ item.bankName }}</strong></div><div v-if="hasOwnField(item, 'bankAccountMask')"><span>账号</span><strong>{{ item.bankAccountMask }}</strong></div></div><p><b>只读说明</b> 来源单据由外部系统同步,需修改业务事实请回到金蝶维护后重新同步。</p></section>
<section v-if="!snapshotHasExpenses && uiRead('ui.application-detail.expenses')" class="section-card"><div class="section-title"><h2>费用明细</h2><span>{{ item.expenseItems.length }} 条</span></div><div v-if="item.expenseItems.length" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th>日期</th><th>类别</th><th>说明</th><th>附件</th><th class="amount">金额</th></tr></thead><tbody><tr v-for="expense in item.expenseItems" :key="expense.id || expense.seqNo"><td data-label="日期">{{ expense.expenseDate }}</td><td data-label="类别">{{ expense.category }}</td><td data-label="说明">{{ expense.description }}</td><td data-label="附件">{{ expenseAttachmentNames(expense) }}</td><td data-label="金额" class="amount">{{ money(expense.amount) }}</td></tr></tbody></table></div></section> <section v-if="!snapshotHasExpenses && uiRead('ui.application-detail.expenses')" class="section-card"><div class="section-title"><h2>费用项目</h2><span>{{ item.expenseItems.length }} 条</span></div><div class="table-wrap"><table class="data-table responsive-table"><thead><tr><th>日期</th><th>费用项目</th><th>说明</th><th>附件</th><th class="amount">金额</th></tr></thead><tbody><tr v-if="!item.expenseItems.length"><td colspan="5"><div class="empty-state"><strong>暂无费用项目</strong></div></td></tr><tr v-for="expense in item.expenseItems" :key="expense.id || expense.seqNo"><td data-label="日期">{{ expense.expenseDate }}</td><td data-label="费用项目">{{ expense.expenseItemName }}</td><td data-label="说明">{{ expense.description }}</td><td data-label="附件">{{ expenseAttachmentNames(expense) }}</td><td data-label="金额" class="amount">{{ money(expense.amount) }}</td></tr></tbody></table></div></section>
<section v-if="uiRead('ui.application-detail.invoices')" class="section-card"><div class="section-title"><h2>发票</h2><span>{{ item.invoices.length }} 张</span></div><div v-if="item.invoices.length" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th>发票号码</th><th class="amount">发票金额</th><th>校验状态</th></tr></thead><tbody><tr v-for="invoice in item.invoices" :key="invoice.id"><td data-label="发票号码">{{ invoice.invoiceNo }}</td><td data-label="发票金额" class="amount">{{ money(invoice.amount) }}</td><td data-label="校验状态">{{ invoice.verifyStatus }}</td></tr></tbody></table></div><div v-else class="empty-state"><strong>暂无发票</strong></div></section> <section v-if="uiRead('ui.application-detail.invoices')" class="section-card"><div class="section-title"><h2>发票</h2><span>{{ item.invoices.length }} 张</span></div><div class="table-wrap"><table class="data-table responsive-table"><thead><tr><th>发票号码</th><th class="amount">发票金额</th><th>校验状态</th></tr></thead><tbody><tr v-if="!item.invoices.length"><td colspan="3"><div class="empty-state"><strong>暂无发票</strong></div></td></tr><tr v-for="invoice in item.invoices" :key="invoice.id"><td data-label="发票号码">{{ invoice.invoiceNo }}</td><td data-label="发票金额" class="amount">{{ money(invoice.amount) }}</td><td data-label="校验状态">{{ invoice.verifyStatus }}</td></tr></tbody></table></div></section>
<section v-if="uiRead('ui.application-detail.expenses') && hasOwnField(item, 'attachments')" class="section-card"><div class="section-title"><h2>附件材料</h2><span>{{ item.attachments.length }} 份</span></div><div v-if="item.attachments.length" class="attachment-grid"><div v-for="file in item.attachments" :key="file.id" class="attachment-item"><span class="file-icon">FILE</span><div><strong>{{ file.fileName }}</strong><small>{{ file.fileType }} · 只读材料</small></div></div></div><div v-else class="empty-state">暂无附件</div></section> <section v-if="uiRead('ui.application-detail.expenses') && hasOwnField(item, 'attachments')" class="section-card"><div class="section-title"><h2>申请附件</h2><span>{{ item.attachments.length }} 份</span></div><div v-if="item.attachments.length" class="attachment-grid"><div v-for="file in item.attachments" :key="file.id" class="attachment-item"><span class="file-icon">FILE</span><div><strong>{{ file.fileName }}</strong><small>{{ file.fileType }} · 只读材料</small></div></div></div><div v-else class="empty-state">暂无附件</div></section>
<section v-if="uiRead('ui.application-detail.timeline')" class="section-card"><div class="section-title"><h2>审批、收单与付款时间线</h2><span>状态留痕</span></div><div class="timeline"><div v-for="entry in timeline" :key="entry.name" class="timeline-item" :class="entry.done ? 'done' : 'pending'"><span class="timeline-dot"></span><div><strong>{{ entry.name }}</strong><p>{{ entry.copy }}</p><time>{{ entry.time }}</time></div></div></div></section> <section v-if="uiRead('ui.application-detail.timeline')" class="section-card"><div class="section-title"><h2>{{ store.financeCheckEnabled ? '审批、财务核对与付款时间线' : '审批与付款时间线' }}</h2><span>状态留痕</span></div><div class="timeline"><div v-for="entry in timeline" :key="entry.name" class="timeline-item" :class="entry.done ? 'done' : 'pending'"><span class="timeline-dot"></span><div><strong>{{ entry.name }}</strong><p>{{ entry.copy }}</p><time>{{ entry.time }}</time></div></div></div></section>
</div><aside v-if="uiRead('ui.application-detail.summary')" class="card side-panel"><div v-if="hasOwnField(item, 'totalAmount')" class="summary-block"><h3>金额汇总</h3><div class="amount-highlight">{{ money(item.totalAmount) }}</div><div class="summary-row"><span>已付款</span><strong>{{ money(store.paidAmount(item)) }}</strong></div><div class="summary-row"><span>未付款</span><strong>{{ money(store.balance(item)) }}</strong></div><div class="summary-total"><span>付款进度</span><strong>{{ item.totalAmount ? `${Math.round(store.paidAmount(item) / item.totalAmount * 100)}%` : '0%' }}</strong></div></div><div v-if="hasOwnField(item, 'payments')" class="summary-block"><h3>付款记录</h3><div v-if="item.payments.length"><div v-for="payment in item.payments" :key="payment.id" class="payment-record"><strong>{{ payment.paymentNo }}</strong><span>{{ money(payment.paymentAmount) }} · {{ payment.paymentTime }}</span><small>{{ payment.paymentMethod }}<template v-if="hasOwnField(payment, 'operatorName')"> · {{ payment.operatorName }}</template></small></div></div><div v-else class="muted-copy">暂无实际付款记录</div></div></aside></div> </div><aside v-if="uiRead('ui.application-detail.summary')" class="card side-panel"><div v-if="hasOwnField(item, 'requestedAmount')" class="summary-block"><h3>金额汇总</h3><div class="amount-highlight">{{ money(item.approvedAmount ?? item.requestedAmount) }}</div><div class="summary-row"><span>申请付款金额</span><strong>{{ money(item.requestedAmount) }}</strong></div><div class="summary-row"><span>累计实付</span><strong>{{ money(store.paidAmount(item)) }}</strong></div><div class="summary-row"><span>未付余额</span><strong>{{ money(store.balance(item)) }}</strong></div><div class="summary-total"><span>付款进度</span><strong>{{ (item.approvedAmount ?? item.requestedAmount) ? `${Math.round(store.paidAmount(item) / (item.approvedAmount ?? item.requestedAmount) * 100)}%` : '0%' }}</strong></div></div><div v-if="hasOwnField(item, 'payments')" class="summary-block"><h3>外部付款记录</h3><div v-if="item.payments.length"><div v-for="payment in item.payments" :key="payment.id" class="payment-record"><strong>{{ payment.paymentNo }}</strong><span>{{ money(payment.actualPaymentAmount) }} · {{ payment.actualPaymentDate || payment.resultRecordedAt || '日期未提供' }}</span><small>{{ payment.actualPaymentMethod || '方式未提供' }}<template v-if="hasOwnField(payment, 'operatorName')"> · {{ payment.operatorName }}</template></small><small>银行流水号:{{ payment.bankTransactionNo || '未提供' }}</small><span class="tag" :class="payment.paymentReceipt ? 'success' : 'pending'">{{ payment.paymentReceipt ? '已留存付款回单' : '待补付款回单' }}</span><small v-if="payment.paymentReceipt">{{ payment.paymentReceipt }}</small></div></div><div v-else class="muted-copy">暂无实际付款记录</div></div></aside></div>
</template> </template>
</div> </div>
</template> </template>
@@ -65,17 +79,36 @@ const editRoute = computed(() => item.value ? `/applications/${item.value.id}/ed
const hasFeishuSnapshot = computed(() => item.value?.formSnapshot?.mode === 'FEISHU') const hasFeishuSnapshot = computed(() => item.value?.formSnapshot?.mode === 'FEISHU')
const snapshotHasExpenses = computed(() => hasFeishuSnapshot.value && item.value?.formSnapshot?.fields.some(field => field.binding === 'EXPENSE_ITEMS' || field.type === 'EXPENSE_ITEMS')) const snapshotHasExpenses = computed(() => hasFeishuSnapshot.value && item.value?.formSnapshot?.fields.some(field => field.binding === 'EXPENSE_ITEMS' || field.type === 'EXPENSE_ITEMS'))
const money = (value: number | undefined) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}` const money = (value: number | undefined) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}`
const tone = (value: string) => ({ 草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger', 待收单: 'pending', 已收单: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 未触发: 'neutral' } as Record<string, string>)[value] || 'neutral' const tone = (value: string) => ({ 草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger', 待核对: 'pending', 已核对: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 未触发: 'neutral' } as Record<string, string>)[value] || 'neutral'
const print = () => window.print() const print = () => window.print()
const workflow = computed(() => item.value ? [{ name: '申请', value: item.value.applicationStatus, tone: tone(item.value.applicationStatus) }, { name: '审批', value: item.value.approvalStatus, tone: tone(item.value.approvalStatus) }, { name: '收单', value: item.value.receiptStatus, tone: tone(item.value.receiptStatus) }, { name: '付款', value: item.value.paymentStatus, tone: tone(item.value.paymentStatus) }] : []) const workflow = computed(() => {
const timeline = computed(() => { const current = item.value; if (!current) return []; return [{ name: '申请提交', copy: current.applicationStatus === '草稿' ? '尚未提交申请' : `${current.applicantName} 已提交报销申请`, done: current.applicationStatus !== '草稿', time: current.submitTime || current.createdAt || '待触发' }, { name: '飞书审批', copy: current.approvalStatus === '退回' ? `退回:${current.returnReason || '需补充信息'}` : current.approvalStatus === '审批通过' ? '审批通过,结果已同步' : `当前节点:${current.currentApprovalNode}`, done: current.approvalStatus !== '未触发', time: current.updatedAt || '待触发' }, { name: '财务收单', copy: current.receiptStatus === '已收单' ? '财务已完成收单' : current.receiptStatus === '待收单' ? '等待财务办理收单' : '审批通过后激活', done: current.receiptStatus === '已收单', time: current.updatedAt || '待触发' }, { name: '付款登记', copy: current.paymentStatus === '未付款' ? '等待外部支付并登记凭据' : `累计已付 ${money(store.paidAmount(current))}`, done: current.paymentStatus === '已付款', time: current.updatedAt || '待办理' }] }) if (!item.value) return []
const steps = [
{ name: '申请', value: item.value.applicationStatus, tone: tone(item.value.applicationStatus) },
{ name: '审批', value: item.value.approvalStatus, tone: tone(item.value.approvalStatus) },
]
if (store.financeCheckEnabled) steps.push({ name: '财务核对', value: item.value.financeCheckStatus, tone: tone(item.value.financeCheckStatus) })
steps.push({ name: '付款结果', value: item.value.paymentStatus, tone: tone(item.value.paymentStatus) })
return steps
})
const timeline = computed(() => {
const current = item.value
if (!current) return []
const entries = [
{ name: '申请提交', copy: current.applicationStatus === '草稿' ? '尚未提交申请' : `${current.applicantName} 已提交付款申请`, done: current.applicationStatus !== '草稿', time: current.submitTime || current.createdAt || '待触发' },
{ name: '飞书审批', copy: current.approvalStatus === '退回' ? `退回:${current.returnReason || '需补充信息'}` : current.approvalStatus === '审批通过' ? '审批通过,结果已同步' : `当前节点:${current.currentApprovalNode}`, done: current.approvalStatus !== '未触发', time: current.updatedAt || '待触发' },
]
if (store.financeCheckEnabled) entries.push({ name: '财务核对(按规则)', copy: current.financeCheckStatus === '已核对' ? '财务已完成核对' : '当前付款情形要求财务核对', done: current.financeCheckStatus === '已核对', time: current.updatedAt || '待触发' })
entries.push({ name: '付款结果', copy: current.paymentStatus === '未付款' ? '等待外部付款结果并登记凭据' : `累计实付 ${money(store.paidAmount(current))}`, done: current.paymentStatus === '已付款', time: current.updatedAt || '待办理' })
return entries
})
const boundValue = (field: ReimbursementFormField): unknown => { const boundValue = (field: ReimbursementFormField): unknown => {
const current = item.value const current = item.value
if (!current) return undefined if (!current) return undefined
const snapshotValues = current.formSnapshot?.values const snapshotValues = current.formSnapshot?.values
if (snapshotValues && Object.prototype.hasOwnProperty.call(snapshotValues, field.valueKey)) return snapshotValues[field.valueKey] if (snapshotValues && Object.prototype.hasOwnProperty.call(snapshotValues, field.valueKey)) return snapshotValues[field.valueKey]
const values: Record<string, unknown> = { APPLICATION_NO: current.applicationNo, TITLE: current.title, APPLICANT_NAME: current.applicantName, APPLICANT_CONTACT: current.applicantName, APPLICANT_DEPARTMENT: current.departmentName, DEPARTMENT: current.departmentName, EXPENSE_TYPE: current.expenseTypeName || current.category, TOTAL_AMOUNT: current.totalAmount, DESCRIPTION: current.description, SOURCE_DOC_NO: current.sourceDocNo } const values: Record<string, unknown> = { APPLICATION_NO: current.applicationNo, TITLE: current.title, APPLICANT_NAME: current.applicantName, APPLICANT_CONTACT: current.applicantName, APPLICANT_DEPARTMENT: current.departmentName, DEPARTMENT: current.departmentName, EXPENSE_TYPE: current.paymentScenario, TOTAL_AMOUNT: current.requestedAmount, DESCRIPTION: current.description, SOURCE_DOC_NO: current.sourceDocNo }
return values[field.binding] return values[field.binding]
} }
const contactDisplayLabel = (value: unknown) => { const contactDisplayLabel = (value: unknown) => {
@@ -149,10 +182,10 @@ const loadDetail = async () => {
try { try {
const detail = await store.loadDetail(String(route.params.id), { strict: true }) const detail = await store.loadDetail(String(route.params.id), { strict: true })
if (store.source === 'api' && !detail?.formSnapshot) throw new Error('服务端详情缺少表单快照,已停止使用列表摘要替代历史详情。') if (store.source === 'api' && !detail?.formSnapshot) throw new Error('服务端详情缺少表单快照,已停止使用列表摘要替代历史详情。')
if (!detail) throw new Error('未找到该报销单或当前无权查看。') if (!detail) throw new Error('未找到该付款申请或当前无权查看。')
detailReady.value = true detailReady.value = true
} catch (error) { } catch (error) {
detailError.value = error instanceof Error && error.message ? error.message : '无法读取权威报销详情,请稍后重试。' detailError.value = error instanceof Error && error.message ? error.message : '无法读取权威付款申请详情,请稍后重试。'
} finally { } finally {
detailLoading.value = false detailLoading.value = false
} }
+77 -193
View File
@@ -2,85 +2,61 @@
<div class="page-content route-list-page"> <div class="page-content route-list-page">
<div class="page-head"> <div class="page-head">
<div> <div>
<span class="eyebrow">APPLICATION CENTER</span>
<h1>申请中心</h1> <h1>申请中心</h1>
<p>集中查看付款申请,以及从飞书同步的出差申请。</p>
</div> </div>
<div class="head-actions"> <div class="head-actions">
<button class="btn" type="button" :disabled="activeLoading" @click="reload">刷新</button> <router-link v-if="canCreate" class="btn primary" to="/applications/new">+ 发起申请</router-link>
<button v-if="applicationKind === 'payment' && canExport" class="btn" type="button" :disabled="!filtered.length" @click="exportApplications">导出</button> <button v-if="canExport" class="btn" type="button" @click="exportApplications">导出</button>
<router-link v-if="applicationKind === 'payment' && canCreate" class="btn primary" to="/applications/new">+ 发起付款申请</router-link>
</div> </div>
</div> </div>
<div v-if="activeLoading" class="load-wrap" role="status" aria-live="polite"> <div v-if="loadingState" class="load-wrap" role="status" aria-live="polite">
<span class="loader" aria-hidden="true"></span> <span class="loader" aria-hidden="true"></span>
<p>正在加载{{ applicationKind === 'travel' ? '出差申请' : '付款申请' }}…</p> <p>正在加载付款申请…</p>
</div> </div>
<div v-else-if="activeBlockingError" class="card empty-state" role="alert"> <div v-else-if="hasBlockingError" class="card empty-state" role="alert">
<strong>{{ applicationKind === 'travel' ? '出差申请' : '付款申请' }}暂时无法加载</strong> <strong>付款申请暂时无法加载</strong>
<span>请检查网络连接后重试,系统不会以空列表代替异常数据。</span> <span>请检查网络连接后重试,系统不会以空列表代替异常数据。</span>
<button class="btn" type="button" @click="reload">重新加载</button> <button class="btn" type="button" @click="reload">重新加载</button>
</div> </div>
<div v-else class="page-content"> <div v-else class="page-content">
<div v-if="applicationKind === 'payment' && hasDataNotice" class="inline-alert" role="status" aria-live="polite"> <div v-if="hasDataNotice" class="inline-alert" role="status" aria-live="polite">
<b aria-hidden="true">i</b> <b aria-hidden="true">i</b>
<span>数据服务暂时不可用,当前记录可能不完整。</span> <span>数据服务暂时不可用,当前记录可能不完整。</span>
<button class="btn small" type="button" @click="reload">重试</button> <button class="btn small" type="button" @click="reload">重试</button>
</div> </div>
<div class="card application-kind-tabs"> <div class="metrics application-metrics">
<div class="tabs" role="tablist" aria-label="申请类型"> <div class="metric neutral"><small>财务核对</small><strong>{{ overviewStatusReadable ? metrics.financeCheck : '—' }}</strong><span>{{ overviewStatusReadable ? (store.financeCheckEnabled ? '待财务核对' : '当前流程未启用') : '指标不可见' }}</span></div>
<button class="tab" :class="{ active: applicationKind === 'payment' }" type="button" role="tab" :aria-selected="applicationKind === 'payment'" @click="applicationKind = 'payment'">付款申请</button> <div class="metric warn"><small>待登记付款结果</small><strong>{{ overviewStatusReadable ? metrics.pendingPayment : '—' }}</strong><span>{{ overviewStatusReadable ? '审批通过且尚未完成登记' : '指标不可见' }}</span></div>
<button v-if="canViewTravel" class="tab" :class="{ active: applicationKind === 'travel' }" type="button" role="tab" :aria-selected="applicationKind === 'travel'" @click="applicationKind = 'travel'">出差申请(飞书)</button> <div class="metric danger"><small>同步异常</small><strong>{{ overviewStatusReadable ? metrics.syncErrors : '—' }}</strong><span>{{ overviewStatusReadable ? '需要检查外部系统同步' : '指标不可见' }}</span></div>
</div> <div class="metric success"><small>付款结果已登记</small><strong>{{ overviewStatusReadable ? metrics.paid : '—' }}</strong><span>{{ overviewStatusReadable ? '已形成有效付款事实' : '指标不可见' }}</span></div>
</div> </div>
<div v-if="applicationKind === 'payment'" class="metrics application-metrics"> <div class="card fill-list-card primary-list-card">
<div class="metric neutral"><small>待申请人处理</small><strong>{{ overviewStatusReadable ? metrics.drafts + metrics.returned : '—' }}</strong><span>{{ overviewStatusReadable ? `${metrics.drafts} 张草稿 · ${metrics.returned} 张退回` : '指标不可见' }}</span></div> <div class="tabs application-status-tabs" role="tablist" aria-label="付款申请状态">
<div class="metric warn"><small>审批中</small><strong>{{ overviewStatusReadable ? tabCounts.approval : '—' }}</strong><span>{{ overviewStatusReadable ? '同步当前审批节点' : '指标不可见' }}</span></div> <button v-for="tab in tabs" :key="tab.key" class="tab" :class="{ active: currentTab === tab.key }" type="button" role="tab" :aria-selected="currentTab === tab.key" @click="currentTab = tab.key">{{ tab.label }}</button>
<div class="metric success"><small>收单状态</small><strong>{{ overviewStatusReadable ? tabCounts.received : '—' }}</strong><span>{{ overviewStatusReadable ? '已收单申请' : '指标不可见' }}</span></div>
<div class="metric neutral"><small>本月申请金额 · CNY</small><strong>{{ overviewAmountReadable ? money(metrics.monthlyAmount) : '—' }}</strong><span>{{ overviewAmountReadable ? `${metrics.monthlyCount} 张申请 · 当前可见范围` : '指标不可见' }}</span></div>
</div>
<div v-if="applicationKind === 'payment'" class="card fill-list-card primary-list-card">
<div class="tabs" role="tablist" aria-label="付款申请列表筛选">
<button
v-for="tab in tabs"
:id="`application-tab-${tab.key}`"
:key="tab.key"
class="tab"
:class="{ active: currentTab === tab.key }"
type="button"
role="tab"
:aria-selected="currentTab === tab.key"
:aria-controls="applicationsPanelId"
@click="currentTab = tab.key"
>
{{ tab.label }} <small>({{ tabCounts[tab.key] }})</small>
</button>
</div> </div>
<div <div
:id="applicationsPanelId" :id="applicationsPanelId"
role="tabpanel" role="region"
class="application-list-panel" class="application-list-panel"
:aria-labelledby="`application-tab-${currentTab}`" aria-label="付款申请记录"
> >
<div class="field-filter-panel application-filter-panel" aria-label="付款申请筛选条件"> <div class="field-filter-panel application-filter-panel" aria-label="付款申请筛选条件">
<div class="application-filter-head"> <div class="application-filter-head">
<strong>筛选</strong> <strong>筛选</strong>
<div class="application-filter-actions"> <div class="application-filter-actions">
<span class="application-filter-result" aria-live="polite">显示 <strong>{{ filtered.length }}</strong> / {{ store.reimbursements.length }} 张</span> <span class="application-filter-result" aria-live="polite">显示 <strong>{{ filtered.length }}</strong> / {{ store.paymentApplications.length }} 张</span>
<span class="filter-count" :class="{ active: activeFilterCount }">{{ activeFilterCount ? `已选 ${activeFilterCount} 项` : '未筛选' }}</span> <span class="filter-count" :class="{ active: activeFilterCount }">{{ activeFilterCount ? `已选 ${activeFilterCount} 项` : '未筛选' }}</span>
<button class="btn small" type="button" :disabled="!hasFilters" @click="clearFilters">清空</button> <button class="btn small" type="button" :disabled="!hasFilters" @click="clearFilters">清空</button>
</div> </div>
</div> </div>
<div class="field-filter-grid application-filter-grid"> <div class="field-filter-grid application-filter-grid">
<label class="filter-keyword"><span>关键词</span><input v-model="query" type="search" placeholder="单号、事项或收款对象" aria-label="关键词"></label> <label class="filter-keyword"><span>关键词</span><input v-model="query" type="search" placeholder="请输入付款申请单号、付款事由或收款方" aria-label="搜索付款申请"></label>
<label v-if="uiRead('ui.applications.column.title')"><span>费用类型</span><select v-model="expenseFilter"><option value="">全部</option><option v-for="value in expenseTypes" :key="value" :value="value">{{ value }}</option></select></label>
<label v-if="statusReadable"><span>申请状态</span><select v-model="applicationFilter"><option value="">全部</option><option v-for="value in applicationStatuses" :key="value" :value="value">{{ value }}</option></select></label> <label v-if="statusReadable"><span>申请状态</span><select v-model="applicationFilter"><option value="">全部</option><option v-for="value in applicationStatuses" :key="value" :value="value">{{ value }}</option></select></label>
<label v-if="statusReadable"><span>收单状态</span><select v-model="receiptFilter"><option value="">全部</option><option v-for="value in receiptStatuses" :key="value" :value="value">{{ value }}</option></select></label> <label v-if="statusReadable"><span>审批状态</span><select v-model="approvalFilter"><option value="">全部</option><option v-for="value in approvalStatuses" :key="value" :value="value">{{ value }}</option></select></label>
<label v-if="statusReadable"><span>付款状态</span><select v-model="paymentFilter"><option value="">全部</option><option v-for="value in paymentStatuses" :key="value" :value="value">{{ value }}</option></select></label> <label v-if="statusReadable"><span>付款状态</span><select v-model="paymentFilter"><option value="">全部</option><option v-for="value in paymentStatuses" :key="value" :value="value">{{ value }}</option></select></label>
<label v-if="statusReadable"><span>同步状态</span><select v-model="syncFilter"><option value="">全部</option><option v-for="value in syncStatuses" :key="value" :value="value">{{ value }}</option></select></label> <label v-if="statusReadable"><span>同步状态</span><select v-model="syncFilter"><option value="">全部</option><option v-for="value in syncStatuses" :key="value" :value="value">{{ value }}</option></select></label>
</div> </div>
@@ -88,75 +64,39 @@
<div class="table-wrap application-table-wrap"> <div class="table-wrap application-table-wrap">
<table class="data-table responsive-table" aria-label="付款申请列表"> <table class="data-table responsive-table" aria-label="付款申请列表">
<caption class="sr-only">付款申请列表,包含申请、审批、收单和付款状态</caption> <caption class="sr-only">付款申请列表,包含申请、事项、金额、申请状态、审批状态、付款状态和当前节点</caption>
<thead> <thead>
<tr> <tr>
<th v-if="uiRead('ui.applications.column.number')" scope="col">申请单号</th> <th v-if="uiRead('ui.applications.column.number')" scope="col">申请</th>
<th v-if="uiRead('ui.applications.column.number')" scope="col">申请日期</th> <th v-if="showApplicationTitleColumn" scope="col">事项</th>
<th v-if="showApplicationTitleColumn" scope="col">申请事项</th> <th v-if="uiRead('ui.applications.column.amount')" scope="col" class="amount">金额</th>
<th v-if="uiRead('ui.applications.column.applicant')" scope="col">收款对象</th> <template v-if="uiRead('ui.applications.column.status')"><th scope="col">申请状态</th><th scope="col">审批状态</th><th scope="col">付款状态</th></template>
<th v-if="uiRead('ui.applications.column.amount')" scope="col" class="amount">申请付款金额</th> <th v-if="statusReadable" scope="col">当前节点</th>
<template v-if="uiRead('ui.applications.column.status')"><th scope="col">申请状态</th><th scope="col">审批状态</th><th scope="col">收单状态</th><th scope="col">付款状态</th></template>
<template v-if="statusReadable"><th scope="col">当前审批节点</th><th scope="col">当前审批人</th></template>
<th scope="col">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-if="!filtered.length"><td :colspan="Math.max(1, Number(uiRead('ui.applications.column.number')) + Number(showApplicationTitleColumn) + Number(uiRead('ui.applications.column.amount')) + (statusReadable ? 4 : 0))"><div class="empty-state"><strong>{{ store.paymentApplications.length ? '没有符合条件的付款申请' : '暂无付款申请' }}</strong><span>请发起付款申请或调整筛选条件。</span><button v-if="hasFilters" class="btn" type="button" @click="clearFilters">清除筛选</button><router-link v-if="canCreate" class="btn primary" to="/applications/new">发起付款申请</router-link></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td v-if="uiRead('ui.applications.column.number')" data-label="申请单号"> <td v-if="uiRead('ui.applications.column.number')" data-label="申请">
<router-link v-if="rowViewable(item)" class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong> <router-link v-if="rowViewable(item)" class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong>
<small>{{ (item.submitTime || item.createdAt)?.slice(0, 10) || '—' }}</small>
</td> </td>
<td v-if="uiRead('ui.applications.column.number')" data-label="申请日期">{{ (item.submitTime || item.createdAt)?.slice(0, 10) || '—' }}</td> <td v-if="showApplicationTitleColumn" data-label="事项">
<td v-if="showApplicationTitleColumn" data-label="申请事项"> <strong v-if="uiRead('ui.applications.column.title')">{{ item.paymentReason || item.title }}</strong>
<strong v-if="uiRead('ui.applications.column.title')">{{ item.title }}</strong> <small><template v-if="uiRead('ui.applications.column.title')">{{ item.paymentScenario || item.expenseItemCategory }}</template><template v-if="uiRead('ui.applications.column.applicant') && hasOwnField(item, 'applicantName')"><template v-if="uiRead('ui.applications.column.title')"> · </template>{{ item.applicantName }}</template><template v-if="uiRead('ui.applications.column.applicant') && item.payeeName"> → {{ item.payeeName }}</template></small>
<small><template v-if="uiRead('ui.applications.column.title')">{{ item.category || item.expenseTypeName }}</template><template v-if="uiRead('ui.applications.column.applicant') && hasOwnField(item, 'applicantName')"><template v-if="uiRead('ui.applications.column.title')"> · </template>{{ item.applicantName }}</template></small>
</td>
<td v-if="uiRead('ui.applications.column.applicant')" data-label="收款对象">{{ hasOwnField(item, 'payeeName') ? item.payeeName || '—' : '字段不可见' }}</td>
<td v-if="uiRead('ui.applications.column.amount') && hasOwnField(item, 'totalAmount')" data-label="申请金额" class="amount">{{ money(item.totalAmount) }}</td>
<td v-else-if="uiRead('ui.applications.column.amount')" data-label="申请金额" class="amount muted-copy">字段不可见</td>
<template v-if="uiRead('ui.applications.column.status')"><td data-label="申请状态"><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></td><td data-label="审批状态"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></td><td data-label="收单状态"><span class="tag" :class="tone(item.receiptStatus)">{{ item.receiptStatus }}</span></td><td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td></template>
<template v-if="statusReadable"><td data-label="当前审批节点">{{ item.currentApprovalNode || '—' }}</td><td data-label="当前审批人"><span class="muted-copy">接口暂未提供</span></td></template>
<td data-label="操作">
<div class="application-row-actions">
<router-link v-if="rowViewable(item)" class="table-action" :to="`/applications/${item.id}`">查看详情</router-link>
<router-link v-if="editable(item)" class="table-action" :to="`/applications/${item.id}/edit`">
{{ item.approvalStatus === '退回' ? '补充材料' : '编辑草稿' }}
</router-link>
<button v-if="submittable(item)" class="table-action" type="button" :disabled="actionPending(item)" @click="submitApplication(item)">{{ actionPending(item) ? '处理中…' : '提交申请' }}</button>
<button v-if="deletable(item)" class="table-action danger" type="button" :disabled="actionPending(item)" @click="deleteApplication(item)">{{ actionPending(item) ? '处理中…' : '删除草稿' }}</button>
<span v-if="!hasRowActions(item)" class="muted-copy">—</span>
</div>
</td> </td>
<td v-if="uiRead('ui.applications.column.amount') && hasOwnField(item, 'requestedAmount')" data-label="金额" class="amount"><strong>{{ money(item.requestedAmount || 0) }}</strong><small>批准 {{ item.approvedAmount == null ? '—' : money(item.approvedAmount) }} · 实付 {{ item.actualPaymentAmount == null ? '—' : money(item.actualPaymentAmount) }}</small></td>
<td v-else-if="uiRead('ui.applications.column.amount')" data-label="金额" class="amount muted-copy">字段不可见</td>
<template v-if="uiRead('ui.applications.column.status')"><td data-label="申请状态"><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></td><td data-label="审批状态"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></td><td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td></template>
<td v-if="statusReadable" data-label="当前节点">{{ item.currentApprovalNode || '—' }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-if="!store.reimbursements.length" class="empty-state">
<strong>暂无付款申请</strong>
<span>发起一笔付款申请后,审批与付款进度会显示在这里。</span>
<router-link v-if="canCreate" class="btn primary" to="/applications/new">发起付款申请</router-link>
</div>
<div v-else-if="!filtered.length" class="empty-state">
<strong>没有符合条件的付款申请</strong>
<span>请调整搜索关键词或筛选条件。</span>
<button class="btn" type="button" @click="clearFilters">清除筛选</button>
</div>
<AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="付款申请列表分页" /> <AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="付款申请列表分页" />
</div> </div>
</div> </div>
<div v-else class="card primary-list-card travel-readonly-panel">
<div class="filter-bar list-toolbar">
<div class="list-toolbar__filters"><label class="filter-search"><span aria-hidden="true">⌕</span><input v-model="travelQuery" type="search" placeholder="搜索单号、目的地或出差事由" aria-label="搜索出差申请"></label><select v-model="travelStatus" aria-label="按出差审批状态筛选"><option value="">全部状态</option><option v-for="status in travelStatuses" :key="status" :value="status">{{ status }}</option></select></div>
<div class="list-toolbar__meta"><span class="tag info">{{ filteredTravel.length }} 笔本人申请</span></div>
</div>
<div v-if="filteredTravel.length" class="table-wrap application-table-wrap" tabindex="0" role="region" aria-label="本人出差申请列表"><table class="data-table responsive-table">
<thead><tr><th>申请单号</th><th>行程</th><th>出差事由</th><th class="amount">预计金额</th><th>状态</th><th>同步时间</th></tr></thead>
<tbody><tr v-for="item in paginatedTravel" :key="item.id"><td data-label="申请单号"><strong>{{ item.travelRequestNo }}</strong><small>{{ item.approvalSystem }}</small></td><td data-label="行程"><strong>{{ item.destination || '未填写目的地' }}</strong><small>{{ travelDateRange(item) }}</small></td><td data-label="出差事由"><strong>{{ item.purpose || '—' }}</strong><small>{{ [item.entity, item.department].filter(Boolean).join(' · ') || '—' }}</small></td><td data-label="预计金额" class="amount">{{ item.estimate == null ? '—' : money(item.estimate) }}</td><td data-label="状态"><span class="tag" :class="tone(travelStatusLabel(item.status))">{{ travelStatusLabel(item.status) }}</span></td><td data-label="同步时间"><small>{{ formatDateTime(item.syncedAt) }}</small></td></tr></tbody>
</table></div>
<div v-else class="empty-state"><strong>暂无可展示的出差申请</strong><span>这里只展示当前登录人作为申请人的飞书出差单,其他员工的申请不会返回。</span><small>审批定义编码可在“系统管理 → 集成与运行 → 集成管理”录入。</small></div>
<AppListPagination v-if="filteredTravel.length" v-model:page="travelPage" v-model:page-size="travelPageSize" :total="filteredTravel.length" aria-label="出差申请列表分页" />
</div>
</div> </div>
</div> </div>
</template> </template>
@@ -165,7 +105,6 @@
import { computed, onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import type { ReimApplicationDetail } from '@/api/reimbursement' import type { ReimApplicationDetail } from '@/api/reimbursement'
import { travelApplicationsApi, type TravelApplication } from '@/api/travelApplications'
import AppListPagination from '@/components/common/AppListPagination.vue' import AppListPagination from '@/components/common/AppListPagination.vue'
import { matchesReadableSearch } from '@/authorization/searchProjection' import { matchesReadableSearch } from '@/authorization/searchProjection'
import { useListPagination } from '@/composables/useListPagination' import { useListPagination } from '@/composables/useListPagination'
@@ -175,97 +114,68 @@ import { useUserStore } from '@/store/user'
import { useWorkbenchStore } from '@/store/workbench' import { useWorkbenchStore } from '@/store/workbench'
import { ElMessage, ElMessageBox } from '@/utils/uiFeedback' import { ElMessage, ElMessageBox } from '@/utils/uiFeedback'
type ApplicationTabKey = 'all' | 'mine' | 'approval' | 'received' type ApplicationTabKey = 'all' | 'approval' | 'paid'
type ApplicationTab = { key: ApplicationTabKey; label: string }
type ApplicationKind = 'payment' | 'travel'
const store = useWorkbenchStore() const store = useWorkbenchStore()
const authorization = useAuthorizationStore() const authorization = useAuthorizationStore()
const userStore = useUserStore() const userStore = useUserStore()
const route = useRoute() const route = useRoute()
const query = ref(String(route.query.q || '')) const query = ref(String(route.query.q || ''))
const applicationKind = ref<ApplicationKind>(String(route.query.tab || '').toLowerCase() === 'travel' ? 'travel' : 'payment')
const travelRows = ref<TravelApplication[]>([])
const travelLoading = ref(false)
const travelLoaded = ref(false)
const travelError = ref('')
const travelQuery = ref('')
const travelStatus = ref('')
const currentTab = ref<ApplicationTabKey>('all') const currentTab = ref<ApplicationTabKey>('all')
const tabs: Array<{ key: ApplicationTabKey; label: string }> = [
{ key: 'all', label: '全部' },
{ key: 'approval', label: '审批中' },
{ key: 'paid', label: '已登记付款结果' },
]
const applicationFilter = ref('') const applicationFilter = ref('')
const expenseFilter = ref('') const approvalFilter = ref('')
const receiptFilter = ref('')
const paymentFilter = ref('') const paymentFilter = ref('')
const syncFilter = ref('') const syncFilter = ref('')
const pendingActionIds = ref<Set<string>>(new Set()) const pendingActionIds = ref<Set<string>>(new Set())
const hasLoaded = ref(Boolean(store.reimbursements.length)) const hasLoaded = ref(Boolean(store.paymentApplications.length))
const applicationsPanelId = 'applications-list-panel' const applicationsPanelId = 'applications-list-panel'
const uiRead = (code: string) => userStore.canRead(code) const uiRead = (code: string) => userStore.canRead(code)
const canCreate = computed(() => userStore.canEdit('reimbursement.application.create') && authorization.can('reimbursement.application:create')) const canCreate = computed(() => userStore.canEdit('reimbursement.application.create') && authorization.can('reimbursement.application:create'))
const canExport = computed(() => userStore.canEdit('ui.applications.export')) const canExport = computed(() => userStore.canEdit('ui.applications.export'))
const canViewTravel = computed(() => userStore.canRead('page.travel-applications'))
const canViewDetail = computed(() => userStore.canRead('page.application-detail') && authorization.can('reimbursement.application:read')) const canViewDetail = computed(() => userStore.canRead('page.application-detail') && authorization.can('reimbursement.application:read'))
const showApplicationTitleColumn = computed(() => uiRead('ui.applications.column.title') || uiRead('ui.applications.column.applicant')) const showApplicationTitleColumn = computed(() => uiRead('ui.applications.column.title') || uiRead('ui.applications.column.applicant'))
const statusReadable = computed(() => uiRead('ui.applications.column.status')) const statusReadable = computed(() => uiRead('ui.applications.column.status'))
const overviewStatusReadable = computed(() => statusReadable.value && uiRead('ui.dashboard.metric.pending')) const overviewStatusReadable = computed(() => statusReadable.value && uiRead('ui.dashboard.metric.pending'))
const overviewAmountReadable = computed(() => uiRead('ui.applications.column.amount') && uiRead('ui.dashboard.metric.amount')) const applicationStatuses = computed(() => [...new Set(store.paymentApplications.map(item => item.applicationStatus).filter(Boolean))])
const expenseTypes = computed(() => [...new Set(store.reimbursements.map(item => item.expenseTypeName).filter(Boolean))]) const approvalStatuses = computed(() => [...new Set(store.paymentApplications.map(item => item.approvalStatus).filter(Boolean))])
const applicationStatuses = computed(() => [...new Set(store.reimbursements.flatMap(item => [item.applicationStatus, item.approvalStatus]).filter(Boolean))]) const paymentStatuses = computed(() => [...new Set(store.paymentApplications.map(item => item.paymentStatus).filter(Boolean))])
const receiptStatuses = computed(() => [...new Set(store.reimbursements.map(item => item.receiptStatus).filter(Boolean))]) const syncStatuses = computed(() => [...new Set(store.paymentApplications.map(item => syncStatusLabel(item.syncStatus)).filter(Boolean))])
const paymentStatuses = computed(() => [...new Set(store.reimbursements.map(item => item.paymentStatus).filter(Boolean))])
const syncStatuses = computed(() => [...new Set(store.reimbursements.map(item => syncStatusLabel(item.sourceStatus)).filter(Boolean))])
const metrics = computed(() => { const metrics = computed(() => {
const monthly = store.reimbursements.filter(item => (item.submitTime || item.createdAt || '').slice(0, 7) === new Date().toISOString().slice(0, 7)) const rows = store.paymentApplications
return { drafts: store.reimbursements.filter(item => item.applicationStatus === '草稿').length, returned: store.reimbursements.filter(item => item.approvalStatus === '退回').length, monthlyCount: monthly.length, monthlyAmount: monthly.reduce((sum, item) => sum + (hasOwnField(item, 'totalAmount') ? Number(item.totalAmount) || 0 : 0), 0) } return {
financeCheck: store.financeCheckEnabled ? rows.filter(item => item.financeCheckStatus === '待核对').length : '未启用',
pendingPayment: rows.filter(item => item.approvalStatus === '审批通过' && ['未付款', '部分付款', '待登记付款结果'].includes(item.paymentStatus)).length,
syncErrors: rows.filter(item => syncStatusLabel(item.syncStatus) === '同步异常').length,
paid: rows.filter(item => ['已付款', '付款结果已登记'].includes(item.paymentStatus)).length,
}
}) })
const tabs: ApplicationTab[] = [ const matchesTab = (item: ReimApplicationDetail) => currentTab.value === 'all'
{ key: 'all', label: '全部' }, || (currentTab.value === 'approval' && item.approvalStatus === '审批中')
{ key: 'mine', label: '我发起的' }, || (currentTab.value === 'paid' && ['已付款', '付款结果已登记'].includes(item.paymentStatus))
{ key: 'approval', label: '审批中' },
{ key: 'received', label: '已收单' },
]
const matchesTab = (item: ReimApplicationDetail, tab: ApplicationTabKey) => (
tab === 'all' ||
(tab === 'mine' && Boolean(userStore.userInfo?.employeeNo) && item.applicantEmployeeNo === userStore.userInfo?.employeeNo) ||
(tab === 'approval' && statusReadable.value && item.approvalStatus === '审批中') ||
(tab === 'received' && statusReadable.value && item.receiptStatus === '已收单')
)
const tabCounts = computed<Record<ApplicationTabKey, number>>(() => ({
all: store.reimbursements.length,
mine: store.reimbursements.filter(item => matchesTab(item, 'mine')).length,
approval: store.reimbursements.filter(item => matchesTab(item, 'approval')).length,
received: store.reimbursements.filter(item => matchesTab(item, 'received')).length,
}))
const filtered = computed(() => { const filtered = computed(() => {
return store.reimbursements.filter(item => ( return store.paymentApplications.filter(item => (
matchesTab(item) &&
matchesReadableSearch(query.value, [ matchesReadableSearch(query.value, [
{ readable: uiRead('ui.applications.column.number'), values: [item.applicationNo] }, { readable: uiRead('ui.applications.column.number'), values: [item.applicationNo] },
{ readable: uiRead('ui.applications.column.title'), values: [item.title, item.category, item.expenseTypeName] }, { readable: uiRead('ui.applications.column.title'), values: [item.title, item.paymentReason, item.paymentScenario, item.expenseItemCategory] },
{ readable: uiRead('ui.applications.column.applicant'), values: [item.applicantName, item.payeeName] }, { readable: uiRead('ui.applications.column.applicant'), values: [item.applicantName, item.payeeName] },
]) && ]) &&
(!statusReadable.value || !applicationFilter.value || item.applicationStatus === applicationFilter.value || item.approvalStatus === applicationFilter.value) && (!statusReadable.value || !applicationFilter.value || item.applicationStatus === applicationFilter.value) &&
(!uiRead('ui.applications.column.title') || !expenseFilter.value || item.expenseTypeName === expenseFilter.value) && (!statusReadable.value || !approvalFilter.value || item.approvalStatus === approvalFilter.value) &&
(!statusReadable.value || !receiptFilter.value || item.receiptStatus === receiptFilter.value) &&
(!statusReadable.value || !paymentFilter.value || item.paymentStatus === paymentFilter.value) && (!statusReadable.value || !paymentFilter.value || item.paymentStatus === paymentFilter.value) &&
(!statusReadable.value || !syncFilter.value || syncStatusLabel(item.sourceStatus) === syncFilter.value) && (!statusReadable.value || !syncFilter.value || syncStatusLabel(item.syncStatus) === syncFilter.value)
matchesTab(item, currentTab.value)
)) ))
}) })
const { page, pageSize, paginatedItems } = useListPagination(filtered, { const { page, pageSize, paginatedItems } = useListPagination(filtered, {
resetSources: [query, currentTab, applicationFilter, expenseFilter, receiptFilter, paymentFilter, syncFilter], resetSources: [currentTab, query, applicationFilter, approvalFilter, paymentFilter, syncFilter],
}) })
const travelStatuses = computed(() => [...new Set(travelRows.value.map(item => travelStatusLabel(item.status)))])
const filteredTravel = computed(() => travelRows.value.filter(item => {
const status = travelStatusLabel(item.status)
const search = travelQuery.value.trim().toLowerCase()
const matchesSearch = !search || [item.travelRequestNo, item.destination, item.purpose, item.entity, item.department, ...(item.travelers || [])].some(value => String(value || '').toLowerCase().includes(search))
return matchesSearch && (!travelStatus.value || status === travelStatus.value)
}))
const { page: travelPage, pageSize: travelPageSize, paginatedItems: paginatedTravel } = useListPagination(filteredTravel, { resetSources: [travelQuery, travelStatus] })
watch(() => route.query.q, value => { watch(() => route.query.q, value => {
const nextQuery = String(value || '') const nextQuery = String(value || '')
if (query.value !== nextQuery) query.value = nextQuery if (query.value !== nextQuery) query.value = nextQuery
@@ -273,17 +183,11 @@ watch(() => route.query.q, value => {
const loadingState = computed(() => store.loading || !hasLoaded.value) const loadingState = computed(() => store.loading || !hasLoaded.value)
const hasBlockingError = computed(() => hasLoaded.value && store.source === 'error') const hasBlockingError = computed(() => hasLoaded.value && store.source === 'error')
const activeLoading = computed(() => applicationKind.value === 'travel' ? travelLoading.value || !travelLoaded.value : loadingState.value)
const activeBlockingError = computed(() => applicationKind.value === 'travel' ? Boolean(travelError.value) : hasBlockingError.value)
const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value) const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value)
const activeFilterCount = computed(() => [query.value.trim(), applicationFilter.value, expenseFilter.value, receiptFilter.value, paymentFilter.value, syncFilter.value].filter(Boolean).length) const activeFilterCount = computed(() => [query.value.trim(), applicationFilter.value, approvalFilter.value, paymentFilter.value, syncFilter.value].filter(Boolean).length)
const hasFilters = computed(() => activeFilterCount.value > 0) const hasFilters = computed(() => activeFilterCount.value > 0)
const reload = async () => { const reload = async () => {
if (applicationKind.value === 'travel') {
await loadTravel()
return
}
hasLoaded.value = false hasLoaded.value = false
try { try {
await store.load() await store.load()
@@ -292,20 +196,10 @@ const reload = async () => {
} }
} }
const loadTravel = async () => {
if (!canViewTravel.value) { travelRows.value = []; travelLoaded.value = true; return }
travelLoading.value = true
travelError.value = ''
try { const rows = await travelApplicationsApi.mine(); travelRows.value = Array.isArray(rows) ? rows : [] }
catch (error) { travelError.value = error instanceof Error ? error.message : '出差申请加载失败' }
finally { travelLoading.value = false; travelLoaded.value = true }
}
const clearFilters = () => { const clearFilters = () => {
query.value = '' query.value = ''
applicationFilter.value = '' applicationFilter.value = ''
expenseFilter.value = '' approvalFilter.value = ''
receiptFilter.value = ''
paymentFilter.value = '' paymentFilter.value = ''
syncFilter.value = '' syncFilter.value = ''
} }
@@ -317,19 +211,19 @@ const csvCell = (value: unknown) => {
} }
const exportApplications = () => { const exportApplications = () => {
if (!canExport.value || !filtered.value.length) return if (!canExport.value) return
if (!filtered.value.length) { ElMessage.info('当前没有可导出的付款申请,请调整筛选条件或发起申请'); return }
const columns: Array<{ label: string; readable: boolean; value: (item: ReimApplicationDetail) => unknown }> = [ const columns: Array<{ label: string; readable: boolean; value: (item: ReimApplicationDetail) => unknown }> = [
{ label: '申请单号', readable: uiRead('ui.applications.column.number'), value: (item: ReimApplicationDetail) => item.applicationNo }, { label: '申请单号', readable: uiRead('ui.applications.column.number'), value: (item: ReimApplicationDetail) => item.applicationNo },
{ label: '申请日期', readable: uiRead('ui.applications.column.number'), value: (item: ReimApplicationDetail) => (item.submitTime || item.createdAt || '').slice(0, 10) }, { label: '申请日期', readable: uiRead('ui.applications.column.number'), value: (item: ReimApplicationDetail) => (item.submitTime || item.createdAt || '').slice(0, 10) },
{ label: '事项', readable: uiRead('ui.applications.column.title'), value: (item: ReimApplicationDetail) => item.title }, { label: '事项', readable: uiRead('ui.applications.column.title'), value: (item: ReimApplicationDetail) => item.title },
{ label: '费用类型', readable: uiRead('ui.applications.column.title'), value: (item: ReimApplicationDetail) => item.expenseTypeName || item.category }, { label: '付款情形', readable: uiRead('ui.applications.column.title'), value: (item: ReimApplicationDetail) => item.paymentScenario },
{ label: '收款对象', readable: uiRead('ui.applications.column.applicant'), value: (item: ReimApplicationDetail) => item.payeeName }, { label: '收款方', readable: uiRead('ui.applications.column.applicant'), value: (item: ReimApplicationDetail) => item.payeeName },
{ label: '申请付款金额', readable: uiRead('ui.applications.column.amount'), value: (item: ReimApplicationDetail) => item.totalAmount }, { label: '申请付款金额', readable: uiRead('ui.applications.column.amount'), value: (item: ReimApplicationDetail) => item.requestedAmount },
{ label: '申请状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.applicationStatus }, { label: '申请状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.applicationStatus },
{ label: '审批状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.approvalStatus }, { label: '审批状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.approvalStatus },
{ label: '收单状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.receiptStatus },
{ label: '付款状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.paymentStatus }, { label: '付款状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.paymentStatus },
{ label: '同步状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => syncStatusLabel(item.sourceStatus) }, { label: '同步状态', readable: statusReadable.value, value: (item: ReimApplicationDetail) => syncStatusLabel(item.syncStatus) },
{ label: '当前审批节点', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.currentApprovalNode }, { label: '当前审批节点', readable: statusReadable.value, value: (item: ReimApplicationDetail) => item.currentApprovalNode },
].filter(column => column.readable) ].filter(column => column.readable)
if (!columns.length) { if (!columns.length) {
@@ -404,32 +298,24 @@ const money = (value: number) => `¥ ${Number(value || 0).toLocaleString('zh-CN'
const syncStatusLabel = (value: string) => ({ const syncStatusLabel = (value: string) => ({
NOT_CONFIGURED: '未同步', PENDING: '待同步', SYNCING: '待同步', SYNCED: '已同步', SUCCESS: '已同步', FAILED: '同步异常', ERROR: '同步异常', NOT_CONFIGURED: '未同步', PENDING: '待同步', SYNCING: '待同步', SYNCED: '已同步', SUCCESS: '已同步', FAILED: '同步异常', ERROR: '同步异常',
} as Record<string, string>)[String(value || '').toUpperCase()] || value || '未同步' } as Record<string, string>)[String(value || '').toUpperCase()] || value || '未同步'
const travelStatusLabel = (value: string) => ({ PENDING: '审批中', APPROVED: '审批通过', REJECTED: '退回', CANCELED: '已撤销', CANCELLED: '已撤销', TERMINATED: '已终止' } as Record<string, string>)[String(value || '').toUpperCase()] || value || '未知'
const travelDateRange = (item: TravelApplication) => [item.startDate, item.endDate].filter(Boolean).join(' 至 ') || '未填写日期'
const formatDateTime = (value: string) => value ? value.replace('T', ' ').slice(0, 16) : '—'
const tone = (value: string) => ({ const tone = (value: string) => ({
草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger', 草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger',
待收单: 'pending', 已收单: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 未触发: 'neutral', 待核对: 'pending', 已核对: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 未触发: 'neutral',
} as Record<string, string>)[value] || 'neutral' } as Record<string, string>)[value] || 'neutral'
onMounted(async () => { onMounted(async () => {
if (applicationKind.value === 'travel' && !canViewTravel.value) applicationKind.value = 'payment'
try { try {
if (!store.reimbursements.length) await store.load() if (!store.paymentApplications.length) await store.load()
} finally { } finally {
hasLoaded.value = true hasLoaded.value = true
} }
if (applicationKind.value === 'travel') await loadTravel()
})
watch(applicationKind, async kind => {
if (kind === 'travel' && !travelLoaded.value && canViewTravel.value) await loadTravel()
}) })
</script> </script>
<style scoped> <style scoped>
.application-kind-tabs { margin-bottom: 12px; } .application-status-tabs { padding: 0 var(--component-inset); }
.application-kind-tabs .tabs { border-bottom: 0; }
.application-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } .application-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.application-metrics .metric.danger::before { background: var(--danger); }
.application-filter-panel { display: grid; gap: 14px; padding: 16px var(--component-inset); border-bottom: 1px solid var(--line); background: var(--surface-raised); } .application-filter-panel { display: grid; gap: 14px; padding: 16px var(--component-inset); border-bottom: 1px solid var(--line); background: var(--surface-raised); }
.application-filter-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 16px; } .application-filter-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 16px; }
.application-filter-head > strong { color: var(--navy); font-size: 13px; } .application-filter-head > strong { color: var(--navy); font-size: 13px; }
@@ -451,6 +337,4 @@ watch(applicationKind, async kind => {
@media (max-width: 900px) { .application-metrics, .application-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .application-filter-head { align-items: flex-start; flex-direction: column; } .application-filter-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; } } @media (max-width: 900px) { .application-metrics, .application-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .application-filter-head { align-items: flex-start; flex-direction: column; } .application-filter-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; } }
@media (max-width: 700px) { .application-list-panel, .application-table-wrap { min-height: 0; flex: 0 0 auto; } } @media (max-width: 700px) { .application-list-panel, .application-table-wrap { min-height: 0; flex: 0 0 auto; } }
@media (max-width: 600px) { .application-metrics, .application-filter-grid { grid-template-columns: 1fr; } } @media (max-width: 600px) { .application-metrics, .application-filter-grid { grid-template-columns: 1fr; } }
.travel-readonly-panel .empty-state { min-height: 260px; }
.travel-readonly-panel small { max-width: 560px; color: var(--quiet); line-height: 1.6; text-align: center; }
</style> </style>
+1 -1
View File
@@ -10,6 +10,6 @@ import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
const title = computed(() => String(route.meta.title || '配置页面')) const title = computed(() => String(route.meta.title || '配置页面'))
const group = computed(() => String(route.meta.configGroup || '业务配置')) const group = computed(() => String(route.meta.configGroup || '业务配置'))
const backTarget = computed(() => route.meta.pageAccess === 'payees' ? '/payees' : '/expense-types') const backTarget = computed(() => route.meta.pageAccess === 'payees' ? '/payees' : '/payment-scenarios')
</script> </script>
<style scoped>.placeholder-card { min-height: 320px; }</style> <style scoped>.placeholder-card { min-height: 320px; }</style>
+57 -55
View File
@@ -2,19 +2,19 @@
<div class="dashboard-page"> <div class="dashboard-page">
<div class="page-head"> <div class="page-head">
<div> <div>
<span class="eyebrow">{{ isFinance ? '财务工作台' : '员工报销' }}</span> <span class="eyebrow">{{ isFinance ? '财务工作台' : '统一付款' }}</span>
<h1>{{ isFinance ? '财务处理工作台' : '我的报销工作台' }}</h1> <h1>{{ isFinance ? '财务处理工作台' : '我的付款申请' }}</h1>
<p v-if="isFinance">你好,{{ userName }}。集中处理收单、付款和业务单据。</p> <p v-if="isFinance">你好,{{ userName }}。集中处理审批记录、付款结果和业务单据。</p>
<p v-else>你好,{{ userName }}。查看报销进度,及时处理退回事项。</p> <p v-else>你好,{{ userName }}。查看付款申请进度,及时处理退回事项。</p>
</div> </div>
<div class="head-actions"> <div class="head-actions">
<template v-if="isFinance"> <template v-if="isFinance">
<router-link v-if="authorization.can('finance.receipt:receive')" class="btn" to="/finance-receipt">查看待收单</router-link> <router-link v-if="store.financeCheckEnabled && authorization.can('finance.receipt:receive')" class="btn" to="/finance-receipt">查看待核对</router-link>
<router-link v-if="authorization.canAny(['finance.payment:read', 'finance.payment:register', 'finance.payment:review'])" class="btn" to="/payments">查看待付款</router-link> <router-link v-if="authorization.canAny(['finance.payment:read', 'finance.payment:register', 'finance.payment:review'])" class="btn" to="/payments">查看待付款</router-link>
</template> </template>
<template v-else> <template v-else>
<router-link v-if="authorization.can('reimbursement.application:create')" class="btn primary" to="/applications/new"><Plus /> 发起报销</router-link> <router-link v-if="authorization.can('reimbursement.application:create')" class="btn primary" to="/applications/new"><Plus /> 发起付款申请</router-link>
<router-link v-if="authorization.can('reimbursement.application:read')" class="btn" to="/applications">查看我的报销</router-link> <router-link v-if="authorization.can('reimbursement.application:read')" class="btn" to="/applications">查看我的付款申请</router-link>
</template> </template>
<button class="btn" type="button" :disabled="store.loading || financeQueueLoading" @click="refresh"> <button class="btn" type="button" :disabled="store.loading || financeQueueLoading" @click="refresh">
<Refresh /> 刷新数据 <Refresh /> 刷新数据
@@ -22,7 +22,7 @@
</div> </div>
</div> </div>
<div v-if="store.loading || financeQueueLoading || (store.source === 'connecting' && !store.reimbursements.length)" class="load-wrap" role="status" aria-live="polite"> <div v-if="store.loading || financeQueueLoading || (store.source === 'connecting' && !store.paymentApplications.length)" class="load-wrap" role="status" aria-live="polite">
<span class="loader"></span> <span class="loader"></span>
<p>正在读取工作台数据…</p> <p>正在读取工作台数据…</p>
</div> </div>
@@ -39,9 +39,9 @@
<div class="welcome-panel__layout"> <div class="welcome-panel__layout">
<div> <div>
<span class="eyebrow">数据概览</span> <span class="eyebrow">数据概览</span>
<h2>{{ isFinance ? '今日处理重点' : '报销进度,随时掌握' }}</h2> <h2>{{ isFinance ? '今日处理重点' : '付款申请进度,随时掌握' }}</h2>
<p v-if="isFinance">待收单和待付款队列按独立业务状态呈现,金额以当前同步结果为准。</p> <p v-if="isFinance">审批事实和付款结果按独立业务状态呈现,金额以当前同步结果为准。</p>
<p v-else>审批、收单和付款状态分别展示,退回事项可以直接继续处理。</p> <p v-else>申请、审批和付款状态分别展示,退回事项可以直接继续处理。</p>
</div> </div>
<div class="sync-status" :class="{ warning: !!store.error }"> <div class="sync-status" :class="{ warning: !!store.error }">
<span class="sync-dot"></span> <span class="sync-dot"></span>
@@ -54,7 +54,7 @@
</section> </section>
<div v-if="!isFinance" class="metrics dashboard-metrics"> <div v-if="!isFinance" class="metrics dashboard-metrics">
<div v-if="uiRead('ui.dashboard.metric.pending')" class="metric warn"> <div v-if="store.financeCheckEnabled && uiRead('ui.dashboard.metric.pending')" class="metric warn">
<small>退回待办</small> <small>退回待办</small>
<strong>{{ returned.length }}</strong> <strong>{{ returned.length }}</strong>
<span>{{ returned.length ? '项待补充材料' : '暂无待处理事项' }}</span> <span>{{ returned.length ? '项待补充材料' : '暂无待处理事项' }}</span>
@@ -64,13 +64,13 @@
<strong>{{ approving.length }}</strong> <strong>{{ approving.length }}</strong>
<span>申请正在审批流程中</span> <span>申请正在审批流程中</span>
</div> </div>
<div v-if="uiRead('ui.dashboard.metric.amount')" class="metric"> <div v-if="store.financeCheckEnabled && uiRead('ui.dashboard.metric.amount')" class="metric">
<small>待付款</small> <small>待付款</small>
<strong>{{ pendingPayment.length }}</strong> <strong>{{ pendingPayment.length }}</strong>
<span>{{ money(pendingPaymentAmount) }} 待支付</span> <span>{{ money(pendingPaymentAmount) }} 待支付</span>
</div> </div>
<div v-if="uiRead('ui.dashboard.metric.amount')" class="metric success"> <div v-if="uiRead('ui.dashboard.metric.amount')" class="metric success">
<small>本月报销金额</small> <small>本月申请付款金额</small>
<strong>{{ money(monthTotal) }}</strong> <strong>{{ money(monthTotal) }}</strong>
<span>{{ monthCount }} 笔本月申请</span> <span>{{ monthCount }} 笔本月申请</span>
</div> </div>
@@ -78,14 +78,14 @@
<div v-else class="metrics dashboard-metrics finance-dashboard-metrics"> <div v-else class="metrics dashboard-metrics finance-dashboard-metrics">
<div v-if="uiRead('ui.dashboard.metric.pending')" class="metric warn"> <div v-if="uiRead('ui.dashboard.metric.pending')" class="metric warn">
<small>待收单</small> <small>待核对</small>
<strong>{{ receipt.length }}</strong> <strong>{{ receipt.length }}</strong>
<span>审批通过,等待财务确认</span> <span>审批通过,等待财务确认</span>
</div> </div>
<div v-if="uiRead('ui.dashboard.metric.pending')" class="metric"> <div v-if="uiRead('ui.dashboard.metric.pending')" class="metric">
<small>待付款</small> <small>待付款</small>
<strong>{{ payable.length }}</strong> <strong>{{ payable.length }}</strong>
<span>已收单且存在未付余额</span> <span>已具备付款结果登记资格</span>
</div> </div>
<div v-if="uiRead('ui.dashboard.metric.amount')" class="metric success"> <div v-if="uiRead('ui.dashboard.metric.amount')" class="metric success">
<small>待付款金额</small> <small>待付款金额</small>
@@ -93,7 +93,7 @@
<span>当前未付余额合计</span> <span>当前未付余额合计</span>
</div> </div>
<div v-if="uiRead('ui.dashboard.metric.amount')" class="metric"> <div v-if="uiRead('ui.dashboard.metric.amount')" class="metric">
<small>已收单</small> <small>已核对</small>
<strong>{{ received.length }}</strong> <strong>{{ received.length }}</strong>
<span>{{ money(receivedAmount) }} 已进入付款环节</span> <span>{{ money(receivedAmount) }} 已进入付款环节</span>
</div> </div>
@@ -102,22 +102,22 @@
<div v-if="!isFinance" class="grid two"> <div v-if="!isFinance" class="grid two">
<section class="card fill-list-card"> <section class="card fill-list-card">
<div class="card-head"> <div class="card-head">
<div><h2>退回待办</h2><p>需要你补充材料的报销事项</p></div> <div><h2>退回待办</h2><p>需要你补充材料的付款申请</p></div>
<span class="tag danger">{{ returned.length }} 项</span> <span class="tag danger">{{ returned.length }} 项</span>
</div> </div>
<div class="card-body task-list fill-card-body"> <div class="card-body task-list fill-card-body">
<div v-for="item in returned" :key="item.id" class="task-item"> <div v-for="item in returned" :key="item.id" class="task-item">
<span class="task-icon danger-icon" aria-hidden="true"><WarningFilled /></span> <span class="task-icon danger-icon" aria-hidden="true"><WarningFilled /></span>
<div><strong>{{ item.title }}</strong><small><template v-if="hasOwnField(item, 'returnReason')">{{ item.returnReason }} </template><template v-if="hasOwnField(item, 'totalAmount')">· {{ money(item.totalAmount) }}</template></small></div> <div><strong>{{ item.title }}</strong><small><template v-if="hasOwnField(item, 'returnReason')">{{ item.returnReason }} </template><template v-if="hasOwnField(item, 'requestedAmount')">· {{ money(item.requestedAmount) }}</template></small></div>
<router-link class="table-action" :to="`/applications/${item.id}/edit`">去补充</router-link> <router-link class="table-action" :to="`/applications/${item.id}/edit`">去补充</router-link>
</div> </div>
<div v-if="!returned.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>暂无需要补充的报销</strong><span>新的审批消息会同步到这里</span></div> <div v-if="!returned.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>暂无需要补充的付款申请</strong><span>新的审批消息会同步到这里</span></div>
</div> </div>
</section> </section>
<section class="card fill-list-card"> <section class="card fill-list-card">
<div class="card-head"> <div class="card-head">
<div><h2>报销状态</h2><p>审批和付款中的申请</p></div> <div><h2>付款申请状态</h2><p>审批和付款中的申请</p></div>
<span class="tag info">我的申请</span> <span class="tag info">我的申请</span>
</div> </div>
<div class="card-body task-list fill-card-body"> <div class="card-body task-list fill-card-body">
@@ -137,24 +137,24 @@
</div> </div>
<div v-else class="grid two"> <div v-else class="grid two">
<section class="card fill-list-card"> <section v-if="store.financeCheckEnabled" class="card fill-list-card">
<div class="card-head"> <div class="card-head">
<div><h2>待收单队列</h2><p>审批通过,等待财务确认收单</p></div> <div><h2>待核对队列</h2><p>当前付款情形要求财务核对</p></div>
<span class="tag pending">{{ receipt.length }} 笔</span> <span class="tag pending">{{ receipt.length }} 笔</span>
</div> </div>
<div class="card-body task-list fill-card-body"> <div class="card-body task-list fill-card-body">
<div v-for="item in receipt.slice(0, 5)" :key="item.id" class="finance-line"> <div v-for="item in receipt.slice(0, 5)" :key="item.id" class="finance-line">
<span class="flow-badge receipt-badge" aria-hidden="true"><Tickets /></span> <span class="flow-badge receipt-badge" aria-hidden="true"><Tickets /></span>
<div><strong>{{ item.applicationNo }}</strong><small><template v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }} · </template>{{ item.title }}<template v-if="hasOwnField(item, 'totalAmount')"> · {{ money(item.totalAmount) }}</template></small></div> <div><strong>{{ item.applicationNo }}</strong><small><template v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }} · </template>{{ item.title }}<template v-if="hasOwnField(item, 'requestedAmount')"> · {{ money(item.requestedAmount) }}</template></small></div>
<router-link class="table-action" to="/finance-receipt">处理</router-link> <router-link class="table-action" to="/finance-receipt">处理</router-link>
</div> </div>
<div v-if="!receipt.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>待收单队列为空</strong><span>新的审批结果同步后会显示在这里</span></div> <div v-if="!receipt.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>待核对队列为空</strong><span>命中财务核对规则的申请会显示在这里</span></div>
</div> </div>
</section> </section>
<section class="card fill-list-card"> <section class="card fill-list-card">
<div class="card-head"> <div class="card-head">
<div><h2>待付款队列</h2><p>已收单且存在未付余额</p></div> <div><h2>待付款队列</h2><p>已获付款结果登记资格且存在未付余额</p></div>
<span class="tag info">{{ payable.length }} 笔</span> <span class="tag info">{{ payable.length }} 笔</span>
</div> </div>
<div class="card-body task-list fill-card-body"> <div class="card-body task-list fill-card-body">
@@ -163,26 +163,27 @@
<div><strong>{{ item.applicationNo }}</strong><small><template v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }} · </template><template v-if="hasOwnField(item, 'totalAmount')">未付 {{ money(store.balance(item)) }}</template></small></div> <div><strong>{{ item.applicationNo }}</strong><small><template v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }} · </template><template v-if="hasOwnField(item, 'totalAmount')">未付 {{ money(store.balance(item)) }}</template></small></div>
<router-link class="table-action" to="/payments">处理</router-link> <router-link class="table-action" to="/payments">处理</router-link>
</div> </div>
<div v-if="!payable.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>待付款队列为空</strong><span>完成收单的申请会进入这里</span></div> <div v-if="!payable.length" class="empty-state"><CircleCheckFilled aria-hidden="true" /><strong>待付款队列为空</strong><span>具备登记资格的申请会进入这里</span></div>
</div> </div>
</section> </section>
</div> </div>
<section v-if="isFinance && uiRead('ui.dashboard.recent')" class="card section-gap"> <section v-if="isFinance && store.financeCheckEnabled && uiRead('ui.dashboard.recent')" class="card section-gap">
<div class="card-head"> <div class="card-head">
<div><h2>已收单记录</h2><p>已完成财务收单的报销申请</p></div> <div><h2>已核对记录</h2><p>已完成财务核对的付款申请</p></div>
<router-link class="card-link" to="/payments">查看付款队列 <ArrowRight /></router-link> <router-link class="card-link" to="/payments">查看付款队列 <ArrowRight /></router-link>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-wrap"> <div class="table-wrap">
<table v-if="received.length" class="data-table responsive-table"> <table class="data-table responsive-table">
<thead><tr><th>报销单号</th><th>报销人 / 事项</th><th class="amount">申请金额</th><th>收单状态</th><th>付款状态</th><th>未付余额</th><th>操作</th></tr></thead> <thead><tr><th>付款申请单号</th><th>申请人 / 付款事由</th><th class="amount">申请付款金额</th><th>财务核对</th><th>付款状态</th><th>未付余额</th><th>操作</th></tr></thead>
<tbody> <tbody>
<tr v-if="!received.length"><td colspan="7"><div class="empty-state"><strong>暂无已核对记录</strong><span>完成财务核对的申请会显示在这里</span></div></td></tr>
<tr v-for="item in received.slice(0, 6)" :key="item.id"> <tr v-for="item in received.slice(0, 6)" :key="item.id">
<td data-label="报销单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ date(item.updatedAt || item.createdAt) }}</small></td> <td data-label="付款申请单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ date(item.updatedAt || item.createdAt) }}</small></td>
<td data-label="报销人 / 事项"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small>{{ item.title }}</small></td> <td data-label="申请人 / 付款事由"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small>{{ item.paymentReason || item.title }}</small></td>
<td v-if="hasOwnField(item, 'totalAmount')" data-label="申请金额" class="amount">{{ money(item.totalAmount) }}</td><td v-else data-label="申请金额" class="amount muted-copy">字段不可见</td> <td v-if="hasOwnField(item, 'requestedAmount')" data-label="申请金额" class="amount">{{ money(item.requestedAmount) }}</td><td v-else data-label="申请金额" class="amount muted-copy">字段不可见</td>
<td data-label="收单状态"><span class="tag success">{{ item.receiptStatus }}</span></td> <td data-label="财务核对"><span class="tag success">{{ item.financeCheckStatus }}</span></td>
<td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td> <td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td>
<td data-label="未付余额" class="amount">{{ money(store.balance(item)) }}</td> <td data-label="未付余额" class="amount">{{ money(store.balance(item)) }}</td>
<td data-label="操作"><router-link class="table-action" to="/payments">查看付款</router-link></td> <td data-label="操作"><router-link class="table-action" to="/payments">查看付款</router-link></td>
@@ -190,34 +191,33 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-if="!received.length" class="empty-state"><strong>暂无已收单记录</strong><span>完成收单的申请会显示在这里</span></div>
</div> </div>
</section> </section>
<section v-else-if="uiRead('ui.dashboard.recent')" class="card section-gap"> <section v-else-if="uiRead('ui.dashboard.recent')" class="card section-gap">
<div class="card-head"> <div class="card-head">
<div><h2>最近报销</h2><p>查看我的申请、审批、收单和付款状态</p></div> <div><h2>最近付款申请</h2><p>查看申请、审批和付款状态</p></div>
<router-link class="card-link" to="/applications">查看全部 <ArrowRight /></router-link> <router-link class="card-link" to="/applications">查看全部 <ArrowRight /></router-link>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-wrap"> <div class="table-wrap">
<table v-if="mine.length" class="data-table responsive-table"> <table class="data-table responsive-table">
<thead><tr><th>报销单号</th><th>报销事项</th><th class="amount">报销金额</th><th>申请状态</th><th>审批状态</th><th>收单</th><th>付款</th><th>操作</th></tr></thead> <thead><tr><th>付款申请单号</th><th>付款事由</th><th class="amount">申请付款金额</th><th>申请状态</th><th>审批状态</th><th v-if="store.financeCheckEnabled">财务核对</th><th>付款</th><th>操作</th></tr></thead>
<tbody> <tbody>
<tr v-if="!mine.length"><td colspan="8"><div class="empty-state"><strong>暂无付款申请</strong><span>发起付款申请后,办理进度会显示在这里</span><router-link class="btn small" to="/applications/new">发起付款申请</router-link></div></td></tr>
<tr v-for="item in mine.slice(0, 6)" :key="item.id"> <tr v-for="item in mine.slice(0, 6)" :key="item.id">
<td data-label="报销单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ date(item.updatedAt || item.createdAt) }}</small></td> <td data-label="付款申请单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ date(item.updatedAt || item.createdAt) }}</small></td>
<td data-label="报销事项"><strong>{{ item.title }}</strong><small>{{ item.category }}</small></td> <td data-label="付款事由"><strong>{{ item.paymentReason || item.title }}</strong><small>{{ item.paymentScenario }}</small></td>
<td v-if="hasOwnField(item, 'totalAmount')" data-label="报销金额" class="amount">{{ money(item.totalAmount) }}</td><td v-else data-label="报销金额" class="amount muted-copy">字段不可见</td> <td v-if="hasOwnField(item, 'requestedAmount')" data-label="申请付款金额" class="amount">{{ money(item.requestedAmount) }}</td><td v-else data-label="申请付款金额" class="amount muted-copy">字段不可见</td>
<td data-label="申请状态"><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></td> <td data-label="申请状态"><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></td>
<td data-label="审批状态"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></td> <td data-label="审批状态"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></td>
<td data-label="收单状态"><span class="tag" :class="tone(item.receiptStatus)">{{ item.receiptStatus }}</span></td> <td v-if="store.financeCheckEnabled" data-label="财务核对"><span class="tag" :class="tone(item.financeCheckStatus)">{{ item.financeCheckStatus }}</span></td>
<td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td> <td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td>
<td data-label="操作"><router-link class="table-action" :to="`/applications/${item.id}`">查看详情</router-link></td> <td data-label="操作"><router-link class="table-action" :to="`/applications/${item.id}`">查看详情</router-link></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-if="!mine.length" class="empty-state"><strong>暂无报销记录</strong><span>发起报销后,申请进度会显示在这里</span><router-link class="btn small" to="/applications/new">发起报销</router-link></div>
</div> </div>
</section> </section>
</template> </template>
@@ -240,22 +240,22 @@ const uiRead = (code: string) => userStore.canRead(code)
const userName = computed(() => userStore.userInfo?.realName || store.user?.realName || '用户') const userName = computed(() => userStore.userInfo?.realName || store.user?.realName || '用户')
const isFinance = computed(() => authorization.canAny(['finance.receipt:receive', 'finance.payment:read', 'finance.payment:register', 'finance.payable:read'])) const isFinance = computed(() => authorization.canAny(['finance.receipt:receive', 'finance.payment:read', 'finance.payment:register', 'finance.payable:read']))
const mine = computed(() => store.reimbursements) const mine = computed(() => store.paymentApplications)
const returned = computed(() => mine.value.filter(item => item.approvalStatus === '退回')) const returned = computed(() => mine.value.filter(item => item.approvalStatus === '退回'))
const approving = computed(() => mine.value.filter(item => item.approvalStatus === '审批中')) const approving = computed(() => mine.value.filter(item => item.approvalStatus === '审批中'))
const receipt = computed(() => store.reimbursements.filter(item => item.approvalStatus === '审批通过' && item.receiptStatus === '待收单')) const receipt = computed(() => store.financeCheckEnabled ? store.paymentApplications.filter(item => item.approvalStatus === '审批通过' && item.financeCheckStatus === '待核对') : [])
const received = computed(() => store.reimbursements.filter(item => item.receiptStatus === '已收单')) const received = computed(() => store.financeCheckEnabled ? store.paymentApplications.filter(item => item.financeCheckStatus === '已核对') : [])
const payable = computed(() => received.value.filter(item => store.balance(item) > 0)) const payable = computed(() => store.paymentApplications.filter(item => item.approvalStatus === '审批通过' && (!store.financeCheckEnabled || item.financeCheckStatus !== '待核对') && store.balance(item) > 0))
const pendingPayment = computed(() => mine.value.filter(item => item.receiptStatus === '已收单' && store.balance(item) > 0)) const pendingPayment = computed(() => mine.value.filter(item => item.approvalStatus === '审批通过' && (!store.financeCheckEnabled || item.financeCheckStatus !== '待核对') && store.balance(item) > 0))
const pendingPaymentAmount = computed(() => pendingPayment.value.reduce((sum, item) => sum + store.balance(item), 0)) const pendingPaymentAmount = computed(() => pendingPayment.value.reduce((sum, item) => sum + store.balance(item), 0))
const payableAmount = computed(() => payable.value.reduce((sum, item) => sum + store.balance(item), 0)) const payableAmount = computed(() => payable.value.reduce((sum, item) => sum + store.balance(item), 0))
const receivedAmount = computed(() => received.value.reduce((sum, item) => sum + item.totalAmount, 0)) const receivedAmount = computed(() => received.value.reduce((sum, item) => sum + item.requestedAmount, 0))
const currentMonth = computed(() => { const currentMonth = computed(() => {
const now = new Date() const now = new Date()
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}` return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
}) })
const monthRows = computed(() => mine.value.filter(item => String(item.createdAt || item.submitTime).slice(0, 7) === currentMonth.value)) const monthRows = computed(() => mine.value.filter(item => String(item.createdAt || item.submitTime).slice(0, 7) === currentMonth.value))
const monthTotal = computed(() => monthRows.value.reduce((sum, item) => sum + item.totalAmount, 0)) const monthTotal = computed(() => monthRows.value.reduce((sum, item) => sum + item.requestedAmount, 0))
const monthCount = computed(() => monthRows.value.length) const monthCount = computed(() => monthRows.value.length)
const syncDescription = computed(() => { const syncDescription = computed(() => {
if (store.error) return '同步需要关注,请稍后重试' if (store.error) return '同步需要关注,请稍后重试'
@@ -267,13 +267,13 @@ const money = (value: number) => `¥ ${Number(value || 0).toLocaleString('zh-CN'
const date = (value: string) => value?.slice(0, 16) || '-' const date = (value: string) => value?.slice(0, 16) || '-'
const tone = (value: string) => ({ const tone = (value: string) => ({
草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger', 草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger',
待收单: 'pending', 已收单: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 待核对: 'pending', 已核对: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success',
未触发: 'neutral', 已取消: 'neutral', 未触发: 'neutral', 已取消: 'neutral',
} as Record<string, string>)[value] || 'neutral' } as Record<string, string>)[value] || 'neutral'
const loadDashboardData = async () => { const loadDashboardData = async () => {
financeQueueError.value = '' financeQueueError.value = ''
if (!isFinance.value) { if (!isFinance.value) {
if (!store.reimbursements.length || store.source === 'error') await store.load() if (!store.paymentApplications.length || store.source === 'error') await store.load()
return return
} }
@@ -281,8 +281,10 @@ const loadDashboardData = async () => {
store.financeQueueError = '' store.financeQueueError = ''
try { try {
const queueErrors: string[] = [] const queueErrors: string[] = []
await store.loadFinanceQueue('receipt') if (store.financeCheckEnabled) {
if (store.financeQueueError) queueErrors.push(store.financeQueueError) await store.loadFinanceQueue('receipt')
if (store.financeQueueError) queueErrors.push(store.financeQueueError)
}
await store.loadFinanceQueue('payment') await store.loadFinanceQueue('payment')
if (store.financeQueueError && !queueErrors.includes(store.financeQueueError)) queueErrors.push(store.financeQueueError) if (store.financeQueueError && !queueErrors.includes(store.financeQueueError)) queueErrors.push(store.financeQueueError)
financeQueueError.value = queueErrors.join(';') financeQueueError.value = queueErrors.join(';')
+16 -16
View File
@@ -2,43 +2,43 @@
<div class="page-content route-list-page"> <div class="page-content route-list-page">
<div class="page-head"> <div class="page-head">
<div> <div>
<span class="eyebrow">EXPENSE TYPES</span> <span class="eyebrow">PAYMENT SCENARIOS</span>
<h1>费用类型</h1> <h1>付款情形</h1>
<p>管理费用类型分类。</p> <p>管理统一付款申请可选择的付款情形及分组。</p>
</div> </div>
</div> </div>
<div class="card fill-list-card primary-list-card"> <div class="card fill-list-card primary-list-card">
<div class="table-wrap" v-if="loaded && !error && items.length > 0" tabindex="0" role="region" aria-label="费用类型列表"><table class="data-table responsive-table"> <div class="table-wrap" v-if="loaded && !error" tabindex="0" role="region" aria-label="付款情形列表"><table class="data-table responsive-table">
<thead><tr><th v-if="uiRead('ui.expense-types.column.code')">编码</th><th v-if="uiRead('ui.expense-types.column.name')">名称</th><th v-if="uiRead('ui.expense-types.column.category')">分类</th><th v-if="uiRead('ui.expense-types.column.status')">状态</th></tr></thead> <thead><tr><th>付款情形</th><th>常见场景</th><th>业务依据</th><th>材料口径</th></tr></thead>
<tbody> <tbody>
<tr v-if="!items.length"><td colspan="4"><div class="empty-state"><strong>暂无付款情形</strong></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td v-if="uiRead('ui.expense-types.column.code')" data-label="编码"><small>{{ item.code }}</small></td> <td data-label="付款情形"><strong v-if="uiRead('ui.expense-types.column.name')">{{ item.scenarioName || '—' }}</strong><small v-if="uiRead('ui.expense-types.column.code')">{{ item.scenarioCode || '—' }}</small></td>
<td v-if="uiRead('ui.expense-types.column.name')" data-label="名称"><strong>{{ item.name }}</strong></td> <td data-label="常见场景">—</td>
<td v-if="uiRead('ui.expense-types.column.category')" data-label="分类"><span class="tag">{{ item.category }}</span></td> <td data-label="业务依据">—</td>
<td v-if="uiRead('ui.expense-types.column.status')" data-label="状态"><span class="tag" :class="item.status==='ACTIVE'?'success':'draft'">{{ item.status }}</span></td> <td data-label="材料口径">—</td>
</tr> </tr>
</tbody> </tbody>
</table></div> </table></div>
<div v-else-if="error" class="empty-state" role="alert"><strong>费用类型加载失败</strong><span>{{ error }}</span><button v-if="uiEdit('ui.expense-types.reload')" class="btn small" type="button" @click="load">重试</button></div> <div v-else-if="error" class="empty-state" role="alert"><strong>付款情形加载失败</strong><span>{{ error }}</span><button v-if="uiEdit('ui.expense-types.reload')" class="btn small" type="button" @click="load">重试</button></div>
<div class="empty-state" v-else-if="loaded"><strong>暂无费用类型</strong></div> <div v-if="!loaded" class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载付款情形…</span></div>
<div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载费用类型…</span></div> <AppListPagination v-if="loaded && !error && items.length" v-model:page="page" v-model:page-size="pageSize" :total="items.length" aria-label="付款情形列表分页" />
<AppListPagination v-if="loaded && !error && items.length" v-model:page="page" v-model:page-size="pageSize" :total="items.length" aria-label="费用类型列表分页" />
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import request from '@/api/request' import { reimbursementApi, type ExpenseTypeMetadata } from '@/api/reimbursement'
import AppListPagination from '@/components/common/AppListPagination.vue' import AppListPagination from '@/components/common/AppListPagination.vue'
import { useListPagination } from '@/composables/useListPagination' import { useListPagination } from '@/composables/useListPagination'
import { useUserStore } from '@/store/user' import { useUserStore } from '@/store/user'
const userStore = useUserStore() const userStore = useUserStore()
const uiRead = (code: string) => userStore.canRead(code) const uiRead = (code: string) => userStore.canRead(code)
const uiEdit = (code: string) => userStore.canEdit(code) const uiEdit = (code: string) => userStore.canEdit(code)
const items = ref<any[]>([]) const items = ref<ExpenseTypeMetadata[]>([])
const loaded = ref(false) const loaded = ref(false)
const error = ref('') const error = ref('')
const { page, pageSize, paginatedItems } = useListPagination(items) const { page, pageSize, paginatedItems } = useListPagination(items)
const load = async () => { loaded.value = false; error.value = ''; try { items.value = await request.get('/metadata/expense-types') || [] } catch (e) { error.value = e instanceof Error ? e.message : '请求失败,请稍后重试。' } finally { loaded.value = true } } const load = async () => { loaded.value = false; error.value = ''; try { items.value = await reimbursementApi.getExpenseTypes() || [] } catch (e) { error.value = e instanceof Error ? e.message : '请求失败,请稍后重试。' } finally { loaded.value = true } }
onMounted(load) onMounted(load)
</script> </script>
+82 -70
View File
@@ -4,44 +4,44 @@
<div> <div>
<span class="eyebrow">FINANCE OPERATIONS</span> <span class="eyebrow">FINANCE OPERATIONS</span>
<h1>财务处理中心</h1> <h1>财务处理中心</h1>
<p>跟进审批与收单,办理付款登记和独立复核,查看已完成单据。</p> <p>跟进审批记录并登记外部付款结果,平台不执行银行付款。</p>
</div> </div>
<div class="head-actions"> <div class="head-actions">
<button class="btn" type="button" :disabled="loadingState" @click="refreshQueue">刷新</button> <button class="btn" type="button" :disabled="loadingState" @click="refreshQueue">刷新</button>
</div> </div>
</div> </div>
<div class="inline-note">审批、收单和付款分别记录;付款金额和完成状态以真实付款及复核结果为准。</div> <div class="inline-note">独立财务核对、付款凭据完成条件以及 12 类审批和金蝶映射均待财务确认;当前不作为系统默认规则。</div>
<div class="tabs finance-operations-tabs" role="tablist" aria-label="财务处理环节"> <div class="tabs finance-operations-tabs" role="tablist" aria-label="财务处理环节">
<button v-if="canViewReceipt" id="finance-approval-tab" class="tab" :class="{ active: activeTab === 'approval' }" type="button" role="tab" :aria-selected="activeTab === 'approval'" aria-controls="finance-approval-panel" @click="selectTab('approval')">审批进度 <span>{{ rows.length }}</span></button> <button v-if="canViewReceipt" id="finance-approval-tab" class="tab" :class="{ active: activeTab === 'approval' }" type="button" role="tab" :aria-selected="activeTab === 'approval'" aria-controls="finance-approval-panel" @click="selectTab('approval')">审批记录 <span>{{ approvalRows.length }}</span></button>
<button v-if="canViewPayments" id="finance-payment-tab" class="tab" :class="{ active: activeTab === 'payment' }" type="button" role="tab" :aria-selected="activeTab === 'payment'" aria-controls="finance-payment-panel" @click="selectTab('payment')">付款办理</button> <button v-if="canViewPayments" id="finance-payment-tab" class="tab" :class="{ active: activeTab === 'payment' }" type="button" role="tab" :aria-selected="activeTab === 'payment'" aria-controls="finance-payment-panel" @click="selectTab('payment')">付款结果 <span>{{ paymentPending.length }}</span></button>
<button v-if="canViewPayments" id="finance-completed-tab" class="tab" :class="{ active: activeTab === 'completed' }" type="button" role="tab" :aria-selected="activeTab === 'completed'" aria-controls="finance-completed-panel" @click="selectTab('completed')">已完成单据 <span>{{ completed.length }}</span></button> <button v-if="canViewPayments" id="finance-completed-tab" class="tab" :class="{ active: activeTab === 'completed' }" type="button" role="tab" :aria-selected="activeTab === 'completed'" aria-controls="finance-completed-panel" @click="selectTab('completed')">已登记 <span>{{ completed.length }}</span></button>
</div> </div>
<section v-if="activeTab === 'payment' && canViewPayments" id="finance-payment-panel" class="finance-payment-panel" role="tabpanel" aria-labelledby="finance-payment-tab"> <section v-if="activeTab === 'payment' && canViewPayments" id="finance-payment-panel" class="finance-payment-panel" role="tabpanel" aria-labelledby="finance-payment-tab">
<Payments /> <Payments embedded />
</section> </section>
<section v-else-if="activeTab === 'completed' && canViewPayments" id="finance-completed-panel" role="tabpanel" aria-labelledby="finance-completed-tab"> <section v-else-if="activeTab === 'completed' && canViewPayments" id="finance-completed-panel" role="tabpanel" aria-labelledby="finance-completed-tab">
<div v-if="loadingState" class="load-wrap" role="status">正在读取已完成单据…</div> <div v-if="loadingState" class="load-wrap" role="status">正在读取付款结果记录…</div>
<div v-else-if="hasBlockingError" class="card empty-state" role="alert"><strong>已完成单据暂时无法加载</strong><button class="btn" type="button" @click="refreshQueue">重新加载</button></div> <div v-else-if="hasBlockingError" class="card empty-state" role="alert"><strong>付款结果记录暂时无法加载</strong><button class="btn" type="button" @click="refreshQueue">重新加载</button></div>
<div v-else class="card"> <div v-else class="card">
<div class="card-head"><div><h2>已完成单据</h2><p>按实际已复核付款记录展示,付款事实与申请、审批记录保持独立。</p></div></div> <div class="card-head"><div><h2>付款结果记录</h2></div></div>
<div class="filter-bar"><input v-model="completedQuery" class="filter-input" type="search" aria-label="搜索已完成单据" placeholder="搜索申请单号、事项、申请人或付款对象"><span class="tag success">{{ filteredCompleted.length }} 张完成</span></div> <div class="filter-bar finance-completed-filter"><input v-model="completedQuery" class="filter-input finance-completed-search" type="search" aria-label="搜索付款结果记录" placeholder="搜索申请单号、付款事由、申请人或收款方"><span class="tag success">{{ filteredCompleted.length }} 张已登记</span></div>
<div v-if="filteredCompleted.length" class="table-wrap"><table class="data-table responsive-table" aria-label="已完成单据"><thead><tr><th>付款申请</th><th v-if="uiRead('ui.payments.column.payee')">申请人/付款对象</th><th v-if="uiRead('ui.payments.column.status')">审批/收单/付款状态</th><th>完成时间</th><th v-if="uiRead('ui.payments.column.amount')" class="amount">完成金额</th><th>操作</th></tr></thead><tbody> <div class="table-wrap mobile-card-wrap"><table class="data-table has-actions" aria-label="付款结果记录"><thead><tr><th>付款申请</th><th v-if="uiRead('ui.payments.column.payee')">申请人/收款方</th><th v-if="uiRead('ui.payments.column.status')">审批状态</th><th v-if="uiRead('ui.payments.column.status')">付款状态</th><th>实际付款日期</th><th v-if="uiRead('ui.payments.column.amount')" class="amount">实际付款金额</th><th>操作</th></tr></thead><tbody>
<tr v-for="item in completedItems" :key="item.id"><td data-label="付款申请"><router-link v-if="canViewDetail" class="table-action" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong><small>{{ item.title }}</small></td><td v-if="uiRead('ui.payments.column.payee')" data-label="申请人/付款对象"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small v-if="hasOwnField(item, 'payeeName')">{{ item.payeeName }}</small></td><td v-if="uiRead('ui.payments.column.status')" data-label="审批/收单/付款状态"><span class="tag">{{ item.approvalStatus }}</span><span class="tag">{{ item.receiptStatus }}</span><span class="tag success">{{ item.paymentStatus }}</span></td><td data-label="完成时间">{{ completionTime(item) }}</td><td v-if="uiRead('ui.payments.column.amount')" data-label="完成金额" class="amount">{{ money(store.paidAmount(item)) }}</td><td data-label="操作"><router-link v-if="canViewDetail" class="table-action" :to="`/applications/${item.id}`">付款详情</router-link><span v-else class="muted-copy">无详情权限</span></td></tr> <tr v-if="!filteredCompleted.length"><td colspan="7"><div class="empty-state"><strong>{{ completed.length ? '没有符合当前条件的付款结果' : '暂无付款结果记录' }}</strong></div></td></tr>
<tr v-for="row in completedItems" :key="row.payment.id"><td data-label="付款申请"><router-link v-if="canViewDetail" class="table-action" :to="`/applications/${row.item.id}`">{{ row.item.applicationNo }}</router-link><strong v-else>{{ row.item.applicationNo }}</strong><small>{{ row.item.paymentReason || row.item.title }}</small></td><td v-if="uiRead('ui.payments.column.payee')" data-label="申请人/收款方"><strong v-if="hasOwnField(row.item, 'applicantName')">{{ row.item.applicantName }}</strong><small v-if="hasOwnField(row.item, 'payeeName')">{{ row.item.payeeName }}</small></td><td v-if="uiRead('ui.payments.column.status')" data-label="审批状态"><span class="tag" :class="tone(row.item.approvalStatus)">{{ row.item.approvalStatus }}</span></td><td v-if="uiRead('ui.payments.column.status')" data-label="付款状态"><span class="tag success">{{ completedPaymentStatus(row.payment, row.item) }}</span></td><td data-label="实际付款日期">{{ row.payment.actualPaymentDate || row.payment.resultRecordedAt || '—' }}</td><td v-if="uiRead('ui.payments.column.amount')" data-label="实际付款金额" class="amount">{{ money(row.payment.actualPaymentAmount) }}</td><td data-label="操作"><router-link v-if="canViewDetail" class="table-action" :to="`/applications/${row.item.id}`">付款结果详情</router-link><span v-else class="muted-copy">无详情权限</span></td></tr>
</tbody></table></div> </tbody></table></div>
<div v-else class="empty-state"><strong>{{ completed.length ? '没有符合条件的已完成单据' : '暂无已完成单据' }}</strong></div>
<AppListPagination v-if="filteredCompleted.length" v-model:page="completedPage" v-model:page-size="completedPageSize" :total="filteredCompleted.length" aria-label="已完成单据分页" /> <AppListPagination v-if="filteredCompleted.length" v-model:page="completedPage" v-model:page-size="completedPageSize" :total="filteredCompleted.length" aria-label="已完成单据分页" />
</div> </div>
</section> </section>
<section v-else-if="canViewReceipt" id="finance-approval-panel" role="tabpanel" aria-labelledby="finance-approval-tab"> <section v-else-if="canViewReceipt" id="finance-approval-panel" role="tabpanel" aria-labelledby="finance-approval-tab">
<div v-if="loadingState" class="load-wrap" role="status" aria-live="polite"> <div v-if="loadingState" class="load-wrap" role="status" aria-live="polite">
<span class="loader" aria-hidden="true"></span> <span class="loader" aria-hidden="true"></span>
<p>正在读取收单队列…</p> <p>正在读取财务核对队列…</p>
</div> </div>
<div v-else-if="hasBlockingError" class="card empty-state" role="alert"> <div v-else-if="hasBlockingError" class="card empty-state" role="alert">
<strong>收单队列暂时无法加载</strong> <strong>财务核对队列暂时无法加载</strong>
<span>请检查网络连接后重试,系统不会以空列表代替异常数据。</span> <span>请检查网络连接后重试,系统不会以空列表代替异常数据。</span>
<button class="btn" type="button" @click="refreshQueue">重新加载</button> <button class="btn" type="button" @click="refreshQueue">重新加载</button>
</div> </div>
@@ -53,71 +53,62 @@
<button class="btn small" type="button" @click="refreshQueue">重试</button> <button class="btn small" type="button" @click="refreshQueue">重试</button>
</div> </div>
<div class="finance-kpis finance-queue-kpis">
<div><span>待收单</span><strong>{{ pending.length }}</strong><small>审批已完成</small></div>
<div><span>已收单</span><strong>{{ received.length }}</strong><small>等待付款执行</small></div>
<div><span>收单金额</span><strong>{{ money(total) }}</strong><small>不等同于已付款</small></div>
</div>
<div class="card fill-list-card primary-list-card"> <div class="card fill-list-card primary-list-card">
<div class="card-head">
<div><h2>审批进度与收单</h2><p>展示当前财务队列中的审批结果;确认收单后进入付款办理。</p></div>
<span class="tag info">财务处理</span>
</div>
<div class="filter-bar finance-queue-filter"> <div class="filter-bar finance-queue-filter">
<label class="filter-search finance-queue-search"> <label class="filter-search finance-queue-search">
<span aria-hidden="true">⌕</span> <span aria-hidden="true">⌕</span>
<input v-model="query" type="search" aria-label="搜索待收单" placeholder="搜索报销单号、报销人或事项"> <input v-model="query" type="search" aria-label="搜索审批记录" placeholder="搜索申请单号、事项或申请人">
</label> </label>
<span class="tag info finance-result-count" aria-live="polite">{{ filtered.length }} 笔结果</span> <select v-model="approvalFilter" class="filter-select" aria-label="按审批状态筛选">
<option value="">全部审批状态</option>
<option value="审批中">审批中</option>
<option value="审批通过">审批通过</option>
<option value="退回">退回</option>
<option value="同步异常">同步异常</option>
</select>
<span class="filter-spacer"></span>
<span class="tag info finance-result-count" aria-live="polite">{{ filtered.length }} 张申请</span>
</div> </div>
<div v-if="filtered.length" class="table-wrap finance-table-wrap"> <div class="table-wrap finance-table-wrap">
<table class="data-table responsive-table" aria-label="财务收单队列"> <table class="data-table has-actions" aria-label="财务核对队列">
<caption class="sr-only">财务收单队列</caption> <caption class="sr-only">财务核对队列</caption>
<thead> <thead>
<tr> <tr>
<th v-if="uiRead('ui.finance-receipt.column.number')" scope="col">报销单号</th><th v-if="uiRead('ui.finance-receipt.column.applicant')" scope="col">报销人 / 事项</th><th v-if="uiRead('ui.finance-receipt.column.amount')" scope="col" class="amount">申请金额</th> <th v-if="uiRead('ui.finance-receipt.column.number')" scope="col">付款申请</th><th v-if="uiRead('ui.finance-receipt.column.applicant')" scope="col">申请人/付款情形</th><th v-if="uiRead('ui.finance-receipt.column.amount')" scope="col" class="amount-heading">申请付款金额</th>
<th scope="col">审批状态</th><th scope="col">收单状态</th><th scope="col">付款状态</th><th scope="col">操作</th> <th scope="col">审批状态/当前节点</th><th scope="col">财务核对</th><th scope="col">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-if="!filtered.length"><td colspan="6"><div class="empty-state"><strong>{{ approvalRows.length ? '没有符合条件的申请' : '当前没有审批记录' }}</strong><span>{{ approvalRows.length ? '请调整搜索条件后重试。' : '提交审批或发生同步异常的付款申请会进入这里。' }}</span></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td v-if="uiRead('ui.finance-receipt.column.number')" data-label="报销单号"><router-link v-if="canViewDetail" class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong><small>{{ item.createdAt?.slice(0, 10) || '-' }}</small></td> <td v-if="uiRead('ui.finance-receipt.column.number')" data-label="付款申请单号"><router-link v-if="canViewDetail" class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong><small>{{ item.createdAt?.slice(0, 10) || '-' }}</small></td>
<td v-if="uiRead('ui.finance-receipt.column.applicant')" data-label="报销人 / 事项"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small>{{ item.title }}</small></td> <td v-if="uiRead('ui.finance-receipt.column.applicant')" data-label="申请人/付款情形"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small>{{ item.paymentScenario || item.expenseItemCategory || '—' }}</small></td>
<td v-if="uiRead('ui.finance-receipt.column.amount') && hasOwnField(item, 'totalAmount')" data-label="申请金额" class="amount">{{ money(item.totalAmount) }}</td> <td v-if="uiRead('ui.finance-receipt.column.amount') && hasOwnField(item, 'requestedAmount')" data-label="申请金额" class="amount">{{ money(item.requestedAmount || 0) }}</td>
<td v-else-if="uiRead('ui.finance-receipt.column.amount')" data-label="申请金额" class="amount muted-copy">字段不可见</td> <td v-else-if="uiRead('ui.finance-receipt.column.amount')" data-label="申请金额" class="amount muted-copy">字段不可见</td>
<td data-label="审批状态"><span class="tag success">{{ item.approvalStatus }}</span></td> <td data-label="审批状态/当前节点"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span><small>{{ item.currentApprovalNode || '—' }}</small></td>
<td data-label="收单状态"><span class="tag" :class="tone(item.receiptStatus)">{{ item.receiptStatus }}</span></td> <td data-label="财务核对"><span class="tag" :class="tone(item.financeCheckStatus)">{{ store.financeCheckEnabled ? item.financeCheckStatus : '未启用' }}</span></td>
<td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td>
<td data-label="操作"> <td data-label="操作">
<div class="finance-row-actions"> <div class="finance-row-actions">
<button <button
v-if="item.receiptStatus === '待收单' && canConfirm" v-if="store.financeCheckEnabled && item.financeCheckStatus === '待核对' && canConfirm"
class="btn small primary" class="btn small primary"
type="button" type="button"
:disabled="isReceiving(item.id)" :disabled="isReceiving(item.id)"
:aria-busy="isReceiving(item.id)" :aria-busy="isReceiving(item.id)"
@click="receive(item)" @click="receive(item)"
>{{ isReceiving(item.id) ? '处理中…' : '确认收单' }}</button> >{{ isReceiving(item.id) ? '处理中…' : '财务核对' }}</button>
<span v-else-if="item.receiptStatus === '待收单'" class="muted-copy">无确认权限</span> <span v-else-if="store.financeCheckEnabled && item.financeCheckStatus === '待核对'" class="muted-copy">无确认权限</span>
<span v-else-if="item.receiptStatus === '已收单'" class="muted-copy">已完成</span> <span v-else-if="store.financeCheckEnabled && item.financeCheckStatus === '已核对'" class="muted-copy">已完成</span>
<span v-else class="muted-copy">无需处理</span> <router-link v-else-if="canViewDetail" class="table-action" :to="`/applications/${item.id}`">审批详情</router-link>
<span v-else class="muted-copy">—</span>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!rows.length" class="empty-state"> <AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="财务核对队列分页" />
<strong>当前没有待收单记录</strong>
<span>审批通过的报销会自动进入这里。</span>
</div>
<div v-else class="empty-state">
<strong>没有符合条件的收单记录</strong>
<span>请调整搜索关键词后重试。</span>
</div>
<AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="财务收单队列分页" />
</div> </div>
</template> </template>
</section> </section>
@@ -130,7 +121,7 @@ import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import Payments from '@/views/Payments.vue' import Payments from '@/views/Payments.vue'
import { ElMessage } from '@/utils/uiFeedback' import { ElMessage } from '@/utils/uiFeedback'
import type { ReimApplicationDetail } from '@/api/reimbursement' import type { PaymentRecord, ReimApplicationDetail } from '@/api/reimbursement'
import AppListPagination from '@/components/common/AppListPagination.vue' import AppListPagination from '@/components/common/AppListPagination.vue'
import { useListPagination } from '@/composables/useListPagination' import { useListPagination } from '@/composables/useListPagination'
import { financeActionError, hasOwnField } from '@/finance/financeUi' import { financeActionError, hasOwnField } from '@/finance/financeUi'
@@ -144,7 +135,7 @@ const userStore = useUserStore()
const uiRead = (code: string) => userStore.canRead(code) const uiRead = (code: string) => userStore.canRead(code)
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const canViewReceipt = computed(() => uiRead('page.finance-receipt') && authorization.can('finance.receipt:receive')) const canViewReceipt = computed(() => uiRead('page.finance-receipt') && authorization.canAny(['finance.receipt:receive', 'finance.payment:read', 'reimbursement.application:read']))
const canViewPayments = computed(() => uiRead('page.finance-receipt') && authorization.canAny(['finance.payment:read', 'finance.payment:register', 'finance.payment:review'])) const canViewPayments = computed(() => uiRead('page.finance-receipt') && authorization.canAny(['finance.payment:read', 'finance.payment:register', 'finance.payment:review']))
type FinanceTab = 'approval' | 'payment' | 'completed' type FinanceTab = 'approval' | 'payment' | 'completed'
const activeTab = computed<FinanceTab>(() => { const activeTab = computed<FinanceTab>(() => {
@@ -154,34 +145,40 @@ const activeTab = computed<FinanceTab>(() => {
}) })
const selectTab = (tab: FinanceTab) => { void router.replace({ query: { ...route.query, tab } }) } const selectTab = (tab: FinanceTab) => { void router.replace({ query: { ...route.query, tab } }) }
const completedQuery = ref('') const completedQuery = ref('')
const completed = computed(() => store.reimbursements.filter(item => item.paymentStatus === '已付款')) const completedPaymentRecord = (payment: PaymentRecord) => ['已登记', '有效', '复核通过', '待补付款回单', 'COMPLETED', 'ACTIVE', 'PENDING_RECEIPT'].includes(payment.paymentStatus)
const completed = computed(() => store.payments
.filter(completedPaymentRecord)
.map(payment => ({ payment, item: store.paymentApplications.find(item => String(item.id) === String(payment.applicationId)) }))
.filter((row): row is { payment: PaymentRecord; item: ReimApplicationDetail } => Boolean(row.item)))
const hasPendingReceipt = (item: ReimApplicationDetail) => store.payments.some(payment => String(payment.applicationId) === String(item.id) && ['待补付款回单', 'PENDING_RECEIPT'].includes(payment.paymentStatus))
const paymentPending = computed(() => store.paymentApplications.filter(item => item.approvalStatus === '审批通过' && (!['已付款', '付款结果已登记'].includes(item.paymentStatus) || hasPendingReceipt(item))))
const filteredCompleted = computed(() => { const filteredCompleted = computed(() => {
const search = completedQuery.value.trim().toLowerCase() const search = completedQuery.value.trim().toLowerCase()
return completed.value.filter(item => `${item.applicationNo} ${item.title} ${uiRead('ui.payments.column.payee') ? `${item.applicantName || ''} ${item.payeeName || ''}` : ''}`.toLowerCase().includes(search)) return completed.value.filter(({ item, payment }) => `${item.applicationNo} ${item.title} ${payment.paymentNo || ''} ${uiRead('ui.payments.column.payee') ? `${item.applicantName || ''} ${item.payeeName || ''}` : ''}`.toLowerCase().includes(search))
}) })
const { page: completedPage, pageSize: completedPageSize, paginatedItems: completedItems } = useListPagination(filteredCompleted, { resetSources: [completedQuery] }) const { page: completedPage, pageSize: completedPageSize, paginatedItems: completedItems } = useListPagination(filteredCompleted, { resetSources: [completedQuery] })
const completionTime = (item: ReimApplicationDetail) => store.payments const completedPaymentStatus = (payment: PaymentRecord, item: ReimApplicationDetail) => ['待补付款回单', 'PENDING_RECEIPT'].includes(payment.paymentStatus) ? '待补付款回单' : (item.paymentStatus === '已付款' ? '付款结果已登记' : item.paymentStatus)
.filter(payment => String(payment.applicationId) === String(item.id) && ['复核通过', 'COMPLETED', 'ACTIVE'].includes(payment.paymentStatus) && hasOwnField(payment, 'paymentTime'))
.map(payment => payment.paymentTime || '').sort().reverse()[0] || '—'
const canConfirm = computed(() => userStore.canEdit('finance.receipt.confirm') && authorization.can('finance.receipt:receive')) const canConfirm = computed(() => userStore.canEdit('finance.receipt.confirm') && authorization.can('finance.receipt:receive'))
const canViewDetail = computed(() => userStore.canRead('page.application-detail') && authorization.can('reimbursement.application:read')) const canViewDetail = computed(() => userStore.canRead('page.application-detail') && authorization.can('reimbursement.application:read'))
const query = ref('') const query = ref('')
const approvalFilter = ref('')
const hasLoaded = ref(false) const hasLoaded = ref(false)
const receiving = ref<Set<string>>(new Set()) const receiving = ref<Set<string>>(new Set())
const rows = computed(() => store.reimbursements.filter(item => item.approvalStatus === '审批通过')) const isSyncError = (item: ReimApplicationDetail) => item.approvalStatus === '同步异常' || ['同步异常', 'FAILED', 'ERROR'].includes(item.syncStatus)
const pending = computed(() => rows.value.filter(item => item.receiptStatus === '待收单')) const approvalRows = computed(() => store.paymentApplications.filter(item => item.approvalStatus !== '未发起' || isSyncError(item)))
const received = computed(() => rows.value.filter(item => item.receiptStatus === '已收单'))
const total = computed(() => rows.value.reduce((sum, item) => sum + item.totalAmount, 0))
const filtered = computed(() => { const filtered = computed(() => {
const normalizedQuery = query.value.trim().toLowerCase() const normalizedQuery = query.value.trim().toLowerCase()
return rows.value.filter(item => `${item.applicationNo} ${item.applicantName} ${item.title}`.toLowerCase().includes(normalizedQuery)) return approvalRows.value.filter(item => {
const matchesStatus = !approvalFilter.value || (approvalFilter.value === '同步异常' ? isSyncError(item) : item.approvalStatus === approvalFilter.value)
return matchesStatus && `${item.applicationNo} ${item.applicantName} ${item.title} ${item.currentApprovalNode || ''}`.toLowerCase().includes(normalizedQuery)
})
}) })
const { page, pageSize, paginatedItems } = useListPagination(filtered, { resetSources: [query] }) const { page, pageSize, paginatedItems } = useListPagination(filtered, { resetSources: [query, approvalFilter] })
const loadingState = computed(() => store.loading || !hasLoaded.value) const loadingState = computed(() => store.loading || !hasLoaded.value)
const hasBlockingError = computed(() => hasLoaded.value && (store.source === 'error' || Boolean(store.financeQueueError))) const hasBlockingError = computed(() => hasLoaded.value && (store.source === 'error' || Boolean(store.financeQueueError)))
const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value) const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value)
const money = (value: number) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}` const money = (value: number) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}`
const tone = (value: string) => ({ 待收单: 'pending', 已收单: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success' } as Record<string, string>)[value] || 'neutral' const tone = (value: string) => ({ 待核对: 'pending', 已核对: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success' } as Record<string, string>)[value] || 'neutral'
const receivingKey = (id: string | number) => String(id) const receivingKey = (id: string | number) => String(id)
const isReceiving = (id: string | number) => receiving.value.has(receivingKey(id)) const isReceiving = (id: string | number) => receiving.value.has(receivingKey(id))
@@ -189,8 +186,8 @@ const refreshQueue = async () => {
hasLoaded.value = false hasLoaded.value = false
store.error = '' store.error = ''
store.financeQueueError = '' store.financeQueueError = ''
if ((activeTab.value === 'payment' || activeTab.value === 'completed') && canViewPayments.value) await store.loadFinanceQueue('payment') if (activeTab.value === 'payment' && canViewPayments.value) await store.loadFinanceQueue('payment')
else if (canViewReceipt.value) await store.loadFinanceQueue('receipt') else await store.load()
hasLoaded.value = true hasLoaded.value = true
} }
@@ -201,9 +198,9 @@ const receive = async (item: ReimApplicationDetail) => {
receiving.value = new Set(receiving.value).add(key) receiving.value = new Set(receiving.value).add(key)
try { try {
await store.receive(item.id) await store.receive(item.id)
ElMessage.success(`${item.applicationNo} 已完成财务收单`) ElMessage.success(`${item.applicationNo} 已完成财务核对`)
} catch (error) { } catch (error) {
ElMessage.error(financeActionError(error, '收单失败,请重试')) ElMessage.error(financeActionError(error, '财务核对失败,请重试'))
} finally { } finally {
const next = new Set(receiving.value) const next = new Set(receiving.value)
next.delete(key) next.delete(key)
@@ -218,6 +215,21 @@ watch([activeTab, canViewReceipt, canViewPayments], () => {
<style scoped> <style scoped>
.finance-operations-tabs { flex-wrap: wrap; } .finance-operations-tabs { flex-wrap: wrap; }
.amount-heading { text-align: center; }
.finance-completed-search {
width: min(100%, 620px);
min-width: min(420px, 100%);
height: var(--control-height);
flex: 1 1 420px;
padding: 0 12px;
}
.finance-completed-filter .tag { flex: 0 0 auto; }
#finance-approval-panel .primary-list-card > .finance-table-wrap {
height: auto;
flex: 0 0 auto;
overflow-x: auto;
overflow-y: visible;
}
.finance-payment-panel :deep(.page-content) { padding: 0; min-height: 0; } .finance-payment-panel :deep(.page-content) { padding: 0; min-height: 0; }
.finance-payment-panel :deep(.page-head) { display: none; } .finance-payment-panel :deep(.page-head) { display: none; }
.finance-payment-panel :deep(.head-actions .router-link-active), .finance-payment-panel :deep(.head-actions .router-link-active),
+3 -3
View File
@@ -10,7 +10,7 @@
<div v-if="!canOpenPage" class="card empty-state" role="alert"> <div v-if="!canOpenPage" class="card empty-state" role="alert">
<strong>无权查看配置</strong> <strong>无权查看配置</strong>
<span>当前账号没有集成管理或金蝶账号绑定权限,可在「人员与权限」中分配。</span> <span>当前账号没有集成管理或金蝶账号绑定权限,可在「组织与权限」中分配。</span>
</div> </div>
<template v-else> <template v-else>
<nav v-if="visibleTabs.length > 1" class="tabs integration-tabs" role="tablist" aria-label="配置分栏"> <nav v-if="visibleTabs.length > 1" class="tabs integration-tabs" role="tablist" aria-label="配置分栏">
@@ -36,7 +36,7 @@
> >
<div v-if="!canViewFeishu" class="card empty-state" role="alert"> <div v-if="!canViewFeishu" class="card empty-state" role="alert">
<strong>无权查看飞书配置</strong> <strong>无权查看飞书配置</strong>
<span>需要「系统管理 / 集成管理」页面权限。</span> <span>需要「系统配置 / 集成管理」页面权限。</span>
</div> </div>
<template v-else> <template v-else>
<div v-if="loadError" class="inline-alert danger" role="alert"> <div v-if="loadError" class="inline-alert danger" role="alert">
@@ -141,7 +141,7 @@
</div> </div>
<template v-else> <template v-else>
<div class="inline-note integration-note"> <div class="inline-note integration-note">
在「人员与权限」中可分别配置:查看本人/全部、绑定本人/全部、解绑本人/全部。财务默认仅本人;系统同步仍使用配置文件中的金蝶系统账号。 在「组织与权限」中可分别配置:查看本人/全部、绑定本人/全部、解绑本人/全部。财务默认仅本人;系统同步仍使用配置文件中的金蝶系统账号。
</div> </div>
<KingdeeAccountBindingPanel embedded /> <KingdeeAccountBindingPanel embedded />
</template> </template>
+21 -21
View File
@@ -28,12 +28,12 @@
</span> </span>
</div> </div>
<div class="product-name"> <div class="product-name">
<strong>费用与付款</strong> <strong>统一付款平台</strong>
<span>SPEND OPERATIONS</span> <span>PAYMENT PLATFORM</span>
</div> </div>
<nav class="main-nav" aria-label="主导航"> <nav class="main-nav" aria-label="主导航">
<div v-if="applicationCenterTarget" class="nav-group"> <div v-if="applicationCenterTarget" class="nav-group">
<span>申请</span> <span>申请与报销</span>
<router-link :to="applicationCenterTarget" @click="handleNavigationClick" :class="{ active: route.path.startsWith('/applications') }" :aria-current="route.path.startsWith('/applications') ? 'page' : undefined"> <router-link :to="applicationCenterTarget" @click="handleNavigationClick" :class="{ active: route.path.startsWith('/applications') }" :aria-current="route.path.startsWith('/applications') ? 'page' : undefined">
<b aria-hidden="true"><DocumentCopy /></b> 申请中心 <i v-if="canPage('applications')" class="nav-count">{{ mineCount }}</i> <b aria-hidden="true"><DocumentCopy /></b> 申请中心 <i v-if="canPage('applications')" class="nav-count">{{ mineCount }}</i>
</router-link> </router-link>
@@ -91,13 +91,13 @@
<div class="topbar-left"> <div class="topbar-left">
<button ref="mobileMenuButton" class="icon-button mobile-menu" type="button" :aria-expanded="sidebarOpen" aria-controls="primary-navigation" @click="toggleSidebar" :aria-label="sidebarOpen ? '关闭导航' : '打开导航'"><Menu /></button> <button ref="mobileMenuButton" class="icon-button mobile-menu" type="button" :aria-expanded="sidebarOpen" aria-controls="primary-navigation" @click="toggleSidebar" :aria-label="sidebarOpen ? '关闭导航' : '打开导航'"><Menu /></button>
<div class="breadcrumb"> <div class="breadcrumb">
<span>统一费用付款平台</span> <span>统一付款平台</span>
<i>/</i> <i>/</i>
<strong>{{ pageTitle }}</strong> <strong>{{ pageTitle }}</strong>
</div> </div>
</div> </div>
<div class="topbar-tools"> <div class="topbar-tools">
<label class="search-box"><Search aria-hidden="true" /><input v-model="search" type="search" placeholder="搜索付款申请、业务单据或收款对象" aria-label="全局搜索" @keyup.enter="runSearch"></label> <label class="search-box"><Search aria-hidden="true" /><input v-model="search" type="search" placeholder="搜索付款申请、审批单据、金蝶单据或收款方" aria-label="全局搜索" @keyup.enter="runSearch"></label>
<button class="icon-button" type="button" @click="showHelp" aria-label="查看帮助" title="帮助"><QuestionFilled /></button> <button class="icon-button" type="button" @click="showHelp" aria-label="查看帮助" title="帮助"><QuestionFilled /></button>
<button ref="notificationButton" class="icon-button notification" @click="showNotifications" :aria-label="notificationButtonLabel" title="通知"> <button ref="notificationButton" class="icon-button notification" @click="showNotifications" :aria-label="notificationButtonLabel" title="通知">
<Bell aria-hidden="true" /> <Bell aria-hidden="true" />
@@ -168,7 +168,7 @@
<div v-else class="notification-empty empty-state"> <div v-else class="notification-empty empty-state">
<span class="notification-empty-icon" aria-hidden="true"><CircleCheckFilled /></span> <span class="notification-empty-icon" aria-hidden="true"><CircleCheckFilled /></span>
<strong>暂无未读通知</strong> <strong>暂无未读通知</strong>
<span>新的报销进度和付款状态会显示在这里。</span> <span>新的付款申请进度和付款状态会显示在这里。</span>
</div> </div>
<footer class="notification-modal-actions"> <footer class="notification-modal-actions">
<button class="btn" type="button" @click="closeNotifications">关闭</button> <button class="btn" type="button" @click="closeNotifications">关闭</button>
@@ -359,13 +359,13 @@ const snapshotPageByRoute: Record<string, PageAccessKey> = {
const currentSnapshotPage = computed(() => snapshotPageByRoute[String(route.name || '')]) const currentSnapshotPage = computed(() => snapshotPageByRoute[String(route.name || '')])
const showDataSyncBanner = computed(() => Boolean(currentSnapshotPage.value) && canPage(currentSnapshotPage.value)) const showDataSyncBanner = computed(() => Boolean(currentSnapshotPage.value) && canPage(currentSnapshotPage.value))
const loadWorkbenchIfAllowed = async () => { const loadWorkbenchIfAllowed = async () => {
if (!showDataSyncBanner.value || workbench.reimbursements.length || workbench.loading) return if (!showDataSyncBanner.value || workbench.paymentApplications.length || workbench.loading) return
await workbench.load() await workbench.load()
} }
watch(() => route.name, () => { void loadWorkbenchIfAllowed() }) watch(() => route.name, () => { void loadWorkbenchIfAllowed() })
const mineCount = computed(() => workbench.reimbursements.filter(item => item.applicantName === userName.value).length) const mineCount = computed(() => workbench.paymentApplications.filter(item => item.applicantName === userName.value).length)
const receiptCount = computed(() => workbench.reimbursements.filter(item => item.receiptStatus === '待收单').length) const receiptCount = computed(() => workbench.financeCheckEnabled ? workbench.paymentApplications.filter(item => item.financeCheckStatus === '待核对').length : 0)
const paymentCount = computed(() => workbench.reimbursements.filter(item => workbench.balance(item) > 0 && item.receiptStatus === '已收单').length) const paymentCount = computed(() => workbench.paymentApplications.filter(item => workbench.balance(item) > 0 && item.approvalStatus === '审批通过' && (!workbench.financeCheckEnabled || item.financeCheckStatus !== '待核对')).length)
const financePendingCount = computed(() => receiptCount.value + paymentCount.value) const financePendingCount = computed(() => receiptCount.value + paymentCount.value)
const sourceLabel = computed(() => { const sourceLabel = computed(() => {
if (workbench.error) return '同步异常' if (workbench.error) return '同步异常'
@@ -385,14 +385,14 @@ const sourceMessage = computed(() => {
const unreadNotificationCount = computed(() => Math.max(0, Math.floor(Number(workbench.notifications) || 0))) const unreadNotificationCount = computed(() => Math.max(0, Math.floor(Number(workbench.notifications) || 0)))
const notificationButtonLabel = computed(() => unreadNotificationCount.value ? `打开通知(${unreadNotificationCount.value}条未读)` : '打开通知(暂无未读)') const notificationButtonLabel = computed(() => unreadNotificationCount.value ? `打开通知(${unreadNotificationCount.value}条未读)` : '打开通知(暂无未读)')
const runSearch = () => { if (search.value.trim()) router.push({ path: '/applications', query: { q: search.value.trim() } }) } const runSearch = () => { if (search.value.trim()) router.push({ path: '/applications', query: { q: search.value.trim() } }) }
const showHelp = () => ElMessageBox.alert('申请、审批、收单和付款是四个独立状态;金蝶来源单据只读,付款登记支持分次付款并保留幂等键。', '平台帮助', { confirmButtonText: '知道了' }) const showHelp = () => ElMessageBox.alert('申请、审批、财务核对和付款结果是独立状态;财务核对及独立复核按已确认规则执行,金蝶来源单据只读。', '平台帮助', { confirmButtonText: '知道了' })
const displayText = (value: unknown, fallback: string) => { const displayText = (value: unknown, fallback: string) => {
const result = String(value ?? '').trim() const result = String(value ?? '').trim()
return result && result !== 'undefined' && result !== 'null' ? result : fallback return result && result !== 'undefined' && result !== 'null' ? result : fallback
} }
const applicationName = (item: ReimApplicationDetail) => displayText(item.applicationNo, `报销单 ${displayText(item.id, '待处理')}`) const applicationName = (item: ReimApplicationDetail) => displayText(item.applicationNo, `付款申请 ${displayText(item.id, '待处理')}`)
const applicationRoute = (item: ReimApplicationDetail) => { const applicationRoute = (item: ReimApplicationDetail) => {
const id = displayText(item.id, '') const id = displayText(item.id, '')
return id ? `/applications/${encodeURIComponent(id)}` : '/applications' return id ? `/applications/${encodeURIComponent(id)}` : '/applications'
@@ -405,32 +405,32 @@ const notificationTime = (item: ReimApplicationDetail) => displayText(item.updat
const financeRoute = (item: ReimApplicationDetail) => canPage('financeReceipt') ? '/finance-receipt' : applicationRoute(item) const financeRoute = (item: ReimApplicationDetail) => canPage('financeReceipt') ? '/finance-receipt' : applicationRoute(item)
const buildNotifications = (count: number) => { const buildNotifications = (count: number) => {
const rows = workbench.reimbursements const rows = workbench.paymentApplications
const dynamic: NotificationItem[] = [] const dynamic: NotificationItem[] = []
const add = (item: NotificationItem) => { if (!dynamic.some(existing => existing.id === item.id)) dynamic.push(item) } const add = (item: NotificationItem) => { if (!dynamic.some(existing => existing.id === item.id)) dynamic.push(item) }
rows.filter(item => item.approvalStatus === '退回').forEach(item => add({ rows.filter(item => item.approvalStatus === '退回').forEach(item => add({
id: `returned-${displayText(item.id, applicationName(item))}`, id: `returned-${displayText(item.id, applicationName(item))}`,
title: '报销需要补充材料', title: '付款申请需要补充材料',
message: `${applicationName(item)} 已退回:${displayText(item.returnReason, '请查看退回原因并补充材料。')}`, message: `${applicationName(item)} 已退回:${displayText(item.returnReason, '请查看退回原因并补充材料。')}`,
time: notificationTime(item), icon: 'WarningFilled', tone: 'danger', route: applicationRoute(item), time: notificationTime(item), icon: 'WarningFilled', tone: 'danger', route: applicationRoute(item),
})) }))
rows.filter(item => ['审批中', '已提交'].includes(item.approvalStatus) && item.approvalStatus !== '退回').forEach(item => add({ rows.filter(item => ['审批中', '已提交'].includes(item.approvalStatus) && item.approvalStatus !== '退回').forEach(item => add({
id: `approval-${displayText(item.id, applicationName(item))}`, id: `approval-${displayText(item.id, applicationName(item))}`,
title: '报销审批进行中', title: '付款申请审批进行中',
message: `${applicationName(item)} 正在${displayText(item.currentApprovalNode, '审批流程')},请留意审批进度。`, message: `${applicationName(item)} 正在${displayText(item.currentApprovalNode, '审批流程')},请留意审批进度。`,
time: notificationTime(item), icon: 'Refresh', tone: 'pending', route: applicationRoute(item), time: notificationTime(item), icon: 'Refresh', tone: 'pending', route: applicationRoute(item),
})) }))
rows.filter(item => item.receiptStatus === '待收单').forEach(item => add({ if (workbench.financeCheckEnabled) rows.filter(item => item.financeCheckStatus === '待核对').forEach(item => add({
id: `receipt-${displayText(item.id, applicationName(item))}`, id: `receipt-${displayText(item.id, applicationName(item))}`,
title: '有报销单待收单', title: '有付款申请待财务核对',
message: `${applicationName(item)} 已审批通过,等待财务收单。`, message: `${applicationName(item)} 已审批通过,后续按付款情形进入财务核对或付款结果登记。`,
time: notificationTime(item), icon: 'Tickets', tone: 'info', route: financeRoute(item), time: notificationTime(item), icon: 'Tickets', tone: 'info', route: financeRoute(item),
})) }))
rows.filter(item => item.receiptStatus === '已收单' && workbench.balance(item) > 0).forEach(item => add({ rows.filter(item => item.approvalStatus === '审批通过' && (!workbench.financeCheckEnabled || item.financeCheckStatus !== '待核对') && workbench.balance(item) > 0).forEach(item => add({
id: `payment-${displayText(item.id, applicationName(item))}`, id: `payment-${displayText(item.id, applicationName(item))}`,
title: '报销单待付款', title: '付款申请待登记付款结果',
message: `${applicationName(item)} 已完成收单,待付款金额 ${money(workbench.balance(item))}。`, message: `${applicationName(item)} 已具备付款结果登记资格,待付金额 ${money(workbench.balance(item))}。`,
time: notificationTime(item), icon: 'Wallet', tone: 'success', route: canPage('payments') ? '/finance-receipt?tab=payment' : applicationRoute(item), time: notificationTime(item), icon: 'Wallet', tone: 'success', route: canPage('payments') ? '/finance-receipt?tab=payment' : applicationRoute(item),
})) }))
+1 -1
View File
@@ -13,7 +13,7 @@
<section class="login-copy" aria-describedby="loginIntro"> <section class="login-copy" aria-describedby="loginIntro">
<span class="eyebrow login-eyebrow">企业登录</span> <span class="eyebrow login-eyebrow">企业登录</span>
<h1 id="loginTitle">统一费用付款平台</h1> <h1 id="loginTitle">统一费用付款平台</h1>
<p id="loginIntro">使用飞书账号登录,连接付款申请、审批、收单与付款办理。</p> <p id="loginIntro">使用飞书账号登录,连接付款申请、审批、财务核对与付款结果登记。</p>
</section> </section>
<section class="login-card" aria-labelledby="loginCardTitle" aria-describedby="loginCardDescription"> <section class="login-card" aria-labelledby="loginCardTitle" aria-describedby="loginCardDescription">
+10 -11
View File
@@ -27,7 +27,7 @@
</label> </label>
<label v-if="canViewAll" class="field"> <label v-if="canViewAll" class="field">
<span>操作人</span> <span>操作人</span>
<input v-model.trim="operator" type="search" placeholder="姓名" autocomplete="off" @keyup.enter="load(true)"> <input v-model.trim="operator" type="search" placeholder="请输入操作人姓名" aria-label="搜索操作人姓名" autocomplete="off" @keyup.enter="load(true)">
</label> </label>
<label v-if="canViewAll" class="field"> <label v-if="canViewAll" class="field">
<span>操作者ID</span> <span>操作者ID</span>
@@ -47,7 +47,7 @@
<span>{{ items.length }} 条</span> <span>{{ items.length }} 条</span>
</div> </div>
<div v-if="loaded && !error && items.length" class="table-wrap" tabindex="0" role="region" aria-label="操作日志列表"> <div v-if="loaded && !error" class="table-wrap" tabindex="0" role="region" aria-label="操作日志列表">
<table class="data-table responsive-table"> <table class="data-table responsive-table">
<thead> <thead>
<tr> <tr>
@@ -61,6 +61,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-if="!items.length"><td colspan="7"><div class="empty-state"><strong>暂无操作日志</strong><span>访问任意接口后会自动出现在这里。</span></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td v-if="fieldVisible('time')" data-label="时间"><small>{{ item.time || '—' }}</small></td> <td v-if="fieldVisible('time')" data-label="时间"><small>{{ item.time || '—' }}</small></td>
<td v-if="fieldVisible('actor')" data-label="操作人"><strong>{{ item.operator || '匿名' }}</strong></td> <td v-if="fieldVisible('actor')" data-label="操作人"><strong>{{ item.operator || '匿名' }}</strong></td>
@@ -77,7 +78,6 @@
</table> </table>
</div> </div>
<div v-else-if="error" class="empty-state" role="alert"><strong>操作日志加载失败</strong><span>{{ error }}</span><button class="btn small" type="button" @click="load(true)">重试</button></div> <div v-else-if="error" class="empty-state" role="alert"><strong>操作日志加载失败</strong><span>{{ error }}</span><button class="btn small" type="button" @click="load(true)">重试</button></div>
<div class="empty-state" v-else-if="loaded"><strong>暂无操作日志</strong><span>访问任意接口后会自动出现在这里。</span></div>
<div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载操作日志…</span></div> <div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载操作日志…</span></div>
<div v-if="loaded && !error && hasMore" class="load-more"><button class="btn" type="button" :disabled="loading" @click="load(false)">{{ loading ? '加载中…' : '加载更多' }}</button></div> <div v-if="loaded && !error && hasMore" class="load-more"><button class="btn" type="button" :disabled="loading" @click="load(false)">{{ loading ? '加载中…' : '加载更多' }}</button></div>
</div> </div>
@@ -85,10 +85,10 @@
<div v-if="activeLane && activeLane !== 'access'" class="card filter-card"> <div v-if="activeLane && activeLane !== 'access'" class="card filter-card">
<div v-if="canViewAll" class="log-filters"> <div v-if="canViewAll" class="log-filters">
<label class="field"><span>操作者ID</span><input v-model.number="actorId" type="number" min="1" placeholder="精确ID"></label> <label class="field"><span>操作者ID</span><input v-model.number="actorId" type="number" min="1" placeholder="精确ID"></label>
<label class="field"><span>动作</span><input v-model.trim="action" type="search" placeholder="输入动作代码"></label> <label class="field"><span>动作</span><input v-model.trim="action" type="search" placeholder="请输入审计动作代码" aria-label="搜索审计动作代码"></label>
<label class="field"><span>结果</span><input v-model.trim="outcome" type="search" placeholder="如 SUCCESS(成功)"></label> <label class="field"><span>结果</span><input v-model.trim="outcome" type="search" placeholder="请输入结果代码,如 SUCCESS" aria-label="搜索审计结果代码"></label>
<label class="field"><span>资源类型</span><input v-model.trim="resourceType" type="search" placeholder="输入资源类型代码"></label> <label class="field"><span>资源类型</span><input v-model.trim="resourceType" type="search" placeholder="请输入资源类型代码" aria-label="搜索资源类型代码"></label>
<label class="field"><span>资源ID</span><input v-model.trim="resourceId" type="search" placeholder="输入资源ID"></label> <label class="field"><span>资源ID</span><input v-model.trim="resourceId" type="search" placeholder="请输入资源 ID" aria-label="搜索资源 ID"></label>
<button class="btn primary" type="button" @click="load(true)">查询</button> <button class="btn primary" type="button" @click="load(true)">查询</button>
</div> </div>
<p v-else class="scope-note">当前 lane 仅允许查询本人事件;客户端不会发送任意 actor 或全量筛选条件。</p> <p v-else class="scope-note">当前 lane 仅允许查询本人事件;客户端不会发送任意 actor 或全量筛选条件。</p>
@@ -96,9 +96,9 @@
<div v-if="activeLane && activeLane !== 'access'" class="card fill-list-card primary-list-card"> <div v-if="activeLane && activeLane !== 'access'" class="card fill-list-card primary-list-card">
<div class="card-head"><div><h2>{{ activeLaneLabel }}</h2><p>仅展示后端 AuditEventView 白名单字段,不接收 payload、attributes 或完整性密钥。</p></div><span>{{ auditItems.length }} 条</span></div> <div class="card-head"><div><h2>{{ activeLaneLabel }}</h2><p>仅展示后端 AuditEventView 白名单字段,不接收 payload、attributes 或完整性密钥。</p></div><span>{{ auditItems.length }} 条</span></div>
<div v-if="loaded && !error && auditItems.length" class="table-wrap" tabindex="0" role="region" :aria-label="`${activeLaneLabel}列表`"> <div v-if="loaded && !error" class="table-wrap" tabindex="0" role="region" :aria-label="`${activeLaneLabel}列表`">
<table class="data-table responsive-table"><thead><tr><th v-if="fieldVisible('time')">时间</th><th v-if="fieldVisible('actor')">Actor</th><th v-if="fieldVisible('action')">动作</th><th v-if="fieldVisible('resource')">资源</th><th v-if="fieldVisible('outcome')">结果</th><th v-if="fieldVisible('trace')">追踪</th></tr></thead> <table class="data-table responsive-table"><thead><tr><th v-if="fieldVisible('time')">时间</th><th v-if="fieldVisible('actor')">Actor</th><th v-if="fieldVisible('action')">动作</th><th v-if="fieldVisible('resource')">资源</th><th v-if="fieldVisible('outcome')">结果</th><th v-if="fieldVisible('trace')">追踪</th></tr></thead>
<tbody><tr v-for="item in auditItems" :key="item.id"> <tbody><tr v-if="!auditItems.length"><td colspan="6"><div class="empty-state"><strong>暂无{{ activeLaneLabel }}</strong><span>当前授权范围和筛选条件内没有事件。</span></div></td></tr><tr v-for="item in auditItems" :key="item.id">
<td v-if="fieldVisible('time')" data-label="时间"><small>{{ item.eventTime || '—' }}</small></td> <td v-if="fieldVisible('time')" data-label="时间"><small>{{ item.eventTime || '—' }}</small></td>
<td v-if="fieldVisible('actor')" data-label="操作者"><strong>{{ item.actorLabel || item.actorType || '用户' }} {{ item.actorId ?? '—' }}</strong></td> <td v-if="fieldVisible('actor')" data-label="操作者"><strong>{{ item.actorLabel || item.actorType || '用户' }} {{ item.actorId ?? '—' }}</strong></td>
<td v-if="fieldVisible('action')" data-label="动作"><strong>{{ item.actionLabel || item.action || '—' }}</strong><small>{{ item.categoryLabel || item.category || activeLaneLabel }}</small></td> <td v-if="fieldVisible('action')" data-label="动作"><strong>{{ item.actionLabel || item.action || '—' }}</strong><small>{{ item.categoryLabel || item.category || activeLaneLabel }}</small></td>
@@ -108,7 +108,6 @@
</tr></tbody></table> </tr></tbody></table>
</div> </div>
<div v-else-if="error" class="empty-state" role="alert"><strong>审计事件加载失败</strong><span>{{ error }}</span><button class="btn small" type="button" @click="load(true)">重试</button></div> <div v-else-if="error" class="empty-state" role="alert"><strong>审计事件加载失败</strong><span>{{ error }}</span><button class="btn small" type="button" @click="load(true)">重试</button></div>
<div v-else-if="loaded" class="empty-state"><strong>暂无{{ activeLaneLabel }}</strong><span>当前授权范围和筛选条件内没有事件。</span></div>
<div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载审计事件…</span></div> <div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载审计事件…</span></div>
<div v-if="loaded && !error && hasMore" class="load-more"><button class="btn" type="button" :disabled="loading" @click="load(false)">{{ loading ? '加载中…' : '加载更多' }}</button></div> <div v-if="loaded && !error && hasMore" class="load-more"><button class="btn" type="button" :disabled="loading" @click="load(false)">{{ loading ? '加载中…' : '加载更多' }}</button></div>
</div> </div>
@@ -160,7 +159,7 @@ const action = ref('')
const outcome = ref('') const outcome = ref('')
const resourceType = ref('') const resourceType = ref('')
const resourceId = ref('') const resourceId = ref('')
const categoryOptions = ['接口访问', '认证登录', '报销申请', '付款操作', '收单操作', '飞书通讯录', '飞书集成', '配置管理', '人员权限', '主数据', '自动任务', '系统日志'] const categoryOptions = ['接口访问', '认证登录', '付款申请', '付款操作', '财务核对', '飞书通讯录', '飞书集成', '配置管理', '人员权限', '主数据', '定时任务', '系统日志']
const canViewAll = computed(() => activeLane.value != null && authorizationStore.can(AUDIT_READ_ALL_CAPABILITY[activeLane.value])) const canViewAll = computed(() => activeLane.value != null && authorizationStore.can(AUDIT_READ_ALL_CAPABILITY[activeLane.value]))
const canViewOwn = computed(() => activeLane.value != null && canAccessLane(activeLane.value)) const canViewOwn = computed(() => activeLane.value != null && canAccessLane(activeLane.value))
const scopeLabel = computed(() => canViewAll.value ? '全部操作人' : canViewOwn.value ? '仅本人' : '无访问权限') const scopeLabel = computed(() => canViewAll.value ? '全部操作人' : canViewOwn.value ? '仅本人' : '无访问权限')
+48 -40
View File
@@ -1,52 +1,57 @@
<template> <template>
<div class="page-content route-list-page"> <div class="page-content route-list-page">
<div class="page-head"> <div class="page-head">
<div><span class="eyebrow">PAYEES</span><h1>付款对象与收款账户</h1><p>员工与供应商均可维护多个收款账户,完整账号不会在列表中回显。</p></div> <div><span class="eyebrow">PAYEES</span><h1>收款方</h1><p>员工与供应商均可作为收款方并维护多个收款账户,完整账号不会在列表中回显。</p></div>
<button v-if="canManage" class="btn primary" type="button" :disabled="loading" @click="openCreateSubject">+ 新增付款对象</button> <button v-if="canManage" class="btn primary" type="button" :disabled="loading" @click="openCreateSubject">+ 新增收款方</button>
</div> </div>
<div class="card fill-list-card primary-list-card"> <div class="card fill-list-card primary-list-card">
<div class="tabs" role="tablist" aria-label="付款对象类型">
<button v-for="type in subjectTypes" :key="type.key" class="tab" :class="{ active: currentType === type.key }" type="button" role="tab" :aria-selected="currentType === type.key" @click="currentType = type.key">{{ type.label }} <small>({{ subjectCounts[type.key] }})</small></button>
</div>
<div class="filter-bar list-toolbar"> <div class="filter-bar list-toolbar">
<div class="list-toolbar__filters"><label class="filter-search"><span aria-hidden="true">⌕</span><input v-model="search" type="search" :placeholder="currentType === 'EMPLOYEE' ? '搜索员工姓名或身份证号' : '搜索供应商或统一社会信用代码'" aria-label="搜索付款对象"></label></div> <div class="list-toolbar__filters"><label class="filter-search"><span aria-hidden="true">⌕</span><input v-model="search" type="search" placeholder="搜索业务编码、名称、国家或身份标识" aria-label="搜索收款方"></label><select v-model="currentType" aria-label="按收款方类型筛选"><option v-for="type in subjectTypeOptions" :key="type.key" :value="type.key">{{ type.label }}</option></select></div>
<div class="list-toolbar__meta"><span class="tag info">{{ filteredSubjects.length }} 个付款对象</span></div> <div class="list-toolbar__meta"><span class="tag info">{{ filteredSubjects.length }} 个收款方</span></div>
</div> </div>
<div v-if="loading" class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载付款对象…</span></div> <div v-if="loading" class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载收款方…</span></div>
<div v-else-if="loadError" class="empty-state" role="alert"><strong>付款对象加载失败</strong><span>{{ loadError }}</span><button class="btn small" type="button" @click="load">重试</button></div> <div v-else-if="loadError" class="empty-state" role="alert"><strong>收款方加载失败</strong><span>{{ loadError }}</span><button class="btn small" type="button" @click="load">重试</button></div>
<div v-else-if="filteredSubjects.length" class="table-wrap" tabindex="0" role="region" aria-label="付款对象列表"> <div v-else class="table-wrap" tabindex="0" role="region" aria-label="收款方列表">
<table class="data-table responsive-table payee-subject-table"> <table class="data-table responsive-table payee-subject-table">
<thead><tr><th v-if="uiRead('ui.payees.column.employee')">付款对象</th><th>类型</th><th>{{ currentType === 'EMPLOYEE' ? '身份证号' : '统一社会信用代码' }}</th><th v-if="uiRead('ui.payees.column.default')">收款账户</th><th v-if="uiRead('ui.payees.column.status')">状态</th><th v-if="canManage">操作</th></tr></thead> <thead><tr><th>业务编码</th><th v-if="uiRead('ui.payees.column.employee')">收款方名称</th><th>收款方类型</th><th>内外部</th><th>国家/地区</th><th>身份唯一标识</th><th v-if="uiRead('ui.payees.column.default')">收款账户</th><th v-if="uiRead('ui.payees.column.status')">状态</th><th>操作</th></tr></thead>
<tbody> <tbody>
<template v-for="subject in paginatedSubjects" :key="subject.id"> <template v-for="subject in paginatedSubjects" :key="subject.id">
<tr> <tr>
<td v-if="uiRead('ui.payees.column.employee')" data-label="付款对象"><strong>{{ subject.displayName }}</strong></td> <td data-label="业务编码"><strong>{{ subject.payeeType === 'EMPLOYEE' ? '内部关联' : subject.payeeCode || '—' }}</strong><small>{{ subject.payeeType === 'EMPLOYEE' ? '飞书人员' : '业务唯一' }}</small></td>
<td data-label="类型"><span class="tag info">{{ subject.payeeType === 'EMPLOYEE' ? '员工' : '供应商' }}</span></td> <td v-if="uiRead('ui.payees.column.employee')" data-label="收款方名称"><strong>{{ subject.displayName || '—' }}</strong></td>
<td :data-label="subject.payeeType === 'EMPLOYEE' ? '身份证号' : '统一社会信用代码'"><small>{{ subject.payeeType === 'EMPLOYEE' ? (subject.identityNumber || '员工主档未维护') : (subject.supplierCreditCode || '未填写') }}</small></td> <td data-label="收款方类型"><span class="tag info">{{ payeeTypeLabel(subject.payeeType) }}</span></td>
<td data-label="内外部">{{ relationLabel(subject.relationType) }}</td>
<td data-label="国家/地区">{{ subject.countryRegion || '—' }}</td>
<td data-label="身份唯一标识"><strong>{{ subject.payeeType === 'EMPLOYEE' ? '不作为通用字段采集' : subject.identityType || '按对象类型维护' }}</strong><small>{{ subject.payeeType === 'EMPLOYEE' ? '—' : subject.identityValueMaintained ? '已维护(默认隐藏)' : '—' }}</small></td>
<td v-if="uiRead('ui.payees.column.default')" data-label="收款账户"><button class="table-action" type="button" :disabled="accountsLoadingId === subject.id" @click="openAccountsDialog(subject)">查看 {{ subject.accountCount || 0 }} 个账户</button></td> <td v-if="uiRead('ui.payees.column.default')" data-label="收款账户"><button class="table-action" type="button" :disabled="accountsLoadingId === subject.id" @click="openAccountsDialog(subject)">查看 {{ subject.accountCount || 0 }} 个账户</button></td>
<td v-if="uiRead('ui.payees.column.status')" data-label="状态"><span class="tag" :class="subject.status === 'ACTIVE' ? 'success' : 'draft'">{{ subject.status === 'ACTIVE' ? '启用' : '已停用' }}</span></td> <td v-if="uiRead('ui.payees.column.status')" data-label="状态"><span class="tag" :class="subject.status === 'ACTIVE' ? 'success' : 'draft'">{{ subject.status === 'ACTIVE' ? '有效' : subject.status === 'INACTIVE' ? '停用' : '—' }}</span></td>
<td v-if="canManage" data-label="操作" class="actions-cell"><template v-if="subject.manageable"><button class="table-action" type="button" @click="openAccount(subject)">新增账户</button><button class="table-action" type="button" @click="openEditSubject(subject)">编辑</button><button v-if="subject.status === 'ACTIVE' && canDeactivate" class="table-action danger-action" type="button" :disabled="deactivatingKey === `subject-${subject.id}`" @click="deactivateSubject(subject)">停用</button></template><span v-else>—</span></td> <td data-label="操作" class="actions-cell"><template v-if="canManage && subject.manageable"><button class="table-action" type="button" @click="openAccount(subject)">新增账户</button><button class="table-action" type="button" @click="openEditSubject(subject)">编辑</button><button v-if="subject.status === 'ACTIVE' && canDeactivate" class="table-action danger-action" type="button" :disabled="deactivatingKey === `subject-${subject.id}`" @click="deactivateSubject(subject)">停用</button></template><span v-else>—</span></td>
</tr> </tr>
</template> </template>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="empty-state"><strong>暂无{{ currentType === 'EMPLOYEE' ? '员工' : '供应商' }}付款对象</strong><span>点击“新增付款对象”后可继续维护多个收款账户。</span></div> <div v-if="!loading && !loadError && !filteredSubjects.length" class="empty-state"><strong>{{ emptyStateTitle }}</strong><span>点击“新增收款方”后可继续维护多个收款账户。</span></div>
<AppListPagination v-if="!loading && !loadError && filteredSubjects.length" v-model:page="page" v-model:page-size="pageSize" :total="filteredSubjects.length" aria-label="付款对象列表分页" /> <AppListPagination v-if="!loading && !loadError && filteredSubjects.length" v-model:page="page" v-model:page-size="pageSize" :total="filteredSubjects.length" aria-label="收款方列表分页" />
</div> </div>
<dialog v-if="canManage" ref="subjectDialog" v-dialog-drag class="app-dialog app-dialog--floating-host" aria-labelledby="subject-editor-title" @cancel.prevent="closeSubjectDialog"> <dialog v-if="canManage" ref="subjectDialog" v-dialog-drag class="app-dialog app-dialog--floating-host" aria-labelledby="subject-editor-title" @cancel.prevent="closeSubjectDialog">
<form @submit.prevent="saveSubject"> <form @submit.prevent="saveSubject">
<div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">PAYEE</span><h2 id="subject-editor-title">{{ editingSubject ? '编辑付款对象' : '新增付款对象' }}</h2><p>{{ editingSubject ? '维护付款对象状态和基础资料。' : '选择付款对象并填写首个收款账户,保存后可继续追加多个账户。' }}</p></div><button class="modal-close" type="button" aria-label="关闭" :disabled="saving" @click="closeSubjectDialog">×</button></div> <div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">PAYEE</span><h2 id="subject-editor-title">{{ editingSubject ? '编辑收款方' : '新增收款方' }}</h2><p>{{ editingSubject ? '维护收款方状态和基础资料。' : '选择收款方并填写首个收款账户,保存后可继续追加多个账户。' }}</p></div><button class="modal-close" type="button" aria-label="关闭" :disabled="saving" @click="closeSubjectDialog">×</button></div>
<div class="modal-body"><div v-if="formError" class="inline-alert danger" role="alert"><b>!</b><span>{{ formError }}</span></div><div class="form-grid payee-subject-grid"> <div class="modal-body"><div v-if="formError" class="inline-alert danger" role="alert"><b>!</b><span>{{ formError }}</span></div><div class="form-grid payee-subject-grid">
<div class="field"><label for="payee-type">付款对象类型 <em>*</em></label><select id="payee-type" v-model="subjectForm.payeeType" :disabled="saving || Boolean(editingSubject)"><option value="EMPLOYEE">员工</option><option value="SUPPLIER">供应商</option></select></div> <div class="field"><label for="payee-type">收款方类型 <em>*</em></label><SearchableSelect id="payee-type" v-model="subjectForm.payeeType" :disabled="saving || Boolean(editingSubject)"><option value="EMPLOYEE">员工</option><option value="SUPPLIER">供应商</option><option value="GOVERNMENT">政府机构</option></SearchableSelect></div>
<div v-if="editingSubject" class="field"><label for="payee-status">主体状态 <em>*</em></label><select id="payee-status" v-model="subjectForm.status" :disabled="saving"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></select></div> <div v-if="editingSubject" class="field"><label for="payee-status">主体状态 <em>*</em></label><SearchableSelect id="payee-status" v-model="subjectForm.status" :disabled="saving"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></SearchableSelect></div>
<div v-if="subjectForm.payeeType === 'EMPLOYEE'" class="field"><label for="payee-user">关联员工 <em>*</em></label><div class="employee-picker" @focusout="closeEmployeeMenu"><input id="payee-user" v-model="employeeQuery" type="search" autocomplete="off" role="combobox" aria-autocomplete="list" aria-controls="payee-employee-options" :aria-expanded="employeeMenuOpen" :disabled="saving || Boolean(editingSubject)" placeholder="输入姓名搜索" @focus="openEmployeeMenu" @input="handleEmployeeQueryInput" @keydown.esc.prevent="employeeMenuOpen = false"><ul v-if="employeeMenuOpen && !editingSubject" id="payee-employee-options" class="employee-picker-menu" role="listbox"><li v-for="user in employeeMatches" :key="user.openId"><button type="button" role="option" :aria-selected="subjectForm.employeeOpenId === user.openId" :disabled="Boolean(user.existingSubject && !user.existingSubject.manageable)" @mousedown.prevent="chooseEmployee(user)"><span>{{ user.realName }}</span><small v-if="user.existingSubject">{{ user.existingSubject.manageable ? '已存在,可新增收款账户' : '已存在,无编辑权限' }}</small></button></li><li v-if="!employeeMatches.length" class="employee-picker-empty">未找到匹配的在职员工</li></ul></div><small class="form-help">已创建付款对象的员工仍会显示,选择后可直接新增收款账户。</small></div> <div v-if="subjectForm.payeeType === 'EMPLOYEE'" class="field"><label for="payee-user">关联员工 <em>*</em></label><div class="employee-picker" @focusout="closeEmployeeMenu"><input id="payee-user" v-model="employeeQuery" type="search" autocomplete="off" role="combobox" aria-autocomplete="list" aria-controls="payee-employee-options" :aria-expanded="employeeMenuOpen" :disabled="saving || Boolean(editingSubject)" placeholder="请输入员工姓名进行搜索" aria-label="搜索关联员工" @focus="openEmployeeMenu" @input="handleEmployeeQueryInput" @keydown.esc.prevent="employeeMenuOpen = false"><ul v-if="employeeMenuOpen && !editingSubject" id="payee-employee-options" class="employee-picker-menu" role="listbox"><li v-for="user in employeeMatches" :key="user.openId"><button type="button" role="option" :aria-selected="subjectForm.employeeOpenId === user.openId" :disabled="Boolean(user.existingSubject && !user.existingSubject.manageable)" @mousedown.prevent="chooseEmployee(user)"><span>{{ user.realName }}</span><small v-if="user.existingSubject">{{ user.existingSubject.manageable ? '已存在,可新增收款账户' : '已存在,无编辑权限' }}</small></button></li><li v-if="!employeeMatches.length" class="employee-picker-empty">未找到匹配的在职员工</li></ul></div><small class="form-help">已创建收款方的员工仍会显示,选择后可直接新增收款账户。</small></div>
<div v-if="subjectForm.payeeType === 'EMPLOYEE'" class="field"><label for="payee-identity-number">身份证号</label><input id="payee-identity-number" v-model.trim="subjectForm.identityNumber" maxlength="18" autocomplete="off" :disabled="saving" placeholder="选填,15位或18位身份证号"><small class="form-help">非必填,可在后续编辑时补充。</small></div> <div v-if="subjectForm.payeeType === 'EMPLOYEE'" class="field"><label for="payee-identity-number">身份证号</label><input id="payee-identity-number" v-model.trim="subjectForm.identityNumber" maxlength="18" autocomplete="off" :disabled="saving" placeholder="选填,15位或18位身份证号"><small class="form-help">非必填,可在后续编辑时补充。</small></div>
<div v-if="subjectForm.payeeType === 'SUPPLIER'" class="field"><label for="payee-name">供应商名称 <em>*</em></label><input id="payee-name" v-model.trim="subjectForm.displayName" required maxlength="200" autocomplete="off" :disabled="saving" placeholder="请输入供应商全称"></div> <template v-if="subjectForm.payeeType !== 'EMPLOYEE'">
<div v-if="subjectForm.payeeType === 'SUPPLIER'" class="field"><label for="payee-credit-code">统一社会信用代码 <em>*</em></label><input id="payee-credit-code" v-model.trim="subjectForm.supplierCreditCode" required maxlength="18" autocomplete="off" placeholder="18位统一社会信用代码" :disabled="saving"></div> <div class="field"><label for="payee-relation">内外部属性 <em>*</em></label><SearchableSelect id="payee-relation" v-model="subjectForm.relationType" :disabled="saving"><option value="EXTERNAL">外部</option><option value="INTERNAL">内部</option></SearchableSelect></div>
<div class="field"><label for="payee-country">国家/地区 <em>*</em></label><input id="payee-country" v-model.trim="subjectForm.countryRegion" required maxlength="100" autocomplete="off" :disabled="saving"></div>
<div class="field"><label for="payee-name">{{ payeeTypeLabel(subjectForm.payeeType) }}名称 <em>*</em></label><input id="payee-name" v-model.trim="subjectForm.displayName" required maxlength="200" autocomplete="off" :disabled="saving" :placeholder="`请输入${payeeTypeLabel(subjectForm.payeeType)}全称`"></div>
<div class="field"><label for="payee-identity-type">身份标识类型 <em>*</em></label><input id="payee-identity-type" v-model="subjectForm.identityType" readonly :disabled="saving"></div>
<div class="field"><label for="payee-credit-code">身份唯一标识 <em>*</em></label><input id="payee-credit-code" v-model.trim="subjectForm.identityValue" required maxlength="18" autocomplete="off" placeholder="18位统一社会信用代码" :disabled="saving"></div>
</template>
<template v-if="!editingSubject"> <template v-if="!editingSubject">
<div class="field full section-divider"><span>首个收款账户</span><small>保存后可继续新增其他银行账户</small></div> <div class="field full section-divider"><span>首个收款账户</span><small>保存后可继续新增其他银行账户</small></div>
<div class="field"><label for="initial-bank">银行名称 <em>*</em></label><input id="initial-bank" v-model.trim="initialAccountForm.bankName" required maxlength="200" autocomplete="off" placeholder="请输入银行名称" :disabled="saving"></div> <div class="field"><label for="initial-bank">银行名称 <em>*</em></label><input id="initial-bank" v-model.trim="initialAccountForm.bankName" required maxlength="200" autocomplete="off" placeholder="请输入银行名称" :disabled="saving"></div>
@@ -54,7 +59,7 @@
<div class="field"><label for="initial-account-number">银行账号 <em>*</em></label><input id="initial-account-number" v-model="initialAccountForm.accountNo" required maxlength="100" inputmode="numeric" autocomplete="off" placeholder="请输入银行账号" :disabled="saving"><small class="form-help">系统会移除空格和连字符,保存后仅显示脱敏账号。</small></div> <div class="field"><label for="initial-account-number">银行账号 <em>*</em></label><input id="initial-account-number" v-model="initialAccountForm.accountNo" required maxlength="100" inputmode="numeric" autocomplete="off" placeholder="请输入银行账号" :disabled="saving"><small class="form-help">系统会移除空格和连字符,保存后仅显示脱敏账号。</small></div>
</template> </template>
</div></div> </div></div>
<div class="modal-actions"><button class="btn" type="button" :disabled="saving" @click="closeSubjectDialog">取消</button><button class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存付款对象' }}</button></div> <div class="modal-actions"><button class="btn" type="button" :disabled="saving" @click="closeSubjectDialog">取消</button><button class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存收款方' }}</button></div>
</form> </form>
</dialog> </dialog>
@@ -84,8 +89,8 @@
<div class="field"><label for="account-bank">银行名称 <em>*</em></label><input id="account-bank" v-model.trim="accountForm.bankName" required maxlength="200" autocomplete="off" :disabled="saving"></div> <div class="field"><label for="account-bank">银行名称 <em>*</em></label><input id="account-bank" v-model.trim="accountForm.bankName" required maxlength="200" autocomplete="off" :disabled="saving"></div>
<div class="field"><label for="account-branch">开户支行</label><input id="account-branch" v-model.trim="accountForm.branchName" maxlength="200" autocomplete="off" :disabled="saving"></div> <div class="field"><label for="account-branch">开户支行</label><input id="account-branch" v-model.trim="accountForm.branchName" maxlength="200" autocomplete="off" :disabled="saving"></div>
<div class="field"><label for="account-number">银行账号 <em v-if="!editingAccount">*</em></label><input id="account-number" v-model="accountForm.accountNo" :required="!editingAccount" maxlength="100" inputmode="numeric" autocomplete="off" :placeholder="editingAccount ? '留空保留原账号' : '请输入银行账号'" :disabled="saving"><small class="form-help">自动移除空格和连字符,列表仅显示尾号。</small></div> <div class="field"><label for="account-number">银行账号 <em v-if="!editingAccount">*</em></label><input id="account-number" v-model="accountForm.accountNo" :required="!editingAccount" maxlength="100" inputmode="numeric" autocomplete="off" :placeholder="editingAccount ? '留空保留原账号' : '请输入银行账号'" :disabled="saving"><small class="form-help">自动移除空格和连字符,列表仅显示尾号。</small></div>
<div class="field"><label for="account-status">账户状态 <em>*</em></label><select id="account-status" v-model="accountForm.status" :disabled="saving"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></select></div> <div class="field"><label for="account-status">账户状态 <em>*</em></label><SearchableSelect id="account-status" v-model="accountForm.status" :disabled="saving"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></SearchableSelect></div>
<label class="check-option"><input v-model="accountForm.isDefault" type="checkbox" :disabled="saving || accountForm.status !== 'ACTIVE'"><span>设为该付款对象的默认账户</span></label> <label class="check-option"><input v-model="accountForm.isDefault" type="checkbox" :disabled="saving || accountForm.status !== 'ACTIVE'"><span>设为该收款方的默认账户</span></label>
</div></div> </div></div>
<div class="modal-actions"><button class="btn" type="button" :disabled="saving" @click="closeAccountDialog">取消</button><button class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存收款账户' }}</button></div> <div class="modal-actions"><button class="btn" type="button" :disabled="saving" @click="closeAccountDialog">取消</button><button class="btn primary" type="submit" :disabled="saving">{{ saving ? '保存中…' : '保存收款账户' }}</button></div>
</form> </form>
@@ -109,10 +114,11 @@ const uiEdit = (code: string) => userStore.canEdit(code)
const canSave = computed(() => uiEdit('dialog.payee.editor.save-finance') || uiEdit('dialog.payee.editor.save-admin')) const canSave = computed(() => uiEdit('dialog.payee.editor.save-finance') || uiEdit('dialog.payee.editor.save-admin'))
const canDeactivate = computed(() => uiEdit('dialog.payee.editor.deactivate-finance') || uiEdit('dialog.payee.editor.deactivate-admin')) const canDeactivate = computed(() => uiEdit('dialog.payee.editor.deactivate-finance') || uiEdit('dialog.payee.editor.deactivate-admin'))
const canManage = computed(() => uiRead('dialog.payee.editor') && canSave.value) const canManage = computed(() => uiRead('dialog.payee.editor') && canSave.value)
const subjectTypes: Array<{ key: PayeeSubjectType; label: string }> = [{ key: 'EMPLOYEE', label: '员工' }, { key: 'SUPPLIER', label: '供应商' }] type PayeeTypeFilter = PayeeSubjectType | 'ALL'
const subjectTypeOptions: Array<{ key: PayeeTypeFilter; label: string }> = [{ key: 'ALL', label: '全部' }, { key: 'EMPLOYEE', label: '员工' }, { key: 'SUPPLIER', label: '供应商' }, { key: 'GOVERNMENT', label: '政府机构' }]
const subjects = ref<PayeeSubject[]>([]) const subjects = ref<PayeeSubject[]>([])
const eligibleUsers = ref<PayeeUser[]>([]) const eligibleUsers = ref<PayeeUser[]>([])
const currentType = ref<PayeeSubjectType>('EMPLOYEE') const currentType = ref<PayeeTypeFilter>('ALL')
const search = ref('') const search = ref('')
const loading = ref(false) const loading = ref(false)
const loadError = ref('') const loadError = ref('')
@@ -129,14 +135,16 @@ const editingSubject = ref<PayeeSubject | null>(null)
const editingAccount = ref<PayeeAccount | null>(null) const editingAccount = ref<PayeeAccount | null>(null)
const accountListSubject = ref<PayeeSubject | null>(null) const accountListSubject = ref<PayeeSubject | null>(null)
const accountSubject = ref<PayeeSubject | null>(null) const accountSubject = ref<PayeeSubject | null>(null)
const emptySubject = (type: PayeeSubjectType): PayeeSubjectPayload => ({ payeeType: type, employeeOpenId: null, identityNumber: '', displayName: '', supplierCreditCode: '', status: 'ACTIVE' }) const emptySubject = (type: PayeeSubjectType): PayeeSubjectPayload => ({ payeeType: type, employeeOpenId: null, identityNumber: '', displayName: '', relationType: type === 'EMPLOYEE' ? 'INTERNAL' : 'EXTERNAL', countryRegion: '中国', identityType: type === 'EMPLOYEE' ? '' : '统一社会信用代码', identityValue: '', supplierCreditCode: '', status: 'ACTIVE' })
const emptyInitialAccount = () => ({ bankName: '', branchName: '', accountNo: '' }) const emptyInitialAccount = () => ({ bankName: '', branchName: '', accountNo: '' })
const emptyAccount = (): PayeeAccountPayload => ({ bankName: '', branchName: '', accountNo: '', isDefault: false, status: 'ACTIVE' }) const emptyAccount = (): PayeeAccountPayload => ({ bankName: '', branchName: '', accountNo: '', isDefault: false, status: 'ACTIVE' })
const subjectForm = reactive<PayeeSubjectPayload>(emptySubject('EMPLOYEE')) const subjectForm = reactive<PayeeSubjectPayload>(emptySubject('EMPLOYEE'))
const initialAccountForm = reactive(emptyInitialAccount()) const initialAccountForm = reactive(emptyInitialAccount())
const accountForm = reactive<PayeeAccountPayload>(emptyAccount()) const accountForm = reactive<PayeeAccountPayload>(emptyAccount())
const subjectCounts = computed<Record<PayeeSubjectType, number>>(() => ({ EMPLOYEE: subjects.value.filter(item => item.payeeType === 'EMPLOYEE').length, SUPPLIER: subjects.value.filter(item => item.payeeType === 'SUPPLIER').length })) const filteredSubjects = computed(() => subjects.value.filter(item => (currentType.value === 'ALL' || item.payeeType === currentType.value) && matchesReadableSearch(search.value, [{ readable: true, values: [item.payeeCode, item.displayName, item.countryRegion, item.identityType, item.identityNumber, item.supplierCreditCode] }])))
const filteredSubjects = computed(() => subjects.value.filter(item => item.payeeType === currentType.value && matchesReadableSearch(search.value, [{ readable: true, values: [item.displayName, item.identityNumber, item.supplierCreditCode] }]))) const payeeTypeLabel = (type: PayeeSubjectType) => ({ EMPLOYEE: '员工', SUPPLIER: '供应商', GOVERNMENT: '政府机构' } as Record<PayeeSubjectType, string>)[type]
const emptyStateTitle = computed(() => currentType.value === 'ALL' ? '暂无收款方' : `暂无${payeeTypeLabel(currentType.value)}收款方`)
const relationLabel = (relation?: string | null) => relation === 'INTERNAL' ? '内部' : relation === 'EXTERNAL' ? '外部' : '—'
const { page, pageSize, paginatedItems: paginatedSubjects } = useListPagination(filteredSubjects, { resetSources: [search, currentType] }) const { page, pageSize, paginatedItems: paginatedSubjects } = useListPagination(filteredSubjects, { resetSources: [search, currentType] })
type PayeeEmployeeOption = PayeeUser & { existingSubject: PayeeSubject | null } type PayeeEmployeeOption = PayeeUser & { existingSubject: PayeeSubject | null }
const employeeOptions = computed<PayeeEmployeeOption[]>(() => { const employeeOptions = computed<PayeeEmployeeOption[]>(() => {
@@ -163,14 +171,14 @@ const handleEmployeeQueryInput = () => {
const chooseEmployee = async (user: PayeeEmployeeOption) => { const chooseEmployee = async (user: PayeeEmployeeOption) => {
if (user.existingSubject) { if (user.existingSubject) {
if (!user.existingSubject.manageable) { if (!user.existingSubject.manageable) {
formError.value = `“${user.realName}”已是付款对象,但当前账号没有编辑权限。` formError.value = `“${user.realName}”已是收款方,但当前账号没有编辑权限。`
return return
} }
employeeMenuOpen.value = false employeeMenuOpen.value = false
subjectDialog.value?.close() subjectDialog.value?.close()
editingSubject.value = null editingSubject.value = null
formError.value = '' formError.value = ''
ElMessage.info(`“${user.realName}”已是付款对象,请直接补充收款账户`) ElMessage.info(`“${user.realName}”已是收款方,请直接补充收款账户`)
await nextTick() await nextTick()
await openAccount(user.existingSubject) await openAccount(user.existingSubject)
return return
@@ -187,18 +195,18 @@ const closeAccountsDialog = () => { if (defaultingAccountId.value) return; accou
const openAccountFromList = async (account?: PayeeAccount) => { const subject = accountListSubject.value; if (!subject?.manageable) return; closeAccountsDialog(); await nextTick(); await openAccount(subject, account) } const openAccountFromList = async (account?: PayeeAccount) => { const subject = accountListSubject.value; if (!subject?.manageable) return; closeAccountsDialog(); await nextTick(); await openAccount(subject, account) }
const setDefaultAccount = async (account: PayeeAccount) => { const subject = accountListSubject.value; if (!subject?.manageable || account.status !== 'ACTIVE' || account.isDefault || defaultingAccountId.value) return; defaultingAccountId.value = account.id; try { await payeesApi.setDefaultSubjectAccount(subject.id, account.id); await refreshAccounts(subject); ElMessage.success('默认收款账户已更新') } catch (error) { ElMessage.error(`设置默认账户失败:${payeeErrorMessage(error)}`) } finally { defaultingAccountId.value = null } } const setDefaultAccount = async (account: PayeeAccount) => { const subject = accountListSubject.value; if (!subject?.manageable || account.status !== 'ACTIVE' || account.isDefault || defaultingAccountId.value) return; defaultingAccountId.value = account.id; try { await payeesApi.setDefaultSubjectAccount(subject.id, account.id); await refreshAccounts(subject); ElMessage.success('默认收款账户已更新') } catch (error) { ElMessage.error(`设置默认账户失败:${payeeErrorMessage(error)}`) } finally { defaultingAccountId.value = null } }
const deactivateAccountFromList = async (account: PayeeAccount) => { const subject = accountListSubject.value; if (!subject) return; await deactivateAccount(subject, account) } const deactivateAccountFromList = async (account: PayeeAccount) => { const subject = accountListSubject.value; if (!subject) return; await deactivateAccount(subject, account) }
const openCreateSubject = async () => { editingSubject.value = null; employeeQuery.value = ''; employeeMenuOpen.value = false; formError.value = ''; Object.assign(subjectForm, emptySubject(currentType.value)); Object.assign(initialAccountForm, emptyInitialAccount()); await nextTick(); subjectDialog.value?.showModal() } const openCreateSubject = async () => { editingSubject.value = null; employeeQuery.value = ''; employeeMenuOpen.value = false; formError.value = ''; Object.assign(subjectForm, emptySubject(currentType.value === 'ALL' ? 'EMPLOYEE' : currentType.value)); Object.assign(initialAccountForm, emptyInitialAccount()); await nextTick(); subjectDialog.value?.showModal() }
const openEditSubject = async (subject: PayeeSubject) => { if (!subject.manageable) return; editingSubject.value = subject; employeeQuery.value = subject.payeeType === 'EMPLOYEE' ? subject.displayName : ''; employeeMenuOpen.value = false; formError.value = ''; Object.assign(subjectForm, { payeeType: subject.payeeType, employeeOpenId: subject.employeeOpenId ?? null, identityNumber: subject.identityNumber || '', displayName: subject.displayName, supplierCreditCode: subject.supplierCreditCode || '', status: subject.status }); await nextTick(); subjectDialog.value?.showModal() } const openEditSubject = async (subject: PayeeSubject) => { if (!subject.manageable) return; editingSubject.value = subject; employeeQuery.value = subject.payeeType === 'EMPLOYEE' ? subject.displayName : ''; employeeMenuOpen.value = false; formError.value = ''; Object.assign(subjectForm, { payeeType: subject.payeeType, employeeOpenId: subject.employeeOpenId ?? null, identityNumber: subject.identityNumber || '', displayName: subject.displayName, relationType: subject.relationType || (subject.payeeType === 'EMPLOYEE' ? 'INTERNAL' : 'EXTERNAL'), countryRegion: subject.countryRegion || '中国', identityType: subject.identityType || (subject.payeeType === 'EMPLOYEE' ? '' : '统一社会信用代码'), identityValue: subject.supplierCreditCode || '', supplierCreditCode: subject.supplierCreditCode || '', status: subject.status }); await nextTick(); subjectDialog.value?.showModal() }
const closeSubjectDialog = () => { if (saving.value) return; employeeMenuOpen.value = false; subjectDialog.value?.close(); editingSubject.value = null; formError.value = '' } const closeSubjectDialog = () => { if (saving.value) return; employeeMenuOpen.value = false; subjectDialog.value?.close(); editingSubject.value = null; formError.value = '' }
const validateSubject = () => { if (subjectForm.payeeType === 'EMPLOYEE' && !subjectForm.employeeOpenId) return '请选择关联员工'; const identityNumber = subjectForm.identityNumber?.trim(); if (subjectForm.payeeType === 'EMPLOYEE' && identityNumber && !/^(?:\d{15}|\d{17}[\dXx])$/.test(identityNumber)) return '身份证号应为15位或18位,18位末位可为X'; if (subjectForm.payeeType === 'SUPPLIER' && !subjectForm.displayName.trim()) return '请填写供应商名称'; if (subjectForm.payeeType === 'SUPPLIER' && !/^[0-9A-HJ-NPQRTUWXY]{18}$/i.test(subjectForm.supplierCreditCode || '')) return '请填写有效的18位统一社会信用代码'; if (!editingSubject.value && !initialAccountForm.bankName.trim()) return '请填写银行名称'; const accountNo = normalizedAccountNumber(initialAccountForm.accountNo); if (!editingSubject.value && !accountNo) return '请填写银行账号'; if (!editingSubject.value && !/^[A-Z0-9]{6,100}$/.test(accountNo)) return '银行账号仅支持6至100位字母或数字'; return '' } const validateSubject = () => { if (subjectForm.payeeType === 'EMPLOYEE' && !subjectForm.employeeOpenId) return '请选择关联员工'; const identityNumber = subjectForm.identityNumber?.trim(); if (subjectForm.payeeType === 'EMPLOYEE' && identityNumber && !/^(?:\d{15}|\d{17}[\dXx])$/.test(identityNumber)) return '身份证号应为15位或18位,18位末位可为X'; if (subjectForm.payeeType !== 'EMPLOYEE' && !subjectForm.displayName.trim()) return `请填写${payeeTypeLabel(subjectForm.payeeType)}名称`; if (subjectForm.payeeType !== 'EMPLOYEE' && !subjectForm.countryRegion?.trim()) return '请填写国家或地区'; const identityValue = subjectForm.identityValue?.trim(); if (subjectForm.payeeType !== 'EMPLOYEE' && identityValue && !/^[0-9A-HJ-NPQRTUWXY]{18}$/i.test(identityValue)) return '请填写有效的18位统一社会信用代码'; if (subjectForm.payeeType !== 'EMPLOYEE' && !identityValue && !(editingSubject.value?.identityValueMaintained)) return '请填写统一社会信用代码'; if (!editingSubject.value && !initialAccountForm.bankName.trim()) return '请填写银行名称'; const accountNo = normalizedAccountNumber(initialAccountForm.accountNo); if (!editingSubject.value && !accountNo) return '请填写银行账号'; if (!editingSubject.value && !/^[A-Z0-9]{6,100}$/.test(accountNo)) return '银行账号仅支持6至100位字母或数字'; return '' }
const saveSubject = async () => { if (saving.value) return; formError.value = validateSubject(); if (formError.value) return; const payload: PayeeSubjectPayload = { ...subjectForm, displayName: subjectForm.payeeType === 'SUPPLIER' ? subjectForm.displayName.trim() : '', identityNumber: subjectForm.payeeType === 'EMPLOYEE' ? (subjectForm.identityNumber?.trim().toUpperCase() || '') : undefined, supplierCreditCode: subjectForm.payeeType === 'SUPPLIER' ? subjectForm.supplierCreditCode?.trim().toUpperCase() : undefined, employeeOpenId: subjectForm.payeeType === 'EMPLOYEE' ? subjectForm.employeeOpenId : undefined, initialAccount: editingSubject.value ? undefined : { bankName: initialAccountForm.bankName.trim(), branchName: initialAccountForm.branchName.trim() || undefined, accountNo: normalizedAccountNumber(initialAccountForm.accountNo) } }; saving.value = true; let saved = false; try { const result = editingSubject.value ? await payeesApi.updateSubject(editingSubject.value.id, payload) : await payeesApi.createSubject(payload); const index = subjects.value.findIndex(item => item.id === result.id); if (index >= 0) subjects.value[index] = result; else subjects.value.push(result); currentType.value = result.payeeType; ElMessage.success(editingSubject.value ? '付款对象已更新' : '付款对象及首个收款账户已创建'); saved = true } catch (error) { formError.value = payeeErrorMessage(error, '付款对象保存失败,请重试。') } finally { saving.value = false; if (saved) closeSubjectDialog() } } const saveSubject = async () => { if (saving.value) return; formError.value = validateSubject(); if (formError.value) return; const external = subjectForm.payeeType !== 'EMPLOYEE'; const identityValue = external ? subjectForm.identityValue?.trim().toUpperCase() : undefined; const payload: PayeeSubjectPayload = { ...subjectForm, displayName: external ? subjectForm.displayName.trim() : '', identityNumber: subjectForm.payeeType === 'EMPLOYEE' ? (subjectForm.identityNumber?.trim().toUpperCase() || '') : undefined, identityValue, supplierCreditCode: subjectForm.payeeType === 'SUPPLIER' ? identityValue : undefined, employeeOpenId: subjectForm.payeeType === 'EMPLOYEE' ? subjectForm.employeeOpenId : undefined, relationType: subjectForm.payeeType === 'EMPLOYEE' ? 'INTERNAL' : subjectForm.relationType, countryRegion: subjectForm.payeeType === 'EMPLOYEE' ? '中国' : subjectForm.countryRegion?.trim(), identityType: external ? '统一社会信用代码' : undefined, initialAccount: editingSubject.value ? undefined : { bankName: initialAccountForm.bankName.trim(), branchName: initialAccountForm.branchName.trim() || undefined, accountNo: normalizedAccountNumber(initialAccountForm.accountNo) } }; saving.value = true; let saved = false; try { const result = editingSubject.value ? await payeesApi.updateSubject(editingSubject.value.id, payload) : await payeesApi.createSubject(payload); const index = subjects.value.findIndex(item => item.id === result.id); if (index >= 0) subjects.value[index] = result; else subjects.value.push(result); ElMessage.success(editingSubject.value ? '收款方已更新' : '收款方及首个收款账户已创建'); saved = true } catch (error) { formError.value = payeeErrorMessage(error, '收款方保存失败,请重试。') } finally { saving.value = false; if (saved) closeSubjectDialog() } }
const openAccount = async (subject: PayeeSubject, account?: PayeeAccount) => { if (!subject.manageable) return; accountSubject.value = subject; editingAccount.value = account || null; formError.value = ''; Object.assign(accountForm, account ? { bankName: account.bankName, branchName: account.branchName || '', accountNo: '', isDefault: account.isDefault, status: account.status } : emptyAccount()); await nextTick(); accountDialog.value?.showModal() } const openAccount = async (subject: PayeeSubject, account?: PayeeAccount) => { if (!subject.manageable) return; accountSubject.value = subject; editingAccount.value = account || null; formError.value = ''; Object.assign(accountForm, account ? { bankName: account.bankName, branchName: account.branchName || '', accountNo: '', isDefault: account.isDefault, status: account.status } : emptyAccount()); await nextTick(); accountDialog.value?.showModal() }
const closeAccountDialog = () => { if (saving.value) return; accountDialog.value?.close(); editingAccount.value = null; accountSubject.value = null; formError.value = '' } const closeAccountDialog = () => { if (saving.value) return; accountDialog.value?.close(); editingAccount.value = null; accountSubject.value = null; formError.value = '' }
const saveAccount = async () => { const subject = accountSubject.value; if (!subject || saving.value) return; formError.value = validatePayeeForm(accountForm, Boolean(editingAccount.value), false); if (formError.value) return; const payload: PayeeAccountPayload = { ...accountForm, bankName: accountForm.bankName.trim(), branchName: accountForm.branchName?.trim(), accountNo: accountForm.accountNo ? normalizedAccountNumber(accountForm.accountNo) : '', isDefault: accountForm.status === 'ACTIVE' && accountForm.isDefault }; saving.value = true; let saved = false; try { if (editingAccount.value) await payeesApi.updateSubjectAccount(subject.id, editingAccount.value.id, payload); else await payeesApi.createSubjectAccount(subject.id, payload); await Promise.all([refreshAccounts(subject), load()]); ElMessage.success(editingAccount.value ? '收款账户已更新' : '收款账户已新增'); saved = true } catch (error) { formError.value = payeeErrorMessage(error, '收款账户保存失败,请重试。') } finally { saving.value = false; if (saved) closeAccountDialog() } } const saveAccount = async () => { const subject = accountSubject.value; if (!subject || saving.value) return; formError.value = validatePayeeForm(accountForm, Boolean(editingAccount.value), false); if (formError.value) return; const payload: PayeeAccountPayload = { ...accountForm, bankName: accountForm.bankName.trim(), branchName: accountForm.branchName?.trim(), accountNo: accountForm.accountNo ? normalizedAccountNumber(accountForm.accountNo) : '', isDefault: accountForm.status === 'ACTIVE' && accountForm.isDefault }; saving.value = true; let saved = false; try { if (editingAccount.value) await payeesApi.updateSubjectAccount(subject.id, editingAccount.value.id, payload); else await payeesApi.createSubjectAccount(subject.id, payload); await Promise.all([refreshAccounts(subject), load()]); ElMessage.success(editingAccount.value ? '收款账户已更新' : '收款账户已新增'); saved = true } catch (error) { formError.value = payeeErrorMessage(error, '收款账户保存失败,请重试。') } finally { saving.value = false; if (saved) closeAccountDialog() } }
const deactivateSubject = async (subject: PayeeSubject) => { if (!subject.manageable || !canDeactivate.value) return; try { await ElMessageBox.confirm(`确认停用“${subject.displayName}”及其全部收款账户?历史单据不受影响。`, '停用付款对象', { type: 'warning', confirmButtonText: '停用', cancelButtonText: '取消' }) } catch { return } deactivatingKey.value = `subject-${subject.id}`; try { const saved = await payeesApi.deactivateSubject(subject.id); const index = subjects.value.findIndex(item => item.id === saved.id); if (index >= 0) subjects.value[index] = saved; ElMessage.success('付款对象已停用') } catch (error) { ElMessage.error(`停用失败:${payeeErrorMessage(error)}`) } finally { deactivatingKey.value = '' } } const deactivateSubject = async (subject: PayeeSubject) => { if (!subject.manageable || !canDeactivate.value) return; try { await ElMessageBox.confirm(`确认停用“${subject.displayName}”及其全部收款账户?历史单据不受影响。`, '停用收款方', { type: 'warning', confirmButtonText: '停用', cancelButtonText: '取消' }) } catch { return } deactivatingKey.value = `subject-${subject.id}`; try { const saved = await payeesApi.deactivateSubject(subject.id); const index = subjects.value.findIndex(item => item.id === saved.id); if (index >= 0) subjects.value[index] = saved; ElMessage.success('收款方已停用') } catch (error) { ElMessage.error(`停用失败:${payeeErrorMessage(error)}`) } finally { deactivatingKey.value = '' } }
const deactivateAccount = async (subject: PayeeSubject, account: PayeeAccount) => { if (!subject.manageable || !canDeactivate.value) return; try { await ElMessageBox.confirm(`确认停用 ${account.bankName}(${account.bankAccountMask})?`, '停用收款账户', { type: 'warning', confirmButtonText: '停用', cancelButtonText: '取消' }) } catch { return } deactivatingKey.value = `account-${account.id}`; try { await payeesApi.deactivateSubjectAccount(subject.id, account.id); await Promise.all([refreshAccounts(subject), load()]); ElMessage.success('收款账户已停用') } catch (error) { ElMessage.error(`停用失败:${payeeErrorMessage(error)}`) } finally { deactivatingKey.value = '' } } const deactivateAccount = async (subject: PayeeSubject, account: PayeeAccount) => { if (!subject.manageable || !canDeactivate.value) return; try { await ElMessageBox.confirm(`确认停用 ${account.bankName}(${account.bankAccountMask})?`, '停用收款账户', { type: 'warning', confirmButtonText: '停用', cancelButtonText: '取消' }) } catch { return } deactivatingKey.value = `account-${account.id}`; try { await payeesApi.deactivateSubjectAccount(subject.id, account.id); await Promise.all([refreshAccounts(subject), load()]); ElMessage.success('收款账户已停用') } catch (error) { ElMessage.error(`停用失败:${payeeErrorMessage(error)}`) } finally { deactivatingKey.value = '' } }
watch(() => accountForm.status, status => { if (status !== 'ACTIVE') accountForm.isDefault = false }) watch(() => accountForm.status, status => { if (status !== 'ACTIVE') accountForm.isDefault = false })
watch(() => subjectForm.payeeType, type => { if (type !== 'EMPLOYEE') { subjectForm.employeeOpenId = null; employeeQuery.value = ''; employeeMenuOpen.value = false } }) watch(() => subjectForm.payeeType, type => { if (type !== 'EMPLOYEE') { subjectForm.employeeOpenId = null; subjectForm.identityNumber = ''; subjectForm.identityType = '统一社会信用代码'; subjectForm.relationType ||= 'EXTERNAL'; subjectForm.countryRegion ||= '中国'; employeeQuery.value = ''; employeeMenuOpen.value = false } else { subjectForm.relationType = 'INTERNAL'; subjectForm.countryRegion = '中国'; subjectForm.identityType = ''; subjectForm.identityValue = ''; subjectForm.supplierCreditCode = '' } })
watch(currentType, () => { if (accountsListDialog.value?.open) closeAccountsDialog() }) watch(currentType, () => { if (accountsListDialog.value?.open) closeAccountsDialog() })
onMounted(() => { void load() }) onMounted(() => { void load() })
</script> </script>
+129 -45
View File
@@ -1,14 +1,14 @@
<template> <template>
<div class="page-content route-list-page finance-queue-page"> <div class="page-content route-list-page finance-queue-page" :class="{ 'payments-embedded': embedded }">
<div class="page-head"> <div v-if="!embedded" class="page-head">
<div> <div>
<span class="eyebrow">PAYMENT QUEUE</span> <span class="eyebrow">PAYMENT QUEUE</span>
<h1>待付款</h1> <h1>付款结果登记</h1>
<p>收单完成后进入付款队列,支持分次付款并保留付款凭据。</p> <p>登记外部系统已发生的付款事实,保留实际日期、方式、银行流水号与付款回单。</p>
</div> </div>
<div class="head-actions"> <div class="head-actions">
<button class="btn" type="button" :disabled="loadingState" @click="refreshQueue">刷新</button> <button class="btn" type="button" :disabled="loadingState" @click="refreshQueue">刷新</button>
<router-link class="btn primary" to="/finance-receipt">返回待收单</router-link> <router-link class="btn primary" to="/finance-receipt">返回财务处理中心</router-link>
</div> </div>
</div> </div>
@@ -16,7 +16,7 @@
<b aria-hidden="true">!</b><span>{{ authorization.error }}</span> <b aria-hidden="true">!</b><span>{{ authorization.error }}</span>
</div> </div>
<div v-else-if="authorization.loaded && !canRegister" class="inline-alert" role="status"> <div v-else-if="authorization.loaded && !canRegister" class="inline-alert" role="status">
<b aria-hidden="true">i</b><span>当前账号没有登记付款权限,付款队列为只读。</span> <b aria-hidden="true">i</b><span>当前账号没有登记付款结果权限,付款队列为只读。</span>
</div> </div>
<div v-if="loadingState" class="load-wrap" role="status" aria-live="polite"> <div v-if="loadingState" class="load-wrap" role="status" aria-live="polite">
@@ -37,40 +37,70 @@
<button class="btn small" type="button" @click="refreshQueue">重试</button> <button class="btn small" type="button" @click="refreshQueue">重试</button>
</div> </div>
<div class="finance-kpis finance-queue-kpis"> <div v-if="!embedded" class="finance-kpis finance-queue-kpis">
<div><span>待付款</span><strong>{{ payable.length }}</strong><small>存在未付余额</small></div> <div><span>待付款</span><strong>{{ payable.length }}</strong><small>存在未付余额</small></div>
<div><span>待付金额</span><strong>{{ money(totalBalance) }}</strong><small>由有效付款记录派生</small></div> <div><span>待付金额</span><strong>{{ money(totalBalance) }}</strong><small>由有效付款记录派生</small></div>
<div><span>待复核</span><strong>{{ pendingReviews.length }}</strong><small>制单后等待独立复核</small></div> <div v-if="store.independentPaymentReviewEnabled"><span>待复核</span><strong>{{ pendingReviews.length }}</strong><small>仅统计命中独立复核规则的记录</small></div>
<div><span>已付款</span><strong>{{ completed.length }}</strong><small>全额完成</small></div> <div><span>已付款</span><strong>{{ completed.length }}</strong><small>全额完成</small></div>
</div> </div>
<div class="card fill-list-card primary-list-card"> <div class="card fill-list-card primary-list-card">
<div class="card-head"> <div v-if="!embedded" class="card-head">
<div><h2>付款登记队列</h2><p>登记结果后,付款状态自动派生并保留付款事实。</p></div> <div><h2>付款登记队列</h2><p>登记结果后,付款状态自动派生并保留付款事实。</p></div>
<span class="tag info">财务处理</span> <span class="tag info">财务处理</span>
</div> </div>
<div class="filter-bar finance-queue-filter"> <div class="filter-bar finance-queue-filter">
<label class="filter-search finance-queue-search"> <label class="filter-search finance-queue-search">
<span aria-hidden="true">⌕</span> <span aria-hidden="true">⌕</span>
<input v-model="query" type="search" aria-label="搜索待付款" placeholder="搜索报销单号、报销人或事项"> <input v-model="query" type="search" aria-label="搜索待付款" :placeholder="embedded ? '搜索申请单号、事项或收款方' : '搜索付款申请单号、申请人、收款方或付款事由'">
</label> </label>
<span class="tag info finance-result-count" aria-live="polite">{{ filtered.length }} 笔结果</span> <select v-if="embedded" v-model="paymentStatusFilter" class="filter-select" aria-label="按付款状态筛选">
<option value="">全部付款状态</option>
<option value="待登记付款结果">待登记付款结果</option>
<option value="登记失败">登记失败</option>
<option value="待补付款回单">待补付款回单</option>
</select>
<span class="filter-spacer"></span>
<span class="tag info finance-result-count" aria-live="polite">{{ filtered.length }} 张申请</span>
</div> </div>
<div v-if="filtered.length" class="table-wrap finance-table-wrap"> <div class="table-wrap finance-table-wrap">
<table class="data-table responsive-table" aria-label="付款登记队列"> <table v-if="embedded" class="data-table has-actions" aria-label="付款结果队列">
<caption class="sr-only">付款结果队列</caption>
<thead>
<tr><th>付款申请</th><th v-if="uiRead('ui.payments.column.payee')">收款方/申请人</th><th v-if="uiRead('ui.payments.column.amount')" class="amount-heading">申请付款金额</th><th v-if="uiRead('ui.payments.column.status')">付款状态</th><th>审批</th><th>付款结果</th></tr>
</thead>
<tbody>
<tr v-if="!filtered.length"><td colspan="6"><div class="empty-state"><strong>{{ rows.length ? '没有符合当前条件的申请' : '当前没有待登记付款结果的申请' }}</strong></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id">
<td data-label="付款申请"><router-link v-if="canViewDetail" class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><strong v-else>{{ item.applicationNo }}</strong><small>{{ item.paymentReason || item.title }}</small></td>
<td v-if="uiRead('ui.payments.column.payee')" data-label="收款方/申请人"><strong v-if="hasOwnField(item, 'payeeName')">{{ item.payeeName }}</strong><small v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</small></td>
<td v-if="uiRead('ui.payments.column.amount') && hasOwnField(item, 'requestedAmount')" data-label="申请付款金额" class="amount">{{ money(item.requestedAmount) }}</td><td v-else-if="uiRead('ui.payments.column.amount')" data-label="申请付款金额" class="amount muted-copy">字段不可见</td>
<td v-if="uiRead('ui.payments.column.status')" data-label="付款状态"><span class="tag" :class="tone(queuePaymentStatus(item))">{{ queuePaymentStatus(item) }}</span></td>
<td data-label="审批"><router-link v-if="canViewDetail" class="table-action" :to="`/applications/${item.id}`">审批详情</router-link><span v-else class="muted-copy">—</span></td>
<td data-label="付款结果">
<router-link v-if="paymentFor(item) && canViewDetail" class="table-action" :to="`/applications/${item.id}`">付款结果详情</router-link>
<button v-else-if="!paymentFor(item) && store.balance(item) > 0 && canRegisterPayment(item, canRegister)" class="btn small primary" type="button" :disabled="saving" :aria-busy="saving && selected?.id === item.id" @click="openPayment(item)">{{ saving && selected?.id === item.id ? '提交中…' : '登记付款结果' }}</button>
<span v-else-if="!paymentFor(item) && !canRegister" class="muted-copy">待登记付款结果</span>
<span v-else class="muted-copy">{{ paymentFor(item) ? '无详情权限' : '待资格条件完成' }}</span>
</td>
</tr>
</tbody>
</table>
<table v-else class="data-table responsive-table" aria-label="付款登记队列">
<caption class="sr-only">付款登记队列</caption> <caption class="sr-only">付款登记队列</caption>
<thead> <thead>
<tr> <tr>
<th scope="col">报销单号</th><th v-if="uiRead('ui.payments.column.payee')" scope="col">报销人 / 收款人</th><template v-if="uiRead('ui.payments.column.amount')"><th scope="col" class="amount">申请金额</th><th scope="col" class="amount">累计已付</th><th scope="col" class="amount">未付余额</th></template><template v-if="uiRead('ui.payments.column.status')"><th scope="col">收单状态</th><th scope="col">付款状态</th></template><th scope="col">操作</th> <th scope="col">付款申请单号</th><th v-if="uiRead('ui.payments.column.payee')" scope="col">申请人 / 收款方</th><template v-if="uiRead('ui.payments.column.amount')"><th scope="col" class="amount-heading">申请付款金额</th><th scope="col" class="amount">批准金额</th><th scope="col" class="amount">累计实付</th><th scope="col" class="amount">未付余额</th></template><template v-if="uiRead('ui.payments.column.status')"><th v-if="store.financeCheckEnabled" scope="col">财务核对</th><th scope="col">付款状态</th></template><th scope="col">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-if="!filtered.length"><td colspan="9"><div class="empty-state"><strong>{{ rows.length ? '没有符合条件的付款记录' : '当前没有待付款记录' }}</strong><span>{{ rows.length ? '请调整搜索关键词后重试。' : '具备登记资格的付款申请会显示在这里。' }}</span></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td data-label="报销单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ item.createdAt?.slice(0, 10) || '-' }}</small></td> <td data-label="付款申请单号"><router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link><small>{{ item.createdAt?.slice(0, 10) || '-' }}</small></td>
<td v-if="uiRead('ui.payments.column.payee')" data-label="报销人 / 收款人"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small v-if="hasOwnField(item, 'payeeName')">{{ item.payeeName }}</small></td> <td v-if="uiRead('ui.payments.column.payee')" data-label="申请人 / 收款方"><strong v-if="hasOwnField(item, 'applicantName')">{{ item.applicantName }}</strong><small v-if="hasOwnField(item, 'payeeName')">{{ item.payeeName }}</small></td>
<template v-if="uiRead('ui.payments.column.amount')"><td v-if="hasOwnField(item, 'totalAmount')" data-label="申请金额" class="amount">{{ money(item.totalAmount) }}</td><td v-else data-label="申请金额" class="amount muted-copy">字段不可见</td><td data-label="累计已付" class="amount">{{ money(store.paidAmount(item)) }}</td><td data-label="未付余额" class="amount">{{ money(store.balance(item)) }}</td></template> <template v-if="uiRead('ui.payments.column.amount')"><td v-if="hasOwnField(item, 'requestedAmount')" data-label="申请付款金额" class="amount">{{ money(item.requestedAmount) }}</td><td v-else data-label="申请付款金额" class="amount muted-copy">字段不可见</td><td data-label="批准金额" class="amount">{{ item.approvedAmount == null ? '—' : money(item.approvedAmount) }}</td><td data-label="累计实付" class="amount">{{ money(store.paidAmount(item)) }}</td><td data-label="未付余额" class="amount">{{ money(store.balance(item)) }}</td></template>
<template v-if="uiRead('ui.payments.column.status')"><td data-label="收单状态"><span class="tag success">{{ item.receiptStatus }}</span></td><td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td></template> <template v-if="uiRead('ui.payments.column.status')"><td v-if="store.financeCheckEnabled" data-label="财务核对"><span class="tag success">{{ item.financeCheckStatus }}</span></td><td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td></template>
<td data-label="操作"> <td data-label="操作">
<div class="finance-row-actions"> <div class="finance-row-actions">
<button <button
@@ -80,39 +110,32 @@
:disabled="saving" :disabled="saving"
:aria-busy="saving && selected?.id === item.id" :aria-busy="saving && selected?.id === item.id"
@click="openPayment(item)" @click="openPayment(item)"
>{{ saving && selected?.id === item.id ? '提交中…' : '登记付款' }}</button> >{{ saving && selected?.id === item.id ? '提交中…' : '登记付款结果' }}</button>
<span v-else-if="store.balance(item) <= 0" class="muted-copy">已完成</span> <span v-else-if="store.balance(item) <= 0" class="muted-copy">已完成</span>
<span v-else-if="!canRegister" class="muted-copy">当前账号无登记付款权限</span> <span v-else-if="!canRegister" class="muted-copy">当前账号无登记付款结果权限</span>
<span v-else class="muted-copy">当前状态或职责分离规则不允许付款</span> <span v-else class="muted-copy">当前状态或职责分离规则不允许登记</span>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!rows.length" class="empty-state">
<strong>当前没有待付款记录</strong>
<span>完成财务收单的报销会自动进入这里。</span>
</div>
<div v-else class="empty-state">
<strong>没有符合条件的付款记录</strong>
<span>请调整搜索关键词后重试。</span>
</div>
<AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="付款登记队列分页" /> <AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="付款登记队列分页" />
</div> </div>
<div class="card fill-list-card section-gap"> <div v-if="!embedded && store.independentPaymentReviewEnabled" class="card fill-list-card section-gap">
<div class="card-head"> <div class="card-head">
<div><h2>付款复核</h2><p>登记只创建待复核记录;复核与拒绝动作由服务端逐条授权。</p></div> <div><h2>付款复核</h2><p>登记只创建待复核记录;复核与拒绝动作由服务端逐条授权。</p></div>
<span class="tag pending">{{ pendingReviews.length }} 笔待复核</span> <span class="tag pending">{{ pendingReviews.length }} 笔待复核</span>
</div> </div>
<div v-if="pendingReviews.length" class="table-wrap finance-table-wrap"> <div class="table-wrap finance-table-wrap">
<table class="data-table responsive-table" aria-label="付款复核队列"> <table class="data-table responsive-table" aria-label="付款复核队列">
<thead><tr><th>付款单号</th><th class="amount">付款金额</th><th>登记人</th><th>状态</th><th>操作</th></tr></thead> <thead><tr><th>付款单号</th><th class="amount">付款金额</th><th>登记人</th><th>状态</th><th>操作</th></tr></thead>
<tbody> <tbody>
<tr v-if="!pendingReviews.length"><td colspan="5"><div class="empty-state"><strong>暂无待复核付款</strong><span>服务端授权范围内的记录会显示在这里。</span></div></td></tr>
<tr v-for="payment in pendingReviews" :key="payment.id"> <tr v-for="payment in pendingReviews" :key="payment.id">
<td data-label="付款单号"><strong>{{ payment.paymentNo }}</strong><small v-if="hasOwnField(payment, 'paymentTime')">{{ payment.paymentTime }}</small></td> <td data-label="付款单号"><strong>{{ payment.paymentNo }}</strong><small v-if="hasOwnField(payment, 'resultRecordedAt')">{{ payment.resultRecordedAt }}</small></td>
<td data-label="付款金额" class="amount">{{ money(payment.paymentAmount) }}</td> <td data-label="实际付款金额" class="amount">{{ money(payment.actualPaymentAmount) }}</td>
<td data-label="登记人"><span v-if="hasOwnField(payment, 'operatorName')">{{ payment.operatorName }}</span><span v-else class="muted-copy">不可见</span></td> <td data-label="登记人"><span v-if="hasOwnField(payment, 'operatorName')">{{ payment.operatorName }}</span><span v-else class="muted-copy">不可见</span></td>
<td data-label="状态"><span class="tag pending">{{ payment.paymentStatus }}</span></td> <td data-label="状态"><span class="tag pending">{{ payment.paymentStatus }}</span></td>
<td data-label="操作"> <td data-label="操作">
@@ -126,7 +149,16 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="empty-state"><strong>暂无待复核付款</strong><span>服务端授权范围内的记录会显示在这里。</span></div> </div>
<div v-if="!embedded" class="card fill-list-card section-gap">
<div class="card-head"><div><h2>待补付款回单</h2><p>付款已生效,只补录外部回单编号或归档引用,不重复登记付款。</p></div><span class="tag pending">{{ pendingReceipts.length }} 笔待补</span></div>
<div class="table-wrap finance-table-wrap">
<table class="data-table responsive-table" aria-label="待补付款回单队列">
<thead><tr><th>付款单号</th><th class="amount">实际付款金额</th><th>实际付款日期</th><th>银行流水号</th><th>操作</th></tr></thead>
<tbody><tr v-if="!pendingReceipts.length"><td colspan="5"><div class="empty-state"><strong>暂无待补付款回单</strong></div></td></tr><tr v-for="payment in pendingReceipts" :key="payment.id"><td data-label="付款单号"><strong>{{ payment.paymentNo }}</strong></td><td data-label="实际付款金额" class="amount">{{ money(payment.actualPaymentAmount) }}</td><td data-label="实际付款日期">{{ payment.actualPaymentDate || payment.resultRecordedAt || '—' }}</td><td data-label="银行流水号">{{ payment.bankTransactionNo || payment.referenceNo || '未提供' }}</td><td data-label="操作"><button v-if="payment.availableActions?.includes('PAYMENT_RECEIPT_ATTACH')" class="btn small primary" type="button" :disabled="reviewing.has(String(payment.id))" @click="attachReceipt(payment)">补录回单</button><span v-else class="muted-copy">当前账号无补录权限</span></td></tr></tbody>
</table>
</div>
</div> </div>
</template> </template>
@@ -145,7 +177,7 @@
<div class="modal-head" data-dialog-drag-handle> <div class="modal-head" data-dialog-drag-handle>
<div> <div>
<span class="eyebrow">PAYMENT RECORD</span> <span class="eyebrow">PAYMENT RECORD</span>
<h2 id="payment-dialog-title">登记付款</h2> <h2 id="payment-dialog-title">登记付款结果</h2>
<p id="payment-dialog-description">{{ selected.applicationNo }} · {{ selected.title }}</p> <p id="payment-dialog-description">{{ selected.applicationNo }} · {{ selected.title }}</p>
</div> </div>
<button class="modal-close" type="button" aria-label="关闭付款登记窗口" :disabled="saving" @click="closePayment">×</button> <button class="modal-close" type="button" aria-label="关闭付款登记窗口" :disabled="saving" @click="closePayment">×</button>
@@ -153,14 +185,15 @@
<div class="modal-body payment-dialog-body"> <div class="modal-body payment-dialog-body">
<div class="payment-summary"> <div class="payment-summary">
<div><span>申请金额</span><strong>{{ money(selected.totalAmount) }}</strong></div> <div><span>申请付款金额</span><strong>{{ money(selected.requestedAmount) }}</strong></div>
<div><span>累计已付</span><strong>{{ money(store.paidAmount(selected)) }}</strong></div> <div><span>批准金额</span><strong>{{ selected.approvedAmount == null ? '—' : money(selected.approvedAmount) }}</strong></div>
<div><span>累计实付</span><strong>{{ money(store.paidAmount(selected)) }}</strong></div>
<div><span>未付余额</span><strong>{{ money(store.balance(selected)) }}</strong></div> <div><span>未付余额</span><strong>{{ money(store.balance(selected)) }}</strong></div>
</div> </div>
<div class="form-grid payment-fields"> <div class="form-grid payment-fields">
<div v-if="uiRead('dialog.payment.register.amount')" class="field"> <div v-if="uiRead('dialog.payment.register.amount')" class="field">
<label for="pay-amount">本次付款金额 <em>*</em></label> <label for="pay-amount">实际付款金额 <em>*</em></label>
<input <input
id="pay-amount" id="pay-amount"
v-model.number="amount" v-model.number="amount"
@@ -175,6 +208,12 @@
> >
<p id="pay-amount-help" class="form-help">不超过未付余额 {{ money(store.balance(selected)) }}</p> <p id="pay-amount-help" class="form-help">不超过未付余额 {{ money(store.balance(selected)) }}</p>
</div> </div>
<template v-if="uiRead('dialog.payment.register.amount')">
<div class="field"><label for="pay-date">实际付款日期 <em>*</em></label><input id="pay-date" v-model="actualPaymentDate" type="date" required :disabled="saving || !uiEdit('dialog.payment.register.amount')"></div>
<div class="field"><label for="pay-method">实际付款方式 <em>*</em></label><input id="pay-method" v-model.trim="actualPaymentMethod" maxlength="50" required placeholder="按外部实际付款结果填写" :disabled="saving || !uiEdit('dialog.payment.register.amount')"></div>
<div class="field"><label for="pay-reference">银行流水号</label><input id="pay-reference" v-model.trim="bankTransactionNo" maxlength="100" placeholder="未取得可留空,不补造流水号" :disabled="saving || !uiEdit('dialog.payment.register.amount')"></div>
<div class="field"><label for="pay-receipt">付款回单引用</label><input id="pay-receipt" v-model.trim="paymentReceipt" maxlength="500" placeholder="外部回单编号或已归档文件引用" :disabled="saving || !uiEdit('dialog.payment.register.amount')"><small class="form-help">{{ paymentReceipt ? '保存回单引用,原件由外部系统或档案保管。' : '待补付款回单' }}</small></div>
</template>
<div v-if="uiRead('dialog.payment.register.remark')" class="field full"> <div v-if="uiRead('dialog.payment.register.remark')" class="field full">
<label for="pay-remark">备注</label> <label for="pay-remark">备注</label>
<textarea id="pay-remark" v-model="remark" rows="3" maxlength="200" placeholder="可填写付款说明或外部凭据" :disabled="saving || !uiEdit('dialog.payment.register.remark')"></textarea> <textarea id="pay-remark" v-model="remark" rows="3" maxlength="200" placeholder="可填写付款说明或外部凭据" :disabled="saving || !uiEdit('dialog.payment.register.remark')"></textarea>
@@ -206,6 +245,8 @@ import { useAuthorizationStore } from '@/store/authorization'
import { useUserStore } from '@/store/user' import { useUserStore } from '@/store/user'
import { useWorkbenchStore } from '@/store/workbench' import { useWorkbenchStore } from '@/store/workbench'
const props = withDefaults(defineProps<{ embedded?: boolean }>(), { embedded: false })
const embedded = computed(() => props.embedded)
const store = useWorkbenchStore() const store = useWorkbenchStore()
const authorization = useAuthorizationStore() const authorization = useAuthorizationStore()
const userStore = useUserStore() const userStore = useUserStore()
@@ -215,33 +256,54 @@ const canRegister = computed(() => uiRead('dialog.payment.register') && uiEdit('
const canSubmitPayment = computed(() => canRegister.value && uiEdit('dialog.payment.register.amount')) const canSubmitPayment = computed(() => canRegister.value && uiEdit('dialog.payment.register.amount'))
const canReview = computed(() => userStore.canEdit('finance.payment.verify') && authorization.can('finance.payment:review')) const canReview = computed(() => userStore.canEdit('finance.payment.verify') && authorization.can('finance.payment:review'))
const canReject = computed(() => userStore.canEdit('finance.payment.reject') && authorization.can('finance.payment:reject')) const canReject = computed(() => userStore.canEdit('finance.payment.reject') && authorization.can('finance.payment:reject'))
const canViewDetail = computed(() => userStore.canRead('page.application-detail') && authorization.can('reimbursement.application:read'))
const query = ref('') const query = ref('')
const paymentStatusFilter = ref('')
const hasLoaded = ref(false) const hasLoaded = ref(false)
const selected = ref<ReimApplicationDetail | null>(null) const selected = ref<ReimApplicationDetail | null>(null)
const dialog = ref<HTMLDialogElement | null>(null) const dialog = ref<HTMLDialogElement | null>(null)
const amount = ref<number | null>(0) const amount = ref<number | null>(0)
const remark = ref('') const remark = ref('')
const actualPaymentDate = ref('')
const actualPaymentMethod = ref('')
const bankTransactionNo = ref('')
const paymentReceipt = ref('')
const idempotencyKey = ref('') const idempotencyKey = ref('')
const saving = ref(false) const saving = ref(false)
const reviewing = ref<Set<string>>(new Set()) const reviewing = ref<Set<string>>(new Set())
const formError = ref('') const formError = ref('')
let trigger: HTMLElement | null = null let trigger: HTMLElement | null = null
const rows = computed(() => store.reimbursements.filter(item => item.receiptStatus === '已收单')) const linkedPayments = (item: ReimApplicationDetail) => store.payments.filter(payment => String(payment.applicationId) === String(item.id))
const paymentFor = (item: ReimApplicationDetail) => linkedPayments(item).find(payment => ['已登记', '有效', '复核通过', '待补付款回单', 'COMPLETED', 'ACTIVE', 'PENDING_RECEIPT'].includes(payment.paymentStatus))
const hasPendingReceipt = (item: ReimApplicationDetail) => linkedPayments(item).some(payment => ['待补付款回单', 'PENDING_RECEIPT'].includes(payment.paymentStatus))
const queuePaymentStatus = (item: ReimApplicationDetail) => {
if (hasPendingReceipt(item)) return '待补付款回单'
if (['登记失败', '登记异常', 'REJECTED', 'FAILED', 'ERROR'].includes(item.paymentStatus)) return '登记失败'
return '待登记付款结果'
}
const approvedRows = computed(() => store.paymentApplications.filter(item => item.approvalStatus === '审批通过'))
const rows = computed(() => embedded.value
? approvedRows.value.filter(item => !['已付款', '付款结果已登记'].includes(item.paymentStatus) || hasPendingReceipt(item))
: approvedRows.value)
const payable = computed(() => rows.value.filter(item => store.balance(item) > 0)) const payable = computed(() => rows.value.filter(item => store.balance(item) > 0))
const completed = computed(() => rows.value.filter(item => store.balance(item) <= 0)) const completed = computed(() => rows.value.filter(item => store.balance(item) <= 0))
const pendingReviews = computed(() => store.payments.filter(payment => payment.paymentStatus === '待复核' || payment.paymentStatus === 'PENDING_REVIEW')) const pendingReviews = computed(() => store.payments.filter(payment => payment.paymentStatus === '待复核' || payment.paymentStatus === 'PENDING_REVIEW'))
const pendingReceipts = computed(() => store.payments.filter(payment => payment.paymentStatus === '待补付款回单' || payment.paymentStatus === 'PENDING_RECEIPT'))
const totalBalance = computed(() => payable.value.reduce((sum, item) => sum + store.balance(item), 0)) const totalBalance = computed(() => payable.value.reduce((sum, item) => sum + store.balance(item), 0))
const filtered = computed(() => { const filtered = computed(() => {
const normalizedQuery = query.value.trim().toLowerCase() const normalizedQuery = query.value.trim().toLowerCase()
return rows.value.filter(item => `${item.applicationNo} ${item.applicantName} ${item.title} ${item.payeeName}`.toLowerCase().includes(normalizedQuery)) return rows.value.filter(item => (
(!paymentStatusFilter.value || queuePaymentStatus(item) === paymentStatusFilter.value) &&
`${item.applicationNo} ${item.applicantName} ${item.title} ${item.payeeName}`.toLowerCase().includes(normalizedQuery)
))
}) })
const { page, pageSize, paginatedItems } = useListPagination(filtered, { resetSources: [query] }) const { page, pageSize, paginatedItems } = useListPagination(filtered, { resetSources: [query, paymentStatusFilter] })
const loadingState = computed(() => store.loading || !hasLoaded.value) const loadingState = computed(() => store.loading || !hasLoaded.value)
const hasBlockingError = computed(() => hasLoaded.value && (store.source === 'error' || Boolean(store.financeQueueError))) const hasBlockingError = computed(() => hasLoaded.value && (store.source === 'error' || Boolean(store.financeQueueError)))
const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value) const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value)
const money = (value: number | undefined) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}` const money = (value: number | undefined) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}`
const tone = (value: string) => ({ 未付款: 'neutral', 部分付款: 'info', 已付款: 'success' } as Record<string, string>)[value] || 'neutral' const tone = (value: string) => ({ 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 待登记付款结果: 'pending', 登记失败: 'danger', 待补付款回单: 'pending' } as Record<string, string>)[value] || 'neutral'
const canVerifyPayment = (payment: PaymentRecord) => canPerformPaymentReview(payment, 'verify', canReview.value) const canVerifyPayment = (payment: PaymentRecord) => canPerformPaymentReview(payment, 'verify', canReview.value)
const canRejectPayment = (payment: PaymentRecord) => canPerformPaymentReview(payment, 'reject', canReject.value) const canRejectPayment = (payment: PaymentRecord) => canPerformPaymentReview(payment, 'reject', canReject.value)
@@ -259,6 +321,10 @@ const openPayment = async (item: ReimApplicationDetail) => {
selected.value = item selected.value = item
amount.value = Number(store.balance(item).toFixed(2)) amount.value = Number(store.balance(item).toFixed(2))
remark.value = '' remark.value = ''
actualPaymentDate.value = ''
actualPaymentMethod.value = ''
bankTransactionNo.value = ''
paymentReceipt.value = ''
idempotencyKey.value = `reim-${item.id}-${Number(store.balance(item).toFixed(2)).toFixed(2)}` idempotencyKey.value = `reim-${item.id}-${Number(store.balance(item).toFixed(2)).toFixed(2)}`
formError.value = '' formError.value = ''
if (!dialog.value) return if (!dialog.value) return
@@ -287,6 +353,10 @@ const handlePaymentBackdrop = (event: MouseEvent) => { if(saving.value){event.pr
const submitPayment = async () => { const submitPayment = async () => {
if (!selected.value || !canSubmitPayment.value || !canRegisterPayment(selected.value, canRegister.value) || saving.value) return if (!selected.value || !canSubmitPayment.value || !canRegisterPayment(selected.value, canRegister.value) || saving.value) return
const max = store.balance(selected.value) const max = store.balance(selected.value)
if (!actualPaymentDate.value || !actualPaymentMethod.value.trim()) {
formError.value = '请填写外部实际付款日期与付款方式'
return
}
const enteredAmount = Number(amount.value) const enteredAmount = Number(amount.value)
if (!Number.isFinite(enteredAmount) || !(enteredAmount > 0) || enteredAmount > max + 0.005) { if (!Number.isFinite(enteredAmount) || !(enteredAmount > 0) || enteredAmount > max + 0.005) {
formError.value = `付款金额须大于 0 且不超过未付余额 ${money(max)}` formError.value = `付款金额须大于 0 且不超过未付余额 ${money(max)}`
@@ -297,16 +367,16 @@ const submitPayment = async () => {
formError.value = '' formError.value = ''
let succeeded = false let succeeded = false
try { try {
await store.pay(selected.value.id, Number(enteredAmount.toFixed(2)), remark.value.trim(), idempotencyKey.value) await store.pay(selected.value.id, Number(enteredAmount.toFixed(2)), remark.value.trim(), idempotencyKey.value, { actualPaymentDate: actualPaymentDate.value, actualPaymentMethod: actualPaymentMethod.value.trim(), bankTransactionNo: bankTransactionNo.value || undefined, paymentReceipt: paymentReceipt.value || undefined, source: 'MANUAL' })
succeeded = true succeeded = true
} catch (error) { } catch (error) {
formError.value = financeActionError(error, '付款失败,请检查后重试') formError.value = financeActionError(error, '付款结果登记失败,请检查后重试')
} finally { } finally {
saving.value = false saving.value = false
} }
if (succeeded) { if (succeeded) {
closePayment() closePayment()
ElMessage.success('付款已登记,等待独立复核') ElMessage.success('外部付款结果已登记,等待服务端复核')
} }
} }
@@ -326,11 +396,25 @@ const reject = async (payment: PaymentRecord) => {
await runReview(payment, () => store.rejectPayment(payment.id, value), '付款已拒绝') await runReview(payment, () => store.rejectPayment(payment.id, value), '付款已拒绝')
} catch { /* user cancelled */ } } catch { /* user cancelled */ }
} }
const attachReceipt = async (payment: PaymentRecord) => {
if (!payment.availableActions?.includes('PAYMENT_RECEIPT_ATTACH')) return
try {
const { value } = await ElMessageBox.prompt('请输入外部付款回单编号或归档引用', '补录付款回单', { confirmButtonText: '确认补录', cancelButtonText: '取消', inputPattern: /^[\s\S]{1,500}$/, inputErrorMessage: '请输入 1-500 个字符的回单引用' })
await runReview(payment, () => store.attachPaymentReceipt(payment.id, value.trim()), '付款回单已补录')
} catch { /* user cancelled */ }
}
onMounted(() => { void refreshQueue() }) onMounted(() => { void refreshQueue() })
</script> </script>
<style scoped> <style scoped>
.amount-heading { text-align: center; }
.payments-embedded .primary-list-card > .finance-table-wrap {
height: auto;
flex: 0 0 auto;
overflow-x: auto;
overflow-y: visible;
}
.payment-dialog-body { background: #fff; container-name: payment-dialog-body; container-type: inline-size; } .payment-dialog-body { background: #fff; container-name: payment-dialog-body; container-type: inline-size; }
.payment-summary { overflow: hidden; border-color: #d7e0e8; border-radius: 6px; } .payment-summary { overflow: hidden; border-color: #d7e0e8; border-radius: 6px; }
.payment-summary > div { padding: 12px 14px; background: var(--surface-raised); } .payment-summary > div { padding: 12px 14px; background: var(--surface-raised); }
+14 -16
View File
@@ -4,7 +4,7 @@
<div class="card-head task-head"> <div class="card-head task-head">
<div> <div>
<span class="eyebrow">SCHEDULED TASKS</span> <span class="eyebrow">SCHEDULED TASKS</span>
<h2 id="scheduled-task-title">自动任务</h2> <h2 id="scheduled-task-title">定时任务</h2>
<p>查看固定系统任务的计划与运行状态。页面时间均按本地时间显示。</p> <p>查看固定系统任务的计划与运行状态。页面时间均按本地时间显示。</p>
</div> </div>
<button class="btn small" type="button" :disabled="initialLoading || refreshing" @click="refreshAll"> <button class="btn small" type="button" :disabled="initialLoading || refreshing" @click="refreshAll">
@@ -13,18 +13,18 @@
</div> </div>
<div v-if="initialLoading" class="load-wrap page-state" role="status" aria-live="polite"> <div v-if="initialLoading" class="load-wrap page-state" role="status" aria-live="polite">
<span class="loader" aria-hidden="true"></span><span>正在加载自动任务…</span> <span class="loader" aria-hidden="true"></span><span>正在加载定时任务…</span>
</div> </div>
<div v-else-if="listError && !tasks.length" class="empty-state page-state" role="alert"> <div v-else-if="listError && !tasks.length" class="empty-state page-state" role="alert">
<strong>自动任务加载失败</strong><span>{{ listError }}</span> <strong>定时任务加载失败</strong><span>{{ listError }}</span>
<button class="btn small" type="button" @click="loadTasks">重试</button> <button class="btn small" type="button" @click="loadTasks">重试</button>
</div> </div>
<div v-else-if="!tasks.length" class="empty-state page-state"> <div v-else-if="!tasks.length" class="empty-state page-state">
<strong>暂无自动任务</strong><span>系统尚未提供可管理的固定任务。</span> <strong>暂无定时任务</strong><span>系统尚未提供可管理的固定任务。</span>
</div> </div>
<div v-else class="task-layout"> <div v-else class="task-layout">
<div v-if="listError" class="inline-alert danger task-list-warning" role="alert">{{ listError }}</div> <div v-if="listError" class="inline-alert danger task-list-warning" role="alert">{{ listError }}</div>
<nav class="task-selector" aria-label="自动任务列表"> <nav class="task-selector" aria-label="定时任务列表">
<button <button
v-for="item in tasks" v-for="item in tasks"
:key="item.code" :key="item.code"
@@ -34,7 +34,7 @@
:aria-current="item.code === selectedCode ? 'true' : undefined" :aria-current="item.code === selectedCode ? 'true' : undefined"
@click="selectTask(item.code)" @click="selectTask(item.code)"
> >
<span class="task-option-title"><strong>{{ uiRead('ui.tasks.column.name') ? item.name : '自动任务' }}</strong><i v-if="uiRead('ui.tasks.column.status')" class="status-dot-small" :class="taskTone(item)"></i></span> <span class="task-option-title"><strong>{{ uiRead('ui.tasks.column.name') ? item.name : '定时任务' }}</strong><i v-if="uiRead('ui.tasks.column.status')" class="status-dot-small" :class="taskTone(item)"></i></span>
<small v-if="uiRead('ui.tasks.column.status')">{{ item.enabled ? `每 ${item.intervalHours} 小时` : '计划已停用' }} · {{ item.status === 'RUNNING' ? '运行中' : '空闲' }}</small> <small v-if="uiRead('ui.tasks.column.status')">{{ item.enabled ? `每 ${item.intervalHours} 小时` : '计划已停用' }} · {{ item.status === 'RUNNING' ? '运行中' : '空闲' }}</small>
</button> </button>
</nav> </nav>
@@ -47,7 +47,7 @@
<template v-else-if="task"> <template v-else-if="task">
<div class="detail-title-row"> <div class="detail-title-row">
<div> <div>
<h3>{{ uiRead('ui.tasks.column.name') ? task.name : '自动任务' }}</h3> <h3>{{ uiRead('ui.tasks.column.name') ? task.name : '定时任务' }}</h3>
<p v-if="uiRead('ui.tasks.column.status')" class="muted-copy">{{ task.enabled ? '自动执行已启用' : '自动执行已停用' }} · {{ intervalLabel(task.intervalHours) }} · 时区 {{ task.timeZone || '—' }}</p> <p v-if="uiRead('ui.tasks.column.status')" class="muted-copy">{{ task.enabled ? '自动执行已启用' : '自动执行已停用' }} · {{ intervalLabel(task.intervalHours) }} · 时区 {{ task.timeZone || '—' }}</p>
</div> </div>
<div class="detail-actions"> <div class="detail-actions">
@@ -89,13 +89,11 @@
<strong>运行记录加载失败</strong><span>{{ historyError }}</span> <strong>运行记录加载失败</strong><span>{{ historyError }}</span>
<button class="btn small" type="button" @click="loadHistory">重试</button> <button class="btn small" type="button" @click="loadHistory">重试</button>
</div> </div>
<div v-else-if="!runs.length" class="empty-state history-state"> <div v-else class="table-wrap history-table-wrap" tabindex="0" role="region" aria-label="定时任务运行记录">
<strong>暂无运行记录</strong><span>任务执行后,结果会显示在这里。</span>
</div>
<div v-else class="table-wrap history-table-wrap" tabindex="0" role="region" aria-label="自动任务运行记录">
<table class="data-table history-table"> <table class="data-table history-table">
<thead><tr><th v-if="uiRead('ui.tasks.run.state')">状态</th><th v-if="uiRead('ui.tasks.run.trigger')">触发方式</th><th v-if="uiRead('ui.tasks.run.queued-at')">入队时间</th><th v-if="uiRead('ui.tasks.run.execution')">执行时间</th><th v-if="uiRead('ui.tasks.run.counts')">结果统计</th><th v-if="uiRead('ui.tasks.run.result')">结果</th></tr></thead> <thead><tr><th v-if="uiRead('ui.tasks.run.state')">状态</th><th v-if="uiRead('ui.tasks.run.trigger')">触发方式</th><th v-if="uiRead('ui.tasks.run.queued-at')">入队时间</th><th v-if="uiRead('ui.tasks.run.execution')">执行时间</th><th v-if="uiRead('ui.tasks.run.counts')">结果统计</th><th v-if="uiRead('ui.tasks.run.result')">结果</th></tr></thead>
<tbody> <tbody>
<tr v-if="!runs.length"><td colspan="6"><div class="empty-state history-state"><strong>暂无运行记录</strong><span>任务执行后,结果会显示在这里。</span></div></td></tr>
<tr v-for="run in runs" :key="run.runId"> <tr v-for="run in runs" :key="run.runId">
<td v-if="uiRead('ui.tasks.run.state')" data-label="状态"><span class="state-badge" :class="runTone(run.state)">{{ stateLabels[run.state] }}</span><small v-if="run.attempts > 1">第 {{ run.attempts }} 次尝试</small></td> <td v-if="uiRead('ui.tasks.run.state')" data-label="状态"><span class="state-badge" :class="runTone(run.state)">{{ stateLabels[run.state] }}</span><small v-if="run.attempts > 1">第 {{ run.attempts }} 次尝试</small></td>
<td v-if="uiRead('ui.tasks.run.trigger')" data-label="触发方式">{{ triggerLabels[run.trigger] }}</td> <td v-if="uiRead('ui.tasks.run.trigger')" data-label="触发方式">{{ triggerLabels[run.trigger] }}</td>
@@ -128,7 +126,7 @@
<dialog v-if="canOpenScheduleDialog" ref="scheduleDialog" v-dialog-drag class="app-dialog schedule-dialog" aria-labelledby="schedule-dialog-title" aria-modal="true" @cancel="handleScheduleCancel" @click="handleScheduleBackdrop"> <dialog v-if="canOpenScheduleDialog" ref="scheduleDialog" v-dialog-drag class="app-dialog schedule-dialog" aria-labelledby="schedule-dialog-title" aria-modal="true" @cancel="handleScheduleCancel" @click="handleScheduleBackdrop">
<section class="app-dialog__panel"> <section class="app-dialog__panel">
<header class="modal-head" data-dialog-drag-handle> <header class="modal-head" data-dialog-drag-handle>
<div><span class="eyebrow">SCHEDULE CONFIGURATION</span><h2 id="schedule-dialog-title">编辑自动计划</h2><p>{{ task?.name }}</p></div> <div><span class="eyebrow">SCHEDULE CONFIGURATION</span><h2 id="schedule-dialog-title">编辑定时计划</h2><p>{{ task?.name }}</p></div>
<button class="modal-close" type="button" aria-label="关闭计划配置窗口" :disabled="scheduleSaving" @click="closeScheduleDialog"></button> <button class="modal-close" type="button" aria-label="关闭计划配置窗口" :disabled="scheduleSaving" @click="closeScheduleDialog"></button>
</header> </header>
<div class="modal-body schedule-form"> <div class="modal-body schedule-form">
@@ -174,7 +172,7 @@ const DEFAULT_TASK_CODE = 'FEISHU_DIRECTORY_SYNC'
withDefaults(defineProps<{ embedded?: boolean }>(), { embedded: false }) withDefaults(defineProps<{ embedded?: boolean }>(), { embedded: false })
const intervalOptions: ScheduledIntervalHours[] = [1, 2, 3, 6, 12, 24] const intervalOptions: ScheduledIntervalHours[] = [1, 2, 3, 6, 12, 24]
const stateLabels = { QUEUED: '排队中', RUNNING: '运行中', SUCCEEDED: '成功', FAILED: '失败' } as const const stateLabels = { QUEUED: '排队中', RUNNING: '运行中', SUCCEEDED: '成功', FAILED: '失败' } as const
const triggerLabels = { MANUAL: '手动', STARTUP: '启动时', SCHEDULED: '自动计划' } as const const triggerLabels = { MANUAL: '手动', STARTUP: '启动时', SCHEDULED: '定时计划' } as const
const userStore = useUserStore() const userStore = useUserStore()
const authorizationStore = useAuthorizationStore() const authorizationStore = useAuthorizationStore()
const uiRead = (code: string) => userStore.canRead(code) const uiRead = (code: string) => userStore.canRead(code)
@@ -354,7 +352,7 @@ async function refreshSelected(background = false, inheritedGeneration?: number)
|| latestResult.status === 'fulfilled' && latestRuns.value.some(item => item.state === 'QUEUED' || item.state === 'RUNNING') || latestResult.status === 'fulfilled' && latestRuns.value.some(item => item.state === 'QUEUED' || item.state === 'RUNNING')
if (detailResult.status === 'fulfilled' || latestResult.status === 'fulfilled') reconcileExecuteLock(confirmedActive) if (detailResult.status === 'fulfilled' || latestResult.status === 'fulfilled') reconcileExecuteLock(confirmedActive)
if (detailResult.status === 'fulfilled' || pageResult.status === 'fulfilled') { if (detailResult.status === 'fulfilled' || pageResult.status === 'fulfilled') {
liveMessage.value = `已更新${detailResult.status === 'fulfilled' ? detailResult.value.name : '自动任务'}的状态和运行记录。` liveMessage.value = `已更新${detailResult.status === 'fulfilled' ? detailResult.value.name : '定时任务'}的状态和运行记录。`
} }
} catch (error) { } catch (error) {
if (!controller.signal.aborted && !disposed) { if (!controller.signal.aborted && !disposed) {
@@ -431,8 +429,8 @@ async function saveSchedule() {
if (disposed) return if (disposed) return
applyTask(updated) applyTask(updated)
scheduleDialog.value?.close() scheduleDialog.value?.close()
ElMessage.success('自动计划已保存') ElMessage.success('定时计划已保存')
liveMessage.value = '自动计划已保存。' liveMessage.value = '定时计划已保存。'
} catch (error) { } catch (error) {
if (controller.signal.aborted || disposed) return if (controller.signal.aborted || disposed) return
if (isConflict(error)) { if (isConflict(error)) {
+3 -3
View File
@@ -9,12 +9,13 @@
</div> </div>
<div class="card fill-list-card primary-list-card"> <div class="card fill-list-card primary-list-card">
<div class="filter-bar list-toolbar"> <div class="filter-bar list-toolbar">
<div class="list-toolbar__filters"><label class="filter-search"><span aria-hidden="true">&#x1F50D;</span><input type="search" v-model="search" placeholder="搜索单据编号" aria-label="搜索"></label></div> <div class="list-toolbar__filters"><label class="filter-search"><span aria-hidden="true">&#x1F50D;</span><input type="search" v-model="search" placeholder="请输入业务单据编号" aria-label="搜索业务单据编号"></label></div>
<div class="list-toolbar__meta"><span class="tag info">{{ filtered.length }} 笔</span></div> <div class="list-toolbar__meta"><span class="tag info">{{ filtered.length }} 笔</span></div>
</div> </div>
<div class="table-wrap" v-if="loaded && !error && filtered.length > 0" tabindex="0" role="region" aria-label="业务单据列表"><table class="data-table responsive-table"> <div class="table-wrap" v-if="loaded && !error" tabindex="0" role="region" aria-label="业务单据列表"><table class="data-table responsive-table">
<thead><tr><th v-if="uiRead('ui.sources.column.number')">单据编号</th><th v-if="uiRead('ui.sources.column.type')">类型</th><th v-if="uiRead('ui.sources.column.amount')" class="amount">金额</th><th v-if="uiRead('ui.sources.column.date')">日期</th><th v-if="uiRead('ui.sources.column.origin')">来源</th></tr></thead> <thead><tr><th v-if="uiRead('ui.sources.column.number')">单据编号</th><th v-if="uiRead('ui.sources.column.type')">类型</th><th v-if="uiRead('ui.sources.column.amount')" class="amount">金额</th><th v-if="uiRead('ui.sources.column.date')">日期</th><th v-if="uiRead('ui.sources.column.origin')">来源</th></tr></thead>
<tbody> <tbody>
<tr v-if="!filtered.length"><td colspan="5"><div class="empty-state"><strong>暂无业务单据</strong><span>金蝶 ERP 数据同步后会自动显示</span></div></td></tr>
<tr v-for="item in paginatedItems" :key="item.id"> <tr v-for="item in paginatedItems" :key="item.id">
<td v-if="uiRead('ui.sources.column.number')" data-label="单据编号"><strong>{{ item.sourceDocNo }}</strong></td> <td v-if="uiRead('ui.sources.column.number')" data-label="单据编号"><strong>{{ item.sourceDocNo }}</strong></td>
<td v-if="uiRead('ui.sources.column.type')" data-label="类型"><span class="tag">{{ item.sourceDocType }}</span></td> <td v-if="uiRead('ui.sources.column.type')" data-label="类型"><span class="tag">{{ item.sourceDocType }}</span></td>
@@ -25,7 +26,6 @@
</tbody> </tbody>
</table></div> </table></div>
<div v-else-if="error" class="empty-state" role="alert"><strong>业务单据加载失败</strong><span>{{ error }}</span><button v-if="uiEdit('ui.sources.reload')" class="btn small" type="button" @click="load">重试</button></div> <div v-else-if="error" class="empty-state" role="alert"><strong>业务单据加载失败</strong><span>{{ error }}</span><button v-if="uiEdit('ui.sources.reload')" class="btn small" type="button" @click="load">重试</button></div>
<div class="empty-state" v-else-if="loaded"><strong>暂无业务单据</strong><span>金蝶 ERP 数据同步后会自动显示</span></div>
<div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载业务单据…</span></div> <div v-else class="load-wrap" role="status"><span class="loader" aria-hidden="true"></span><span>正在加载业务单据…</span></div>
<AppListPagination v-if="loaded && !error && filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="业务单据列表分页" /> <AppListPagination v-if="loaded && !error && filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="业务单据列表分页" />
</div> </div>
+28 -26
View File
@@ -1,25 +1,25 @@
<template> <template>
<div class="admin-page page-content route-list-page"> <div class="admin-page page-content route-list-page">
<div class="page-head"><div><span class="eyebrow">SYSTEM MANAGEMENT</span><h1>人员与权限</h1><p>{{ pageDescription }}</p></div><div class="head-actions"><button v-if="activeTab==='roles' && canAccessTab('roles') && canEdit('iam.role:create')" class="btn primary" type="button" @click="openRoleForm()">新建角色</button><button v-if="activeTab==='groups' && canAccessTab('groups') && canEdit('iam.group:create')" class="btn primary" type="button" @click="openGroupForm()">新建用户组</button></div></div> <div class="page-head"><div><span class="eyebrow">{{ pageEyebrow }}</span><h1>{{ pageTitle }}</h1><p>{{ pageDescription }}</p></div><div class="head-actions"><button v-if="activeTab==='roles' && canAccessTab('roles') && canEdit('iam.role:create')" class="btn primary" type="button" @click="openRoleForm()">新建角色</button><button v-if="activeTab==='groups' && canAccessTab('groups') && canEdit('iam.group:create')" class="btn primary" type="button" @click="openGroupForm()">新建权限组</button></div></div>
<div v-if="permissionsFailed" class="inline-alert danger" role="alert"><b>!</b><span>权限加载失败,所有管理能力已关闭。</span><button class="btn small" type="button" @click="retryPermissions">重试</button></div> <div v-if="permissionsFailed" class="inline-alert danger" role="alert"><b>!</b><span>权限加载失败,所有管理能力已关闭。</span><button class="btn small" type="button" @click="retryPermissions">重试</button></div>
<nav v-if="availableTabs.length" class="tabs" role="tablist" aria-label="系统管理页面" @keydown="moveTab"> <nav v-if="availableTabs.length" class="tabs" role="tablist" aria-label="组织与权限页面" @keydown="moveTab">
<button v-for="tab in availableTabs" :id="`admin-tab-${tab.key}`" :key="tab.key" class="tab" :class="{active:activeTab===tab.key}" type="button" role="tab" :aria-selected="activeTab===tab.key" :tabindex="activeTab===tab.key?0:-1" @click="switchTab(tab.key)">{{ tab.label }}</button> <button v-for="tab in availableTabs" :id="`admin-tab-${tab.key}`" :key="tab.key" class="tab" :class="{active:activeTab===tab.key}" type="button" role="tab" :aria-selected="activeTab===tab.key" :tabindex="activeTab===tab.key?0:-1" @click="switchTab(tab.key)">{{ tab.label }}</button>
</nav> </nav>
<div v-else-if="!permissionsFailed" class="card empty-state" role="alert"><strong>无可访问管理页面</strong><span>请联系管理员配置用户组、角色或飞书通讯录页面权限。</span></div> <div v-else-if="!permissionsFailed" class="card empty-state" role="alert"><strong>无可访问管理页面</strong><span>请联系管理员配置权限组、角色或飞书通讯录页面权限。</span></div>
<dialog ref="memberDialog" v-dialog-drag class="app-dialog admin-dialog member-dialog" aria-labelledby="member-dialog-title" @cancel="handleMemberDialogCancel"><form @submit.prevent="saveGroupMembers"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">GROUP MEMBERS</span><h2 id="member-dialog-title">绑定用户 · {{ memberGroup ? groupDisplayName(memberGroup) : '' }}</h2><p>维护用户组成员归属。</p></div><button class="modal-close" type="button" aria-label="关闭成员绑定窗口" :disabled="memberSaving" @click="closeMemberDialog">×</button></div><div class="modal-body binding-dialog-body"> <dialog ref="memberDialog" v-dialog-drag class="app-dialog admin-dialog member-dialog" aria-labelledby="member-dialog-title" @cancel="handleMemberDialogCancel"><form @submit.prevent="saveGroupMembers"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">GROUP MEMBERS</span><h2 id="member-dialog-title">绑定用户 · {{ memberGroup ? groupDisplayName(memberGroup) : '' }}</h2><p>维护权限组成员归属。</p></div><button class="modal-close" type="button" aria-label="关闭成员绑定窗口" :disabled="memberSaving" @click="closeMemberDialog">×</button></div><div class="modal-body binding-dialog-body">
<div v-if="memberGroup?.status!=='ACTIVE'" class="inline-alert warning" role="status"><b>!</b><span>停用后成员仍占用该组归属,但本组角色不会生效。</span></div><p v-if="isDefaultGroup(memberGroup)" class="binding-note default-group-note"><strong>普通用户组</strong>:组织内所有飞书用户,无需绑定。该组固定置顶且只读。</p><p v-else-if="isSuperAdminGroup(memberGroup)" class="binding-note default-group-note"><strong>默认超级管理员组</strong>:可按现有权限维护成员;后台会确保至少保留一名超级管理员。</p><div v-if="blockedCandidateWarning" class="inline-alert warning blocked-candidate-warning" role="alert" aria-live="assertive"><b>!</b><span>{{ blockedCandidateWarning }}</span></div> <div v-if="memberGroup?.status!=='ACTIVE'" class="inline-alert warning" role="status"><b>!</b><span>停用后成员仍占用该组归属,但本组角色不会生效。</span></div><p v-if="isDefaultGroup(memberGroup)" class="binding-note default-group-note"><strong>普通权限组</strong>:组织内所有飞书用户,无需绑定。该组固定置顶且只读。</p><p v-else-if="isSuperAdminGroup(memberGroup)" class="binding-note default-group-note"><strong>默认超级管理员组</strong>:可按现有权限维护成员;后台会确保至少保留一名超级管理员。</p><div v-if="blockedCandidateWarning" class="inline-alert warning blocked-candidate-warning" role="alert" aria-live="assertive"><b>!</b><span>{{ blockedCandidateWarning }}</span></div>
<LoadState :loading="memberBindingLoading" :error="memberBindingError" label="成员绑定" @retry="reloadMemberDialog" /><template v-if="!memberBindingLoading&&!memberBindingError"><div v-if="!canViewMemberCandidates" class="member-list-restricted" role="note"><strong>{{ currentMemberIds.length }} 名成员</strong><span>需要成员管理或用户查看权限才能查看名单</span></div><template v-else><div v-if="snapshotAlert" class="inline-alert warning snapshot-alert" role="alert"><b>!</b><span>{{ snapshotAlert }}</span></div><label class="filter-search"><span class="sr-only">{{ candidateSearchLabel }}</span><input v-model="candidateKeyword" type="search" :placeholder="candidateSearchPlaceholder" autocomplete="off" :aria-label="candidateSearchLabel" :aria-controls="memberGroup ? `group-candidates-${memberGroup.id}` : undefined"></label><div class="candidate-state" aria-live="polite"><span v-if="candidateLoading" role="status">正在搜索候选人员…</span><span v-else-if="candidateError" class="candidate-error" role="alert">候选人员加载失败:{{ candidateError }} <button class="table-action" type="button" @click="loadCandidates(candidateKeyword)">重试</button></span><span v-else-if="candidateKeyword.trim()">找到 {{ candidateMatches.length }} 个匹配结果</span></div><div v-if="candidateTruncated&&!candidateLoading&&!candidateError" class="inline-alert warning truncation-notice" role="status"><span>结果较多,仅显示前 {{ candidateLimit }} 条,请缩小搜索范围。</span></div><div :id="memberGroup ? `group-candidates-${memberGroup.id}` : undefined" class="candidate-list" :aria-busy="candidateLoading"><div v-for="person in displayedCandidates" :key="person.id" class="candidate-row" :class="{disabled:memberCandidateDisabled(person)}"><label class="candidate-main"><input v-model="selectedMemberIds" type="checkbox" :value="person.id" :disabled="groupMembersDynamic||!groupMembersEditable||!canEdit('iam.group.member:manage')||memberCandidateDisabled(person)"><span><strong>{{ memberDisplayName(person) }}</strong><small v-if="person.assignedGroupId!==null && person.assignedGroupId!==memberGroup?.id" class="assignment-note">不可选择,已属于:{{ person.assignedGroupName||'其他用户组' }}</small><small v-else-if="selectedMemberIds.includes(person.id) && !currentMembers.some(item=>item.id===person.id) && !candidateMatches.some(item=>item.id===person.id)" class="assignment-note selected-note">已选草稿(保留显示)</small></span></label><button v-if="memberCandidateDisabled(person)&&selectedMemberIds.includes(person.id)&&canEdit('iam.group.member:manage')" class="table-action draft-remove" type="button" :aria-label="`从成员草稿移除 ${memberDisplayName(person)}`" @click="removeMemberDraft(person.id)">移出草稿</button></div><div v-if="showFreshEmpty" class="empty-state compact-empty" role="status"><span>{{ candidateKeyword.trim()?'没有匹配的飞书用户。':'当前没有可添加的飞书用户。' }}</span></div></div></template></template></div><div class="modal-actions"><button class="btn" type="button" :disabled="memberSaving" @click="closeMemberDialog">取消</button><button v-if="!isDefaultGroup(memberGroup)&&!groupMembersDynamic&&groupMembersEditable&&canEdit('iam.group.member:manage')" class="btn primary" type="submit" :disabled="memberSaving||memberBindingLoading||!!memberBindingError||hasBlockedMemberDraft">{{ memberSaving?'保存中…':'保存成员' }}</button></div></form></dialog> <LoadState :loading="memberBindingLoading" :error="memberBindingError" label="成员绑定" @retry="reloadMemberDialog" /><template v-if="!memberBindingLoading&&!memberBindingError"><div v-if="!canViewMemberCandidates" class="member-list-restricted" role="note"><strong>{{ currentMemberIds.length }} 名成员</strong><span>需要成员管理或用户查看权限才能查看名单</span></div><template v-else><div v-if="snapshotAlert" class="inline-alert warning snapshot-alert" role="alert"><b>!</b><span>{{ snapshotAlert }}</span></div><label class="filter-search"><span class="sr-only">{{ candidateSearchLabel }}</span><input v-model="candidateKeyword" type="search" :placeholder="candidateSearchPlaceholder" autocomplete="off" :aria-label="candidateSearchLabel" :aria-controls="memberGroup ? `group-candidates-${memberGroup.id}` : undefined"></label><div class="candidate-state" aria-live="polite"><span v-if="candidateLoading" role="status">正在搜索候选人员…</span><span v-else-if="candidateError" class="candidate-error" role="alert">候选人员加载失败:{{ candidateError }} <button class="table-action" type="button" @click="loadCandidates(candidateKeyword)">重试</button></span><span v-else-if="candidateKeyword.trim()">找到 {{ candidateMatches.length }} 个匹配结果</span></div><div v-if="candidateTruncated&&!candidateLoading&&!candidateError" class="inline-alert warning truncation-notice" role="status"><span>结果较多,仅显示前 {{ candidateLimit }} 条,请缩小搜索范围。</span></div><div :id="memberGroup ? `group-candidates-${memberGroup.id}` : undefined" class="candidate-list" :aria-busy="candidateLoading"><div v-for="person in displayedCandidates" :key="person.id" class="candidate-row" :class="{disabled:memberCandidateDisabled(person)}"><label class="candidate-main"><input v-model="selectedMemberIds" type="checkbox" :value="person.id" :disabled="groupMembersDynamic||!groupMembersEditable||!canEdit('iam.group.member:manage')||memberCandidateDisabled(person)"><span><strong>{{ memberDisplayName(person) }}</strong><small v-if="person.assignedGroupId!==null && person.assignedGroupId!==memberGroup?.id" class="assignment-note">不可选择,已属于:{{ person.assignedGroupName||'其他权限组' }}</small><small v-else-if="selectedMemberIds.includes(person.id) && !currentMembers.some(item=>item.id===person.id) && !candidateMatches.some(item=>item.id===person.id)" class="assignment-note selected-note">已选草稿(保留显示)</small></span></label><button v-if="memberCandidateDisabled(person)&&selectedMemberIds.includes(person.id)&&canEdit('iam.group.member:manage')" class="table-action draft-remove" type="button" :aria-label="`从成员草稿移除 ${memberDisplayName(person)}`" @click="removeMemberDraft(person.id)">移出草稿</button></div><div v-if="showFreshEmpty" class="empty-state compact-empty" role="status"><span>{{ candidateKeyword.trim()?'没有匹配的飞书用户。':'当前没有可添加的飞书用户。' }}</span></div></div></template></template></div><div class="modal-actions"><button class="btn" type="button" :disabled="memberSaving" @click="closeMemberDialog">取消</button><button v-if="!isDefaultGroup(memberGroup)&&!groupMembersDynamic&&groupMembersEditable&&canEdit('iam.group.member:manage')" class="btn primary" type="submit" :disabled="memberSaving||memberBindingLoading||!!memberBindingError||hasBlockedMemberDraft">{{ memberSaving?'保存中…':'保存成员' }}</button></div></form></dialog>
<dialog ref="groupRoleDialog" v-dialog-drag class="app-dialog admin-dialog group-role-dialog" aria-labelledby="group-role-dialog-title" @cancel="handleGroupRoleDialogCancel"><form @submit.prevent="saveGroupRoles"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">GROUP ROLES</span><h2 id="group-role-dialog-title">绑定角色 · {{ roleGroup ? groupDisplayName(roleGroup) : '' }}</h2><p>为当前用户组选择统一生效的角色。</p></div><button class="modal-close" type="button" aria-label="关闭角色绑定窗口" :disabled="groupRoleSaving" @click="closeGroupRoleDialog">×</button></div><div class="modal-body binding-dialog-body"><p v-if="isDefaultGroup(roleGroup)" class="binding-note default-group-note"><strong>普通用户组</strong>:系统默认组固定角色,只读且不可修改。</p><div v-if="isDefaultGroup(roleGroup)" class="fixed-role"><span class="tag info">EMPLOYEE</span><div><strong>普通用户</strong><small>系统默认组固定角色,只读且不可修改。</small></div></div><LoadState :loading="roleBindingLoading" :error="groupRoleCandidateError" label="角色绑定" @retry="loadGroupRoleBinding" /><template v-if="!isDefaultGroup(roleGroup)&&!roleBindingLoading&&!groupRoleCandidateError"><p class="binding-note">可多选启用中的角色;普通管理员不可绑定超级管理员角色,后端仍会再次校验。</p><div v-if="!roles.length" class="empty-state compact-empty"><strong>暂无角色候选</strong><span>当前没有可绑定角色。</span></div><div class="role-options group-role-options"><label v-for="role in roles" :key="role.id" class="check-option" :class="{disabled:(role.status!=='ACTIVE'&&!selectedGroupRoleIds.includes(role.id))||(role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)}"><input v-model="selectedGroupRoleIds" type="checkbox" :value="role.id" :disabled="!canEdit('iam.group.role:manage')||(role.status!=='ACTIVE'&&!selectedGroupRoleIds.includes(role.id))||(role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)"><span><strong>{{ role.roleName }} <i v-if="role.builtIn" class="policy-marker neutral">内置</i></strong><small>{{ role.roleCode }}<template v-if="role.description"> · {{ role.description }}</template><template v-if="role.status!=='ACTIVE'"> · {{ selectedGroupRoleIds.includes(role.id)?'已停用,仅可移除':'已停用,不可绑定' }}</template><template v-if="role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin"> · 不可委派</template></small></span></label></div></template></div><div class="modal-actions"><button class="btn" type="button" :disabled="groupRoleSaving" @click="closeGroupRoleDialog">取消</button><button v-if="!isDefaultGroup(roleGroup)&&canEdit('iam.group.role:manage')" class="btn primary" type="submit" :disabled="groupRoleSaving||roleBindingLoading||!!groupRoleCandidateError">{{ groupRoleSaving?'保存中…':'保存角色' }}</button></div></form></dialog> <dialog ref="groupRoleDialog" v-dialog-drag class="app-dialog admin-dialog group-role-dialog" aria-labelledby="group-role-dialog-title" @cancel="handleGroupRoleDialogCancel"><form @submit.prevent="saveGroupRoles"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">GROUP ROLES</span><h2 id="group-role-dialog-title">绑定角色 · {{ roleGroup ? groupDisplayName(roleGroup) : '' }}</h2><p>为当前权限组选择统一生效的角色。</p></div><button class="modal-close" type="button" aria-label="关闭角色绑定窗口" :disabled="groupRoleSaving" @click="closeGroupRoleDialog">×</button></div><div class="modal-body binding-dialog-body"><p v-if="isDefaultGroup(roleGroup)" class="binding-note default-group-note"><strong>普通权限组</strong>:系统默认组固定角色,只读且不可修改。</p><div v-if="isDefaultGroup(roleGroup)" class="fixed-role"><span class="tag info">EMPLOYEE</span><div><strong>普通用户</strong><small>系统默认组固定角色,只读且不可修改。</small></div></div><LoadState :loading="roleBindingLoading" :error="groupRoleCandidateError" label="角色绑定" @retry="loadGroupRoleBinding" /><template v-if="!isDefaultGroup(roleGroup)&&!roleBindingLoading&&!groupRoleCandidateError"><p class="binding-note">可多选启用中的角色;普通管理员不可绑定超级管理员角色,后端仍会再次校验。</p><div v-if="!roles.length" class="empty-state compact-empty"><strong>暂无角色候选</strong><span>当前没有可绑定角色。</span></div><div class="role-options group-role-options"><label v-for="role in roles" :key="role.id" class="check-option" :class="{disabled:(role.status!=='ACTIVE'&&!selectedGroupRoleIds.includes(role.id))||(role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)}"><input v-model="selectedGroupRoleIds" type="checkbox" :value="role.id" :disabled="!canEdit('iam.group.role:manage')||(role.status!=='ACTIVE'&&!selectedGroupRoleIds.includes(role.id))||(role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)"><span><strong>{{ role.roleName }} <i v-if="role.builtIn" class="policy-marker neutral">内置</i></strong><small>{{ role.roleCode }}<template v-if="role.description"> · {{ role.description }}</template><template v-if="role.status!=='ACTIVE'"> · {{ selectedGroupRoleIds.includes(role.id)?'已停用,仅可移除':'已停用,不可绑定' }}</template><template v-if="role.roleCode==='SUPER_ADMIN'&&!isSuperAdmin"> · 不可委派</template></small></span></label></div></template></div><div class="modal-actions"><button class="btn" type="button" :disabled="groupRoleSaving" @click="closeGroupRoleDialog">取消</button><button v-if="!isDefaultGroup(roleGroup)&&canEdit('iam.group.role:manage')" class="btn primary" type="submit" :disabled="groupRoleSaving||roleBindingLoading||!!groupRoleCandidateError">{{ groupRoleSaving?'保存中…':'保存角色' }}</button></div></form></dialog>
<section v-if="activeTab==='groups' && canAccessTab('groups')" class="management-workspace route-list-region" role="tabpanel" aria-labelledby="admin-tab-groups"> <section v-if="activeTab==='groups' && canAccessTab('groups')" class="management-workspace route-list-region" role="tabpanel" aria-labelledby="admin-tab-groups">
<div class="card admin-card primary-list-card"><div class="card-head"><div><h2>用户组</h2><p>分别维护成员归属与角色绑定。</p></div><span>{{ groups.length }} 个</span></div><LoadState :loading="groupsLoading" :error="groupsError" label="用户组" @retry="loadGroups" /><div v-if="!groupsLoading&&!groupsError&&groups.length" class="table-wrap" tabindex="0" role="region" aria-label="用户组列表"><table class="data-table responsive-table"><thead><tr><th v-if="uiRead('ui.groups.column.identity')">用户组</th><th v-if="uiRead('ui.groups.column.membership')">成员 / 角色</th><th v-if="uiRead('ui.groups.column.status')">状态</th><th>操作</th></tr></thead><tbody><tr v-for="group in paginatedGroups" :key="group.id"><td v-if="uiRead('ui.groups.column.identity')" data-label="用户组"><div class="group-name-line"><strong>{{ groupDisplayName(group) }}</strong><span v-if="isDefaultGroup(group)" class="tag info">普通用户组 · 无需绑定</span><span v-if="isSuperAdminGroup(group)" class="tag info">默认超级管理员组</span><span v-if="group.membershipMode==='DYNAMIC'" class="tag neutral">动态成员</span></div><small>{{ group.groupCode }}<template v-if="isDefaultGroup(group)"> · 组织内所有飞书用户</template></small></td><td v-if="uiRead('ui.groups.column.membership')" data-label="成员 / 角色"><span :class="{'unresolved-count':group.memberCount===null}">{{ memberCountText(group.memberCount) }}</span> / {{ group.roleCount }}</td><td v-if="uiRead('ui.groups.column.status')" data-label="状态"><span class="tag" :class="group.status==='ACTIVE'?'success':'danger'">{{ group.status==='ACTIVE'?'启用':'停用' }}</span></td><td data-label="操作" class="actions-cell"><button v-if="canOpenMemberBinding()" class="table-action" type="button" aria-haspopup="dialog" :aria-label="`为${groupDisplayName(group)}绑定用户`" @click="openMemberDialog(group)">绑定用户</button><button v-if="canOpenRoleBinding()" class="table-action" type="button" aria-haspopup="dialog" :aria-label="`为${groupDisplayName(group)}绑定角色`" @click="openGroupRoleDialog(group)">绑定角色</button><button v-if="!isDefaultGroup(group) && canEdit('iam.group:update')" class="table-action" type="button" @click="openGroupForm(group)">编辑</button><button v-if="!isDefaultGroup(group) && canEdit('iam.group:delete')" class="table-action danger-action" type="button" @click="deleteGroup(group)">删除</button></td></tr></tbody></table></div><div v-else-if="!groupsLoading&&!groupsError" class="empty-state"><strong>暂无用户组</strong></div><AppListPagination v-if="!groupsLoading&&!groupsError&&groups.length" v-model:page="groupPage" v-model:page-size="groupPageSize" :total="groups.length" aria-label="用户组列表分页" /></div> <div class="card admin-card primary-list-card"><div class="card-head"><div><h2>权限组</h2><p>分别维护成员归属与角色绑定。</p></div><span>{{ groups.length }} 个</span></div><LoadState :loading="groupsLoading" :error="groupsError" label="权限组" @retry="loadGroups" /><div v-if="!groupsLoading&&!groupsError" class="table-wrap" tabindex="0" role="region" aria-label="权限组列表"><table class="data-table responsive-table"><thead><tr><th v-if="uiRead('ui.groups.column.identity')">权限组</th><th v-if="uiRead('ui.groups.column.membership')">成员 / 角色</th><th v-if="uiRead('ui.groups.column.status')">状态</th><th>操作</th></tr></thead><tbody><tr v-if="!groups.length"><td colspan="4"><div class="empty-state"><strong>暂无权限组</strong></div></td></tr><tr v-for="group in paginatedGroups" :key="group.id"><td v-if="uiRead('ui.groups.column.identity')" data-label="权限组"><div class="group-name-line"><strong>{{ groupDisplayName(group) }}</strong><span v-if="isDefaultGroup(group)" class="tag info">普通权限组 · 无需绑定</span><span v-if="isSuperAdminGroup(group)" class="tag info">默认超级管理员组</span><span v-if="group.membershipMode==='DYNAMIC'" class="tag neutral">动态成员</span></div><small>{{ group.groupCode }}<template v-if="isDefaultGroup(group)"> · 组织内所有飞书用户</template></small></td><td v-if="uiRead('ui.groups.column.membership')" data-label="成员 / 角色"><span :class="{'unresolved-count':group.memberCount===null}">{{ memberCountText(group.memberCount) }}</span> / {{ group.roleCount }}</td><td v-if="uiRead('ui.groups.column.status')" data-label="状态"><span class="tag" :class="group.status==='ACTIVE'?'success':'danger'">{{ group.status==='ACTIVE'?'启用':'停用' }}</span></td><td data-label="操作" class="actions-cell"><button v-if="canOpenMemberBinding()" class="table-action" type="button" aria-haspopup="dialog" :aria-label="`为${groupDisplayName(group)}绑定用户`" @click="openMemberDialog(group)">绑定用户</button><button v-if="canOpenRoleBinding()" class="table-action" type="button" aria-haspopup="dialog" :aria-label="`为${groupDisplayName(group)}绑定角色`" @click="openGroupRoleDialog(group)">绑定角色</button><button v-if="!isDefaultGroup(group) && canEdit('iam.group:update')" class="table-action" type="button" @click="openGroupForm(group)">编辑</button><button v-if="!isDefaultGroup(group) && canEdit('iam.group:delete')" class="table-action danger-action" type="button" @click="deleteGroup(group)">删除</button></td></tr></tbody></table></div><AppListPagination v-if="!groupsLoading&&!groupsError&&groups.length" v-model:page="groupPage" v-model:page-size="groupPageSize" :total="groups.length" aria-label="权限组列表分页" /></div>
</section> </section>
<section v-if="activeTab==='roles' && canAccessTab('roles')" class="card admin-card primary-list-card" role="tabpanel" aria-labelledby="admin-tab-roles"> <section v-if="activeTab==='roles' && canAccessTab('roles')" class="card admin-card primary-list-card" role="tabpanel" aria-labelledby="admin-tab-roles">
<div class="card-head"><div><h2>角色列表</h2><p>角色资料与权限配置分别受控。</p></div><span>{{ roles.length }} 个</span></div><LoadState :loading="rolesLoading" :error="rolesError" label="角色" @retry="loadRolesForTab" /> <div class="card-head"><div><h2>角色列表</h2><p>角色资料与权限配置分别受控。</p></div><span>{{ roles.length }} 个</span></div><LoadState :loading="rolesLoading" :error="rolesError" label="角色" @retry="loadRolesForTab" />
<div v-if="!rolesLoading && !rolesError && roles.length" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th v-if="uiRead('ui.roles.column.identity')">角色</th><th v-if="uiRead('ui.roles.column.description')">说明</th><th v-if="uiRead('ui.roles.column.status')">状态</th><th v-if="uiRead('ui.roles.column.permissions')">权限</th><th>操作</th></tr></thead><tbody><tr v-for="role in paginatedRoles" :key="role.id"><td v-if="uiRead('ui.roles.column.identity')" data-label="角色"><strong>{{ role.roleName }} <i v-if="role.builtIn" class="policy-marker neutral">内置角色</i></strong><small>{{ role.roleCode }} · 权限层级 {{ role.privilegeTier??10 }}</small></td><td v-if="uiRead('ui.roles.column.description')" data-label="说明">{{ role.description||'-' }}</td><td v-if="uiRead('ui.roles.column.status')" data-label="状态"><span class="tag" :class="role.status==='ACTIVE'?'success':'danger'">{{ role.status==='ACTIVE'?'启用':'停用' }}</span></td><td v-if="uiRead('ui.roles.column.permissions')" data-label="权限">{{ role.permissionCount??0 }}</td><td data-label="操作" class="actions-cell"><button v-if="canEdit('iam.role:update') || canViewRoleAuthorization || canViewRoleGroups" class="table-action" type="button" @click="openRoleForm(role)">{{ canEdit('iam.role:update') || canManageRoleAuthorization || canEditRoleGroups ? '编辑 / 配权' : '查看权限' }}</button><button v-if="!role.builtIn && canEdit('iam.role:delete')" class="table-action danger-action" type="button" @click="deleteRole(role)">删除</button></td></tr></tbody></table></div><div v-else-if="!rolesLoading&&!rolesError" class="empty-state"><strong>暂无角色</strong></div><AppListPagination v-if="!rolesLoading&&!rolesError&&roles.length" v-model:page="rolePage" v-model:page-size="rolePageSize" :total="roles.length" aria-label="角色列表分页" /> <div v-if="!rolesLoading && !rolesError" class="table-wrap"><table class="data-table responsive-table"><thead><tr><th v-if="uiRead('ui.roles.column.identity')">角色</th><th v-if="uiRead('ui.roles.column.description')">说明</th><th v-if="uiRead('ui.roles.column.status')">状态</th><th v-if="uiRead('ui.roles.column.permissions')">权限</th><th>操作</th></tr></thead><tbody><tr v-if="!roles.length"><td colspan="5"><div class="empty-state"><strong>暂无角色</strong></div></td></tr><tr v-for="role in paginatedRoles" :key="role.id"><td v-if="uiRead('ui.roles.column.identity')" data-label="角色"><strong>{{ role.roleName }} <i v-if="role.builtIn" class="policy-marker neutral">内置角色</i></strong><small>{{ role.roleCode }} · 权限层级 {{ role.privilegeTier??10 }}</small></td><td v-if="uiRead('ui.roles.column.description')" data-label="说明">{{ role.description||'-' }}</td><td v-if="uiRead('ui.roles.column.status')" data-label="状态"><span class="tag" :class="role.status==='ACTIVE'?'success':'danger'">{{ role.status==='ACTIVE'?'启用':'停用' }}</span></td><td v-if="uiRead('ui.roles.column.permissions')" data-label="权限">{{ role.permissionCount??0 }}</td><td data-label="操作" class="actions-cell"><button v-if="canEdit('iam.role:update') || canViewRoleAuthorization || canViewRoleGroups" class="table-action" type="button" @click="openRoleForm(role)">{{ canEdit('iam.role:update') || canManageRoleAuthorization || canEditRoleGroups ? '编辑 / 配权' : '查看权限' }}</button><button v-if="!role.builtIn && canEdit('iam.role:delete')" class="table-action danger-action" type="button" @click="deleteRole(role)">删除</button></td></tr></tbody></table></div><AppListPagination v-if="!rolesLoading&&!rolesError&&roles.length" v-model:page="rolePage" v-model:page-size="rolePageSize" :total="roles.length" aria-label="角色列表分页" />
</section> </section>
<section v-if="activeTab==='directory' && canAccessTab('directory')" class="directory-tab-panel route-list-region" role="tabpanel" aria-labelledby="admin-tab-directory"> <section v-if="activeTab==='directory' && canAccessTab('directory')" class="directory-tab-panel route-list-region" role="tabpanel" aria-labelledby="admin-tab-directory">
@@ -33,12 +33,12 @@
<section class="role-basic-section" aria-labelledby="role-basic-title"><div class="dialog-section-head"><div><span class="section-index">01</span><h3 id="role-basic-title">基础信息</h3></div><p>用于识别角色及说明适用范围</p></div><div class="form-grid role-basic-grid"><div v-if="uiRead('dialog.role.editor.code')" class="field"><label for="role-code">角色编码 <em>*</em></label><input id="role-code" v-model.trim="roleForm.roleCode" required :disabled="roleSaving||!!editingRole||!uiEdit('dialog.role.editor.code')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></div><div v-if="uiRead('dialog.role.editor.name')" class="field"><label for="role-name">角色名称 <em>*</em></label><input id="role-name" v-model.trim="roleForm.roleName" required :disabled="roleSaving||!uiEdit('dialog.role.editor.name')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></div><div v-if="uiRead('dialog.role.editor.description')" class="field full"><label for="role-description">角色说明</label><textarea id="role-description" v-model.trim="roleForm.description" rows="2" :disabled="roleSaving||!uiEdit('dialog.role.editor.description')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></textarea></div></div></section> <section class="role-basic-section" aria-labelledby="role-basic-title"><div class="dialog-section-head"><div><span class="section-index">01</span><h3 id="role-basic-title">基础信息</h3></div><p>用于识别角色及说明适用范围</p></div><div class="form-grid role-basic-grid"><div v-if="uiRead('dialog.role.editor.code')" class="field"><label for="role-code">角色编码 <em>*</em></label><input id="role-code" v-model.trim="roleForm.roleCode" required :disabled="roleSaving||!!editingRole||!uiEdit('dialog.role.editor.code')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></div><div v-if="uiRead('dialog.role.editor.name')" class="field"><label for="role-name">角色名称 <em>*</em></label><input id="role-name" v-model.trim="roleForm.roleName" required :disabled="roleSaving||!uiEdit('dialog.role.editor.name')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></div><div v-if="uiRead('dialog.role.editor.description')" class="field full"><label for="role-description">角色说明</label><textarea id="role-description" v-model.trim="roleForm.description" rows="2" :disabled="roleSaving||!uiEdit('dialog.role.editor.description')||!canEdit(editingRole?'iam.role:update':'iam.role:create')"></textarea></div></div></section>
<section v-if="canViewRoleAuthorization" class="role-permission-section" aria-labelledby="role-permission-section-title"><div class="dialog-section-head permission-section-head"><div><span class="section-index">02</span><h3 id="role-permission-section-title">系统导航与页面权限</h3></div><p>左侧选择导航页面,右侧配置字段、按钮与弹窗</p></div><div v-if="rolePermissionLoading" class="load-wrap modal-state" role="status"><span class="loader"></span><span>正在加载权限目录…</span></div><div v-else-if="rolePermissionError" class="inline-alert danger permission-alert" role="alert"><span>{{ rolePermissionError }}</span><button class="btn small" type="button" @click="loadRolePermissionData">重试</button></div><RolePermissionEditor v-else v-model="permissionDraft" :catalog="roleCatalog" :summary="roleDerivedSummary" :disabled="roleSaving||!canManageRoleAuthorization" /></section> <section v-if="canViewRoleAuthorization" class="role-permission-section" aria-labelledby="role-permission-section-title"><div class="dialog-section-head permission-section-head"><div><span class="section-index">02</span><h3 id="role-permission-section-title">系统导航与页面权限</h3></div><p>左侧选择导航页面,右侧配置字段、按钮与弹窗</p></div><div v-if="rolePermissionLoading" class="load-wrap modal-state" role="status"><span class="loader"></span><span>正在加载权限目录…</span></div><div v-else-if="rolePermissionError" class="inline-alert danger permission-alert" role="alert"><span>{{ rolePermissionError }}</span><button class="btn small" type="button" @click="loadRolePermissionData">重试</button></div><RolePermissionEditor v-else v-model="permissionDraft" :catalog="roleCatalog" :summary="roleDerivedSummary" :disabled="roleSaving||!canManageRoleAuthorization" /></section>
<section v-if="canViewRoleGroups" class="role-basic-section" aria-labelledby="role-groups-title"> <section v-if="canViewRoleGroups" class="role-basic-section" aria-labelledby="role-groups-title">
<div class="dialog-section-head"><div><span class="section-index">03</span><h3 id="role-groups-title">授权用户组</h3></div><p>已选 {{ selectedRoleGroupIds.length }} 个用户组</p></div> <div class="dialog-section-head"><div><span class="section-index">03</span><h3 id="role-groups-title">授权权限组</h3></div><p>已选 {{ selectedRoleGroupIds.length }} 个权限组</p></div>
<div class="role-group-content"><p class="binding-note">角色通过用户组批量授予员工;员工加入用户组后获得该组角色。系统默认普通用户组的固定角色为只读。</p> <div class="role-group-content"><p class="binding-note">角色通过权限组批量授予员工;员工加入权限组后获得该组角色。系统默认普通权限组的固定角色为只读。</p>
<LoadState :loading="roleGroupsLoading" :error="roleGroupsError" label="授权用户组" @retry="loadRoleGroups" /> <LoadState :loading="roleGroupsLoading" :error="roleGroupsError" label="授权权限组" @retry="loadRoleGroups" />
<template v-if="!roleGroupsLoading&&!roleGroupsError"><label class="filter-search"><span class="sr-only">搜索授权用户组</span><input v-model="roleGroupQuery" type="search" placeholder="搜索组名或编码"></label> <template v-if="!roleGroupsLoading&&!roleGroupsError"><label class="filter-search"><span class="sr-only">搜索授权权限组</span><input v-model="roleGroupQuery" type="search" placeholder="请输入权限组名称或编码" aria-label="搜索授权权限组"></label>
<div class="table-wrap"><table class="data-table"><thead><tr><th>选择</th><th>用户组</th><th>编码</th><th>成员数</th><th>状态</th></tr></thead><tbody><tr v-for="group in filteredRoleGroups" :key="group.id"><td><input v-model="selectedRoleGroupIds" type="checkbox" :value="group.id" :aria-label="`授权给${groupDisplayName(group)}`" :disabled="roleSaving||!canEditRoleGroups||isDefaultGroup(group)||(group.status!=='ACTIVE'&&!selectedRoleGroupIds.includes(group.id))||(editingRole?.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)"></td><td>{{ groupDisplayName(group) }}<small v-if="isDefaultGroup(group)">固定角色 · 只读</small></td><td>{{ group.groupCode }}</td><td>{{ memberCountText(group.memberCount) }}</td><td><span class="tag" :class="group.status==='ACTIVE'?'success':'danger'">{{ group.status==='ACTIVE'?'启用':'停用' }}</span></td></tr><tr v-if="!filteredRoleGroups.length"><td colspan="5">没有匹配的用户组</td></tr></tbody></table></div> <div class="table-wrap"><table class="data-table"><thead><tr><th>选择</th><th>权限组</th><th>编码</th><th>成员数</th><th>状态</th></tr></thead><tbody><tr v-for="group in filteredRoleGroups" :key="group.id"><td><input v-model="selectedRoleGroupIds" type="checkbox" :value="group.id" :aria-label="`授权给${groupDisplayName(group)}`" :disabled="roleSaving||!canEditRoleGroups||isDefaultGroup(group)||(group.status!=='ACTIVE'&&!selectedRoleGroupIds.includes(group.id))||(editingRole?.roleCode==='SUPER_ADMIN'&&!isSuperAdmin)"></td><td>{{ groupDisplayName(group) }}<small v-if="isDefaultGroup(group)">固定角色 · 只读</small></td><td>{{ group.groupCode }}</td><td>{{ memberCountText(group.memberCount) }}</td><td><span class="tag" :class="group.status==='ACTIVE'?'success':'danger'">{{ group.status==='ACTIVE'?'启用':'停用' }}</span></td></tr><tr v-if="!filteredRoleGroups.length"><td colspan="5">没有匹配的权限组</td></tr></tbody></table></div>
</template><p v-if="!canEditRoleGroups" class="binding-note">当前账号仅可查看用户组授权。</p> </template><p v-if="!canEditRoleGroups" class="binding-note">当前账号仅可查看权限组授权。</p>
</div> </div>
</section> </section>
</div> </div>
@@ -46,7 +46,7 @@
</form> </form>
</dialog> </dialog>
<dialog v-if="uiRead('dialog.group.editor')" ref="groupDialog" v-dialog-drag class="app-dialog admin-dialog" aria-labelledby="group-title" @cancel="handleGroupDialogCancel"><form @submit.prevent="saveGroup"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">USER GROUP</span><h2 id="group-title">{{ editingGroup?'编辑用户组':'新建用户组' }}</h2><p>维护用户组基础资料,成员与角色绑定可在保存后单独配置。</p></div><button class="modal-close" type="button" aria-label="关闭用户组窗口" :disabled="groupSaving" @click="closeGroupDialog">×</button></div><div class="modal-body"><div class="form-grid group-form-grid"><div v-if="uiRead('dialog.group.editor.code')" class="field"><label for="group-code">组编码 <em>*</em></label><input id="group-code" v-model.trim="groupForm.groupCode" required :disabled="groupSaving||!!editingGroup||!uiEdit('dialog.group.editor.code')"></div><div v-if="uiRead('dialog.group.editor.name')" class="field"><label for="group-name">名称 <em>*</em></label><input id="group-name" v-model.trim="groupForm.groupName" required :disabled="groupSaving||!uiEdit('dialog.group.editor.name')"></div><div v-if="uiRead('dialog.group.editor.status')" class="field"><label for="group-status">状态</label><select id="group-status" v-model="groupForm.status" class="select" :disabled="groupSaving||!uiEdit('dialog.group.editor.status')||isDefaultGroup(editingGroup)"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></select></div><div v-if="uiRead('dialog.group.editor.description')" class="field full"><label for="group-description">说明</label><textarea id="group-description" v-model.trim="groupForm.description" rows="3" :disabled="groupSaving||!uiEdit('dialog.group.editor.description')"></textarea></div><div v-if="isDefaultGroup(editingGroup)" class="inline-alert warning full" role="status"><span>系统默认组的编码和状态不可修改。</span></div><div v-else-if="editingGroup&&groupForm.status==='INACTIVE'" class="inline-alert warning full" role="status"><span>停用后成员仍占用该组归属,但本组角色不会生效。</span></div></div></div><div class="modal-actions"><button class="btn" type="button" :disabled="groupSaving" @click="closeGroupDialog">取消</button><button class="btn primary" type="submit" :disabled="groupSaving">{{ groupSaving?'保存中…':'保存用户组' }}</button></div></form></dialog> <dialog v-if="uiRead('dialog.group.editor')" ref="groupDialog" v-dialog-drag class="app-dialog admin-dialog" aria-labelledby="group-title" @cancel="handleGroupDialogCancel"><form @submit.prevent="saveGroup"><div class="modal-head" data-dialog-drag-handle><div><span class="eyebrow">USER GROUP</span><h2 id="group-title">{{ editingGroup?'编辑权限组':'新建权限组' }}</h2><p>维护权限组基础资料,成员与角色绑定可在保存后单独配置。</p></div><button class="modal-close" type="button" aria-label="关闭权限组窗口" :disabled="groupSaving" @click="closeGroupDialog">×</button></div><div class="modal-body"><div class="form-grid group-form-grid"><div v-if="uiRead('dialog.group.editor.code')" class="field"><label for="group-code">组编码 <em>*</em></label><input id="group-code" v-model.trim="groupForm.groupCode" required :disabled="groupSaving||!!editingGroup||!uiEdit('dialog.group.editor.code')"></div><div v-if="uiRead('dialog.group.editor.name')" class="field"><label for="group-name">名称 <em>*</em></label><input id="group-name" v-model.trim="groupForm.groupName" required :disabled="groupSaving||!uiEdit('dialog.group.editor.name')"></div><div v-if="uiRead('dialog.group.editor.status')" class="field"><label for="group-status">状态</label><SearchableSelect id="group-status" v-model="groupForm.status" class="select" :disabled="groupSaving||!uiEdit('dialog.group.editor.status')||isDefaultGroup(editingGroup)"><option value="ACTIVE">启用</option><option value="INACTIVE">停用</option></SearchableSelect></div><div v-if="uiRead('dialog.group.editor.description')" class="field full"><label for="group-description">说明</label><textarea id="group-description" v-model.trim="groupForm.description" rows="3" :disabled="groupSaving||!uiEdit('dialog.group.editor.description')"></textarea></div><div v-if="isDefaultGroup(editingGroup)" class="inline-alert warning full" role="status"><span>系统默认组的编码和状态不可修改。</span></div><div v-else-if="editingGroup&&groupForm.status==='INACTIVE'" class="inline-alert warning full" role="status"><span>停用后成员仍占用该组归属,但本组角色不会生效。</span></div></div></div><div class="modal-actions"><button class="btn" type="button" :disabled="groupSaving" @click="closeGroupDialog">取消</button><button class="btn primary" type="submit" :disabled="groupSaving">{{ groupSaving?'保存中…':'保存权限组' }}</button></div></form></dialog>
</div> </div>
</template> </template>
@@ -83,10 +83,12 @@ const canEditRoleGroups=computed(()=>canViewRoleGroups.value&&canEdit('iam.group
const canOpenMemberBinding=()=>uiRead('dialog.group.members')&&uiEdit('dialog.group.members.view')&&(canRead('iam.group.member:read')||canEdit('iam.group.member:manage')) const canOpenMemberBinding=()=>uiRead('dialog.group.members')&&uiEdit('dialog.group.members.view')&&(canRead('iam.group.member:read')||canEdit('iam.group.member:manage'))
const canOpenRoleBinding=()=>uiRead('dialog.group.roles')&&uiEdit('dialog.group.roles.view')&&(canRead('iam.group.role:read')||canEdit('iam.group.role:manage')) const canOpenRoleBinding=()=>uiRead('dialog.group.roles')&&uiEdit('dialog.group.roles.view')&&(canRead('iam.group.role:read')||canEdit('iam.group.role:manage'))
const route=useRoute(); const router=useRouter() const route=useRoute(); const router=useRouter()
const tabs:{key:Tab;label:string;pageAccess:PageAccessKey}[]=[{key:'groups',label:'用户组管理',pageAccess:'userGroups'},{key:'roles',label:'角色管理',pageAccess:'userRoles'},{key:'directory',label:'飞书通讯录',pageAccess:'directory'}] const tabs:{key:Tab;label:string;pageAccess:PageAccessKey}[]=[{key:'directory',label:'人员与组织',pageAccess:'directory'},{key:'groups',label:'权限组',pageAccess:'userGroups'},{key:'roles',label:'角色',pageAccess:'userRoles'}]
const canAccessTab=(tab:Tab)=>{const definition=tabs.find(item=>item.key===tab);return Boolean(definition&&hasPageAccess(definition.pageAccess,userStore.canRead,authorizationStore.can))} const canAccessTab=(tab:Tab)=>{const definition=tabs.find(item=>item.key===tab);return Boolean(definition&&hasPageAccess(definition.pageAccess,userStore.canRead,authorizationStore.can))}
const availableTabs=computed(()=>tabs.filter(tab=>canAccessTab(tab.key))); const activeTab=ref<Tab>('groups'); const permissionsFailed=computed(()=>availableTabs.value.length===0&&Boolean(userStore.permissionsError||authorizationStore.error)) const availableTabs=computed(()=>tabs.filter(tab=>canAccessTab(tab.key))); const activeTab=ref<Tab>('directory'); const permissionsFailed=computed(()=>availableTabs.value.length===0&&Boolean(userStore.permissionsError||authorizationStore.error))
const pageDescription=computed(()=>activeTab.value==='directory'?'查看已同步的飞书组织架构与员工资料,并维护通讯录同步状态。':activeTab.value==='roles'?'维护角色资料与菜单、页面、字段、按钮及弹窗权限。':'通过用户组管理成员归属,并为用户组统一绑定角色权限。') const pageTitle=computed(()=>activeTab.value==='directory'?'人员与组织':activeTab.value==='roles'?'角色':'权限组')
const pageEyebrow=computed(()=>activeTab.value==='directory'?'PEOPLE & ORGANIZATION':activeTab.value==='roles'?'ROLES':'PERMISSION GROUPS')
const pageDescription=computed(()=>activeTab.value==='directory'?'查看已同步的飞书组织架构与员工资料,并维护通讯录同步状态。':activeTab.value==='roles'?'维护角色资料与菜单、页面、字段、按钮及弹窗权限。':'通过权限组管理成员归属,并为权限组统一绑定角色权限。')
const roles=ref<Role[]>([]),groups=ref<UserGroup[]>([]); const rolesLoading=ref(false),groupsLoading=ref(false),rolesLoaded=ref(false); const rolesError=ref(''),groupsError=ref('') const roles=ref<Role[]>([]),groups=ref<UserGroup[]>([]); const rolesLoading=ref(false),groupsLoading=ref(false),rolesLoaded=ref(false); const rolesError=ref(''),groupsError=ref('')
const {page:groupPage,pageSize:groupPageSize,paginatedItems:paginatedGroups}=useListPagination(groups) const {page:groupPage,pageSize:groupPageSize,paginatedItems:paginatedGroups}=useListPagination(groups)
const {page:rolePage,pageSize:rolePageSize,paginatedItems:paginatedRoles}=useListPagination(roles) const {page:rolePage,pageSize:rolePageSize,paginatedItems:paginatedRoles}=useListPagination(roles)
@@ -99,7 +101,7 @@ const errorText=(error:unknown)=>{const responseMessage=(error as {response?:{da
const isSuperAdmin=computed(()=>userStore.userInfo?.isSuperAdmin===true||(userStore.userInfo?.roleCodes||[]).some(code=>String(code).toUpperCase()==='SUPER_ADMIN')) const isSuperAdmin=computed(()=>userStore.userInfo?.isSuperAdmin===true||(userStore.userInfo?.roleCodes||[]).some(code=>String(code).toUpperCase()==='SUPER_ADMIN'))
const loadRoles=async(requireRolePage=false)=>{if((requireRolePage&&!canAccessTab('roles'))||(!requireRolePage&&!canLoadRoleCandidates.value))return false;if(roleLoadPromise)return roleLoadPromise;rolesLoading.value=true;rolesError.value='';const current=(async()=>{try{const rows=await adminApi.listRoles()||[];if((requireRolePage&&!canAccessTab('roles'))||(!requireRolePage&&!canLoadRoleCandidates.value)){roles.value=[];rolesLoaded.value=false;return false}roles.value=rows;rolesLoaded.value=true;return true}catch(e){rolesLoaded.value=false;rolesError.value=errorText(e);ElMessage.error(`角色候选加载失败:${rolesError.value}`);return false}finally{rolesLoading.value=false}})();roleLoadPromise=current;try{return await current}finally{if(roleLoadPromise===current)roleLoadPromise=null}} const loadRoles=async(requireRolePage=false)=>{if((requireRolePage&&!canAccessTab('roles'))||(!requireRolePage&&!canLoadRoleCandidates.value))return false;if(roleLoadPromise)return roleLoadPromise;rolesLoading.value=true;rolesError.value='';const current=(async()=>{try{const rows=await adminApi.listRoles()||[];if((requireRolePage&&!canAccessTab('roles'))||(!requireRolePage&&!canLoadRoleCandidates.value)){roles.value=[];rolesLoaded.value=false;return false}roles.value=rows;rolesLoaded.value=true;return true}catch(e){rolesLoaded.value=false;rolesError.value=errorText(e);ElMessage.error(`角色候选加载失败:${rolesError.value}`);return false}finally{rolesLoading.value=false}})();roleLoadPromise=current;try{return await current}finally{if(roleLoadPromise===current)roleLoadPromise=null}}
const loadRolesForTab=()=>loadRoles(true) const loadRolesForTab=()=>loadRoles(true)
const loadGroups=async()=>{if(!canAccessTab('groups'))return;groupsLoading.value=true;groupsError.value='';try{const rows=await adminApi.listGroups()||[];if(!canAccessTab('groups')){groups.value=[];return}groups.value=sortUserGroups(rows)}catch(e){groupsError.value=errorText(e);ElMessage.error(`用户组加载失败:${groupsError.value}`)}finally{groupsLoading.value=false}} const loadGroups=async()=>{if(!canAccessTab('groups'))return;groupsLoading.value=true;groupsError.value='';try{const rows=await adminApi.listGroups()||[];if(!canAccessTab('groups')){groups.value=[];return}groups.value=sortUserGroups(rows)}catch(e){groupsError.value=errorText(e);ElMessage.error(`权限组加载失败:${groupsError.value}`)}finally{groupsLoading.value=false}}
const syncTabQuery=(tab:Tab)=>{if(String(route.query.tab||'')===tab)return;void router.replace({query:{...route.query,tab}})} const syncTabQuery=(tab:Tab)=>{if(String(route.query.tab||'')===tab)return;void router.replace({query:{...route.query,tab}})}
const activateTab=(tab:Tab)=>{if(!canAccessTab(tab))return;activeTab.value=tab;if(tab==='groups'&&!groups.value.length)void loadGroups();if(tab==='roles'&&!rolesLoaded.value)void loadRolesForTab()} const activateTab=(tab:Tab)=>{if(!canAccessTab(tab))return;activeTab.value=tab;if(tab==='groups'&&!groups.value.length)void loadGroups();if(tab==='roles'&&!rolesLoaded.value)void loadRolesForTab()}
const switchTab=(tab:Tab)=>{if(!availableTabs.value.some(item=>item.key===tab))return;activateTab(tab);syncTabQuery(tab)} const switchTab=(tab:Tab)=>{if(!availableTabs.value.some(item=>item.key===tab))return;activateTab(tab);syncTabQuery(tab)}
@@ -112,7 +114,7 @@ watch(()=>route.query.tab,tab=>{const next=resolveTab(tab);if(next&&next!==activ
watch(availableTabs,next=>{const keys=next.map(item=>item.key);if(!canAccessTab('groups')){groups.value=[];groupsError.value=''}if(!canAccessTab('roles')){roles.value=[];rolesLoaded.value=false;rolesError.value=''}const selected=selectAccessibleTab(route.query.tab,activeTab.value,keys);if(!selected)return;if(selected!==activeTab.value)activateTab(selected);syncTabQuery(selected)},{flush:'post'}) watch(availableTabs,next=>{const keys=next.map(item=>item.key);if(!canAccessTab('groups')){groups.value=[];groupsError.value=''}if(!canAccessTab('roles')){roles.value=[];rolesLoaded.value=false;rolesError.value=''}const selected=selectAccessibleTab(route.query.tab,activeTab.value,keys);if(!selected)return;if(selected!==activeTab.value)activateTab(selected);syncTabQuery(selected)},{flush:'post'})
onMounted(async()=>{try{await loadAvailableAccess()}catch(e){ElMessage.error(errorText(e))}}) onMounted(async()=>{try{await loadAvailableAccess()}catch(e){ElMessage.error(errorText(e))}})
const groupDisplayName=(group:UserGroup)=>isDefaultGroup(group)?'普通用户组':isSuperAdminGroup(group)?'超级管理员组':group.groupName const groupDisplayName=(group:UserGroup)=>isDefaultGroup(group)?'普通权限组':isSuperAdminGroup(group)?'超级管理员组':group.groupName
type MemberCandidateOption=Omit<GroupCandidate,'id'>&{id:string;localUserId:number|null} type MemberCandidateOption=Omit<GroupCandidate,'id'>&{id:string;localUserId:number|null}
const memberDisplayName=(person:MemberCandidateOption)=>person.realName const memberDisplayName=(person:MemberCandidateOption)=>person.realName
const show=async(dialog:HTMLDialogElement|null)=>{await nextTick();if(dialog&&!dialog.open)dialog.showModal()}; const closeDialog=(dialog:HTMLDialogElement|null)=>dialog?.close() const show=async(dialog:HTMLDialogElement|null)=>{await nextTick();if(dialog&&!dialog.open)dialog.showModal()}; const closeDialog=(dialog:HTMLDialogElement|null)=>dialog?.close()
@@ -127,7 +129,7 @@ const sortedIds=(ids:number[])=>[...ids].sort((a,b)=>a-b)
const roleGroupsDirty=computed(()=>JSON.stringify(sortedIds(selectedRoleGroupIds.value))!==JSON.stringify(sortedIds(roleGroupBaseline.value))) const roleGroupsDirty=computed(()=>JSON.stringify(sortedIds(selectedRoleGroupIds.value))!==JSON.stringify(sortedIds(roleGroupBaseline.value)))
const filteredRoleGroups=computed(()=>roleGroupOptions.value.filter(group=>`${group.groupName} ${group.groupCode}`.toLocaleLowerCase().includes(roleGroupQuery.value.trim().toLocaleLowerCase()))) const filteredRoleGroups=computed(()=>roleGroupOptions.value.filter(group=>`${group.groupName} ${group.groupCode}`.toLocaleLowerCase().includes(roleGroupQuery.value.trim().toLocaleLowerCase())))
const roleHasUnsavedChanges=computed(()=>hasUnsavedRoleDraft(roleForm,permissionDraft.value,roleFormBaseline.value,permissionBaseline.value)||roleGroupsDirty.value) const roleHasUnsavedChanges=computed(()=>hasUnsavedRoleDraft(roleForm,permissionDraft.value,roleFormBaseline.value,permissionBaseline.value)||roleGroupsDirty.value)
const loadRoleGroups=async()=>{const generation=++roleGroupsGeneration;const targetId=currentRoleId();roleGroupsLoading.value=true;roleGroupsError.value='';try{const [options,binding]=await Promise.all([adminApi.listGroups(),targetId===null?Promise.resolve({groupIds:[]}):adminApi.getRoleGroups(targetId)]);if(generation!==roleGroupsGeneration||currentRoleId()!==targetId||!roleDialog.value?.open)return;if(!Array.isArray(binding.groupIds)||!binding.groupIds.every(id=>Number.isInteger(id)))throw new Error('用户组授权响应无效');roleGroupOptions.value=sortUserGroups(options);selectedRoleGroupIds.value=[...binding.groupIds];roleGroupBaseline.value=[...binding.groupIds]}catch(e){if(generation===roleGroupsGeneration&&currentRoleId()===targetId)roleGroupsError.value=errorText(e)}finally{if(generation===roleGroupsGeneration&&currentRoleId()===targetId)roleGroupsLoading.value=false}} const loadRoleGroups=async()=>{const generation=++roleGroupsGeneration;const targetId=currentRoleId();roleGroupsLoading.value=true;roleGroupsError.value='';try{const [options,binding]=await Promise.all([adminApi.listGroups(),targetId===null?Promise.resolve({groupIds:[]}):adminApi.getRoleGroups(targetId)]);if(generation!==roleGroupsGeneration||currentRoleId()!==targetId||!roleDialog.value?.open)return;if(!Array.isArray(binding.groupIds)||!binding.groupIds.every(id=>Number.isInteger(id)))throw new Error('权限组授权响应无效');roleGroupOptions.value=sortUserGroups(options);selectedRoleGroupIds.value=[...binding.groupIds];roleGroupBaseline.value=[...binding.groupIds]}catch(e){if(generation===roleGroupsGeneration&&currentRoleId()===targetId)roleGroupsError.value=errorText(e)}finally{if(generation===roleGroupsGeneration&&currentRoleId()===targetId)roleGroupsLoading.value=false}}
const snapshotRoleBaseline=()=>{roleFormBaseline.value=JSON.stringify(roleForm);permissionBaseline.value=JSON.stringify(permissionDraft.value)} const snapshotRoleBaseline=()=>{roleFormBaseline.value=JSON.stringify(roleForm);permissionBaseline.value=JSON.stringify(permissionDraft.value)}
let rolePermissionGeneration=0,roleGroupsGeneration=0 let rolePermissionGeneration=0,roleGroupsGeneration=0
const currentRoleId=()=>editingRole.value?.id??null const currentRoleId=()=>editingRole.value?.id??null
@@ -171,7 +173,7 @@ const saveRole=async()=>{
} }
if(saveGroups){ if(saveGroups){
try{await adminApi.updateRoleGroups(saved.id,{groupIds:groupSnapshot,expectedGroupIds});roleGroupBaseline.value=[...groupSnapshot]} try{await adminApi.updateRoleGroups(saved.id,{groupIds:groupSnapshot,expectedGroupIds});roleGroupBaseline.value=[...groupSnapshot]}
catch(e){await loadRoles();ElMessage.error(isConflict(e)?'用户组授权已被他人更新,草稿已保留;请重新打开角色后核对。':`用户组授权保存失败:${errorText(e)}。草稿已保留,请重试。`);return} catch(e){await loadRoles();ElMessage.error(isConflict(e)?'权限组授权已被他人更新,草稿已保留;请重新打开角色后核对。':`权限组授权保存失败:${errorText(e)}。草稿已保留,请重试。`);return}
} }
await loadRoles() await loadRoles()
ElMessage.success(mayConfigurePermissions?(mayEditRole?'角色和权限已保存':'角色权限已保存'):(targetRole?'角色资料已保存':'角色已创建')) ElMessage.success(mayConfigurePermissions?(mayEditRole?'角色和权限已保存':'角色权限已保存'):(targetRole?'角色资料已保存':'角色已创建'))
@@ -190,7 +192,7 @@ const groupDialog=ref<HTMLDialogElement|null>(null),editingGroup=ref<UserGroup|n
const closeGroupDialog=()=>{if(groupSaving.value)return;closeDialog(groupDialog.value)} const closeGroupDialog=()=>{if(groupSaving.value)return;closeDialog(groupDialog.value)}
const handleGroupDialogCancel=(event:Event)=>{event.preventDefault();if(!groupSaving.value)closeGroupDialog()} const handleGroupDialogCancel=(event:Event)=>{event.preventDefault();if(!groupSaving.value)closeGroupDialog()}
const openGroupForm=async(group?:UserGroup)=>{if(groupSaving.value||isDefaultGroup(group))return;const code=group?'iam.group:update':'iam.group:create';const uiCode=group?'system.group.edit':'system.group.create';if(!uiRead('dialog.group.editor')||!uiEdit(uiCode)||!canEdit(code))return;editingGroup.value=group||null;Object.assign(groupForm,{groupCode:group?.groupCode||'',groupName:group?.groupName||'',description:group?.description||'',status:group?.status||'ACTIVE'});await show(groupDialog.value)} const openGroupForm=async(group?:UserGroup)=>{if(groupSaving.value||isDefaultGroup(group))return;const code=group?'iam.group:update':'iam.group:create';const uiCode=group?'system.group.edit':'system.group.create';if(!uiRead('dialog.group.editor')||!uiEdit(uiCode)||!canEdit(code))return;editingGroup.value=group||null;Object.assign(groupForm,{groupCode:group?.groupCode||'',groupName:group?.groupName||'',description:group?.description||'',status:group?.status||'ACTIVE'});await show(groupDialog.value)}
const saveGroup=async()=>{const targetGroup=editingGroup.value;const code=targetGroup?'iam.group:update':'iam.group:create';if(groupSaving.value||isDefaultGroup(targetGroup)||!canEdit(code))return;if(targetGroup&&targetGroup.status==='ACTIVE'&&groupForm.status==='INACTIVE'){try{await ElMessageBox.confirm('停用后成员仍占用该组归属,但本组角色不会生效。确定继续吗?','确认停用用户组',{type:'warning'})}catch(e){if(e==='cancel'||e==='close')return;throw e}}const payload={...groupForm};groupSaving.value=true;let savedSuccessfully=false;try{const saved=targetGroup?await adminApi.updateGroup(targetGroup.id,payload):await adminApi.createGroup(payload);if(targetGroup)Object.assign(targetGroup,saved);else groups.value=sortUserGroups([...groups.value,saved]);await loadGroups();savedSuccessfully=true;ElMessage.success('用户组已保存')}catch(e){ElMessage.error(errorText(e))}finally{groupSaving.value=false;if(savedSuccessfully)closeGroupDialog()}} const saveGroup=async()=>{const targetGroup=editingGroup.value;const code=targetGroup?'iam.group:update':'iam.group:create';if(groupSaving.value||isDefaultGroup(targetGroup)||!canEdit(code))return;if(targetGroup&&targetGroup.status==='ACTIVE'&&groupForm.status==='INACTIVE'){try{await ElMessageBox.confirm('停用后成员仍占用该组归属,但本组角色不会生效。确定继续吗?','确认停用权限组',{type:'warning'})}catch(e){if(e==='cancel'||e==='close')return;throw e}}const payload={...groupForm};groupSaving.value=true;let savedSuccessfully=false;try{const saved=targetGroup?await adminApi.updateGroup(targetGroup.id,payload):await adminApi.createGroup(payload);if(targetGroup)Object.assign(targetGroup,saved);else groups.value=sortUserGroups([...groups.value,saved]);await loadGroups();savedSuccessfully=true;ElMessage.success('权限组已保存')}catch(e){ElMessage.error(errorText(e))}finally{groupSaving.value=false;if(savedSuccessfully)closeGroupDialog()}}
const memberDialog=ref<HTMLDialogElement|null>(null),groupRoleDialog=ref<HTMLDialogElement|null>(null) const memberDialog=ref<HTMLDialogElement|null>(null),groupRoleDialog=ref<HTMLDialogElement|null>(null)
const memberGroup=ref<UserGroup|null>(null),roleGroup=ref<UserGroup|null>(null) const memberGroup=ref<UserGroup|null>(null),roleGroup=ref<UserGroup|null>(null)
const memberBindingLoading=ref(false),memberBindingError=ref(''),candidateLoading=ref(false),candidateError=ref(''),candidateKeyword=ref('') const memberBindingLoading=ref(false),memberBindingError=ref(''),candidateLoading=ref(false),candidateError=ref(''),candidateKeyword=ref('')
@@ -229,7 +231,7 @@ const blockedCandidateWarning=computed(()=>!candidateKeyword.value.trim()||candi
const showFreshEmpty=computed(()=>memberAdditionsAllowed.value&&!candidateLoading.value&&!candidateError.value&&candidateMatches.value.length===0&&!blockedMatchesPresent.value) const showFreshEmpty=computed(()=>memberAdditionsAllowed.value&&!candidateLoading.value&&!candidateError.value&&candidateMatches.value.length===0&&!blockedMatchesPresent.value)
const memberCandidateDisabled=(person:MemberCandidateOption)=>currentMemberIds.value.includes(person.id)?false:!memberAdditionsAllowed.value||!person.directoryIdentity||!validDirectoryKeys.value.has(person.id)||Boolean(memberGroup.value&&candidateDisabled({...person,id:person.localUserId},memberGroup.value.id)) const memberCandidateDisabled=(person:MemberCandidateOption)=>currentMemberIds.value.includes(person.id)?false:!memberAdditionsAllowed.value||!person.directoryIdentity||!validDirectoryKeys.value.has(person.id)||Boolean(memberGroup.value&&candidateDisabled({...person,id:person.localUserId},memberGroup.value.id))
const hasBlockedMemberDraft=computed(()=>selectedMemberIds.value.some(key=>!currentMemberIds.value.includes(key)&&(!candidateHistory.value.find(person=>person.id===key)||memberCandidateDisabled(candidateHistory.value.find(person=>person.id===key)!)))) const hasBlockedMemberDraft=computed(()=>selectedMemberIds.value.some(key=>!currentMemberIds.value.includes(key)&&(!candidateHistory.value.find(person=>person.id===key)||memberCandidateDisabled(candidateHistory.value.find(person=>person.id===key)!))))
const groupRoleCandidateError=computed(()=>isDefaultGroup(roleGroup.value)?'':roleBindingError.value||rolesError.value||(!roleBindingLoading.value&&selectedGroupRoleIds.value.length>0&&roles.value.length===0?'当前用户组已有角色,但角色候选为空,禁止保存以避免清空现有绑定。':'')) const groupRoleCandidateError=computed(()=>isDefaultGroup(roleGroup.value)?'':roleBindingError.value||rolesError.value||(!roleBindingLoading.value&&selectedGroupRoleIds.value.length>0&&roles.value.length===0?'当前权限组已有角色,但角色候选为空,禁止保存以避免清空现有绑定。':''))
const confirmDiscard=async(kind:'成员'|'角色',dirty:boolean)=>{if(!dirty)return true;try{await ElMessageBox.confirm(`${kind}绑定尚未保存,确定放弃这些更改吗?`,'放弃未保存更改',{type:'warning'});return true}catch(e){if(e!=='cancel'&&e!=='close')ElMessage.error(errorText(e));return false}} const confirmDiscard=async(kind:'成员'|'角色',dirty:boolean)=>{if(!dirty)return true;try{await ElMessageBox.confirm(`${kind}绑定尚未保存,确定放弃这些更改吗?`,'放弃未保存更改',{type:'warning'});return true}catch(e){if(e!=='cancel'&&e!=='close')ElMessage.error(errorText(e));return false}}
const candidateOption=(person:GroupCandidate,currentIds:ReadonlySet<number>):MemberCandidateOption=>{const id=person.id!==null&&currentIds.has(person.id)?localMemberKey(person.id):person.directoryIdentity?directoryIdentityKey(person.directoryIdentity):person.id!==null?`readonly-local:${person.id}`:`readonly-directory:${JSON.stringify([person.realName,person.employeeNo??'',person.departmentNames??[]])}`;return {...person,id,localUserId:person.id}} const candidateOption=(person:GroupCandidate,currentIds:ReadonlySet<number>):MemberCandidateOption=>{const id=person.id!==null&&currentIds.has(person.id)?localMemberKey(person.id):person.directoryIdentity?directoryIdentityKey(person.directoryIdentity):person.id!==null?`readonly-local:${person.id}`:`readonly-directory:${JSON.stringify([person.realName,person.employeeNo??'',person.departmentNames??[]])}`;return {...person,id,localUserId:person.id}}
const rememberCandidates=(people:MemberCandidateOption[])=>{const history=new Map(candidateHistory.value.map(person=>[person.id,person]));people.forEach(person=>history.set(person.id,person));candidateHistory.value=[...history.values()]} const rememberCandidates=(people:MemberCandidateOption[])=>{const history=new Map(candidateHistory.value.map(person=>[person.id,person]));people.forEach(person=>history.set(person.id,person));candidateHistory.value=[...history.values()]}
@@ -315,7 +317,7 @@ const refreshMembersAfterConflict=async(targetId:number,targetGeneration:number)
} }
const saveGroupMembers=async()=>{if(memberSaving.value)return;const target=memberGroup.value;if(!target||isDefaultGroup(target)||groupMembersDynamic.value||!groupMembersEditable.value||!canEdit('iam.group.member:manage')||memberBindingLoading.value||memberBindingError.value||hasBlockedMemberDraft.value)return;const targetGroup=target,targetId=target.id,targetGeneration=memberGeneration;const selectedKeysSnapshot=[...selectedMemberIds.value],expectedUserIdsSnapshot=[...memberBaselineIds.value];const userIdsSnapshot=expectedUserIdsSnapshot.filter(id=>selectedKeysSnapshot.includes(localMemberKey(id)));const directoryIdentitiesSnapshot=selectedKeysSnapshot.flatMap(key=>{if(currentMemberIds.value.includes(key))return [];const identity=candidateHistory.value.find(person=>person.id===key)?.directoryIdentity;return identity?[directoryIdentityPayload(identity)]:[]}) as DirectoryIdentity[];memberSaving.value=true;try{const result=await adminApi.updateGroupMembers(targetId,{userIds:userIdsSnapshot,directoryIdentities:directoryIdentitiesSnapshot,expectedUserIds:expectedUserIdsSnapshot});if(!result||!Array.isArray(result.userIds))throw new Error('成员绑定响应无效');targetGroup.memberCount=result.userIds.length;if(memberGroup.value?.id===targetId&&memberGeneration===targetGeneration){memberBaselineIds.value=[...result.userIds];currentMemberIds.value=result.userIds.map(localMemberKey);selectedMemberIds.value=[...currentMemberIds.value];closeDialog(memberDialog.value);resetMemberDialog()}ElMessage.success('成员绑定已保存')}catch(e){ElMessage.error(errorText(e));if(isConflict(e)&&memberGroup.value?.id===targetId&&memberGeneration===targetGeneration)await refreshMembersAfterConflict(targetId,targetGeneration)}finally{memberSaving.value=false}} const saveGroupMembers=async()=>{if(memberSaving.value)return;const target=memberGroup.value;if(!target||isDefaultGroup(target)||groupMembersDynamic.value||!groupMembersEditable.value||!canEdit('iam.group.member:manage')||memberBindingLoading.value||memberBindingError.value||hasBlockedMemberDraft.value)return;const targetGroup=target,targetId=target.id,targetGeneration=memberGeneration;const selectedKeysSnapshot=[...selectedMemberIds.value],expectedUserIdsSnapshot=[...memberBaselineIds.value];const userIdsSnapshot=expectedUserIdsSnapshot.filter(id=>selectedKeysSnapshot.includes(localMemberKey(id)));const directoryIdentitiesSnapshot=selectedKeysSnapshot.flatMap(key=>{if(currentMemberIds.value.includes(key))return [];const identity=candidateHistory.value.find(person=>person.id===key)?.directoryIdentity;return identity?[directoryIdentityPayload(identity)]:[]}) as DirectoryIdentity[];memberSaving.value=true;try{const result=await adminApi.updateGroupMembers(targetId,{userIds:userIdsSnapshot,directoryIdentities:directoryIdentitiesSnapshot,expectedUserIds:expectedUserIdsSnapshot});if(!result||!Array.isArray(result.userIds))throw new Error('成员绑定响应无效');targetGroup.memberCount=result.userIds.length;if(memberGroup.value?.id===targetId&&memberGeneration===targetGeneration){memberBaselineIds.value=[...result.userIds];currentMemberIds.value=result.userIds.map(localMemberKey);selectedMemberIds.value=[...currentMemberIds.value];closeDialog(memberDialog.value);resetMemberDialog()}ElMessage.success('成员绑定已保存')}catch(e){ElMessage.error(errorText(e));if(isConflict(e)&&memberGroup.value?.id===targetId&&memberGeneration===targetGeneration)await refreshMembersAfterConflict(targetId,targetGeneration)}finally{memberSaving.value=false}}
const saveGroupRoles=async()=>{if(groupRoleSaving.value)return;const target=roleGroup.value;if(!target||isDefaultGroup(target)||!canEdit('iam.group.role:manage')||roleBindingLoading.value||groupRoleCandidateError.value)return;const targetGroup=target,targetId=target.id,targetGeneration=roleBindingGeneration;const roleIdsSnapshot=[...selectedGroupRoleIds.value],expectedRoleIdsSnapshot=[...roleBaselineIds.value];groupRoleSaving.value=true;try{await adminApi.updateGroupRoles(targetId,{roleIds:roleIdsSnapshot,expectedRoleIds:expectedRoleIdsSnapshot});targetGroup.roleCount=roleIdsSnapshot.length;if(roleGroup.value?.id===targetId&&roleBindingGeneration===targetGeneration)roleBaselineIds.value=[...roleIdsSnapshot];ElMessage.success('角色绑定已保存')}catch(e){ElMessage.error(errorText(e));if(isConflict(e)&&roleGroup.value?.id===targetId&&roleBindingGeneration===targetGeneration)await loadGroupRoleBinding(true)}finally{groupRoleSaving.value=false}} const saveGroupRoles=async()=>{if(groupRoleSaving.value)return;const target=roleGroup.value;if(!target||isDefaultGroup(target)||!canEdit('iam.group.role:manage')||roleBindingLoading.value||groupRoleCandidateError.value)return;const targetGroup=target,targetId=target.id,targetGeneration=roleBindingGeneration;const roleIdsSnapshot=[...selectedGroupRoleIds.value],expectedRoleIdsSnapshot=[...roleBaselineIds.value];groupRoleSaving.value=true;try{await adminApi.updateGroupRoles(targetId,{roleIds:roleIdsSnapshot,expectedRoleIds:expectedRoleIdsSnapshot});targetGroup.roleCount=roleIdsSnapshot.length;if(roleGroup.value?.id===targetId&&roleBindingGeneration===targetGeneration)roleBaselineIds.value=[...roleIdsSnapshot];ElMessage.success('角色绑定已保存')}catch(e){ElMessage.error(errorText(e));if(isConflict(e)&&roleGroup.value?.id===targetId&&roleBindingGeneration===targetGeneration)await loadGroupRoleBinding(true)}finally{groupRoleSaving.value=false}}
const deleteGroup=async(group:UserGroup)=>{if(memberSaving.value||groupRoleSaving.value||isDefaultGroup(group)||!canEdit('iam.group:delete'))return;try{await ElMessageBox.confirm(`确定删除用户组“${group.groupName}”吗?`,'确认删除',{type:'warning'});await adminApi.deleteGroup(group.id);groups.value=groups.value.filter(g=>g.id!==group.id)}catch(e){if(e!=='cancel'&&e!=='close')ElMessage.error(errorText(e))}} const deleteGroup=async(group:UserGroup)=>{if(memberSaving.value||groupRoleSaving.value||isDefaultGroup(group)||!canEdit('iam.group:delete'))return;try{await ElMessageBox.confirm(`确定删除权限组“${group.groupName}”吗?`,'确认删除',{type:'warning'});await adminApi.deleteGroup(group.id);groups.value=groups.value.filter(g=>g.id!==group.id)}catch(e){if(e!=='cancel'&&e!=='close')ElMessage.error(errorText(e))}}
</script> </script>
<style scoped> <style scoped>
+101 -50
View File
@@ -12,7 +12,7 @@
class="btn primary" class="btn primary"
@click="openSubjectDialog" @click="openSubjectDialog"
> >
+ 新增二级科目 + 新增预算科目
</button> </button>
<button <button
v-if="activeView === 'ledger' && canAdjust" v-if="activeView === 'ledger' && canAdjust"
@@ -40,9 +40,9 @@
<template v-if="activeView === 'subjects'"> <template v-if="activeView === 'subjects'">
<div class="prototype-governance-note"> <div class="prototype-governance-note">
<strong>两级科目</strong <strong>科目分级</strong
><span ><span
>一级分类由系统预置,只能在启用的一级分类下新增二级科目;预算额度实际记录在二级科目。</span >一级分类由系统预置;新增的预算科目须归属启用的一级分类,预算额度记录在预算科目。</span
> >
</div> </div>
<section <section
@@ -64,35 +64,26 @@
</div> </div>
<LoadState :loading="loading" :error="loadError" @retry="load" /> <LoadState :loading="loading" :error="loadError" @retry="load" />
<div <div
v-if="!loading && !loadError && filteredSubjects.length" v-if="!loading && !loadError"
class="table-wrap" class="table-wrap"
> >
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
<th>层级/编码</th> <th>一级分类</th>
<th>预算分类</th> <th>预算科目</th>
<th>科目名称</th> <th>科目编码</th>
<th>适用说明</th>
<th>状态</th> <th>状态</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="subject in filteredSubjects" :key="subject.id"> <tr v-for="subject in filteredSubjects" :key="subject.id">
<td>{{ subject.level === 1 ? subject.name : (subject.parentName || '—') }}</td>
<td> <td>
<div class="prototype-cell-stack"> <strong>{{ subject.level === 2 ? subject.name : '—' }}</strong>
<strong>{{ subject.code }}</strong
><small>{{
subject.level === 1 ? "一级分类" : "二级科目"
}}</small>
</div>
</td> </td>
<td>{{ subject.level === 1 ? "—" : subject.parentName }}</td> <td>{{ subject.code || '—' }}</td>
<td>
<strong>{{ subject.name }}</strong>
</td>
<td>{{ subject.description || "—" }}</td>
<td><StatusBadge :active="subject.status === 'ACTIVE'" /></td> <td><StatusBadge :active="subject.status === 'ACTIVE'" /></td>
<td> <td>
<template v-if="subject.level === 2 && canSubjectStatus" <template v-if="subject.level === 2 && canSubjectStatus"
@@ -110,13 +101,21 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!loading && !loadError" class="prototype-empty"> <div v-if="!loading && !loadError && !filteredSubjects.length" class="prototype-empty">
没有符合当前筛选条件的预算科目。 没有符合当前筛选条件的预算科目。
</div> </div>
</section> </section>
</template> </template>
<template v-else> <template v-else>
<section class="card budget-year-heading">
<div>
<span class="eyebrow">CURRENT YEAR LEDGER</span>
<h2>{{ overview.fiscalYear }} 年度预算台账</h2>
<p>仅展示并汇总当前年度的真实预算额度、占用与执行数据。</p>
</div>
<span class="budget-current-year">当前年度</span>
</section>
<div class="budget-summary"> <div class="budget-summary">
<article <article
v-for="item in overview.summary" v-for="item in overview.summary"
@@ -209,7 +208,7 @@
</div> </div>
<LoadState :loading="loading" :error="loadError" @retry="load" /> <LoadState :loading="loading" :error="loadError" @retry="load" />
<div <div
v-if="!loading && !loadError && filteredLedgers.length" v-if="!loading && !loadError"
class="table-wrap" class="table-wrap"
> >
<table class="data-table prototype-table budget-ledger-table"> <table class="data-table prototype-table budget-ledger-table">
@@ -285,7 +284,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!loading && !loadError" class="prototype-empty"> <div v-if="!loading && !loadError && !filteredLedgers.length" class="prototype-empty">
没有符合当前条件的预算额度。 没有符合当前条件的预算额度。
</div> </div>
</section> </section>
@@ -322,7 +321,7 @@
</div> </div>
<LoadState :loading="loading" :error="loadError" @retry="load" /> <LoadState :loading="loading" :error="loadError" @retry="load" />
<div <div
v-if="!loading && !loadError && filteredAdjustments.length" v-if="!loading && !loadError"
class="table-wrap" class="table-wrap"
> >
<table class="data-table prototype-table"> <table class="data-table prototype-table">
@@ -391,7 +390,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else-if="!loading && !loadError" class="prototype-empty"> <div v-if="!loading && !loadError && !filteredAdjustments.length" class="prototype-empty">
暂无预算调整记录。 暂无预算调整记录。
</div> </div>
</section> </section>
@@ -408,8 +407,8 @@
<div class="modal-head" data-dialog-drag-handle> <div class="modal-head" data-dialog-drag-handle>
<div> <div>
<span class="eyebrow">BUDGET SUBJECT</span> <span class="eyebrow">BUDGET SUBJECT</span>
<h2>新增二级预算科目</h2> <h2>新增预算科目</h2>
<p>一级分类为系统目录,科目编码自动生成。</p> <p>预算科目须归属于一个启用的一级分类,科目编码由系统自动生成。</p>
</div> </div>
<button <button
class="modal-close" class="modal-close"
@@ -425,7 +424,7 @@
<div class="prototype-form-grid"> <div class="prototype-form-grid">
<div class="field full"> <div class="field full">
<label>一级预算分类 <em>*</em></label <label>一级预算分类 <em>*</em></label
><select ><SearchableSelect
v-model.number="subjectForm.parentId" v-model.number="subjectForm.parentId"
required required
:disabled="saving" :disabled="saving"
@@ -438,10 +437,10 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field full"> <div class="field full">
<label>二级科目名称 <em>*</em></label <label>预算科目名称 <em>*</em></label
><input ><input
v-model.trim="subjectForm.name" v-model.trim="subjectForm.name"
required required
@@ -459,6 +458,9 @@
></textarea> ></textarea>
</div> </div>
</div> </div>
<div class="inline-note">
保存时由系统按所选一级分类自动生成唯一科目编码;只新增二级预算科目,不会新增一级分类,也不会改动付款情形目录。
</div>
</div> </div>
<div class="modal-actions"> <div class="modal-actions">
<button <button
@@ -521,7 +523,7 @@
</div> </div>
<div class="field"> <div class="field">
<label>币种</label <label>币种</label
><select ><SearchableSelect
v-model="adjustForm.currencyCode" v-model="adjustForm.currencyCode"
:disabled="saving || adjustmentLocked" :disabled="saving || adjustmentLocked"
> >
@@ -532,11 +534,11 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field full"> <div class="field full">
<label>法人主体 <em>*</em></label <label>法人主体 <em>*</em></label
><select ><SearchableSelect
v-model.number="adjustForm.legalEntityId" v-model.number="adjustForm.legalEntityId"
:disabled="saving || adjustmentLocked" :disabled="saving || adjustmentLocked"
> >
@@ -548,11 +550,11 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field"> <div class="field">
<label>成本中心 <em>*</em></label <label>成本中心 <em>*</em></label
><select ><SearchableSelect
v-model.number="adjustForm.costCenterId" v-model.number="adjustForm.costCenterId"
:disabled="saving || adjustmentLocked" :disabled="saving || adjustmentLocked"
> >
@@ -564,11 +566,11 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field"> <div class="field">
<label>预算分类 <em>*</em></label <label>预算分类 <em>*</em></label
><select ><SearchableSelect
v-model.number="adjustCategoryId" v-model.number="adjustCategoryId"
:disabled="saving || adjustmentLocked" :disabled="saving || adjustmentLocked"
> >
@@ -580,15 +582,17 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field full"> <div class="field full">
<label>预算科目 <em>*</em></label <label>预算科目 <em>*</em></label
><select ><SearchableSelect
v-model.number="adjustForm.subjectId" v-model.number="adjustForm.subjectId"
:disabled="saving || adjustmentLocked || !adjustCategoryId" :disabled="saving || !adjustCategoryId"
> >
<option :value="null" disabled>请选择二级科目</option> <option :value="null" disabled>
{{ availableSubjects.length ? "请选择预算科目" : "当前分类暂无启用的预算科目" }}
</option>
<option <option
v-for="item in availableSubjects" v-for="item in availableSubjects"
:key="item.id" :key="item.id"
@@ -596,14 +600,14 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field"> <div class="field">
<label>调整方向 <em>*</em></label <label>调整方向 <em>*</em></label
><select v-model="adjustForm.direction" :disabled="saving"> ><SearchableSelect v-model="adjustForm.direction" :disabled="saving">
<option value="INCREASE">增加额度</option> <option value="INCREASE">增加额度</option>
<option value="DECREASE">减少额度</option> <option value="DECREASE">减少额度</option>
</select> </SearchableSelect>
</div> </div>
<div class="field"> <div class="field">
<label>调整额 <em>*</em></label <label>调整额 <em>*</em></label
@@ -746,6 +750,7 @@ const loadError = ref("");
const saving = ref(false); const saving = ref(false);
const formError = ref(""); const formError = ref("");
const changingSubjectId = ref<number | null>(null); const changingSubjectId = ref<number | null>(null);
const lastCreatedSubjectId = ref<number | null>(null);
const subjectKeyword = ref(""); const subjectKeyword = ref("");
const subjectStatus = ref<"ALL" | "ACTIVE" | "INACTIVE">("ALL"); const subjectStatus = ref<"ALL" | "ACTIVE" | "INACTIVE">("ALL");
const ledgerKeyword = ref(""); const ledgerKeyword = ref("");
@@ -854,6 +859,7 @@ const filteredLedgers = computed(() => {
const q = ledgerKeyword.value.toLocaleLowerCase(); const q = ledgerKeyword.value.toLocaleLowerCase();
return overview.ledgers.filter( return overview.ledgers.filter(
(item) => (item) =>
item.fiscalYear === overview.fiscalYear &&
(ledgerCenter.value === "ALL" || (ledgerCenter.value === "ALL" ||
String(item.costCenterId) === ledgerCenter.value) && String(item.costCenterId) === ledgerCenter.value) &&
(ledgerCurrency.value === "ALL" || (ledgerCurrency.value === "ALL" ||
@@ -877,6 +883,7 @@ const filteredAdjustments = computed(() => {
const q = adjustmentKeyword.value.toLocaleLowerCase(); const q = adjustmentKeyword.value.toLocaleLowerCase();
return overview.adjustments.filter( return overview.adjustments.filter(
(item) => (item) =>
item.fiscalYear === overview.fiscalYear &&
(adjustmentDirection.value === "ALL" || (adjustmentDirection.value === "ALL" ||
item.direction === adjustmentDirection.value) && item.direction === adjustmentDirection.value) &&
(adjustmentCurrency.value === "ALL" || (adjustmentCurrency.value === "ALL" ||
@@ -973,9 +980,13 @@ const saveSubject = async () => {
...subjectForm, ...subjectForm,
parentId: subjectForm.parentId, parentId: subjectForm.parentId,
}); });
overview.subjects.push(saved); lastCreatedSubjectId.value = saved.id;
await load();
if (!overview.subjects.some((item) => item.id === saved.id)) {
overview.subjects.push(saved);
}
subjectDialog.value?.close(); subjectDialog.value?.close();
ElMessage.success("二级预算科目已新增"); ElMessage.success("预算科目已新增,可在预算调整中直接选择");
} catch (error) { } catch (error) {
formError.value = errorText(error, "预算科目保存失败"); formError.value = errorText(error, "预算科目保存失败");
} finally { } finally {
@@ -1024,10 +1035,20 @@ const openAdjustment = async (ledger?: BudgetLedger) => {
amount: 0, amount: 0,
reason: "", reason: "",
}); });
adjustCategoryId.value = ledger const preferredSubject = ledger
? (overview.subjects.find((item) => item.id === ledger.subjectId) ? overview.subjects.find((item) => item.id === ledger.subjectId)
?.parentId ?? null) : overview.subjects.find(
: null; (item) =>
item.id === lastCreatedSubjectId.value &&
item.level === 2 &&
item.status === "ACTIVE",
);
adjustCategoryId.value =
preferredSubject?.parentId ?? activeCategories.value[0]?.id ?? null;
if (!ledger) {
adjustForm.subjectId =
preferredSubject?.id ?? availableSubjects.value[0]?.id ?? null;
}
formError.value = ""; formError.value = "";
await nextTick(); await nextTick();
adjustDialog.value?.showModal(); adjustDialog.value?.showModal();
@@ -1075,7 +1096,12 @@ watch(
}, },
); );
watch(adjustCategoryId, () => { watch(adjustCategoryId, () => {
if (!adjustmentLocked.value) adjustForm.subjectId = null; if (
!adjustmentLocked.value &&
!availableSubjects.value.some((item) => item.id === adjustForm.subjectId)
) {
adjustForm.subjectId = availableSubjects.value[0]?.id ?? null;
}
}); });
onMounted(() => { onMounted(() => {
void load(); void load();
@@ -1088,6 +1114,31 @@ onMounted(() => {
flex: 0 0 auto; flex: 0 0 auto;
margin: 0 0 16px; margin: 0 0 16px;
} }
.budget-year-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
margin-bottom: 16px;
padding: 18px 20px;
}
.budget-year-heading h2 {
margin: 4px 0 6px;
font-size: 20px;
}
.budget-year-heading p {
margin: 0;
color: var(--muted);
}
.budget-current-year {
flex: 0 0 auto;
border-radius: 999px;
padding: 6px 12px;
color: var(--blue);
background: var(--blue-soft);
font-size: 13px;
font-weight: 700;
}
.budget-summary { .budget-summary {
display: grid; display: grid;
width: 100%; width: 100%;
+8 -8
View File
@@ -52,13 +52,13 @@
<span>{{ loadError }}</span <span>{{ loadError }}</span
><button class="btn small" @click="load">重试</button> ><button class="btn small" @click="load">重试</button>
</div> </div>
<div v-else-if="filteredRows.length" class="table-wrap" tabindex="0"> <div v-else class="table-wrap" tabindex="0">
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
<th v-if="read('code')">成本中心编码</th> <th v-if="read('code')">成本中心编码</th>
<th v-if="read('name')">成本中心名称</th> <th v-if="read('name')">成本中心名称</th>
<th v-if="read('legalEntityId')">法人主体</th> <th v-if="read('legalEntityId')">所属法人主体</th>
<th v-if="read('managerName')">负责人</th> <th v-if="read('managerName')">负责人</th>
<th v-if="read('status')">状态</th> <th v-if="read('status')">状态</th>
<th>操作</th> <th>操作</th>
@@ -70,7 +70,7 @@
<strong>{{ row.code }}</strong> <strong>{{ row.code }}</strong>
</td> </td>
<td v-if="read('name')">{{ row.name }}</td> <td v-if="read('name')">{{ row.name }}</td>
<td v-if="read('legalEntityId')">{{ row.legalEntityName }}</td> <td v-if="read('legalEntityId')">{{ row.legalEntityName || '—' }}</td>
<td v-if="read('managerName')">{{ row.managerName || "—" }}</td> <td v-if="read('managerName')">{{ row.managerName || "—" }}</td>
<td v-if="read('status')"> <td v-if="read('status')">
<StatusBadge :active="row.status === 'ACTIVE'" /> <StatusBadge :active="row.status === 'ACTIVE'" />
@@ -97,7 +97,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="prototype-empty">没有符合当前筛选条件的成本中心。</div> <div v-if="!loading && !loadError && !filteredRows.length" class="prototype-empty">没有符合当前筛选条件的成本中心。</div>
</section> </section>
<dialog <dialog
v-if="canCreate" v-if="canCreate"
@@ -139,7 +139,7 @@
</div> </div>
<div class="field"> <div class="field">
<label>法人主体 <em>*</em></label <label>法人主体 <em>*</em></label
><select ><SearchableSelect
v-model.number="form.legalEntityId" v-model.number="form.legalEntityId"
required required
:disabled="saving" :disabled="saving"
@@ -152,14 +152,14 @@
> >
{{ item.code }} · {{ item.name }} {{ item.code }} · {{ item.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field"> <div class="field">
<label>负责人 <em>*</em></label <label>负责人 <em>*</em></label
><select v-model="form.managerOpenId" required :disabled="saving"> ><SearchableSelect v-model="form.managerOpenId" required :disabled="saving">
<option value="" disabled>请选择负责人</option> <option value="" disabled>请选择负责人</option>
<option v-for="employee in employees" :key="employee.openId" :value="employee.openId">{{ employee.name }}</option> <option v-for="employee in employees" :key="employee.openId" :value="employee.openId">{{ employee.name }}</option>
</select> </SearchableSelect>
</div> </div>
</div> </div>
</div> </div>
+2 -2
View File
@@ -48,7 +48,7 @@
<span>{{ loadError }}</span <span>{{ loadError }}</span
><button class="btn small" @click="load">重试</button> ><button class="btn small" @click="load">重试</button>
</div> </div>
<div v-else-if="filteredRows.length" class="table-wrap" tabindex="0"> <div v-else class="table-wrap" tabindex="0">
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
@@ -77,7 +77,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="prototype-empty">没有符合当前筛选条件的币种。</div> <div v-if="!loading && !loadError && !filteredRows.length" class="prototype-empty">没有符合当前筛选条件的币种。</div>
</section> </section>
</div> </div>
</template> </template>
+6 -6
View File
@@ -51,12 +51,12 @@
<span>{{ loadError }}</span <span>{{ loadError }}</span
><button class="btn small" type="button" @click="load">重试</button> ><button class="btn small" type="button" @click="load">重试</button>
</div> </div>
<div v-else-if="filteredRows.length" class="table-wrap" tabindex="0"> <div v-else class="table-wrap" tabindex="0">
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
<th v-if="read('code')">主体编码</th> <th v-if="read('code')">法人编码</th>
<th v-if="read('name')">主体名称</th> <th v-if="read('name')">法人主体名称</th>
<th v-if="read('creditCode')">统一社会信用代码</th> <th v-if="read('creditCode')">统一社会信用代码</th>
<th v-if="read('status')">状态</th> <th v-if="read('status')">状态</th>
<th>操作</th> <th>操作</th>
@@ -64,10 +64,10 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="row in filteredRows" :key="row.id"> <tr v-for="row in filteredRows" :key="row.id">
<td v-if="read('code')" data-label="主体编码"> <td v-if="read('code')" data-label="法人编码">
<strong>{{ row.code }}</strong> <strong>{{ row.code }}</strong>
</td> </td>
<td v-if="read('name')" data-label="主体名称">{{ row.name }}</td> <td v-if="read('name')" data-label="法人主体名称">{{ row.name || '—' }}</td>
<td v-if="read('creditCode')" data-label="统一社会信用代码"> <td v-if="read('creditCode')" data-label="统一社会信用代码">
<span class="mono">{{ row.creditCode }}</span> <span class="mono">{{ row.creditCode }}</span>
</td> </td>
@@ -98,7 +98,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="prototype-empty">没有符合当前筛选条件的法人主体。</div> <div v-if="!loading && !loadError && !filteredRows.length" class="prototype-empty">没有符合当前筛选条件的法人主体。</div>
</section> </section>
<dialog <dialog
+10 -14
View File
@@ -2,8 +2,8 @@
<div class="page-content route-list-page prototype-config-page"> <div class="page-content route-list-page prototype-config-page">
<BusinessConfigHeader <BusinessConfigHeader
eyebrow="PAYMENT ACCOUNTS" eyebrow="PAYMENT ACCOUNTS"
title="公司付款账户" title="付款账户"
description="维护本公司各法人及分公司用于实际付款的银行账户;与付款对象的收款账户分开管理。" description="维护本公司各付款单位用于实际付款的银行账户;与收款方的收款账户分开管理。"
><button v-if="canCreate" class="btn primary" @click="openCreate"> ><button v-if="canCreate" class="btn primary" @click="openCreate">
+ 新增付款账户 + 新增付款账户
</button></BusinessConfigHeader </button></BusinessConfigHeader
@@ -47,13 +47,12 @@
<span>{{ loadError }}</span <span>{{ loadError }}</span
><button class="btn small" @click="load">重试</button> ><button class="btn small" @click="load">重试</button>
</div> </div>
<div v-else-if="filteredRows.length" class="table-wrap"> <div v-else class="table-wrap">
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
<th v-if="read('code')">账户编码</th> <th v-if="read('code')">账户编码</th>
<th v-if="read('legalEntityId')">法人主体</th> <th v-if="read('legalEntityId')">付款单位</th>
<th v-if="read('branchName')">所属分公司</th>
<th v-if="read('bankName') || read('accountNo')"> <th v-if="read('bankName') || read('accountNo')">
开户银行/账号 开户银行/账号
</th> </th>
@@ -68,10 +67,7 @@
<td v-if="read('code')"> <td v-if="read('code')">
<strong>{{ row.code }}</strong> <strong>{{ row.code }}</strong>
</td> </td>
<td v-if="read('legalEntityId')">{{ row.legalEntityName }}</td> <td v-if="read('legalEntityId')">{{ row.legalEntityName || '—' }}</td>
<td v-if="read('branchName')">
{{ row.branchName?.trim() || "总部" }}
</td>
<td v-if="read('bankName') || read('accountNo')"> <td v-if="read('bankName') || read('accountNo')">
<div class="prototype-cell-stack"> <div class="prototype-cell-stack">
<strong v-if="read('bankName')">{{ row.bankName }}</strong <strong v-if="read('bankName')">{{ row.bankName }}</strong
@@ -105,7 +101,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="prototype-empty">没有符合当前筛选条件的付款账户。</div> <div v-if="!loading && !loadError && !filteredRows.length" class="prototype-empty">没有符合当前筛选条件的付款账户。</div>
</section> </section>
<dialog <dialog
v-if="canCreate" v-if="canCreate"
@@ -138,7 +134,7 @@
:class="{ full: !canReadCreateField('branchName') }" :class="{ full: !canReadCreateField('branchName') }"
> >
<label>法人主体 <em>*</em></label <label>法人主体 <em>*</em></label
><select ><SearchableSelect
v-model.number="form.legalEntityId" v-model.number="form.legalEntityId"
required required
:disabled="saving" :disabled="saving"
@@ -151,7 +147,7 @@
> >
{{ entity.code }} · {{ entity.name }} {{ entity.code }} · {{ entity.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div v-if="canReadCreateField('branchName')" class="field"> <div v-if="canReadCreateField('branchName')" class="field">
<label>所属分公司</label <label>所属分公司</label
@@ -183,7 +179,7 @@
</div> </div>
<div class="field"> <div class="field">
<label>币种 <em>*</em></label <label>币种 <em>*</em></label
><select v-model="form.currencyCode" required :disabled="saving"> ><SearchableSelect v-model="form.currencyCode" required :disabled="saving">
<option <option
v-for="currency in activeCurrencies" v-for="currency in activeCurrencies"
:key="currency.code" :key="currency.code"
@@ -191,7 +187,7 @@
> >
{{ currency.code }} · {{ currency.name }} {{ currency.code }} · {{ currency.name }}
</option> </option>
</select> </SearchableSelect>
</div> </div>
<div class="field full"> <div class="field full">
<label>允许付款方式 <em>*</em></label> <label>允许付款方式 <em>*</em></label>
+3 -3
View File
@@ -36,7 +36,7 @@
<span>{{ loadError }}</span <span>{{ loadError }}</span
><button class="btn small" @click="load">重试</button> ><button class="btn small" @click="load">重试</button>
</div> </div>
<div v-else-if="filteredRows.length" class="table-wrap"> <div v-else class="table-wrap">
<table class="data-table prototype-table"> <table class="data-table prototype-table">
<thead> <thead>
<tr> <tr>
@@ -53,7 +53,7 @@
<strong>{{ row.code }}</strong> <strong>{{ row.code }}</strong>
</td> </td>
<td v-if="read('name')">{{ row.name }}</td> <td v-if="read('name')">{{ row.name }}</td>
<td v-if="read('description')">{{ row.description }}</td> <td v-if="read('description')">{{ row.description || '—' }}</td>
<td v-if="read('status')"> <td v-if="read('status')">
<StatusBadge :active="row.status === 'ACTIVE'" /> <StatusBadge :active="row.status === 'ACTIVE'" />
</td> </td>
@@ -72,7 +72,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-else class="prototype-empty">没有符合当前筛选条件的付款方式。</div> <div v-if="!loading && !loadError && !filteredRows.length" class="prototype-empty">没有符合当前筛选条件的付款方式。</div>
</section> </section>
<dialog <dialog
v-if="canCreate" v-if="canCreate"
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.