提交
This commit is contained in:
1 parent
f9676f8759
commit
725774ef0c
155 files changed
+50675
-5242
No files matched your search
@@ -0,0 +1,302 @@
|
||||
import bxRequest from '@/utils/http/bx'
|
||||
|
||||
export type BxId = string | number
|
||||
|
||||
export const expenseItemApi = {
|
||||
tree() {
|
||||
return bxRequest.get('/expense-items/tree')
|
||||
},
|
||||
getById(id: BxId) {
|
||||
return bxRequest.get(`/expense-items/${id}`)
|
||||
},
|
||||
create(data: Record<string, any>) {
|
||||
return bxRequest.post('/expense-items/', data)
|
||||
},
|
||||
update(id: BxId, data: Record<string, any>) {
|
||||
return bxRequest.put(`/expense-items/${id}`, data)
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/expense-items/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const workflowApi = {
|
||||
list(params: { page: number; pageSize: number }) {
|
||||
return bxRequest.get('/workflows/', { params })
|
||||
},
|
||||
getByBizType(bizType: string) {
|
||||
return bxRequest.get(`/workflows/biz/${bizType}`)
|
||||
},
|
||||
getById(id: BxId) {
|
||||
return bxRequest.get(`/workflows/${id}`)
|
||||
},
|
||||
create(data: Record<string, any>) {
|
||||
return bxRequest.post('/workflows/', data)
|
||||
},
|
||||
update(id: BxId, data: Record<string, any>) {
|
||||
return bxRequest.put(`/workflows/${id}`, data)
|
||||
},
|
||||
saveNodes(id: BxId, nodes: Record<string, any>[]) {
|
||||
return bxRequest.put(`/workflows/${id}/nodes`, nodes)
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/workflows/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const advanceApi = {
|
||||
list(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
status?: string
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/advances/', { params })
|
||||
},
|
||||
my(params: { page: number; pageSize: number; status?: string; keyword?: string; applyDate?: string }) {
|
||||
return bxRequest.get('/advances/my', { params })
|
||||
},
|
||||
myStats() {
|
||||
return bxRequest.get('/advances/my/stats')
|
||||
},
|
||||
statusCounts() {
|
||||
return bxRequest.get('/advances/stats/status-counts')
|
||||
},
|
||||
pendingApproval(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/advances/pending-approval', { params })
|
||||
},
|
||||
pendingApprovalStats() {
|
||||
return bxRequest.get('/advances/pending-approval/stats')
|
||||
},
|
||||
approvedByMe(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/advances/approved-by-me', { params })
|
||||
},
|
||||
getById(id: BxId) {
|
||||
return bxRequest.get(`/advances/${id}`)
|
||||
},
|
||||
getApprovals(id: BxId) {
|
||||
return bxRequest.get(`/advances/${id}/approvals`)
|
||||
},
|
||||
getApprovalHistory(id: BxId) {
|
||||
return bxRequest.get(`/advances/${id}/approval-history`)
|
||||
},
|
||||
create(data: Record<string, any>) {
|
||||
return bxRequest.post('/advances/', data)
|
||||
},
|
||||
update(id: BxId, data: Record<string, any>) {
|
||||
return bxRequest.put(`/advances/${id}`, data)
|
||||
},
|
||||
submit(id: BxId) {
|
||||
return bxRequest.post(`/advances/${id}/submit`)
|
||||
},
|
||||
approve(id: BxId, data: { approvalOpinion?: string }) {
|
||||
return bxRequest.post(`/advances/${id}/approve`, data)
|
||||
},
|
||||
reject(id: BxId, data: { approvalOpinion?: string }) {
|
||||
return bxRequest.post(`/advances/${id}/reject`, data)
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/advances/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const reimburseApi = {
|
||||
generateTitle() {
|
||||
return bxRequest.get('/reimburses/generate-title')
|
||||
},
|
||||
list(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
status?: string
|
||||
keyword?: string
|
||||
expenseId?: BxId
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/reimburses/', { params })
|
||||
},
|
||||
my(params: { page: number; pageSize: number; status?: string; keyword?: string; applyDate?: string }) {
|
||||
return bxRequest.get('/reimburses/my', { params })
|
||||
},
|
||||
myStats() {
|
||||
return bxRequest.get('/reimburses/my/stats')
|
||||
},
|
||||
statusCounts() {
|
||||
return bxRequest.get('/reimburses/stats/status-counts')
|
||||
},
|
||||
pendingApproval(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/reimburses/pending-approval', { params })
|
||||
},
|
||||
pendingApprovalStats() {
|
||||
return bxRequest.get('/reimburses/pending-approval/stats')
|
||||
},
|
||||
approvedByMe(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/reimburses/approved-by-me', { params })
|
||||
},
|
||||
getById(id: BxId) {
|
||||
return bxRequest.get(`/reimburses/${id}`)
|
||||
},
|
||||
getApprovals(id: BxId) {
|
||||
return bxRequest.get(`/reimburses/${id}/approvals`)
|
||||
},
|
||||
getApprovalHistory(id: BxId) {
|
||||
return bxRequest.get(`/reimburses/${id}/approval-history`)
|
||||
},
|
||||
create(data: Record<string, any>) {
|
||||
return bxRequest.post('/reimburses/', data)
|
||||
},
|
||||
update(id: BxId, data: Record<string, any>) {
|
||||
return bxRequest.put(`/reimburses/${id}`, data)
|
||||
},
|
||||
submit(id: BxId) {
|
||||
return bxRequest.post(`/reimburses/${id}/submit`)
|
||||
},
|
||||
approve(id: BxId, data: { approvalOpinion?: string }) {
|
||||
return bxRequest.post(`/reimburses/${id}/approve`, data)
|
||||
},
|
||||
reject(id: BxId, data: { approvalOpinion?: string }) {
|
||||
return bxRequest.post(`/reimburses/${id}/reject`, data)
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/reimburses/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export const paymentApi = {
|
||||
financeStats() {
|
||||
return bxRequest.get('/payments/stats')
|
||||
},
|
||||
advanceIssueStats() {
|
||||
return bxRequest.get('/payments/advance-issues/stats')
|
||||
},
|
||||
pending(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
bizType?: string
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/payments/pending', { params })
|
||||
},
|
||||
pay(id: BxId, data?: { payRemark?: string; actualAmount?: number }) {
|
||||
return bxRequest.post(`/payments/${id}/pay`, data)
|
||||
},
|
||||
offset(id: BxId, data: { advanceId: BxId; offsetAmount: number; remark?: string }) {
|
||||
return bxRequest.post(`/payments/${id}/offset`, data)
|
||||
},
|
||||
batchOffset(
|
||||
id: BxId,
|
||||
data: { items: Array<{ advanceId: BxId; offsetAmount: number }>; payAmount: number; remark?: string }
|
||||
) {
|
||||
return bxRequest.post(`/payments/${id}/batch-offset`, data)
|
||||
},
|
||||
advanceIssues(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
issueStatus?: string
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/payments/advance-issues', {
|
||||
params: {
|
||||
page: params.page,
|
||||
pageSize: params.pageSize,
|
||||
issue_status: params.issueStatus,
|
||||
keyword: params.keyword,
|
||||
applicantId: params.applicantId,
|
||||
applyDate: params.applyDate
|
||||
}
|
||||
})
|
||||
},
|
||||
exportAdvanceIssues(params: {
|
||||
issueStatus?: string
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/payments/advance-issues/export', {
|
||||
params: {
|
||||
issue_status: params.issueStatus,
|
||||
keyword: params.keyword,
|
||||
applicantId: params.applicantId,
|
||||
applyDate: params.applyDate
|
||||
},
|
||||
responseType: 'blob'
|
||||
})
|
||||
},
|
||||
issueAdvance(advanceId: BxId, data: { issueRemark?: string; actualAmount?: number }) {
|
||||
return bxRequest.post(`/payments/advance/${advanceId}/issue`, data)
|
||||
},
|
||||
advanceOffsetRecords(advanceId: BxId) {
|
||||
return bxRequest.get(`/payments/advance/${advanceId}/offset-records`)
|
||||
},
|
||||
reimburseOffsetRecords(reimburseId: BxId) {
|
||||
return bxRequest.get(`/payments/${reimburseId}/offset-records`)
|
||||
},
|
||||
processed(params: {
|
||||
page: number
|
||||
pageSize: number
|
||||
bizType?: string
|
||||
keyword?: string
|
||||
applicantId?: BxId
|
||||
applyDate?: string
|
||||
}) {
|
||||
return bxRequest.get('/payments/processed', { params })
|
||||
}
|
||||
}
|
||||
|
||||
export const attachmentApi = {
|
||||
upload(file: File, bizType: string = '', bizId: BxId = 0) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return bxRequest.post('/attachments/upload', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
params: { biz_type: bizType, biz_id: bizId }
|
||||
})
|
||||
},
|
||||
download(id: BxId) {
|
||||
return bxRequest.get(`/attachments/download/${id}`, { responseType: 'blob' })
|
||||
},
|
||||
preview(id: BxId) {
|
||||
return bxRequest.get(`/attachments/preview/${id}`)
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/attachments/${id}`)
|
||||
},
|
||||
listByBiz(bizType: string, bizId: BxId) {
|
||||
return bxRequest.get('/attachments/list', { params: { biz_type: bizType, biz_id: bizId } })
|
||||
},
|
||||
bindBiz(ids: BxId[], bizType: string, bizId: BxId) {
|
||||
return bxRequest.put('/attachments/bind-biz', null, {
|
||||
params: { ids: ids.join(','), biz_type: bizType, biz_id: bizId }
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -27,3 +27,6 @@
|
||||
|
||||
// 主题切换圆形扩散动画
|
||||
@use './core/theme-animation.scss';
|
||||
|
||||
// 报销模块(bx)页面样式(从 bx-web 迁移,与 Fresh Mint Token 对齐)
|
||||
@use '../../styles/bx/index.scss';
|
||||
@@ -0,0 +1,223 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { Check, Close, Clock } from '@element-plus/icons-vue'
|
||||
|
||||
interface ApprovalNode {
|
||||
id: number
|
||||
nodeName: string
|
||||
nodeOrder: number
|
||||
approvalStatus: string
|
||||
approvalOpinion?: string | null
|
||||
approverName: string
|
||||
approvalTime?: string | null
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
nodes: ApprovalNode[]
|
||||
loading?: boolean
|
||||
}>(),
|
||||
{
|
||||
loading: false
|
||||
}
|
||||
)
|
||||
|
||||
const statusConfig: Record<string, { color: string; text: string; icon: any; circleClass: string }> = {
|
||||
approved: { color: 'var(--success)', text: '已通过', icon: Check, circleClass: 'is-approved' },
|
||||
rejected: { color: 'var(--danger)', text: '已驳回', icon: Close, circleClass: 'is-rejected' },
|
||||
pending: { color: 'var(--primary)', text: '待处理', icon: Clock, circleClass: 'is-pending' }
|
||||
}
|
||||
|
||||
function getConfig(status: string) {
|
||||
return (
|
||||
statusConfig[status] || {
|
||||
color: 'var(--text-muted)',
|
||||
text: '未知',
|
||||
icon: null,
|
||||
circleClass: 'is-pending'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const sortedNodes = computed(() =>
|
||||
[...props.nodes].sort((a, b) => a.nodeOrder - b.nodeOrder)
|
||||
)
|
||||
|
||||
function connectorClass(index: number) {
|
||||
const node = sortedNodes.value[index]
|
||||
return node?.approvalStatus === 'approved' ? 'is-done' : ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="approval-flow-view">
|
||||
<el-skeleton v-if="loading" :rows="2" animated />
|
||||
<template v-else>
|
||||
<p v-if="sortedNodes.length === 0" class="approval-empty">暂无审批记录</p>
|
||||
<div v-else class="approval-flow-scroll">
|
||||
<div class="approval-flow-track">
|
||||
<template v-for="(node, index) in sortedNodes" :key="node.id">
|
||||
<div class="approval-flow-step">
|
||||
<div
|
||||
class="approval-flow-circle"
|
||||
:class="getConfig(node.approvalStatus).circleClass"
|
||||
>
|
||||
<el-icon v-if="getConfig(node.approvalStatus).icon" class="approval-status-icon">
|
||||
<component :is="getConfig(node.approvalStatus).icon" />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="approval-flow-label">{{ node.nodeName }}</div>
|
||||
<div
|
||||
class="approval-flow-status"
|
||||
:style="{ color: getConfig(node.approvalStatus).color }"
|
||||
>
|
||||
{{ getConfig(node.approvalStatus).text }}
|
||||
</div>
|
||||
<div class="approval-flow-meta">
|
||||
<span v-if="node.approverName">审批人:{{ node.approverName }}</span>
|
||||
<span v-if="node.approvalTime">{{ node.approvalTime }}</span>
|
||||
</div>
|
||||
<div v-if="node.approvalOpinion" class="approval-flow-opinion">
|
||||
{{ node.approvalOpinion }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="index < sortedNodes.length - 1"
|
||||
class="approval-flow-connector"
|
||||
:class="connectorClass(index)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.approval-flow-view {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.approval-empty {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.approval-flow-scroll {
|
||||
overflow-x: auto;
|
||||
padding: 8px 4px 12px;
|
||||
}
|
||||
|
||||
.approval-flow-track {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 0;
|
||||
min-width: min-content;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.approval-flow-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: 132px;
|
||||
flex: 0 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.approval-flow-circle {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 2px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.approval-flow-circle.is-approved {
|
||||
border-color: var(--success, #10b981);
|
||||
background: linear-gradient(135deg, #10b981, #059669);
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
|
||||
}
|
||||
|
||||
.approval-flow-circle.is-rejected {
|
||||
border-color: var(--danger, #ef4444);
|
||||
background: #fef2f2;
|
||||
color: var(--danger, #ef4444);
|
||||
}
|
||||
|
||||
.approval-flow-circle.is-pending {
|
||||
border-color: var(--primary, #10b981);
|
||||
background: #fff;
|
||||
color: var(--primary, #10b981);
|
||||
}
|
||||
|
||||
.approval-status-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.approval-flow-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.approval-flow-status {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.approval-flow-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.approval-flow-opinion {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
max-width: 120px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.approval-flow-connector {
|
||||
width: 56px;
|
||||
height: 2px;
|
||||
background: #e2e8f0;
|
||||
margin-top: 18px;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.approval-flow-connector.is-done {
|
||||
background: linear-gradient(90deg, #10b981, #34d399);
|
||||
}
|
||||
|
||||
.approval-flow-connector.is-done::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: -3px;
|
||||
top: -3px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-top: 2px solid #10b981;
|
||||
border-right: 2px solid #10b981;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,202 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { Check, Close, Clock } from '@element-plus/icons-vue'
|
||||
|
||||
interface ApprovalHistoryItem {
|
||||
id: number | string
|
||||
nodeName: string
|
||||
nodeOrder: number
|
||||
approvalStatus: string
|
||||
approvalOpinion?: string | null
|
||||
approverName: string
|
||||
approvalTime?: string | null
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
items: ApprovalHistoryItem[]
|
||||
loading?: boolean
|
||||
}>(),
|
||||
{
|
||||
loading: false
|
||||
}
|
||||
)
|
||||
|
||||
const statusConfig: Record<string, { color: string; text: string; icon: any; circleClass: string }> = {
|
||||
approved: { color: 'var(--success)', text: '已通过', icon: Check, circleClass: 'is-approved' },
|
||||
rejected: { color: 'var(--danger)', text: '已驳回', icon: Close, circleClass: 'is-rejected' },
|
||||
pending: { color: 'var(--primary)', text: '待处理', icon: Clock, circleClass: 'is-pending' }
|
||||
}
|
||||
|
||||
function getConfig(status: string) {
|
||||
return (
|
||||
statusConfig[status] || {
|
||||
color: 'var(--text-muted)',
|
||||
text: '未知',
|
||||
icon: null,
|
||||
circleClass: 'is-pending'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const sortedItems = computed(() =>
|
||||
[...props.items].sort((a, b) => {
|
||||
const ta = a.approvalTime ? new Date(a.approvalTime).getTime() : 0
|
||||
const tb = b.approvalTime ? new Date(b.approvalTime).getTime() : 0
|
||||
if (ta !== tb) return ta - tb
|
||||
return a.nodeOrder - b.nodeOrder
|
||||
})
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="approval-history-view">
|
||||
<el-skeleton v-if="loading" :rows="2" animated />
|
||||
<template v-else>
|
||||
<p v-if="sortedItems.length === 0" class="approval-empty">暂无审批历史</p>
|
||||
<div v-else class="approval-history-scroll">
|
||||
<div class="approval-history-track">
|
||||
<template v-for="(item, index) in sortedItems" :key="item.id">
|
||||
<div class="approval-history-step">
|
||||
<div
|
||||
class="approval-history-circle"
|
||||
:class="getConfig(item.approvalStatus).circleClass"
|
||||
>
|
||||
<el-icon v-if="getConfig(item.approvalStatus).icon" class="approval-status-icon">
|
||||
<component :is="getConfig(item.approvalStatus).icon" />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="approval-history-label">{{ item.nodeName }}</div>
|
||||
<div
|
||||
class="approval-history-status"
|
||||
:style="{ color: getConfig(item.approvalStatus).color }"
|
||||
>
|
||||
{{ getConfig(item.approvalStatus).text }}
|
||||
</div>
|
||||
<div class="approval-history-meta">
|
||||
<span v-if="item.approverName">审批人:{{ item.approverName }}</span>
|
||||
<span v-if="item.approvalTime">{{ item.approvalTime }}</span>
|
||||
</div>
|
||||
<div v-if="item.approvalOpinion" class="approval-history-opinion">
|
||||
{{ item.approvalOpinion }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="index < sortedItems.length - 1" class="approval-history-connector" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.approval-history-view {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.approval-empty {
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.approval-history-scroll {
|
||||
overflow-x: auto;
|
||||
padding: 8px 4px 12px;
|
||||
}
|
||||
|
||||
.approval-history-track {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-start;
|
||||
gap: 0;
|
||||
min-width: min-content;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.approval-history-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: 132px;
|
||||
flex: 0 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.approval-history-circle {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 2px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
.approval-history-circle.is-approved {
|
||||
border-color: var(--success, #10b981);
|
||||
background: linear-gradient(135deg, #10b981, #059669);
|
||||
color: #fff;
|
||||
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
|
||||
}
|
||||
|
||||
.approval-history-circle.is-rejected {
|
||||
border-color: var(--danger, #ef4444);
|
||||
background: #fef2f2;
|
||||
color: var(--danger, #ef4444);
|
||||
}
|
||||
|
||||
.approval-history-circle.is-pending {
|
||||
border-color: var(--primary, #10b981);
|
||||
background: #fff;
|
||||
color: var(--primary, #10b981);
|
||||
}
|
||||
|
||||
.approval-status-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.approval-history-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.approval-history-status {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.approval-history-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.approval-history-opinion {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
max-width: 120px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.approval-history-connector {
|
||||
width: 40px;
|
||||
height: 2px;
|
||||
background: #cbd5e1;
|
||||
margin-top: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import type { Component } from 'vue'
|
||||
|
||||
defineProps<{
|
||||
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
|
||||
loading?: boolean
|
||||
link?: boolean
|
||||
plain?: boolean
|
||||
icon?: Component
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [event: MouseEvent]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-button
|
||||
class="bx-btn"
|
||||
:type="type"
|
||||
:loading="loading"
|
||||
:link="link"
|
||||
:plain="plain"
|
||||
@click="emit('click', $event)"
|
||||
>
|
||||
<el-icon v-if="icon" class="ic"><component :is="icon" /></el-icon>
|
||||
<slot />
|
||||
</el-button>
|
||||
</template>
|
||||
@@ -0,0 +1,124 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
text?: string | number | null
|
||||
lines?: number
|
||||
expandText?: string
|
||||
collapseText?: string
|
||||
}>(), {
|
||||
text: '',
|
||||
lines: 3,
|
||||
expandText: '展开',
|
||||
collapseText: '收起',
|
||||
})
|
||||
|
||||
const expanded = ref(false)
|
||||
const overflow = ref(false)
|
||||
const contentRef = ref<HTMLElement>()
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
const displayText = computed(() => {
|
||||
const value = props.text
|
||||
if (value === null || value === undefined || String(value).trim() === '') {
|
||||
return '-'
|
||||
}
|
||||
return String(value)
|
||||
})
|
||||
|
||||
const clampStyle = computed(() => {
|
||||
if (expanded.value) {
|
||||
return {}
|
||||
}
|
||||
return {
|
||||
WebkitLineClamp: String(props.lines),
|
||||
}
|
||||
})
|
||||
|
||||
const checkOverflow = async () => {
|
||||
await nextTick()
|
||||
const el = contentRef.value
|
||||
if (!el) {
|
||||
overflow.value = false
|
||||
return
|
||||
}
|
||||
overflow.value = el.scrollHeight - el.clientHeight > 1
|
||||
}
|
||||
|
||||
watch(() => props.text, () => {
|
||||
expanded.value = false
|
||||
checkOverflow()
|
||||
})
|
||||
|
||||
watch(() => props.lines, () => {
|
||||
expanded.value = false
|
||||
checkOverflow()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
checkOverflow()
|
||||
if (typeof ResizeObserver !== 'undefined' && contentRef.value) {
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
checkOverflow()
|
||||
})
|
||||
resizeObserver.observe(contentRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (resizeObserver) {
|
||||
resizeObserver.disconnect()
|
||||
resizeObserver = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="clamp-wrap">
|
||||
<div ref="contentRef" class="clamp-content" :class="{ expanded }" :style="clampStyle">
|
||||
{{ displayText }}
|
||||
</div>
|
||||
<button
|
||||
v-if="overflow"
|
||||
type="button"
|
||||
class="clamp-toggle"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
{{ expanded ? collapseText : expandText }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.clamp-wrap {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.clamp-content {
|
||||
min-width: 0;
|
||||
line-height: 1.5;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.clamp-content.expanded {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.clamp-toggle {
|
||||
margin-top: 4px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
color: var(--primary-dark);
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.clamp-toggle:hover {
|
||||
color: var(--primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{
|
||||
title: string
|
||||
data?: any[]
|
||||
emptyText?: string
|
||||
embedded?: boolean
|
||||
}>(), {
|
||||
data: () => [],
|
||||
emptyText: '暂无数据',
|
||||
embedded: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="{ 'dlg-view-section': !embedded }">
|
||||
<h4 v-if="!embedded" class="dlg-view-section-title">{{ title }}</h4>
|
||||
<slot v-if="data.length" />
|
||||
<el-empty v-else :description="emptyText" :image-size="56" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
const visible = defineModel<boolean>({ required: true })
|
||||
|
||||
defineProps<{
|
||||
title: string
|
||||
width?: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog v-model="visible" :title="title" :width="width" class="bx-dialog" align-center>
|
||||
<slot />
|
||||
<template v-if="$slots.footer" #footer>
|
||||
<slot name="footer" />
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
const modelValue = defineModel<string | number | undefined>()
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
clearable?: boolean
|
||||
type?: 'text' | 'textarea' | 'password'
|
||||
rows?: number
|
||||
disabled?: boolean
|
||||
}>(),
|
||||
{
|
||||
placeholder: '',
|
||||
clearable: true,
|
||||
type: 'text',
|
||||
rows: 3,
|
||||
disabled: false
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-input
|
||||
v-model="modelValue"
|
||||
class="bx-input"
|
||||
:placeholder="placeholder"
|
||||
:clearable="clearable"
|
||||
:type="type"
|
||||
:rows="rows"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import type { Component } from 'vue'
|
||||
|
||||
defineProps<{
|
||||
primary?: boolean
|
||||
loading?: boolean
|
||||
icon?: Component
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [event: MouseEvent]
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-button
|
||||
class="bx-op-btn"
|
||||
:class="{ primary }"
|
||||
:loading="loading"
|
||||
@click="emit('click', $event)"
|
||||
>
|
||||
<el-icon v-if="icon" class="ic-sm"><component :is="icon" /></el-icon>
|
||||
<slot />
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
type Model = string | number | null | undefined
|
||||
|
||||
const modelValue = defineModel<Model>()
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
placeholder?: string
|
||||
clearable?: boolean
|
||||
}>(),
|
||||
{
|
||||
placeholder: '',
|
||||
clearable: true
|
||||
}
|
||||
)
|
||||
|
||||
function handleClear() {
|
||||
modelValue.value = undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-select v-model="modelValue" class="bx-select" :placeholder="placeholder" :clearable="clearable" @clear="handleClear">
|
||||
<slot />
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps<{
|
||||
data: any[]
|
||||
showSummary?: boolean
|
||||
summaryMethod?: (...args: any[]) => any
|
||||
height?: string | number
|
||||
maxHeight?: string | number
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
selectionChange: [rows: any[]]
|
||||
}>()
|
||||
|
||||
const elTableRef = ref<any>()
|
||||
|
||||
function toggleRowExpansion(row: any, expanded?: boolean) {
|
||||
elTableRef.value?.toggleRowExpansion(row, expanded)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
toggleRowExpansion,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-table
|
||||
ref="elTableRef"
|
||||
class="bx-table"
|
||||
:data="data"
|
||||
:show-summary="showSummary"
|
||||
:summary-method="summaryMethod"
|
||||
:height="height"
|
||||
:max-height="maxHeight"
|
||||
@selection-change="(rows) => emit('selectionChange', rows)"
|
||||
>
|
||||
<slot />
|
||||
</el-table>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
tone?: 'pending' | 'processing' | 'done' | 'warning' | 'error' | 'info'
|
||||
}>(),
|
||||
{
|
||||
tone: 'info'
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="bx-tag" :class="`bx-tag--${tone}`">
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<div v-if="files.length" class="attachment-upload">
|
||||
<div class="attachment-list">
|
||||
<div
|
||||
v-for="file in files"
|
||||
:key="String(file.id)"
|
||||
class="attachment-item"
|
||||
>
|
||||
<div
|
||||
class="attachment-preview"
|
||||
@click="canBxPreview(file) ? handlePreview(file) : undefined"
|
||||
>
|
||||
<template v-if="isBxImageFile(file) && file.previewUrl">
|
||||
<img :src="file.previewUrl" :alt="file.fileName" />
|
||||
</template>
|
||||
<template v-else-if="isBxVideoFile(file)">
|
||||
<div class="attachment-preview__icon attachment-preview__icon--video">
|
||||
<el-icon :size="28"><VideoPlay /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="attachment-preview__icon attachment-preview__icon--doc">
|
||||
<el-icon :size="28"><Document /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="attachment-footer">
|
||||
<span class="attachment-name" :title="file.fileName">{{ file.fileName }}</span>
|
||||
<div class="attachment-actions">
|
||||
<el-icon class="action-btn" title="下载" @click="handleDownload(file)">
|
||||
<Download />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="previewVisible"
|
||||
title="附件预览"
|
||||
width="800px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
>
|
||||
<img
|
||||
v-if="previewMode === 'image' && previewUrl"
|
||||
:src="previewUrl"
|
||||
:alt="previewFileName"
|
||||
class="bx-attachment-preview-media"
|
||||
/>
|
||||
<video
|
||||
v-else-if="previewMode === 'video' && previewUrl"
|
||||
:src="previewUrl"
|
||||
controls
|
||||
class="bx-attachment-preview-media"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { VideoPlay, Document, Download } from '@element-plus/icons-vue'
|
||||
import {
|
||||
type BxAttachmentItem,
|
||||
isBxImageFile,
|
||||
isBxVideoFile,
|
||||
canBxPreview,
|
||||
downloadBxAttachment,
|
||||
previewBxAttachment
|
||||
} from '@/utils/bx/attachment'
|
||||
|
||||
defineProps<{
|
||||
files: BxAttachmentItem[]
|
||||
}>()
|
||||
|
||||
const previewVisible = ref(false)
|
||||
const previewUrl = ref('')
|
||||
const previewFileName = ref('')
|
||||
const previewMode = ref<'image' | 'video'>('image')
|
||||
|
||||
function handleDownload(file: BxAttachmentItem) {
|
||||
downloadBxAttachment(file)
|
||||
}
|
||||
|
||||
async function handlePreview(file: BxAttachmentItem) {
|
||||
const result = await previewBxAttachment(file)
|
||||
if (!result) return
|
||||
previewMode.value = result.type
|
||||
previewUrl.value = result.url
|
||||
previewFileName.value = result.fileName
|
||||
previewVisible.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '@/styles/bx/attachment.scss';
|
||||
</style>
|
||||
@@ -0,0 +1,242 @@
|
||||
<template>
|
||||
<div class="attachment-upload">
|
||||
<div class="attachment-list">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
:multiple="true"
|
||||
:disabled="disabled || globalUploading"
|
||||
accept="image/*,video/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.zip,.rar"
|
||||
@change="handleAttachmentChange"
|
||||
>
|
||||
<div class="upload-card">
|
||||
<el-icon :size="28" color="#10b981"><Plus /></el-icon>
|
||||
<span class="upload-card-text">上传附件</span>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div
|
||||
v-for="(file, index) in files"
|
||||
:key="String(file.id)"
|
||||
class="attachment-item"
|
||||
:class="{ 'is-uploading': file._uploading }"
|
||||
>
|
||||
<div
|
||||
class="attachment-preview"
|
||||
@click="canBxPreview(file) ? handlePreview(file) : undefined"
|
||||
>
|
||||
<template v-if="isBxImageFile(file) && (file.previewUrl || file._uploading)">
|
||||
<img v-if="file.previewUrl" :src="file.previewUrl" :alt="file.fileName" />
|
||||
<el-icon v-else :size="24" color="#94a3b8"><Loading /></el-icon>
|
||||
</template>
|
||||
<template v-else-if="isBxImageFile(file) && !file.previewUrl">
|
||||
<el-icon :size="24" color="#94a3b8"><Loading /></el-icon>
|
||||
</template>
|
||||
<template v-else-if="isBxVideoFile(file)">
|
||||
<div class="attachment-preview__icon attachment-preview__icon--video">
|
||||
<el-icon :size="28"><VideoPlay /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="attachment-preview__icon attachment-preview__icon--doc">
|
||||
<el-icon :size="28"><Document /></el-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="attachment-footer">
|
||||
<span class="attachment-name" :title="file.fileName">{{ file.fileName }}</span>
|
||||
<div class="attachment-actions">
|
||||
<el-icon class="action-btn" title="下载" @click="handleDownload(file)">
|
||||
<Download />
|
||||
</el-icon>
|
||||
<el-icon
|
||||
class="action-btn action-btn--danger"
|
||||
title="删除"
|
||||
@click="removeAttachment(index)"
|
||||
>
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span v-if="showHint" class="upload-hint">{{ hint }}</span>
|
||||
|
||||
<el-dialog
|
||||
v-model="previewVisible"
|
||||
title="附件预览"
|
||||
width="800px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
>
|
||||
<img
|
||||
v-if="previewMode === 'image' && previewUrl"
|
||||
:src="previewUrl"
|
||||
:alt="previewFileName"
|
||||
class="bx-attachment-preview-media"
|
||||
/>
|
||||
<video
|
||||
v-else-if="previewMode === 'video' && previewUrl"
|
||||
:src="previewUrl"
|
||||
controls
|
||||
class="bx-attachment-preview-media"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
import {
|
||||
Plus,
|
||||
Loading,
|
||||
VideoPlay,
|
||||
Document,
|
||||
Download,
|
||||
Delete
|
||||
} from '@element-plus/icons-vue'
|
||||
import type { UploadFile, UploadInstance } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { attachmentApi, type BxId } from '@/api/bx'
|
||||
import {
|
||||
type BxAttachmentItem,
|
||||
isBxImageFile,
|
||||
isBxVideoFile,
|
||||
canBxPreview,
|
||||
downloadBxAttachment,
|
||||
previewBxAttachment
|
||||
} from '@/utils/bx/attachment'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: BxAttachmentItem[]
|
||||
bizType: string
|
||||
bizId?: BxId
|
||||
hint?: string
|
||||
showHint?: boolean
|
||||
disabled?: boolean
|
||||
maxSizeMb?: number
|
||||
}>(),
|
||||
{
|
||||
bizId: 0,
|
||||
hint: '支持图片、视频、PDF、Word、Excel等文件,单文件不超过 20MB',
|
||||
showHint: true,
|
||||
disabled: false,
|
||||
maxSizeMb: 20
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: BxAttachmentItem[]]
|
||||
}>()
|
||||
|
||||
const uploadRef = ref<UploadInstance>()
|
||||
const globalUploading = ref(false)
|
||||
const previewVisible = ref(false)
|
||||
const previewUrl = ref('')
|
||||
const previewFileName = ref('')
|
||||
const previewMode = ref<'image' | 'video'>('image')
|
||||
|
||||
const files = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
function syncFiles(next: BxAttachmentItem[]) {
|
||||
emit('update:modelValue', next)
|
||||
}
|
||||
|
||||
async function handleAttachmentChange(uploadFile: UploadFile) {
|
||||
const rawFile = uploadFile.raw
|
||||
if (!rawFile) return
|
||||
|
||||
const maxBytes = props.maxSizeMb * 1024 * 1024
|
||||
if (rawFile.size > maxBytes) {
|
||||
ElMessage.error(`单文件不能超过 ${props.maxSizeMb}MB`)
|
||||
uploadRef.value?.clearFiles()
|
||||
return
|
||||
}
|
||||
|
||||
const item: BxAttachmentItem = {
|
||||
id: `upload-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||
fileName: rawFile.name,
|
||||
fileType: rawFile.type,
|
||||
fileSize: rawFile.size,
|
||||
previewUrl: '',
|
||||
_uploading: true
|
||||
}
|
||||
syncFiles([...files.value, item])
|
||||
globalUploading.value = true
|
||||
|
||||
try {
|
||||
const res: any = await attachmentApi.upload(rawFile, props.bizType, props.bizId ?? 0)
|
||||
item.id = res.data.id
|
||||
item.fileName = res.data.fileName || item.fileName
|
||||
item.fileType = res.data.fileType || item.fileType
|
||||
item.fileSize = res.data.fileSize ?? item.fileSize
|
||||
item._uploading = false
|
||||
if (isBxImageFile(item)) {
|
||||
try {
|
||||
const previewRes: any = await attachmentApi.preview(item.id)
|
||||
item.previewUrl = previewRes.data?.url || ''
|
||||
} catch {
|
||||
/* preview optional */
|
||||
}
|
||||
}
|
||||
syncFiles([...files.value])
|
||||
} catch (error: any) {
|
||||
syncFiles(files.value.filter((entry) => entry.id !== item.id))
|
||||
ElMessage.error(error?.message || '上传失败')
|
||||
} finally {
|
||||
globalUploading.value = files.value.some((entry) => entry._uploading)
|
||||
await nextTick()
|
||||
uploadRef.value?.clearFiles()
|
||||
}
|
||||
}
|
||||
|
||||
async function removeAttachment(index: number) {
|
||||
const file = files.value[index]
|
||||
if (!file || file._uploading) return
|
||||
try {
|
||||
await ElMessageBox.confirm('确定删除该附件?', '提示', { type: 'warning' })
|
||||
if (typeof file.id === 'number' || /^\d+$/.test(String(file.id))) {
|
||||
await attachmentApi.delete(file.id)
|
||||
}
|
||||
const next = [...files.value]
|
||||
next.splice(index, 1)
|
||||
syncFiles(next)
|
||||
ElMessage.success('已删除')
|
||||
} catch {
|
||||
/* cancelled */
|
||||
}
|
||||
}
|
||||
|
||||
function handleDownload(file: BxAttachmentItem) {
|
||||
if (file._uploading) return
|
||||
downloadBxAttachment(file)
|
||||
}
|
||||
|
||||
async function handlePreview(file: BxAttachmentItem) {
|
||||
const result = await previewBxAttachment(file)
|
||||
if (!result) return
|
||||
previewMode.value = result.type
|
||||
previewUrl.value = result.url
|
||||
previewFileName.value = result.fileName
|
||||
previewVisible.value = true
|
||||
}
|
||||
|
||||
function hasUploading() {
|
||||
return files.value.some((item) => item._uploading)
|
||||
}
|
||||
|
||||
function getFileIds() {
|
||||
return files.value.filter((item) => !item._uploading).map((item) => item.id)
|
||||
}
|
||||
|
||||
defineExpose({ hasUploading, getFileIds })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@use '@/styles/bx/attachment.scss';
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
workflowNodeLabel,
|
||||
workflowNodeTone,
|
||||
shouldShowWorkflowNodeTag,
|
||||
} from '@/utils/bx/format'
|
||||
import BaseTag from './BaseTag.vue'
|
||||
|
||||
defineProps<{
|
||||
currentNode?: unknown
|
||||
status?: unknown
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BaseTag
|
||||
v-if="shouldShowWorkflowNodeTag(currentNode, status)"
|
||||
:tone="workflowNodeTone(currentNode, status)"
|
||||
>
|
||||
{{ workflowNodeLabel(currentNode, status) }}
|
||||
</BaseTag>
|
||||
<span v-else class="node-current-empty">-</span>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
title: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="panel-top">{{ title }}</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { Refresh, Search } from '@element-plus/icons-vue'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
/** 是否与「展开更多条件」联动(收起/展开文案);无更多筛选项时可不传 */
|
||||
showMore?: boolean
|
||||
/** 为 true 时才显示「展开更多条件 / 收起更多条件」按钮 */
|
||||
hasExpandableFilters?: boolean
|
||||
loading?: boolean
|
||||
}>(),
|
||||
{
|
||||
showMore: false,
|
||||
hasExpandableFilters: false,
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggleMore: []
|
||||
reset: []
|
||||
search: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="filter-block">
|
||||
<div class="filter-main">
|
||||
<slot />
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<el-button
|
||||
v-if="hasExpandableFilters"
|
||||
link
|
||||
class="btn-link"
|
||||
@click="emit('toggleMore')"
|
||||
>
|
||||
{{ showMore ? '收起更多条件' : '展开更多条件' }}
|
||||
</el-button>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="filter-reset" :loading="loading" @click="emit('reset')">
|
||||
<el-icon class="ic"><Refresh /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
<el-button class="filter-search" type="primary" plain :loading="loading" @click="emit('search')">
|
||||
<el-icon class="ic"><Search /></el-icon>
|
||||
查询
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import DataTablePanel from './DataTablePanel.vue'
|
||||
import FilterBlock from './FilterBlock.vue'
|
||||
import ListToolbar from './ListToolbar.vue'
|
||||
import BaseTable from '../base/BaseTable.vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
panelTitle: string
|
||||
showMore?: boolean
|
||||
/** 为 true 时显示「展开更多条件」;筛选项全部在主区域时不要传或传 false */
|
||||
hasExpandableFilters?: boolean
|
||||
selectedCount: number
|
||||
rows: any[]
|
||||
rangeText: string
|
||||
total: number
|
||||
currentPage: number
|
||||
pageSize: number
|
||||
pageSizes?: number[]
|
||||
showSummary?: boolean
|
||||
summaryMethod?: (...args: any[]) => any
|
||||
tableMaxHeight?: string | number
|
||||
loading?: boolean
|
||||
/** 追加到 .table-scroll 的类名(如合计行样式) */
|
||||
tableScrollClass?: string
|
||||
}>(),
|
||||
{
|
||||
pageSizes: () => [10, 20, 30],
|
||||
showSummary: false,
|
||||
showMore: false,
|
||||
hasExpandableFilters: false,
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggleMore: []
|
||||
reset: []
|
||||
search: []
|
||||
'update:currentPage': [value: number]
|
||||
'update:pageSize': [value: number]
|
||||
sizeChange: []
|
||||
selectionChange: [rows: any[]]
|
||||
}>()
|
||||
|
||||
const currentPageModel = computed({
|
||||
get: () => props.currentPage,
|
||||
set: (value: number) => emit('update:currentPage', value)
|
||||
})
|
||||
|
||||
const pageSizeModel = computed({
|
||||
get: () => props.pageSize,
|
||||
set: (value: number) => emit('update:pageSize', value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DataTablePanel :title="panelTitle">
|
||||
<FilterBlock
|
||||
:show-more="showMore"
|
||||
:has-expandable-filters="hasExpandableFilters"
|
||||
:loading="loading"
|
||||
@toggle-more="emit('toggleMore')"
|
||||
@reset="emit('reset')"
|
||||
@search="emit('search')"
|
||||
>
|
||||
<slot name="filters" />
|
||||
</FilterBlock>
|
||||
|
||||
<ListToolbar :selected-count="selectedCount">
|
||||
<slot name="toolbar" />
|
||||
</ListToolbar>
|
||||
|
||||
<div class="table-scroll" :class="tableScrollClass">
|
||||
<BaseTable
|
||||
:data="rows"
|
||||
:show-summary="showSummary"
|
||||
:summary-method="summaryMethod"
|
||||
:max-height="tableMaxHeight"
|
||||
@selection-change="(rows: any[]) => emit('selectionChange', rows)"
|
||||
>
|
||||
<slot name="table-columns" />
|
||||
</BaseTable>
|
||||
</div>
|
||||
|
||||
<div class="list-pager">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<div class="list-pager-right">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPageModel"
|
||||
v-model:page-size="pageSizeModel"
|
||||
:total="total"
|
||||
layout="sizes, prev, pager, next"
|
||||
:page-sizes="pageSizes"
|
||||
prev-text="上一页"
|
||||
next-text="下一页"
|
||||
@size-change="emit('sizeChange')"
|
||||
/>
|
||||
<span class="pager-size-suffix">条</span>
|
||||
</div>
|
||||
</div>
|
||||
</DataTablePanel>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
selectedCount: number
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<span class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedCount }}</span> 条
|
||||
</span>
|
||||
<div class="list-toolbar-actions">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -287,7 +287,7 @@
|
||||
const isCollapsed = isDualMenu.value && !menuOpen.value
|
||||
return {
|
||||
transform: isCollapsed ? 'translateY(-50px)' : 'translateY(0)',
|
||||
height: isCollapsed ? 'calc(100% + 50px)' : 'calc(100% - 72px)',
|
||||
height: isCollapsed ? 'calc(100% + 50px)' : 'calc(100% - 56px)',
|
||||
transition: 'transform 0.3s ease'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -169,8 +169,8 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 72px;
|
||||
padding: 10px 12px 8px;
|
||||
height: 56px;
|
||||
padding: 0 12px;
|
||||
overflow: hidden;
|
||||
line-height: normal;
|
||||
cursor: pointer;
|
||||
@@ -179,10 +179,10 @@
|
||||
|
||||
.header-brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -196,19 +196,21 @@
|
||||
position: static;
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: 100%;
|
||||
flex: 0 1 auto;
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
color: #111827 !important;
|
||||
text-align: center;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
&.is-dual-menu-name {
|
||||
margin: auto;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,12 +107,16 @@ $popup-menu-radius: 6px;
|
||||
// 菜单折叠样式
|
||||
.menu-left-close {
|
||||
.header {
|
||||
.header-brand {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.header-brand-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.logo {
|
||||
margin: 0 auto;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { ref } from 'vue'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
|
||||
export function useApplicantOptions() {
|
||||
const applicantOptions = ref<{ label: string; value: string }[]>([])
|
||||
|
||||
async function loadApplicantOptions() {
|
||||
try {
|
||||
const res = await fetchUserOptions()
|
||||
const data = (res as any)?.data ?? res ?? []
|
||||
applicantOptions.value = (Array.isArray(data) ? data : []).map((u: any) => ({
|
||||
value: String(u.value ?? u.id ?? ''),
|
||||
label: String(u.label ?? u.nickName ?? u.realName ?? u.username ?? '')
|
||||
}))
|
||||
} catch {
|
||||
applicantOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
return { applicantOptions, loadApplicantOptions }
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { ref } from 'vue'
|
||||
import { advanceApi, reimburseApi } from '@/api/bx'
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
export const advanceApproverStats = ref({ pendingTotal: 0, monthPendingAmount: 0 })
|
||||
export const reimburseApproverStats = ref({ pendingTotal: 0, monthPendingAmount: 0 })
|
||||
|
||||
function collectMenuCodes(items: AppRouteRecord[]): Set<string> {
|
||||
const codes = new Set<string>()
|
||||
function walk(list: AppRouteRecord[]) {
|
||||
for (const item of list) {
|
||||
const code = item.meta?.menuCode as string | undefined
|
||||
if (code) codes.add(code)
|
||||
if (item.children?.length) walk(item.children)
|
||||
}
|
||||
}
|
||||
walk(items)
|
||||
return codes
|
||||
}
|
||||
|
||||
export function getMenuPendingCount(menuCode?: string | null): number {
|
||||
if (menuCode === 'bx:advanceApprove:list') return advanceApproverStats.value.pendingTotal
|
||||
if (menuCode === 'bx:reimburseApprove:list') return reimburseApproverStats.value.pendingTotal
|
||||
return 0
|
||||
}
|
||||
|
||||
/** 刷新侧栏「备用金审批 / 报销审批」待办数量(按用户菜单权限按需请求) */
|
||||
export async function refreshApproveMenuBadges(menuList: AppRouteRecord[]) {
|
||||
const codes = collectMenuCodes(menuList)
|
||||
const tasks: Promise<void>[] = []
|
||||
|
||||
if (codes.has('bx:advanceApprove:list')) {
|
||||
tasks.push(
|
||||
advanceApi.pendingApprovalStats().then((res: any) => {
|
||||
const d = res.data || {}
|
||||
advanceApproverStats.value = {
|
||||
pendingTotal: Number(d.pendingTotal ?? 0),
|
||||
monthPendingAmount: Number(d.monthPendingAmount ?? 0)
|
||||
}
|
||||
})
|
||||
)
|
||||
} else {
|
||||
advanceApproverStats.value = { pendingTotal: 0, monthPendingAmount: 0 }
|
||||
}
|
||||
|
||||
if (codes.has('bx:reimburseApprove:list')) {
|
||||
tasks.push(
|
||||
reimburseApi.pendingApprovalStats().then((res: any) => {
|
||||
const d = res.data || {}
|
||||
reimburseApproverStats.value = {
|
||||
pendingTotal: Number(d.pendingTotal ?? 0),
|
||||
monthPendingAmount: Number(d.monthPendingAmount ?? 0)
|
||||
}
|
||||
})
|
||||
)
|
||||
} else {
|
||||
reimburseApproverStats.value = { pendingTotal: 0, monthPendingAmount: 0 }
|
||||
}
|
||||
|
||||
await Promise.allSettled(tasks)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { expenseItemApi } from '@/api/bx'
|
||||
|
||||
export interface ExpenseItem {
|
||||
id: string
|
||||
parentId: string
|
||||
itemName: string
|
||||
itemCode: string
|
||||
level: number
|
||||
sortOrder: number
|
||||
status: number | string
|
||||
childCount: number
|
||||
children?: ExpenseItem[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载费用项目树形数据,供 el-tree-select 使用。
|
||||
*
|
||||
* 用法:
|
||||
* const { expenseTree, flatList, displayName, load } = useExpenseItemTree()
|
||||
*/
|
||||
export function useExpenseItemTree() {
|
||||
const expenseTree = ref<ExpenseItem[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
/** 扁平列表(含所有层级),用于根据 ID 查找名称 */
|
||||
const flatList = ref<ExpenseItem[]>([])
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await expenseItemApi.tree()
|
||||
const tree: ExpenseItem[] = res.data ?? []
|
||||
expenseTree.value = tree
|
||||
flatList.value = flattenTree(tree)
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载费用项目失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
|
||||
return { expenseTree, flatList, loading, load }
|
||||
}
|
||||
|
||||
function flattenTree(tree: ExpenseItem[]): ExpenseItem[] {
|
||||
const result: ExpenseItem[] = []
|
||||
for (const node of tree) {
|
||||
result.push(node)
|
||||
if (node.children?.length) result.push(...flattenTree(node.children))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据费用项目 ID 查找并返回展示名称。
|
||||
* - 二级项目 → "一级名称/二级名称"
|
||||
* - 一级项目 → "一级名称"
|
||||
*
|
||||
* @param id 费用项目 ID
|
||||
* @param flatList 扁平列表(由 useExpenseItemTree 提供)
|
||||
*/
|
||||
export function formatExpenseName(id: string | null | undefined, flatList: ExpenseItem[]): string {
|
||||
if (id == null) return '-'
|
||||
const item = flatList.find(i => i.id === id)
|
||||
if (!item) return '-'
|
||||
if (item.level === 1) return item.itemName
|
||||
const parent = flatList.find(i => i.id === item.parentId)
|
||||
return parent ? `${parent.itemName}/${item.itemName}` : item.itemName
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { computed, ref, type ComputedRef, type Ref } from 'vue'
|
||||
|
||||
type Source<T> = Ref<T[]> | ComputedRef<T[]> | (() => T[])
|
||||
|
||||
interface UsePagedTableOptions {
|
||||
initialPage?: number
|
||||
initialPageSize?: number
|
||||
}
|
||||
|
||||
export function usePagedTable<T>(source: Source<T>, options: UsePagedTableOptions = {}) {
|
||||
const currentPage = ref(options.initialPage ?? 1)
|
||||
const pageSize = ref(options.initialPageSize ?? 10)
|
||||
|
||||
const sourceRows = computed(() => {
|
||||
if (typeof source === 'function') return source()
|
||||
return source.value
|
||||
})
|
||||
|
||||
const total = computed(() => sourceRows.value.length)
|
||||
|
||||
const pagedRows = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
const end = start + pageSize.value
|
||||
return sourceRows.value.slice(start, end)
|
||||
})
|
||||
|
||||
const rangeText = computed(() => {
|
||||
const count = total.value
|
||||
const start = count === 0 ? 0 : (currentPage.value - 1) * pageSize.value + 1
|
||||
const end = Math.min(currentPage.value * pageSize.value, count)
|
||||
return `显示 ${start}-${end} / ${count}`
|
||||
})
|
||||
|
||||
function onSizeChange() {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
return {
|
||||
currentPage,
|
||||
pageSize,
|
||||
total,
|
||||
pagedRows,
|
||||
rangeText,
|
||||
onSizeChange
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import type { Ref } from 'vue'
|
||||
|
||||
interface UseServerPagedOptions {
|
||||
initialPage?: number
|
||||
initialPageSize?: number
|
||||
}
|
||||
|
||||
export function useServerPaged<T>(
|
||||
fetchFn: (params: { page: number; pageSize: number; [k: string]: any }) => Promise<{ rows: T[]; total: number }>,
|
||||
options: UseServerPagedOptions = {},
|
||||
) {
|
||||
const currentPage = ref(options.initialPage ?? 1)
|
||||
const pageSize = ref(options.initialPageSize ?? 10)
|
||||
const total = ref(0)
|
||||
const rows: Ref<T[]> = ref([]) as Ref<T[]>
|
||||
const loading = ref(false)
|
||||
const searchParams = ref<Record<string, any>>({})
|
||||
const skipNextWatchRefresh = ref(false)
|
||||
|
||||
const rangeText = computed(() => {
|
||||
const count = total.value
|
||||
const start = count === 0 ? 0 : (currentPage.value - 1) * pageSize.value + 1
|
||||
const end = Math.min(currentPage.value * pageSize.value, count)
|
||||
return `显示 ${start}-${end} / ${count}`
|
||||
})
|
||||
|
||||
async function refresh(extraParams: Record<string, any> = {}) {
|
||||
if (Object.keys(extraParams).length > 0) {
|
||||
searchParams.value = { ...extraParams }
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchFn({ page: currentPage.value, pageSize: pageSize.value, ...searchParams.value })
|
||||
rows.value = res.rows
|
||||
total.value = res.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function search(extraParams: Record<string, any> = {}) {
|
||||
searchParams.value = { ...extraParams }
|
||||
if (currentPage.value !== 1) {
|
||||
skipNextWatchRefresh.value = true
|
||||
currentPage.value = 1
|
||||
}
|
||||
await refresh()
|
||||
}
|
||||
|
||||
function onSizeChange() {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
watch([currentPage, pageSize], async () => {
|
||||
if (skipNextWatchRefresh.value) {
|
||||
skipNextWatchRefresh.value = false
|
||||
return
|
||||
}
|
||||
await refresh()
|
||||
})
|
||||
|
||||
return {
|
||||
currentPage,
|
||||
pageSize,
|
||||
total,
|
||||
rows,
|
||||
loading,
|
||||
rangeText,
|
||||
refresh,
|
||||
search,
|
||||
onSizeChange,
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { AppRouteRecord } from '@/types/router'
|
||||
|
||||
/**
|
||||
* 前端路由(4 个一级菜单:控制台、CRM 管理、工作流管理、系统管理)
|
||||
* 与后端菜单对齐时请同步 `backend/app/api/menu.py`。
|
||||
* 前端路由(控制台、报销管理、CRM 管理、工作流管理、系统管理)
|
||||
* 与后端菜单对齐时请同步 `backend/app/api/menu.py` 与 `sys_menu`(bx 见 docs/sql/20260606_bx_menu.sql)。
|
||||
*/
|
||||
export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
// ──────────────────────────────────────────────
|
||||
@@ -22,7 +22,157 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
},
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 2. CRM 管理
|
||||
// 2. 报销管理(bx)
|
||||
// ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'BX00000000000000000000000000001',
|
||||
name: 'BxManagement',
|
||||
path: '/bx',
|
||||
component: '/index/index',
|
||||
meta: {
|
||||
title: '报销管理',
|
||||
icon: 'ri:wallet-3-line',
|
||||
keepAlive: false,
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: 'BX00000000000000000000000000003',
|
||||
name: 'BxExpenseItem',
|
||||
path: 'config/expense-item',
|
||||
component: '/bx/expense-item/index',
|
||||
meta: {
|
||||
title: '费用项目管理',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:expenseItem:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000004',
|
||||
name: 'BxWorkflowAdvance',
|
||||
path: 'config/workflow-advance',
|
||||
component: '/bx/workflow/advance/index',
|
||||
meta: {
|
||||
title: '工作流配置(备用金)',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:workflowAdvance:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000005',
|
||||
name: 'BxWorkflowReimburse',
|
||||
path: 'config/workflow-reimburse',
|
||||
component: '/bx/workflow/reimburse/index',
|
||||
meta: {
|
||||
title: '工作流配置(报销单)',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:workflowReimburse:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000007',
|
||||
name: 'BxAdvanceApply',
|
||||
path: 'advance/apply',
|
||||
component: '/bx/advance/apply/index',
|
||||
meta: {
|
||||
title: '备用金申请',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:advanceApply:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000008',
|
||||
name: 'BxAdvanceApprove',
|
||||
path: 'advance/approve',
|
||||
component: '/bx/advance/approve/index',
|
||||
meta: {
|
||||
title: '备用金审批',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:advanceApprove:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000009',
|
||||
name: 'BxAdvanceIssue',
|
||||
path: 'advance/issue',
|
||||
component: '/bx/advance/issue/index',
|
||||
meta: {
|
||||
title: '备用金发放管理',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:advanceIssue:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000011',
|
||||
name: 'BxReimburseApply',
|
||||
path: 'reimburse/apply',
|
||||
component: '/bx/reimburse/apply/index',
|
||||
meta: {
|
||||
title: '报销申请',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:reimburseApply:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000012',
|
||||
name: 'BxReimburseApprove',
|
||||
path: 'reimburse/approve',
|
||||
component: '/bx/reimburse/approve/index',
|
||||
meta: {
|
||||
title: '报销审批',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:reimburseApprove:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000013',
|
||||
name: 'BxPayment',
|
||||
path: 'reimburse/payment',
|
||||
component: '/bx/payment/index',
|
||||
meta: {
|
||||
title: '支付管理(发放/冲抵)',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:payment:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000015',
|
||||
name: 'BxViewMine',
|
||||
path: 'view/mine',
|
||||
component: '/bx/view/mine/index',
|
||||
meta: {
|
||||
title: '我的申请单',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:viewMine:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000016',
|
||||
name: 'BxViewTodo',
|
||||
path: 'view/todo',
|
||||
component: '/bx/view/todo/index',
|
||||
meta: {
|
||||
title: '待我审批',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:viewTodo:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000017',
|
||||
name: 'BxViewAll',
|
||||
path: 'view/all',
|
||||
component: '/bx/view/all/index',
|
||||
meta: {
|
||||
title: '全部申请单(总经理)',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:viewAll:list'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 3. CRM 管理
|
||||
// ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'CRM00000000000000000000000000001',
|
||||
@@ -276,7 +426,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
},
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 3. 工作流管理
|
||||
// 4. 工作流管理
|
||||
// ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'WKF00000000000000000000000000001',
|
||||
@@ -350,7 +500,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
},
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 4. 系统管理
|
||||
// 5. 系统管理
|
||||
// ──────────────────────────────────────────────
|
||||
{
|
||||
id: 'SYSM000000000000000000000000000001',
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
.attachment-upload {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.attachment-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.upload-card {
|
||||
width: 140px;
|
||||
height: 96px;
|
||||
border: 1px dashed #a7f3d0;
|
||||
border-radius: 8px;
|
||||
background: #f0fdf4;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: #10b981;
|
||||
border-style: solid;
|
||||
background: #ecfdf5;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-card-text {
|
||||
font-size: 12px;
|
||||
color: #10b981;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: #94a3b8;
|
||||
margin-top: 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.attachment-item {
|
||||
width: 140px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
|
||||
&.is-uploading {
|
||||
opacity: 0.6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #10b981;
|
||||
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-preview {
|
||||
width: 100%;
|
||||
height: 96px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f8fafc;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-preview__icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&--video {
|
||||
background: #ede9fe;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
&--doc {
|
||||
background: #e0f2fe;
|
||||
color: #0284c7;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.attachment-name {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
font-size: 11px;
|
||||
color: #334155;
|
||||
line-height: 1.4;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.attachment-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 4px;
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #10b981;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--danger:hover {
|
||||
background: #ef4444;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.bx-attachment-preview-media {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 70vh;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.attachment-upload :deep(.el-upload) {
|
||||
display: block;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,103 @@
|
||||
import { attachmentApi, type BxId } from '@/api/bx'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
export type BxAttachmentItem = {
|
||||
id: number | string
|
||||
fileName: string
|
||||
fileType?: string
|
||||
fileSize?: number
|
||||
previewUrl?: string
|
||||
_uploading?: boolean
|
||||
_existing?: boolean
|
||||
}
|
||||
|
||||
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp|svg)$/i
|
||||
const VIDEO_EXT = /\.(mp4|webm|ogg|mov|avi)$/i
|
||||
|
||||
export function isBxImageFile(file: { fileName?: string; fileType?: string }) {
|
||||
const name = String(file.fileName || '').toLowerCase()
|
||||
const type = String(file.fileType || '').toLowerCase()
|
||||
return type.startsWith('image/') || IMAGE_EXT.test(name)
|
||||
}
|
||||
|
||||
export function isBxVideoFile(file: { fileName?: string; fileType?: string }) {
|
||||
const name = String(file.fileName || '').toLowerCase()
|
||||
const type = String(file.fileType || '').toLowerCase()
|
||||
return type.startsWith('video/') || VIDEO_EXT.test(name)
|
||||
}
|
||||
|
||||
export function canBxPreview(file: BxAttachmentItem) {
|
||||
if (file._uploading) return false
|
||||
return isBxImageFile(file) || isBxVideoFile(file)
|
||||
}
|
||||
|
||||
export async function fillBxAttachmentPreviews(files: BxAttachmentItem[]) {
|
||||
const tasks = files
|
||||
.filter((file) => isBxImageFile(file) && !file.previewUrl)
|
||||
.map(async (file) => {
|
||||
try {
|
||||
const res: any = await attachmentApi.preview(file.id)
|
||||
file.previewUrl = res.data?.url || ''
|
||||
} catch {
|
||||
/* preview optional */
|
||||
}
|
||||
})
|
||||
await Promise.all(tasks)
|
||||
}
|
||||
|
||||
export async function loadBxAttachments(bizType: string, bizId: BxId): Promise<BxAttachmentItem[]> {
|
||||
const res: any = await attachmentApi.listByBiz(bizType, bizId)
|
||||
const files: BxAttachmentItem[] = (res.data || []).map((item: any) => ({
|
||||
id: item.id,
|
||||
fileName: item.fileName,
|
||||
fileType: item.fileType || '',
|
||||
fileSize: item.fileSize,
|
||||
previewUrl: '',
|
||||
_existing: true
|
||||
}))
|
||||
await fillBxAttachmentPreviews(files)
|
||||
return files
|
||||
}
|
||||
|
||||
export async function downloadBxAttachment(file: { id: number | string; fileName: string }) {
|
||||
try {
|
||||
const res: any = await attachmentApi.download(file.id)
|
||||
const blob = new Blob([res], { type: 'application/octet-stream' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = url
|
||||
anchor.download = file.fileName
|
||||
anchor.click()
|
||||
URL.revokeObjectURL(url)
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '下载失败')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export async function previewBxAttachment(file: BxAttachmentItem) {
|
||||
if (isBxVideoFile(file)) {
|
||||
try {
|
||||
const res: any = await attachmentApi.preview(file.id)
|
||||
return { type: 'video' as const, url: res.data?.url || '', fileName: file.fileName }
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '预览失败')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
if (isBxImageFile(file)) {
|
||||
if (file.previewUrl) {
|
||||
return { type: 'image' as const, url: file.previewUrl, fileName: file.fileName }
|
||||
}
|
||||
try {
|
||||
const res: any = await attachmentApi.preview(file.id)
|
||||
file.previewUrl = res.data?.url || ''
|
||||
return { type: 'image' as const, url: file.previewUrl, fileName: file.fileName }
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.message || '预览失败')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
await downloadBxAttachment(file)
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
|
||||
/** 递归收集树上已有项目编码(含子节点) */
|
||||
export function flattenExpenseItemCodes(nodes: unknown[]): string[] {
|
||||
const out: string[] = []
|
||||
const walk = (arr: unknown[]) => {
|
||||
for (const n of arr) {
|
||||
const row = n as { itemCode?: string; children?: unknown[] }
|
||||
if (row.itemCode != null && String(row.itemCode).trim() !== '') {
|
||||
out.push(String(row.itemCode).trim())
|
||||
}
|
||||
if (Array.isArray(row.children) && row.children.length) {
|
||||
walk(row.children)
|
||||
}
|
||||
}
|
||||
}
|
||||
walk(nodes)
|
||||
return out
|
||||
}
|
||||
|
||||
/** 项目名称 → 拼音首字母缩写(大写、字母数字) */
|
||||
export function itemNameToCodeBase(name: string): string {
|
||||
const s = name.trim()
|
||||
if (!s) return ''
|
||||
const py = pinyin(s, {
|
||||
pattern: 'first',
|
||||
toneType: 'none',
|
||||
type: 'string',
|
||||
separator: ''
|
||||
})
|
||||
return py
|
||||
.toUpperCase()
|
||||
.replace(/[^A-Z0-9]/g, '')
|
||||
.slice(0, 32)
|
||||
}
|
||||
|
||||
/** 在已有编码集合中分配不重复编码:优先 base,冲突则 base01、base02… */
|
||||
export function allocateItemCode(base: string, existingCodes: string[]): string {
|
||||
const upperExisting = new Set(existingCodes.map((c) => c.toUpperCase()))
|
||||
let b = base.toUpperCase().replace(/[^A-Z0-9]/g, '')
|
||||
if (!b) b = 'XM'
|
||||
if (!upperExisting.has(b)) return b
|
||||
for (let n = 1; n <= 999; n++) {
|
||||
const candidate = `${b}${String(n).padStart(2, '0')}`
|
||||
if (!upperExisting.has(candidate)) return candidate
|
||||
}
|
||||
return `${b}${Date.now().toString().slice(-6)}`
|
||||
}
|
||||
|
||||
/** 根据当前费用项目树生成建议的项目编码 */
|
||||
export function suggestExpenseItemCode(itemName: string, treeNodes: unknown[]): string {
|
||||
if (!itemName.trim()) return ''
|
||||
const base = itemNameToCodeBase(itemName)
|
||||
const existing = flattenExpenseItemCodes(treeNodes)
|
||||
return allocateItemCode(base || 'XM', existing)
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
export function statusLabel(status: number | string | null | undefined): string {
|
||||
if (status == null) return '-'
|
||||
const map: Record<string | number, string> = {
|
||||
1: '启用',
|
||||
0: '禁用',
|
||||
draft: '待提交',
|
||||
pending: '审批中',
|
||||
approved: '审批通过',
|
||||
rejected: '审批驳回',
|
||||
issued: '已发放',
|
||||
paid: '已发放',
|
||||
offset: '已冲抵',
|
||||
processed: '已处理',
|
||||
}
|
||||
return map[status] ?? String(status)
|
||||
}
|
||||
|
||||
export function statusTone(status: number | string | null | undefined): string {
|
||||
if (status == null) return 'info'
|
||||
const map: Record<string | number, string> = {
|
||||
1: 'done',
|
||||
0: 'info',
|
||||
draft: 'info',
|
||||
pending: 'warning',
|
||||
approved: 'done',
|
||||
rejected: 'error',
|
||||
issued: 'done',
|
||||
paid: 'done',
|
||||
offset: 'done',
|
||||
processed: 'done',
|
||||
}
|
||||
return map[status] ?? 'info'
|
||||
}
|
||||
|
||||
/** bx 状态 → Element Plus Tag type(对齐 OpenSpec 语义色) */
|
||||
export function statusTagType(
|
||||
status: number | string | null | undefined
|
||||
): 'success' | 'warning' | 'danger' | 'info' | 'primary' {
|
||||
const tone = statusTone(status)
|
||||
const map: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
|
||||
done: 'success',
|
||||
error: 'danger',
|
||||
warning: 'warning',
|
||||
info: 'info',
|
||||
processing: 'primary',
|
||||
}
|
||||
return map[tone] ?? 'info'
|
||||
}
|
||||
|
||||
export function menuTypeLabel(type: number): string {
|
||||
const map: Record<number, string> = { 1: '目录', 2: '菜单', 3: '按钮' }
|
||||
return map[type] ?? String(type)
|
||||
}
|
||||
|
||||
function formatMoneyNumber(value: unknown): string {
|
||||
const n = Number(value)
|
||||
if (!Number.isFinite(n)) return '0.00'
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
}
|
||||
|
||||
/** 金额展示:¥ + 固定两位小数(500 → ¥500.00) */
|
||||
export function formatMoney(value: unknown): string {
|
||||
return `¥${formatMoneyNumber(value)}`
|
||||
}
|
||||
|
||||
/** 带 ¥ 前缀的金额展示(与 formatMoney 一致,保留别名便于语义区分) */
|
||||
export function formatMoneyYuan(value: unknown): string {
|
||||
return formatMoney(value)
|
||||
}
|
||||
|
||||
/** 列表合计行金额展示 */
|
||||
export function formatSumMoney(n: number): string {
|
||||
return formatMoney(n)
|
||||
}
|
||||
|
||||
/** el-table-column 金额列 formatter */
|
||||
export function moneyTableFormatter(_row: unknown, _column: unknown, cellValue: unknown): string {
|
||||
return formatMoney(cellValue)
|
||||
}
|
||||
|
||||
/** 列表「当前节点」是否有可展示文案(空/null/空白串视为无) */
|
||||
export function hasWorkflowNode(value: unknown): boolean {
|
||||
if (value == null) return false
|
||||
return String(value).trim() !== ''
|
||||
}
|
||||
|
||||
const DRAFT_STATUS_SET = new Set(['draft', '待提交', '未提交'])
|
||||
const COMPLETED_NODE_STATUS_SET = new Set([
|
||||
'approved',
|
||||
'issued',
|
||||
'paid',
|
||||
'offset',
|
||||
'processed',
|
||||
'审批通过',
|
||||
'已发放',
|
||||
'已冲抵',
|
||||
'已处理',
|
||||
])
|
||||
|
||||
/** 当前节点展示文案:无节点名时按单据状态回退(如未提交、已完成) */
|
||||
export function workflowNodeLabel(currentNode: unknown, status: unknown): string | null {
|
||||
if (hasWorkflowNode(currentNode)) return String(currentNode).trim()
|
||||
const s = String(status ?? '').trim()
|
||||
if (!s) return null
|
||||
if (DRAFT_STATUS_SET.has(s)) return '未提交'
|
||||
if (COMPLETED_NODE_STATUS_SET.has(s)) return '已完成'
|
||||
if (s === 'rejected' || s === '审批驳回') return '已驳回'
|
||||
return null
|
||||
}
|
||||
|
||||
/** 当前节点标签语义色 */
|
||||
export function workflowNodeTone(currentNode: unknown, status: unknown): string {
|
||||
if (hasWorkflowNode(currentNode)) return statusTone(currentNode)
|
||||
const label = workflowNodeLabel(currentNode, status)
|
||||
if (label === '未提交') return 'info'
|
||||
if (label === '已完成') return 'done'
|
||||
if (label === '已驳回') return 'error'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
export function shouldShowWorkflowNodeTag(currentNode: unknown, status: unknown): boolean {
|
||||
return workflowNodeLabel(currentNode, status) != null
|
||||
}
|
||||
|
||||
/** 当前节点 → Element Plus Tag type */
|
||||
export function workflowNodeTagType(
|
||||
currentNode: unknown,
|
||||
status: unknown
|
||||
): 'success' | 'warning' | 'danger' | 'info' | 'primary' {
|
||||
const tone = workflowNodeTone(currentNode, status)
|
||||
const map: Record<string, 'success' | 'warning' | 'danger' | 'info' | 'primary'> = {
|
||||
done: 'success',
|
||||
error: 'danger',
|
||||
warning: 'warning',
|
||||
info: 'info',
|
||||
processing: 'primary',
|
||||
}
|
||||
return map[tone] ?? 'info'
|
||||
}
|
||||
|
||||
/** 详情键值区等纯文本展示 */
|
||||
export function workflowNodeDisplay(currentNode: unknown, status: unknown): string {
|
||||
return workflowNodeLabel(currentNode, status) ?? '-'
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* bx 报销模块 HTTP 客户端
|
||||
* 协议:code === 0、msg、data.rows(与门户 request code===200 分离)
|
||||
*/
|
||||
import axios, { type AxiosRequestConfig, type InternalAxiosRequestConfig } from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
export interface BxApiResponse<T = unknown> {
|
||||
code: number
|
||||
msg: string
|
||||
data?: T
|
||||
}
|
||||
|
||||
const bxAxios = axios.create({
|
||||
baseURL: '/api',
|
||||
timeout: 60000,
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
|
||||
bxAxios.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
||||
const token = useUserStore().accessToken
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
})
|
||||
|
||||
bxAxios.interceptors.response.use(
|
||||
async (res) => {
|
||||
if (res.config.responseType === 'blob') {
|
||||
const contentType = String(res.headers['content-type'] || '')
|
||||
if (contentType.includes('application/json')) {
|
||||
const text = await (res.data as Blob).text()
|
||||
try {
|
||||
const json = JSON.parse(text) as BxApiResponse
|
||||
if (json.code !== 0) {
|
||||
ElMessage.error(json.msg || '请求失败')
|
||||
return Promise.reject(new Error(json.msg))
|
||||
}
|
||||
} catch {
|
||||
/* 非 JSON blob 直出 */
|
||||
}
|
||||
}
|
||||
return res.data
|
||||
}
|
||||
|
||||
const body = res.data as BxApiResponse
|
||||
if (body?.code !== undefined && body.code !== 0) {
|
||||
ElMessage.error(body.msg || '请求失败')
|
||||
return Promise.reject(new Error(body.msg || '请求失败'))
|
||||
}
|
||||
return body
|
||||
},
|
||||
async (err) => {
|
||||
if (err.response?.status === 401) {
|
||||
const userStore = useUserStore()
|
||||
await userStore.logOut()
|
||||
} else {
|
||||
const detail = err.response?.data?.detail || err.response?.data?.msg
|
||||
ElMessage.error(detail || err.message || '网络异常')
|
||||
}
|
||||
return Promise.reject(err)
|
||||
}
|
||||
)
|
||||
|
||||
function request<T = unknown>(config: AxiosRequestConfig) {
|
||||
return bxAxios.request<any, BxApiResponse<T>>(config)
|
||||
}
|
||||
|
||||
const bxRequest = {
|
||||
get<T = unknown>(url: string, config?: AxiosRequestConfig) {
|
||||
return request<T>({ ...config, url, method: 'GET' })
|
||||
},
|
||||
post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig) {
|
||||
return request<T>({ ...config, url, method: 'POST', data })
|
||||
},
|
||||
put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig) {
|
||||
return request<T>({ ...config, url, method: 'PUT', data })
|
||||
},
|
||||
delete<T = unknown>(url: string, config?: AxiosRequestConfig) {
|
||||
return request<T>({ ...config, url, method: 'DELETE' })
|
||||
}
|
||||
}
|
||||
|
||||
export default bxRequest
|
||||
@@ -0,0 +1,802 @@
|
||||
<!-- 备用金申请 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">备用金申请列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请单号">
|
||||
<el-input v-model="filterForm.keyword" placeholder="请输入申请单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="filterForm.status" placeholder="全部" clearable>
|
||||
<el-option label="待提交" value="draft" />
|
||||
<el-option label="审批中" value="pending" />
|
||||
<el-option label="审批通过" value="approved" />
|
||||
<el-option label="审批驳回" value="rejected" />
|
||||
<el-option label="已发放" value="issued" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请金额区间(元)">
|
||||
<el-input v-model="filterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="showMoreFilters" id="advance-apply-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="当前节点">
|
||||
<el-select v-model="filterForm.currentNode" placeholder="全部" clearable>
|
||||
<el-option label="草稿" value="草稿" />
|
||||
<el-option label="发起人主管审批" value="发起人主管审批" />
|
||||
<el-option label="财务复核" value="财务复核" />
|
||||
<el-option label="总经理审批" value="总经理审批" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMoreFilters"
|
||||
aria-controls="advance-apply-filter-extra"
|
||||
@click="toggleMoreFilters"
|
||||
>
|
||||
{{ showMoreFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMoreFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="openAdd">
|
||||
<el-icon><Plus /></el-icon>新增备用金申请
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="handleToolbarEdit">
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.submit" @click="handleToolbarSubmit">
|
||||
<el-icon><Upload /></el-icon>提交审批
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="openFlowDialog()">
|
||||
<el-icon><View /></el-icon>查看审批流
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary advance-apply-summary-merge">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="summaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applicantName"
|
||||
label="申请人"
|
||||
min-width="100"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="reason"
|
||||
label="申请原因"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="实际发放金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
row.actualAmount != null && row.actualAmount !== ''
|
||||
? formatMoney(row.actualAmount)
|
||||
: '—'
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="冲抵总金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatMoney(row.offsetAmount || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="360" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
@click="openEdit(row)"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap[`submit_${row.id}`]"
|
||||
@click="handleSubmit(row)"
|
||||
>
|
||||
<el-icon><Upload /></el-icon>提交
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap[`del_${row.id}`]"
|
||||
@click="handleDelete(row)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.add"
|
||||
:title="editingId ? '编辑备用金申请' : '新增备用金申请'"
|
||||
width="720px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="dlg-note">提交后进入顺序审批流程,可在「查看审批流」中确认节点与审批人。</p>
|
||||
<el-form
|
||||
ref="addFormRef"
|
||||
:model="addForm"
|
||||
:rules="addFormRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="申请原因" prop="reason" style="grid-column: 1 / -1">
|
||||
<el-input v-model="addForm.reason" type="textarea" :rows="3" placeholder="请输入申请原因" />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请金额(元)" prop="amount" class="field-amount">
|
||||
<el-input v-model="addForm.amount" placeholder="请输入申请金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注说明" style="grid-column: 1 / -1">
|
||||
<el-input v-model="addForm.remark" type="textarea" :rows="4" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.add = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addSubmit" @click="submitAdd">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.view"
|
||||
title="备用金申请详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="statusTagType(viewData.status)" size="small">
|
||||
{{ statusLabel(viewData.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
申请金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ viewData.applicantName || '-' }}</div>
|
||||
<div class="k">申请原因</div>
|
||||
<div class="v"><BaseClampText :text="viewData.reason" /></div>
|
||||
<div class="k">实际发放金额(元)</div>
|
||||
<div class="v money-value">
|
||||
{{ viewData.actualAmount != null ? formatMoneyYuan(viewData.actualAmount) : '—' }}
|
||||
</div>
|
||||
<div class="k">申请金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(viewData.amount || 0) }}</div>
|
||||
<div class="k">冲抵总金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(viewData.offsetAmount || 0) }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(viewData.currentNode, viewData.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ viewData.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BaseDetailTableSection title="冲抵记录" :data="viewOffsetRecords" empty-text="暂无冲抵记录">
|
||||
<el-table class="list-table" :data="viewOffsetRecords" stripe size="small">
|
||||
<el-table-column
|
||||
prop="reimburseApplyCode"
|
||||
label="报销单号"
|
||||
min-width="130"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="reimburseApplicantName"
|
||||
label="报销申请人"
|
||||
min-width="110"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="reimburseTitle"
|
||||
label="报销标题"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="冲抵金额(元)"
|
||||
min-width="120"
|
||||
class-name="col-money"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row: offsetRow }">
|
||||
{{ formatMoneyYuan(offsetRow.offsetAmount || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="冲抵时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="operator" label="操作人" min-width="100" align="center" header-align="center" />
|
||||
</el-table>
|
||||
</BaseDetailTableSection>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.view = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.viewFlow"
|
||||
title="审批流程"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="flowNodes" :loading="flowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="flowHistory" :loading="flowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewFlow = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted, nextTick, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
EditPen,
|
||||
Upload,
|
||||
View,
|
||||
Close,
|
||||
Delete,
|
||||
Check,
|
||||
Search,
|
||||
RefreshLeft,
|
||||
ArrowUpBold,
|
||||
ArrowDownBold
|
||||
} from '@element-plus/icons-vue'
|
||||
import { advanceApi, paymentApi } from '@/api/bx'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatSumMoney,
|
||||
formatMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import BaseDetailTableSection from '@/components/bx/base/BaseDetailTableSection.vue'
|
||||
|
||||
type DialogKey = 'add' | 'view' | 'viewFlow'
|
||||
|
||||
const showMoreFilters = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
add: false,
|
||||
view: false,
|
||||
viewFlow: false
|
||||
})
|
||||
|
||||
const { rows, total, currentPage, pageSize, rangeText, loading, refresh, search, onSizeChange } =
|
||||
useServerPaged(async (params) => {
|
||||
const res: any = await advanceApi.my(params)
|
||||
return res.data
|
||||
})
|
||||
|
||||
const myAdvanceStats = ref({
|
||||
pendingCount: 0,
|
||||
monthApplyAmount: 0,
|
||||
issuedAmount: 0,
|
||||
offsetTotal: 0,
|
||||
pendingIssueCount: 0
|
||||
})
|
||||
|
||||
async function loadMyAdvanceStats() {
|
||||
try {
|
||||
const res: any = await advanceApi.myStats()
|
||||
const d = res.data || {}
|
||||
myAdvanceStats.value = {
|
||||
pendingCount: Number(d.pendingCount ?? 0),
|
||||
monthApplyAmount: Number(d.monthApplyAmount ?? 0),
|
||||
issuedAmount: Number(d.issuedAmount ?? 0),
|
||||
offsetTotal: Number(d.offsetTotal ?? 0),
|
||||
pendingIssueCount: Number(d.pendingIssueCount ?? 0)
|
||||
}
|
||||
} catch {
|
||||
/* 拦截器已提示 */
|
||||
}
|
||||
}
|
||||
|
||||
const stats = computed(() => {
|
||||
const s = myAdvanceStats.value
|
||||
return [
|
||||
{ name: '待审批申请', value: String(s.pendingCount) },
|
||||
{ name: '本月申请金额(元)', value: formatMoney(s.monthApplyAmount) },
|
||||
{ name: '已发放金额(元)', value: formatMoney(s.issuedAmount) },
|
||||
{ name: '累计已冲抵金额(元)', value: formatMoney(s.offsetTotal) },
|
||||
{ name: '待发放申请', value: String(s.pendingIssueCount) }
|
||||
]
|
||||
})
|
||||
|
||||
const filterForm = reactive({
|
||||
keyword: '',
|
||||
status: '',
|
||||
amountRange: '',
|
||||
applyDate: null as string | null,
|
||||
currentNode: ''
|
||||
})
|
||||
|
||||
const addForm = reactive({
|
||||
reason: '',
|
||||
amount: '',
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const addFormRules = {
|
||||
reason: [{ required: true, message: '请输入申请原因', trigger: 'blur' }],
|
||||
amount: [{ required: true, message: '请输入申请金额', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const addFormRef = ref<FormInstance>()
|
||||
const viewData = ref<Record<string, any>>({})
|
||||
const selectedRows = ref<any[]>([])
|
||||
const editingId = ref<number | null>(null)
|
||||
const flowNodes = ref<any[]>([])
|
||||
const flowHistory = ref<any[]>([])
|
||||
const flowLoading = ref(false)
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
const viewOffsetRecords = ref<any[]>([])
|
||||
|
||||
const ADVANCE_APPLY_SUMMARY_COLS = 11
|
||||
const ADVANCE_APPLY_SUMMARY_LABEL_COLSPAN = 4
|
||||
|
||||
function mergeAdvanceApplySummaryFooter() {
|
||||
nextTick(() => {
|
||||
const root = document.querySelector('.advance-apply-summary-merge .el-table__footer-wrapper')
|
||||
if (!root) return
|
||||
const tr = root.querySelector('tfoot tr') || root.querySelector('table tr')
|
||||
if (!tr) return
|
||||
const cells = Array.from(tr.querySelectorAll('td')) as HTMLTableCellElement[]
|
||||
if (cells.length !== ADVANCE_APPLY_SUMMARY_COLS) return
|
||||
const first = cells[0]
|
||||
if (first.colSpan === ADVANCE_APPLY_SUMMARY_LABEL_COLSPAN) return
|
||||
first.colSpan = ADVANCE_APPLY_SUMMARY_LABEL_COLSPAN
|
||||
for (let i = ADVANCE_APPLY_SUMMARY_LABEL_COLSPAN - 1; i >= 1; i--) {
|
||||
cells[i].remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
async function refreshListAndStats() {
|
||||
await refresh()
|
||||
await loadMyAdvanceStats()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshListAndStats()
|
||||
})
|
||||
|
||||
watch([rows, loading], () => mergeAdvanceApplySummaryFooter(), { flush: 'post' })
|
||||
|
||||
function toggleMoreFilters() {
|
||||
showMoreFilters.value = !showMoreFilters.value
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
const q: Record<string, string> = { keyword: filterForm.keyword, status: filterForm.status }
|
||||
if (filterForm.applyDate) q.applyDate = filterForm.applyDate
|
||||
search(q)
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, { keyword: '', status: '', amountRange: '', applyDate: null, currentNode: '' })
|
||||
search()
|
||||
}
|
||||
|
||||
function handleToolbarEdit() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要编辑的申请')
|
||||
return
|
||||
}
|
||||
const row = selectedRows.value[0]
|
||||
if (row.status !== 'draft' && row.status !== 'rejected') {
|
||||
ElMessage.warning('仅草稿或已驳回的申请可编辑')
|
||||
return
|
||||
}
|
||||
openEdit(row)
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
Object.assign(addForm, { reason: '', amount: '', remark: '' })
|
||||
editingId.value = null
|
||||
dialogs.add = true
|
||||
}
|
||||
|
||||
async function openEdit(row: any) {
|
||||
try {
|
||||
const res: any = await advanceApi.getById(row.id)
|
||||
const data = res.data || res
|
||||
Object.assign(addForm, {
|
||||
reason: data.reason || '',
|
||||
amount: data.amount ?? '',
|
||||
remark: data.remark || ''
|
||||
})
|
||||
editingId.value = row.id
|
||||
dialogs.add = true
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToolbarSubmit() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要提交的申请')
|
||||
return
|
||||
}
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
await advanceApi.submit(row.id)
|
||||
}
|
||||
ElMessage.success('提交成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitAdd() {
|
||||
const valid = await addFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
const amountNum = Number(String(addForm.amount ?? '').trim())
|
||||
if (Number.isNaN(amountNum) || amountNum <= 0) {
|
||||
ElMessage.warning('请输入大于 0 的申请金额')
|
||||
return
|
||||
}
|
||||
loadingMap.addSubmit = true
|
||||
try {
|
||||
const reason = addForm.reason?.trim() ?? ''
|
||||
if (editingId.value) {
|
||||
await advanceApi.update(editingId.value, {
|
||||
reason,
|
||||
amount: amountNum,
|
||||
remark: addForm.remark || undefined
|
||||
})
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
await advanceApi.create({
|
||||
reason,
|
||||
amount: amountNum,
|
||||
remark: addForm.remark || undefined
|
||||
})
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
dialogs.add = false
|
||||
Object.assign(addForm, { reason: '', amount: '', remark: '' })
|
||||
editingId.value = null
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || (editingId.value ? '保存失败' : '新增失败'))
|
||||
} finally {
|
||||
loadingMap.addSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openView(row: any) {
|
||||
try {
|
||||
const res = await advanceApi.getById(row.id)
|
||||
viewData.value = res.data || res
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewOffsetRecords.value = []
|
||||
dialogs.view = true
|
||||
viewFlowLoading.value = true
|
||||
try {
|
||||
const [flowRes, historyRes, offsetRes]: any[] = await Promise.all([
|
||||
advanceApi.getApprovals(row.id),
|
||||
advanceApi.getApprovalHistory(row.id),
|
||||
paymentApi.advanceOffsetRecords(row.id).catch(() => ({ data: [] }))
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
viewOffsetRecords.value = offsetRes.data || []
|
||||
} catch {
|
||||
// ignore flow fetch error in view
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function openFlowDialog(row?: any) {
|
||||
const target = row || selectedRows.value[0]
|
||||
if (!target) {
|
||||
ElMessage.warning('请先选择一条申请记录')
|
||||
return
|
||||
}
|
||||
flowNodes.value = []
|
||||
flowHistory.value = []
|
||||
flowLoading.value = true
|
||||
dialogs.viewFlow = true
|
||||
try {
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
advanceApi.getApprovals(target.id),
|
||||
advanceApi.getApprovalHistory(target.id)
|
||||
])
|
||||
flowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
flowHistory.value = historyRes.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载审批流程失败')
|
||||
} finally {
|
||||
flowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit(row: any) {
|
||||
loadingMap[`submit_${row.id}`] = true
|
||||
try {
|
||||
await advanceApi.submit(row.id)
|
||||
ElMessage.success('提交成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`submit_${row.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该申请单吗?删除后不可恢复。', '删除确认', {
|
||||
confirmButtonText: '确定删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
loadingMap[`del_${row.id}`] = true
|
||||
await advanceApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
ElMessage.error(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[`del_${row.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
function summaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const totalApply = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const totalActual = data.reduce((s, r) => {
|
||||
if (r.actualAmount != null && r.actualAmount !== '') return s + Number(r.actualAmount)
|
||||
return s
|
||||
}, 0)
|
||||
const totalOffset = data.reduce((s, r) => s + Number(r.offsetAmount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return [
|
||||
lbl,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
formatSumMoney(totalApply),
|
||||
formatSumMoney(totalActual),
|
||||
formatSumMoney(totalOffset),
|
||||
'',
|
||||
''
|
||||
]
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,653 @@
|
||||
<!-- 备用金审批 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">备用金审批</h2>
|
||||
</div>
|
||||
|
||||
<div class="panel-tabs">
|
||||
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
|
||||
<!-- 待我审批 -->
|
||||
<el-tab-pane label="待我审批" name="pending">
|
||||
<div class="filter-block">
|
||||
<el-form :model="pendingFilterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请单号">
|
||||
<el-input v-model="pendingFilterForm.code" placeholder="请输入申请单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="pendingFilterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="pendingFilterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">按申请单号、申请人、申请时间筛选待审批单据。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="pendingLoading" @click="handlePendingReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="pendingLoading" @click="handlePendingSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleBatchApprove">
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="handleBatchReject">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="pendingRows"
|
||||
v-loading="pendingLoading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="pendingSummaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="reason"
|
||||
label="申请原因"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openApproveDialog([row], 'approve')">
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openApproveDialog([row], 'reject')">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ pendingRangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="pendingPage"
|
||||
v-model:page-size="pendingPageSize"
|
||||
:total="pendingTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onPendingSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 我已审批 -->
|
||||
<el-tab-pane label="我已审批" name="approved">
|
||||
<div class="filter-block">
|
||||
<el-form :model="approvedFilterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请单号">
|
||||
<el-input v-model="approvedFilterForm.code" placeholder="请输入申请单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="approvedFilterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="approvedFilterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">查询本人已审批的备用金申请记录。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="approvedLoading" @click="handleApprovedReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="approvedLoading" @click="handleApprovedSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="approvedRows"
|
||||
v-loading="approvedLoading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="approvedSummaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="reason"
|
||||
label="申请原因"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ approvedRangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="approvedPage"
|
||||
v-model:page-size="approvedPageSize"
|
||||
:total="approvedTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onApprovedSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 详情 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.view"
|
||||
title="备用金申请详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="statusTagType(viewData.status)" size="small">
|
||||
{{ statusLabel(viewData.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
申请金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ viewData.applicantName || '-' }}</div>
|
||||
<div class="k">申请原因</div>
|
||||
<div class="v"><BaseClampText :text="viewData.reason" /></div>
|
||||
<div class="k">申请金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(viewData.amount || 0) }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(viewData.currentNode, viewData.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ viewData.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4>审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4>审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.view = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 审批确认 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.approve"
|
||||
:title="approveAction === 'approve' ? '审批通过确认' : '审批驳回确认'"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="审批时间">
|
||||
<el-input :model-value="approveTime" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批数量">
|
||||
<el-input :model-value="`${approveRows.length} 条`" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批意见" style="grid-column: 1 / -1">
|
||||
<el-input v-model="approvalOpinion" type="textarea" :rows="4" placeholder="请输入审批意见" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.approve = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
:type="approveAction === 'approve' ? 'primary' : 'danger'"
|
||||
:loading="loadingMap[approveAction === 'approve' ? 'approvePass' : 'approveReject']"
|
||||
@click="handleConfirmApprove"
|
||||
>
|
||||
<el-icon><Check /></el-icon>
|
||||
{{ approveAction === 'approve' ? '确认通过' : '确认驳回' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Close, View, Search, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import { advanceApi } from '@/api/bx'
|
||||
import { advanceApproverStats, refreshApproveMenuBadges } from '@/hooks/bx/useApproveMenuBadge'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatSumMoney,
|
||||
formatMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
|
||||
type DialogKey = 'view' | 'approve'
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
view: false,
|
||||
approve: false
|
||||
})
|
||||
|
||||
const {
|
||||
rows: pendingRows,
|
||||
total: pendingTotal,
|
||||
currentPage: pendingPage,
|
||||
pageSize: pendingPageSize,
|
||||
rangeText: pendingRangeText,
|
||||
loading: pendingLoading,
|
||||
refresh: refreshPending,
|
||||
search: searchPending,
|
||||
onSizeChange: onPendingSizeChange
|
||||
} = useServerPaged(async (params) => {
|
||||
const res: any = await advanceApi.pendingApproval(params)
|
||||
return res.data
|
||||
})
|
||||
|
||||
const {
|
||||
rows: approvedRows,
|
||||
total: approvedTotal,
|
||||
currentPage: approvedPage,
|
||||
pageSize: approvedPageSize,
|
||||
rangeText: approvedRangeText,
|
||||
loading: approvedLoading,
|
||||
search: searchApproved,
|
||||
onSizeChange: onApprovedSizeChange
|
||||
} = useServerPaged(async (params) => {
|
||||
const res: any = await advanceApi.approvedByMe(params)
|
||||
return res.data
|
||||
})
|
||||
|
||||
const tabLoaded = reactive({ pending: false, approved: false })
|
||||
const activeTab = ref('pending')
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
const stats = computed(() => {
|
||||
const s = advanceApproverStats.value
|
||||
return [
|
||||
{ name: '待审批', value: String(s.pendingTotal) },
|
||||
{ name: '本月审批金额(元)', value: formatMoney(s.monthPendingAmount) }
|
||||
]
|
||||
})
|
||||
|
||||
const viewData = ref<Record<string, any>>({})
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
|
||||
const approveAction = ref<'approve' | 'reject'>('approve')
|
||||
const approveRows = ref<any[]>([])
|
||||
const approvalOpinion = ref('')
|
||||
const approveTime = ref('')
|
||||
|
||||
function formatNow() {
|
||||
const d = new Date()
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
||||
}
|
||||
|
||||
function openApproveDialog(rows: any[], action: 'approve' | 'reject') {
|
||||
approveRows.value = rows
|
||||
approveAction.value = action
|
||||
approvalOpinion.value = action === 'approve' ? '审批通过' : '审批驳回'
|
||||
approveTime.value = formatNow()
|
||||
dialogs.approve = true
|
||||
}
|
||||
|
||||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||||
|
||||
const pendingFilterForm = reactive({
|
||||
code: '',
|
||||
applicantId: undefined as number | undefined,
|
||||
applyDate: null as string | null
|
||||
})
|
||||
|
||||
const approvedFilterForm = reactive({
|
||||
code: '',
|
||||
applicantId: undefined as number | undefined,
|
||||
applyDate: null as string | null
|
||||
})
|
||||
|
||||
function buildPendingQuery() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const code = pendingFilterForm.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (pendingFilterForm.applicantId != null) q.applicantId = pendingFilterForm.applicantId
|
||||
if (pendingFilterForm.applyDate) q.applyDate = pendingFilterForm.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
function buildApprovedQuery() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const code = approvedFilterForm.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (approvedFilterForm.applicantId != null) q.applicantId = approvedFilterForm.applicantId
|
||||
if (approvedFilterForm.applyDate) q.applyDate = approvedFilterForm.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
loadApplicantOptions()
|
||||
await refreshApproveMenuBadges(menuStore.menuList)
|
||||
searchPending()
|
||||
tabLoaded.pending = true
|
||||
})
|
||||
|
||||
function handlePendingSearch() {
|
||||
searchPending(buildPendingQuery())
|
||||
}
|
||||
|
||||
function handlePendingReset() {
|
||||
Object.assign(pendingFilterForm, { code: '', applicantId: undefined, applyDate: null })
|
||||
searchPending()
|
||||
}
|
||||
|
||||
function handleApprovedSearch() {
|
||||
searchApproved(buildApprovedQuery())
|
||||
}
|
||||
|
||||
function handleApprovedReset() {
|
||||
Object.assign(approvedFilterForm, { code: '', applicantId: undefined, applyDate: null })
|
||||
searchApproved()
|
||||
}
|
||||
|
||||
function handleTabChange(tab: string | number) {
|
||||
if (tab === 'pending' && !tabLoaded.pending) {
|
||||
searchPending()
|
||||
tabLoaded.pending = true
|
||||
}
|
||||
if (tab === 'approved' && !tabLoaded.approved) {
|
||||
searchApproved()
|
||||
tabLoaded.approved = true
|
||||
}
|
||||
}
|
||||
|
||||
const selectedRows = ref<any[]>([])
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
function handleBatchApprove() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要审批的申请')
|
||||
return
|
||||
}
|
||||
openApproveDialog([...selectedRows.value], 'approve')
|
||||
}
|
||||
|
||||
function handleBatchReject() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要驳回的申请')
|
||||
return
|
||||
}
|
||||
openApproveDialog([...selectedRows.value], 'reject')
|
||||
}
|
||||
|
||||
async function openView(row: any) {
|
||||
try {
|
||||
const res = await advanceApi.getById(row.id)
|
||||
viewData.value = res.data || res
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
dialogs.view = true
|
||||
viewFlowLoading.value = true
|
||||
try {
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
advanceApi.getApprovals(row.id),
|
||||
advanceApi.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch {
|
||||
// ignore flow fetch error
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
function pendingSummaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const t = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return ['', '', '', lbl, '', '', formatSumMoney(t), '', '', '']
|
||||
}
|
||||
|
||||
function approvedSummaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const t = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return ['', '', '', lbl, '', formatSumMoney(t), '', '', '', '']
|
||||
}
|
||||
|
||||
async function handleConfirmApprove() {
|
||||
const key = approveAction.value === 'approve' ? 'approvePass' : 'approveReject'
|
||||
loadingMap[key] = true
|
||||
const apiFn = approveAction.value === 'approve' ? advanceApi.approve : advanceApi.reject
|
||||
const msg = approveAction.value === 'approve' ? '审批通过成功' : '驳回成功'
|
||||
try {
|
||||
for (const row of approveRows.value) {
|
||||
await apiFn(row.id, { approvalOpinion: approvalOpinion.value })
|
||||
}
|
||||
ElMessage.success(approveRows.value.length > 1 ? `批量${msg}` : msg)
|
||||
dialogs.approve = false
|
||||
await refreshPending()
|
||||
await refreshApproveMenuBadges(menuStore.menuList)
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,718 @@
|
||||
<!-- 备用金发放 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">备用金发放</h2>
|
||||
</div>
|
||||
|
||||
<div class="panel-tabs">
|
||||
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
|
||||
<el-tab-pane label="待发放" name="pending">
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请单号">
|
||||
<el-input v-model="filterForm.keyword" placeholder="请输入申请单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="filterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">审批通过后由财务人员操作标记发放并上传发放截图。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleToolbarIssue">
|
||||
<el-icon><Check /></el-icon>发放
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.export" @click="handleExport">
|
||||
<el-icon><Download /></el-icon>导出
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="advanceIssueSummary"
|
||||
:max-height="'min(520px, calc(100vh - 360px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="reason"
|
||||
label="申请原因"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="实际发放金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
row.actualAmount != null && row.actualAmount !== ''
|
||||
? formatSumMoney(Number(row.actualAmount))
|
||||
: '—'
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="冲抵总金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatSumMoney(Number(row.offsetAmount ?? 0)) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="approveTime"
|
||||
label="审批通过时间"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openIssueDialog(row)">
|
||||
<el-icon><Check /></el-icon>标记发放
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="已发放" name="issued">
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请单号">
|
||||
<el-input v-model="filterForm.keyword" placeholder="请输入申请单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="filterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">查询已完成发放的备用金申请记录。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<el-button class="btn-ghost" :loading="loadingMap.export" @click="handleExport">
|
||||
<el-icon><Download /></el-icon>导出
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="advanceIssueSummary"
|
||||
:max-height="'min(520px, calc(100vh - 360px))'"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="reason"
|
||||
label="申请原因"
|
||||
min-width="160"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
label="实际发放金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
row.actualAmount != null && row.actualAmount !== ''
|
||||
? formatSumMoney(Number(row.actualAmount))
|
||||
: '—'
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="冲抵总金额(元)"
|
||||
class-name="col-money"
|
||||
min-width="130"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ formatSumMoney(Number(row.offsetAmount ?? 0)) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="issueTime" label="发放时间" min-width="140" align="center" header-align="center" />
|
||||
<el-table-column prop="issueUserName" label="发放操作人" min-width="110" align="center" header-align="center" />
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 标记发放 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.issue"
|
||||
title="标记已发放"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="发放金额(元)" class="field-amount">
|
||||
<el-input :model-value="String(currentRow.amount || '')" disabled placeholder="发放金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="实际发放金额(元)" class="field-amount">
|
||||
<el-input v-model="actualAmount" placeholder="请输入实际发放金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发放备注" style="grid-column: 1 / -1">
|
||||
<el-input v-model="issueRemark" type="textarea" :rows="3" placeholder="请输入发放备注" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<div class="form-section form-section-last">
|
||||
<h4>发放附件(必填)</h4>
|
||||
<BxAttachmentUpload
|
||||
ref="issueAttachmentRef"
|
||||
v-model="uploadedFiles"
|
||||
biz-type="advance_issue"
|
||||
:biz-id="currentRow.id"
|
||||
hint="支持上传发放截图等凭证,至少 1 个附件。"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.issue = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.issueSubmit" @click="submitIssue">
|
||||
<el-icon><Check /></el-icon>确认发放
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 查看详情 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.view"
|
||||
title="备用金发放详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="issueStatusTagType(viewData.issueStatus)" size="small">
|
||||
{{ issueStatusLabel(viewData.issueStatus) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
申请金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||||
<template v-if="viewData.actualAmount != null">
|
||||
实际发放金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.actualAmount) }}</b>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">申请信息</h4>
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ viewData.applicantName || '-' }}</div>
|
||||
<div class="k">申请原因</div>
|
||||
<div class="v"><BaseClampText :text="viewData.reason" /></div>
|
||||
<div class="k">审批通过时间</div>
|
||||
<div class="v">{{ viewData.approveTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="viewData.issueStatus === 'issued'" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">发放信息</h4>
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">发放时间</div>
|
||||
<div class="v">{{ viewData.issueTime || '-' }}</div>
|
||||
<div class="k">发放操作人</div>
|
||||
<div class="v">{{ viewData.issueUserName || '-' }}</div>
|
||||
<div class="k">发放备注</div>
|
||||
<div class="v"><BaseClampText :text="viewData.issueRemark" /></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BaseDetailTableSection title="冲抵流水" :data="offsetRecords" empty-text="暂无冲抵记录">
|
||||
<el-table class="list-table" :data="offsetRecords" stripe size="small">
|
||||
<el-table-column prop="reimburseApplyCode" label="报销单号" min-width="130" align="center" header-align="center" />
|
||||
<el-table-column prop="reimburseApplicantName" label="报销申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column label="冲抵金额(元)" min-width="120" class-name="col-money" align="right" header-align="center">
|
||||
<template #default="{ row: offsetRow }">
|
||||
{{ formatMoney(offsetRow.offsetAmount || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="冲抵时间" min-width="160" align="center" header-align="center" />
|
||||
<el-table-column prop="operator" label="操作人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column prop="remark" label="备注" min-width="140" align="left" header-align="center" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</BaseDetailTableSection>
|
||||
|
||||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">发放附件</h4>
|
||||
<BxAttachmentReadonly :files="viewAttachments" />
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="approvalNodes" :loading="approvalLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="approvalHistory" :loading="approvalLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.view = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Download, View, Close, Search, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import { paymentApi, advanceApi } from '@/api/bx'
|
||||
import { type BxAttachmentItem, loadBxAttachments } from '@/utils/bx/attachment'
|
||||
import { formatSumMoney, formatMoney, formatMoneyYuan, moneyTableFormatter } from '@/utils/bx/format'
|
||||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import BaseDetailTableSection from '@/components/bx/base/BaseDetailTableSection.vue'
|
||||
import BxAttachmentUpload from '@/components/bx/base/BxAttachmentUpload.vue'
|
||||
import BxAttachmentReadonly from '@/components/bx/base/BxAttachmentReadonly.vue'
|
||||
|
||||
type DialogKey = 'issue' | 'view'
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
issue: false,
|
||||
view: false
|
||||
})
|
||||
|
||||
const activeTab = ref('pending')
|
||||
|
||||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||||
|
||||
const filterForm = reactive({
|
||||
keyword: '',
|
||||
applicantId: undefined as number | undefined,
|
||||
applyDate: null as string | null
|
||||
})
|
||||
|
||||
const { rows, total, currentPage, pageSize, rangeText, loading, refresh, search, onSizeChange } = useServerPaged(
|
||||
async (params) => {
|
||||
const issueStatus = activeTab.value === 'pending' ? 'pending' : 'issued'
|
||||
const res: any = await paymentApi.advanceIssues({ ...params, issueStatus })
|
||||
const data = res.data
|
||||
if (Array.isArray(data)) {
|
||||
return { rows: data, total: data.length }
|
||||
}
|
||||
return { rows: data?.rows ?? [], total: data?.total ?? 0 }
|
||||
}
|
||||
)
|
||||
|
||||
const stats = ref([
|
||||
{ name: '待发放', value: '-' },
|
||||
{ name: '已发放', value: '-' },
|
||||
{ name: '本月发放金额(元)', value: '-' },
|
||||
{ name: '待发放金额(元)', value: '-' }
|
||||
])
|
||||
|
||||
async function loadAdvanceIssueStats() {
|
||||
try {
|
||||
const res: any = await paymentApi.advanceIssueStats()
|
||||
const d = res.data
|
||||
if (!d) return
|
||||
stats.value = [
|
||||
{ name: '待发放', value: String(d.pendingCount ?? 0) },
|
||||
{ name: '已发放', value: String(d.issuedCount ?? 0) },
|
||||
{ name: '本月发放金额(元)', value: formatMoney(d.issuedMonthAmount ?? 0) },
|
||||
{ name: '待发放金额(元)', value: formatMoney(d.pendingAmount ?? 0) }
|
||||
]
|
||||
} catch {
|
||||
/* interceptor */
|
||||
}
|
||||
}
|
||||
|
||||
const currentRow = ref<Record<string, any>>({})
|
||||
const selectedRows = ref<any[]>([])
|
||||
const issueRemark = ref('')
|
||||
const viewData = ref<Record<string, any>>({})
|
||||
|
||||
const actualAmount = ref<number | string>('')
|
||||
const uploadedFiles = ref<BxAttachmentItem[]>([])
|
||||
const issueAttachmentRef = ref<InstanceType<typeof BxAttachmentUpload> | null>(null)
|
||||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||||
const approvalNodes = ref<Array<any>>([])
|
||||
const approvalHistory = ref<Array<any>>([])
|
||||
const approvalLoading = ref(false)
|
||||
const offsetRecords = ref<Array<any>>([])
|
||||
|
||||
function issueStatusLabel(status: string) {
|
||||
return status === 'issued' ? '已发放' : '待发放'
|
||||
}
|
||||
|
||||
function issueStatusTagType(status: string): 'success' | 'warning' {
|
||||
return status === 'issued' ? 'success' : 'warning'
|
||||
}
|
||||
|
||||
function advanceIssueSummary(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const tAmt = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const tAct = data.reduce((s, r) => s + Number(r.actualAmount ?? 0), 0)
|
||||
const tOff = data.reduce((s, r) => s + Number(r.offsetAmount ?? 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
const body = ['', '', '', lbl, '', '', formatSumMoney(tAmt), formatSumMoney(tAct), formatSumMoney(tOff)]
|
||||
if (activeTab.value === 'pending') {
|
||||
return [...body, '', '']
|
||||
}
|
||||
return [...body, '', '', '']
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadApplicantOptions()
|
||||
refresh()
|
||||
loadAdvanceIssueStats()
|
||||
})
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
function handleToolbarIssue() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选一条待发放记录')
|
||||
return
|
||||
}
|
||||
openIssueDialog(selectedRows.value[0])
|
||||
}
|
||||
|
||||
function handleTabChange(tab: string | number) {
|
||||
activeTab.value = String(tab)
|
||||
Object.assign(filterForm, { keyword: '', applicantId: undefined, applyDate: null })
|
||||
search()
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const kw = filterForm.keyword.trim()
|
||||
if (kw) q.keyword = kw
|
||||
if (filterForm.applicantId != null) q.applicantId = filterForm.applicantId
|
||||
if (filterForm.applyDate) q.applyDate = filterForm.applyDate
|
||||
search(q)
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, { keyword: '', applicantId: undefined, applyDate: null })
|
||||
search()
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
loadingMap.export = true
|
||||
try {
|
||||
const issueStatus = activeTab.value === 'pending' ? 'pending' : 'issued'
|
||||
const res: any = await paymentApi.exportAdvanceIssues({
|
||||
issueStatus,
|
||||
keyword: filterForm.keyword.trim() || undefined,
|
||||
applicantId: filterForm.applicantId,
|
||||
applyDate: filterForm.applyDate || undefined
|
||||
})
|
||||
const blob = new Blob([res], { type: 'text/csv;charset=utf-8' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
const statusText = activeTab.value === 'pending' ? '待发放' : '已发放'
|
||||
a.download = `备用金${statusText}列表.csv`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
ElMessage.success('导出成功')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '导出失败')
|
||||
} finally {
|
||||
loadingMap.export = false
|
||||
}
|
||||
}
|
||||
|
||||
function openIssueDialog(row: any) {
|
||||
currentRow.value = row
|
||||
issueRemark.value = ''
|
||||
actualAmount.value = row.amount || ''
|
||||
uploadedFiles.value = []
|
||||
dialogs.issue = true
|
||||
}
|
||||
|
||||
async function submitIssue() {
|
||||
if (uploadedFiles.value.length === 0) {
|
||||
ElMessage.warning('请至少上传 1 个发放附件')
|
||||
return
|
||||
}
|
||||
if (issueAttachmentRef.value?.hasUploading()) {
|
||||
ElMessage.warning('附件上传中,请稍候')
|
||||
return
|
||||
}
|
||||
loadingMap.issueSubmit = true
|
||||
try {
|
||||
await paymentApi.issueAdvance(currentRow.value.id, {
|
||||
issueRemark: issueRemark.value,
|
||||
actualAmount: actualAmount.value !== '' ? Number(actualAmount.value) : undefined
|
||||
})
|
||||
ElMessage.success('发放成功')
|
||||
dialogs.issue = false
|
||||
await refresh()
|
||||
await loadAdvanceIssueStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '发放失败')
|
||||
} finally {
|
||||
loadingMap.issueSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openView(row: any) {
|
||||
try {
|
||||
viewData.value = row
|
||||
viewAttachments.value = []
|
||||
approvalNodes.value = []
|
||||
approvalHistory.value = []
|
||||
offsetRecords.value = []
|
||||
|
||||
if (row.issueStatus === 'issued' && row.id) {
|
||||
try {
|
||||
viewAttachments.value = await loadBxAttachments('advance_issue', row.id)
|
||||
} catch {
|
||||
viewAttachments.value = []
|
||||
}
|
||||
}
|
||||
|
||||
if (row.id) {
|
||||
approvalLoading.value = true
|
||||
try {
|
||||
const [aRes, historyRes, offsetRes]: any[] = await Promise.all([
|
||||
advanceApi.getApprovals(row.id),
|
||||
advanceApi.getApprovalHistory(row.id),
|
||||
paymentApi.advanceOffsetRecords(row.id).catch(() => ({ data: [] }))
|
||||
])
|
||||
approvalNodes.value = (aRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
approvalHistory.value = historyRes.data || []
|
||||
offsetRecords.value = offsetRes.data || []
|
||||
} catch {
|
||||
/* skip */
|
||||
} finally {
|
||||
approvalLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
dialogs.view = true
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载详情失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,586 @@
|
||||
<!-- 费用项目管理(报销管理) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">费用项目列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="项目名称">
|
||||
<el-input v-model="searchForm.name" placeholder="请输入项目名称" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编码">
|
||||
<el-input v-model="searchForm.code" placeholder="请输入项目编码" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="层级">
|
||||
<el-select v-model="searchForm.level" placeholder="全部" clearable>
|
||||
<el-option label="一级" value="1" />
|
||||
<el-option label="二级" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="searchForm.status" placeholder="全部" clearable>
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="禁用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions-row">
|
||||
<span class="filter-hint">按项目名称、编码筛选;树形数据加载后前端过滤。</span>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">0</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="openAddDialog">
|
||||
<el-icon><Plus /></el-icon>新增一级项目
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="expandAll">
|
||||
<el-icon><SortDown /></el-icon>展开全部
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="collapseAll">
|
||||
<el-icon><SortUp /></el-icon>收起全部
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
class="list-table"
|
||||
:data="filteredTree"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
row-key="id"
|
||||
:tree-props="{ children: 'children', hasChildren: 'childCount > 0' }"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="itemName"
|
||||
label="项目名称"
|
||||
min-width="200"
|
||||
align="left"
|
||||
header-align="left"
|
||||
class-name="col-align-left"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="itemCode"
|
||||
label="项目编码"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="level" label="层级" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.level === 1 ? 'primary' : 'info'" size="small">
|
||||
{{ row.level === 1 ? '一级' : '二级' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="childCount"
|
||||
label="子项数量"
|
||||
min-width="100"
|
||||
align="center"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="sortOrder" label="排序号" min-width="80" align="center" header-align="center" />
|
||||
<el-table-column prop="status" label="状态" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" :loading="loadingMap.rowEdit" @click="openEditDialog(row)">
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.level === 1"
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap.rowAddChild"
|
||||
@click="openAddChildDialog(row)"
|
||||
>
|
||||
<el-icon><Plus /></el-icon>新增子项
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" :loading="loadingMap.rowDelete" @click="handleDelete(row)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 新增一级项目 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.addProject"
|
||||
title="新增一级项目"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@close="resetForm"
|
||||
>
|
||||
<el-form
|
||||
ref="addFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="项目名称" prop="itemName">
|
||||
<el-input v-model="formData.itemName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编码">
|
||||
<el-input v-model="formData.itemCode" disabled placeholder="根据项目名称自动生成" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级项目">
|
||||
<el-select v-model="formData.parentId" disabled placeholder="无" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号">
|
||||
<el-input-number v-model="formData.sortOrder" controls-position="right" :min="0" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="grid-column: 1 / -1">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.addProject = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addSubmit" @click="handleAddSubmit">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 编辑项目 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.editProject"
|
||||
title="编辑项目"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="editFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="项目名称" prop="itemName">
|
||||
<el-input v-model="formData.itemName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编码">
|
||||
<el-input v-model="formData.itemCode" disabled placeholder="项目编码不可修改" />
|
||||
</el-form-item>
|
||||
<el-form-item label="层级">
|
||||
<el-select v-model="formData.level" placeholder="请选择层级">
|
||||
<el-option label="一级" :value="1" />
|
||||
<el-option label="二级" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号">
|
||||
<el-input-number v-model="formData.sortOrder" controls-position="right" :min="0" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级项目">
|
||||
<el-select
|
||||
v-model="formData.parentId"
|
||||
:disabled="formData.level === 1"
|
||||
:placeholder="formData.level === 1 ? '无' : '请选择上级项目'"
|
||||
clearable
|
||||
>
|
||||
<el-option v-for="p in parentOptions" :key="p.id" :label="p.itemName" :value="p.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="grid-column: 1 / -1">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.editProject = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.editSubmit" @click="handleEditSubmit">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 新增二级项目 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.addChild"
|
||||
title="新增二级项目"
|
||||
width="640px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@close="resetForm"
|
||||
>
|
||||
<el-form
|
||||
ref="addChildFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="项目名称" prop="itemName">
|
||||
<el-input v-model="formData.itemName" placeholder="请输入项目名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="项目编码">
|
||||
<el-input v-model="formData.itemCode" disabled placeholder="根据项目名称自动生成" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级项目">
|
||||
<el-select v-model="formData.parentId" disabled placeholder="上级项目">
|
||||
<el-option v-for="p in parentOptions" :key="p.id" :label="p.itemName" :value="p.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号">
|
||||
<el-input-number v-model="formData.sortOrder" controls-position="right" :min="0" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="formData.status" placeholder="请选择状态">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="禁用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="grid-column: 1 / -1">
|
||||
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.addChild = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addChildSubmit" @click="handleAddChildSubmit">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, computed, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
EditPen,
|
||||
Delete,
|
||||
Close,
|
||||
Check,
|
||||
Search,
|
||||
RefreshLeft,
|
||||
SortUp,
|
||||
SortDown
|
||||
} from '@element-plus/icons-vue'
|
||||
import { expenseItemApi } from '@/api/bx'
|
||||
import { statusLabel, statusTagType } from '@/utils/bx/format'
|
||||
import { suggestExpenseItemCode } from '@/utils/bx/expenseItemCode'
|
||||
|
||||
type DialogKey = 'addProject' | 'editProject' | 'addChild'
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
addProject: false,
|
||||
editProject: false,
|
||||
addChild: false
|
||||
})
|
||||
|
||||
const searchForm = reactive({
|
||||
name: '',
|
||||
code: '',
|
||||
level: '',
|
||||
status: ''
|
||||
})
|
||||
|
||||
const expenseTree = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
const formData = reactive({
|
||||
id: 0 as number,
|
||||
itemName: '',
|
||||
itemCode: '',
|
||||
level: 1 as number,
|
||||
parentId: null as string | number | null,
|
||||
sortOrder: 1 as number,
|
||||
status: 1 as number,
|
||||
remark: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
itemName: [{ required: true, message: '项目名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const addFormRef = ref<FormInstance>()
|
||||
const editFormRef = ref<FormInstance>()
|
||||
const addChildFormRef = ref<FormInstance>()
|
||||
|
||||
const parentOptions = computed(() => expenseTree.value.filter((r: any) => r.level === 1))
|
||||
|
||||
function resolveParentId(row: any): string | number | null {
|
||||
if (row.level === 1) return null
|
||||
const pid = row.parentId ?? row.parent_id
|
||||
if (pid == null || pid === '' || pid === 0 || pid === '0') return null
|
||||
return pid
|
||||
}
|
||||
|
||||
function buildSubmitPayload() {
|
||||
return {
|
||||
...formData,
|
||||
parentId: formData.level === 1 ? 0 : formData.parentId || 0
|
||||
}
|
||||
}
|
||||
|
||||
function filterTreeNodes(nodes: any[]): any[] {
|
||||
return nodes
|
||||
.map((node) => {
|
||||
const children = node.children?.length ? filterTreeNodes(node.children) : []
|
||||
const nameOk = !searchForm.name || String(node.itemName || '').includes(searchForm.name)
|
||||
const codeOk = !searchForm.code || String(node.itemCode || '').includes(searchForm.code)
|
||||
const levelOk = !searchForm.level || String(node.level) === searchForm.level
|
||||
const statusOk = !searchForm.status || String(node.status) === searchForm.status
|
||||
const selfMatch = nameOk && codeOk && levelOk && statusOk
|
||||
if (selfMatch || children.length) {
|
||||
return { ...node, children: children.length ? children : node.children?.length ? [] : undefined }
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter(Boolean) as any[]
|
||||
}
|
||||
|
||||
const filteredTree = computed(() => {
|
||||
const hasFilter = searchForm.name || searchForm.code || searchForm.level || searchForm.status
|
||||
if (!hasFilter) return expenseTree.value
|
||||
return filterTreeNodes(expenseTree.value)
|
||||
})
|
||||
|
||||
async function loadTree() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await expenseItemApi.tree()
|
||||
expenseTree.value = res.data ?? []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载数据失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(formData, {
|
||||
id: 0,
|
||||
itemName: '',
|
||||
itemCode: '',
|
||||
level: 1,
|
||||
parentId: null,
|
||||
sortOrder: 1,
|
||||
status: 1,
|
||||
remark: ''
|
||||
})
|
||||
addFormRef.value?.resetFields()
|
||||
editFormRef.value?.resetFields()
|
||||
addChildFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
resetForm()
|
||||
formData.level = 1
|
||||
formData.parentId = null
|
||||
dialogs.addProject = true
|
||||
}
|
||||
|
||||
function openEditDialog(row: any) {
|
||||
Object.assign(formData, {
|
||||
id: row.id,
|
||||
itemName: row.itemName ?? '',
|
||||
itemCode: row.itemCode ?? '',
|
||||
level: row.level ?? 1,
|
||||
parentId: resolveParentId(row),
|
||||
sortOrder: row.sortOrder ?? 1,
|
||||
status: row.status ?? 1,
|
||||
remark: row.remark ?? ''
|
||||
})
|
||||
dialogs.editProject = true
|
||||
}
|
||||
|
||||
function openAddChildDialog(row: any) {
|
||||
resetForm()
|
||||
formData.level = 2
|
||||
formData.parentId = row.id
|
||||
dialogs.addChild = true
|
||||
}
|
||||
|
||||
async function handleAddSubmit() {
|
||||
const valid = await addFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.addSubmit = true
|
||||
try {
|
||||
await expenseItemApi.create(buildSubmitPayload())
|
||||
ElMessage.success('新增成功')
|
||||
dialogs.addProject = false
|
||||
resetForm()
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.addSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEditSubmit() {
|
||||
const valid = await editFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.editSubmit = true
|
||||
try {
|
||||
await expenseItemApi.update(formData.id, buildSubmitPayload())
|
||||
ElMessage.success('编辑成功')
|
||||
dialogs.editProject = false
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.editSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAddChildSubmit() {
|
||||
const valid = await addChildFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.addChildSubmit = true
|
||||
try {
|
||||
await expenseItemApi.create(buildSubmitPayload())
|
||||
ElMessage.success('新增成功')
|
||||
dialogs.addChild = false
|
||||
resetForm()
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.addChildSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要删除费用项目「${row.itemName || row.itemCode}」吗?`,
|
||||
'删除确认',
|
||||
{ confirmButtonText: '确定删除', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
loadingMap.rowDelete = true
|
||||
try {
|
||||
await expenseItemApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.rowDelete = false
|
||||
}
|
||||
}
|
||||
|
||||
const tableRef = ref()
|
||||
|
||||
function expandAll() {
|
||||
const table = tableRef.value
|
||||
if (!table) return
|
||||
filteredTree.value.forEach((row) => {
|
||||
if (row.children && row.children.length > 0) {
|
||||
table.toggleRowExpansion(row, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapseAll() {
|
||||
const table = tableRef.value
|
||||
if (!table) return
|
||||
filteredTree.value.forEach((row) => {
|
||||
if (row.children && row.children.length > 0) {
|
||||
table.toggleRowExpansion(row, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
loadTree()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
searchForm.name = ''
|
||||
searchForm.code = ''
|
||||
searchForm.level = ''
|
||||
searchForm.status = ''
|
||||
loadTree()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formData.level,
|
||||
(level) => {
|
||||
if (level === 1) {
|
||||
formData.parentId = null
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
[() => formData.itemName, () => dialogs.addProject, () => dialogs.addChild, expenseTree],
|
||||
() => {
|
||||
if (!dialogs.addProject && !dialogs.addChild) return
|
||||
formData.itemCode = suggestExpenseItemCode(formData.itemName, expenseTree.value)
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
loadTree()
|
||||
})
|
||||
</script>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,977 @@
|
||||
<!-- 报销申请 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">报销申请列表</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="报销单号">
|
||||
<el-input v-model="filterForm.keyword" placeholder="请输入报销单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="费用项目">
|
||||
<el-input v-model="filterForm.expenseName" placeholder="请输入费用项目" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="filterForm.status" placeholder="全部" clearable>
|
||||
<el-option label="待提交" value="draft" />
|
||||
<el-option label="审批中" value="pending" />
|
||||
<el-option label="审批通过" value="approved" />
|
||||
<el-option label="审批驳回" value="rejected" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="openAddDialog">
|
||||
<el-icon><Plus /></el-icon>新增报销申请
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.submit" @click="handleToolbarSubmit">
|
||||
<el-icon><Upload /></el-icon>提交审批
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="openFlowDialog()">
|
||||
<el-icon><View /></el-icon>查看审批流
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="summaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="报销单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="报销标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="expenseName"
|
||||
label="费用项目"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="报销金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="360" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
@click="openEditDialog(row)"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap[`submit_${row.id}`]"
|
||||
@click="handleSubmit(row)"
|
||||
>
|
||||
<el-icon><Upload /></el-icon>提交
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 'draft' || row.status === 'rejected'"
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap[`del_${row.id}`]"
|
||||
@click="handleDelete(row)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 新增/编辑 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.add"
|
||||
:title="editingId ? '编辑报销申请' : '新增报销申请'"
|
||||
width="780px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p class="dlg-note">提交后进入顺序审批流程,可在「查看审批流」中确认节点与审批人。</p>
|
||||
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="报销标题" style="grid-column: 1 / -1">
|
||||
<el-input v-model="addForm.title" placeholder="不填则自动生成" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<div class="form-section">
|
||||
<h4>报销明细</h4>
|
||||
<div class="detail-table-wrap">
|
||||
<table class="detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-index">序号</th>
|
||||
<th class="col-expense">费用项目<span class="th-required">*</span></th>
|
||||
<th class="col-amount">金额(元)<span class="th-required">*</span></th>
|
||||
<th class="col-remark">报销事由<span class="th-required">*</span></th>
|
||||
<th class="col-action">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(line, idx) in addForm.details" :key="idx">
|
||||
<td class="col-index">{{ idx + 1 }}</td>
|
||||
<td class="col-expense">
|
||||
<el-tree-select
|
||||
v-model="line.expenseItemId"
|
||||
:data="expenseTreeForSelect"
|
||||
:props="{ label: 'itemName', value: 'id', children: 'children', disabled: 'disabled' }"
|
||||
placeholder="请选择费用项目"
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</td>
|
||||
<td class="col-amount">
|
||||
<el-input-number
|
||||
v-model="line.amount"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
placeholder="金额"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</td>
|
||||
<td class="col-remark">
|
||||
<el-input v-model="line.remark" placeholder="请输入报销事由" />
|
||||
</td>
|
||||
<td class="col-action">
|
||||
<el-button
|
||||
v-if="addForm.details.length > 1"
|
||||
type="danger"
|
||||
link
|
||||
size="small"
|
||||
@click="removeDetailLine(idx)"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="detail-footer">
|
||||
<el-button class="btn-ghost" size="small" @click="addDetailLine">
|
||||
<el-icon><Plus /></el-icon>新增明细行
|
||||
</el-button>
|
||||
<span class="detail-total">
|
||||
合计金额(元):<b>{{ formatMoneyYuan(detailTotalAmount) }}</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<h4>附件上传</h4>
|
||||
<BxAttachmentUpload
|
||||
ref="attachmentUploadRef"
|
||||
v-model="uploadedFiles"
|
||||
biz-type="reimburse_apply"
|
||||
:biz-id="editingId || 0"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="备注说明">
|
||||
<el-input v-model="addForm.remark" type="textarea" :rows="4" placeholder="请输入报销说明" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.add = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addSubmit" @click="submitAdd">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 详情 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.view"
|
||||
title="报销单详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="statusTagType(viewData.status)" size="small">
|
||||
{{ statusLabel(viewData.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
报销金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">报销标题</div>
|
||||
<div class="v kv-full"><BaseClampText :text="viewData.title" /></div>
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ viewData.applicantName || '-' }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(viewData.currentNode, viewData.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ viewData.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">报销明细</h4>
|
||||
<el-table
|
||||
class="list-table view-detail-table"
|
||||
:data="viewData.details || []"
|
||||
stripe
|
||||
size="small"
|
||||
show-summary
|
||||
:summary-method="viewDetailSummary"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column prop="expenseName" label="费用项目" min-width="160" align="left" header-align="center" />
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="金额(元)"
|
||||
min-width="120"
|
||||
class-name="col-money"
|
||||
align="right"
|
||||
header-align="center"
|
||||
>
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount || 0) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="报销事由" min-width="140" align="left" header-align="center">
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">附件</h4>
|
||||
<BxAttachmentReadonly :files="viewAttachments" />
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">报销说明</div>
|
||||
<div class="v kv-full"><BaseClampText :text="viewData.remark" /></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="
|
||||
['processed', 'paid', 'offset'].includes(String(viewData.status)) ||
|
||||
viewData.payStatus ||
|
||||
Number(viewData.offsetAmount || 0) > 0
|
||||
"
|
||||
class="dlg-view-section"
|
||||
>
|
||||
<h4>处理情况</h4>
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">处理方式</div>
|
||||
<div class="v">{{ viewProcessMode(viewData) }}</div>
|
||||
<div class="k">冲抵金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(viewData.offsetAmount || 0) }}</div>
|
||||
<div class="k">发放金额(元)</div>
|
||||
<div class="v money-value">
|
||||
{{
|
||||
formatMoneyYuan(
|
||||
viewData.actualAmount ?? Number(viewData.amount || 0) - Number(viewData.offsetAmount || 0)
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<div class="k">处理时间</div>
|
||||
<div class="v">{{ viewData.payTime || '-' }}</div>
|
||||
<div class="k">处理操作人</div>
|
||||
<div class="v">{{ viewData.payUserName || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="viewPayAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">发放附件</h4>
|
||||
<BxAttachmentReadonly :files="viewPayAttachments" />
|
||||
</div>
|
||||
|
||||
<div v-if="viewOffsetAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">冲抵附件</h4>
|
||||
<BxAttachmentReadonly :files="viewOffsetAttachments" />
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.view = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.viewFlow"
|
||||
title="审批流程"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view-section">
|
||||
<h4>审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="flowNodes" :loading="flowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<h4>审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="flowHistory" :loading="flowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewFlow = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
EditPen,
|
||||
Upload,
|
||||
View,
|
||||
Close,
|
||||
Delete,
|
||||
Check,
|
||||
Search,
|
||||
RefreshLeft
|
||||
} from '@element-plus/icons-vue'
|
||||
import { reimburseApi, attachmentApi } from '@/api/bx'
|
||||
import { type BxAttachmentItem, loadBxAttachments } from '@/utils/bx/attachment'
|
||||
import { useExpenseItemTree, type ExpenseItem } from '@/hooks/bx/useExpenseItemTree'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatSumMoney,
|
||||
formatMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import BxAttachmentUpload from '@/components/bx/base/BxAttachmentUpload.vue'
|
||||
import BxAttachmentReadonly from '@/components/bx/base/BxAttachmentReadonly.vue'
|
||||
|
||||
type DialogKey = 'add' | 'view' | 'viewFlow'
|
||||
|
||||
interface DetailLine {
|
||||
expenseItemId: string
|
||||
amount: number | string
|
||||
remark: string
|
||||
}
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
add: false,
|
||||
view: false,
|
||||
viewFlow: false
|
||||
})
|
||||
|
||||
const { rows, total, currentPage, pageSize, rangeText, loading, refresh, search, onSizeChange } = useServerPaged(
|
||||
async (params) => {
|
||||
const res: any = await reimburseApi.my(params)
|
||||
return res.data
|
||||
}
|
||||
)
|
||||
|
||||
const { expenseTree } = useExpenseItemTree()
|
||||
|
||||
function markDisabledExpenseNodes(tree: ExpenseItem[]): ExpenseItem[] {
|
||||
return tree.map((node) => ({
|
||||
...node,
|
||||
disabled: Number(node.status) === 0,
|
||||
children: node.children?.length ? markDisabledExpenseNodes(node.children) : node.children
|
||||
}))
|
||||
}
|
||||
|
||||
const expenseTreeForSelect = computed(() => markDisabledExpenseNodes(expenseTree.value))
|
||||
|
||||
const myReimburseStats = ref({
|
||||
pendingCount: 0,
|
||||
monthApplyAmount: 0,
|
||||
approvedAmount: 0,
|
||||
approvedCount: 0
|
||||
})
|
||||
|
||||
async function loadMyReimburseStats() {
|
||||
try {
|
||||
const res: any = await reimburseApi.myStats()
|
||||
const d = res.data || {}
|
||||
myReimburseStats.value = {
|
||||
pendingCount: Number(d.pendingCount ?? 0),
|
||||
monthApplyAmount: Number(d.monthApplyAmount ?? 0),
|
||||
approvedAmount: Number(d.approvedAmount ?? 0),
|
||||
approvedCount: Number(d.approvedCount ?? 0)
|
||||
}
|
||||
} catch {
|
||||
/* 拦截器已提示 */
|
||||
}
|
||||
}
|
||||
|
||||
const stats = computed(() => {
|
||||
const s = myReimburseStats.value
|
||||
return [
|
||||
{ name: '待审批申请', value: String(s.pendingCount) },
|
||||
{ name: '本月申请金额(元)', value: formatMoney(s.monthApplyAmount) },
|
||||
{ name: '已审批金额(元)', value: formatMoney(s.approvedAmount) },
|
||||
{ name: '已通过申请', value: String(s.approvedCount) }
|
||||
]
|
||||
})
|
||||
|
||||
const filterForm = reactive({
|
||||
keyword: '',
|
||||
status: '',
|
||||
expenseName: '',
|
||||
applyDate: null as string | null
|
||||
})
|
||||
|
||||
const addForm = reactive({
|
||||
title: '',
|
||||
remark: '',
|
||||
details: [{ expenseItemId: '', amount: '' as number | string, remark: '' }] as DetailLine[]
|
||||
})
|
||||
|
||||
const viewData = ref<Record<string, any>>({})
|
||||
const selectedRows = ref<any[]>([])
|
||||
const flowNodes = ref<any[]>([])
|
||||
const flowHistory = ref<any[]>([])
|
||||
const flowLoading = ref(false)
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
const uploadedFiles = ref<BxAttachmentItem[]>([])
|
||||
const attachmentUploadRef = ref<InstanceType<typeof BxAttachmentUpload> | null>(null)
|
||||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewPayAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewOffsetAttachments = ref<BxAttachmentItem[]>([])
|
||||
const editingId = ref<number | null>(null)
|
||||
|
||||
const detailTotalAmount = computed(() => {
|
||||
return addForm.details.reduce((sum: number, d) => sum + Number(d.amount || 0), 0)
|
||||
})
|
||||
|
||||
async function openAddDialog() {
|
||||
addForm.title = ''
|
||||
addForm.remark = ''
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
uploadedFiles.value = []
|
||||
editingId.value = null
|
||||
dialogs.add = true
|
||||
try {
|
||||
const res: any = await reimburseApi.generateTitle()
|
||||
addForm.title = res.data || ''
|
||||
} catch {
|
||||
/* fallback: user can type manually */
|
||||
}
|
||||
}
|
||||
|
||||
async function openEditDialog(row: any) {
|
||||
try {
|
||||
const res: any = await reimburseApi.getById(row.id)
|
||||
const data = res.data || res
|
||||
addForm.title = data.title || ''
|
||||
addForm.remark = data.remark || ''
|
||||
addForm.details = (data.details || []).map((d: any) => ({
|
||||
expenseItemId: d.expenseId,
|
||||
amount: d.amount,
|
||||
remark: d.remark || ''
|
||||
}))
|
||||
if (addForm.details.length === 0) {
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
}
|
||||
editingId.value = row.id
|
||||
uploadedFiles.value = []
|
||||
dialogs.add = true
|
||||
try {
|
||||
uploadedFiles.value = await loadBxAttachments('reimburse_apply', row.id)
|
||||
} catch {
|
||||
/* ignore attachment fetch error */
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
function addDetailLine() {
|
||||
addForm.details.push({ expenseItemId: '', amount: '', remark: '' })
|
||||
}
|
||||
|
||||
function removeDetailLine(index: number) {
|
||||
addForm.details.splice(index, 1)
|
||||
}
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
async function refreshListAndStats() {
|
||||
await refresh()
|
||||
await loadMyReimburseStats()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshListAndStats()
|
||||
})
|
||||
|
||||
function handleSearch() {
|
||||
const q: Record<string, string> = { keyword: filterForm.keyword, status: filterForm.status }
|
||||
if (filterForm.applyDate) q.applyDate = filterForm.applyDate
|
||||
search(q)
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, { keyword: '', status: '', expenseName: '', applyDate: null })
|
||||
search()
|
||||
}
|
||||
|
||||
async function handleToolbarSubmit() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要提交的报销单')
|
||||
return
|
||||
}
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
await reimburseApi.submit(row.id)
|
||||
}
|
||||
ElMessage.success('提交成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitAdd() {
|
||||
const validDetails = addForm.details.filter((d) => d.expenseItemId && d.amount)
|
||||
if (validDetails.length === 0) {
|
||||
ElMessage.warning('请至少填写一条报销明细')
|
||||
return
|
||||
}
|
||||
const missingReason = validDetails.some((d) => !String(d.remark ?? '').trim())
|
||||
if (missingReason) {
|
||||
ElMessage.warning('请为每条报销明细填写报销事由')
|
||||
return
|
||||
}
|
||||
if (attachmentUploadRef.value?.hasUploading()) {
|
||||
ElMessage.warning('附件上传中,请稍候')
|
||||
return
|
||||
}
|
||||
loadingMap.addSubmit = true
|
||||
try {
|
||||
if (editingId.value) {
|
||||
await reimburseApi.update(editingId.value, {
|
||||
details: validDetails.map((d) => ({
|
||||
expenseItemId: String(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim()
|
||||
})),
|
||||
remark: addForm.remark
|
||||
})
|
||||
const newFiles = uploadedFiles.value.filter((f) => !f._existing)
|
||||
if (newFiles.length) {
|
||||
const fileIds = newFiles.map((f) => f.id)
|
||||
await attachmentApi.bindBiz(fileIds, 'reimburse_apply', editingId.value)
|
||||
}
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
const res: any = await reimburseApi.create({
|
||||
title: addForm.title || undefined,
|
||||
remark: addForm.remark,
|
||||
details: validDetails.map((d) => ({
|
||||
expenseItemId: String(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim()
|
||||
}))
|
||||
})
|
||||
const newId = res.data?.id
|
||||
if (newId && uploadedFiles.value.length) {
|
||||
const fileIds = uploadedFiles.value.map((f) => f.id)
|
||||
await attachmentApi.bindBiz(fileIds, 'reimburse_apply', newId)
|
||||
}
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
dialogs.add = false
|
||||
addForm.title = ''
|
||||
addForm.remark = ''
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
uploadedFiles.value = []
|
||||
editingId.value = null
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || (editingId.value ? '保存失败' : '新增失败'))
|
||||
} finally {
|
||||
loadingMap.addSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openView(row: any) {
|
||||
try {
|
||||
const res = await reimburseApi.getById(row.id)
|
||||
viewData.value = res.data || res
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewAttachments.value = []
|
||||
viewPayAttachments.value = []
|
||||
viewOffsetAttachments.value = []
|
||||
dialogs.view = true
|
||||
if (row.id) {
|
||||
try {
|
||||
const [applyFiles, payFiles, offsetFiles] = await Promise.all([
|
||||
loadBxAttachments('reimburse_apply', row.id).catch(() => []),
|
||||
loadBxAttachments('reimburse_pay', row.id).catch(() => []),
|
||||
loadBxAttachments('reimburse_offset', row.id).catch(() => [])
|
||||
])
|
||||
viewAttachments.value = applyFiles
|
||||
viewPayAttachments.value = payFiles
|
||||
viewOffsetAttachments.value = offsetFiles
|
||||
} catch {
|
||||
/* ignore attachment fetch error */
|
||||
}
|
||||
}
|
||||
viewFlowLoading.value = true
|
||||
try {
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
reimburseApi.getApprovals(row.id),
|
||||
reimburseApi.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch {
|
||||
/* ignore flow fetch error in view */
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
function viewProcessMode(data: Record<string, any>) {
|
||||
const hasOffset = Number(data.offsetAmount || 0) > 0
|
||||
const hasPay = Number(data.actualAmount ?? 0) > 0 || data.payStatus === 'paid'
|
||||
if (hasOffset && hasPay) return '冲抵 + 发放'
|
||||
if (hasOffset) return '仅冲抵'
|
||||
if (hasPay) return '仅发放'
|
||||
return '未处理'
|
||||
}
|
||||
|
||||
async function openFlowDialog(row?: any) {
|
||||
const target = row || selectedRows.value[0]
|
||||
if (!target) {
|
||||
ElMessage.warning('请先选择一条申请记录')
|
||||
return
|
||||
}
|
||||
flowNodes.value = []
|
||||
flowHistory.value = []
|
||||
flowLoading.value = true
|
||||
dialogs.viewFlow = true
|
||||
try {
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
reimburseApi.getApprovals(target.id),
|
||||
reimburseApi.getApprovalHistory(target.id)
|
||||
])
|
||||
flowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
flowHistory.value = historyRes.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载审批流程失败')
|
||||
} finally {
|
||||
flowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit(row: any) {
|
||||
loadingMap[`submit_${row.id}`] = true
|
||||
try {
|
||||
await reimburseApi.submit(row.id)
|
||||
ElMessage.success('提交成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`submit_${row.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要删除该报销单吗?删除后不可恢复。', '删除确认', {
|
||||
confirmButtonText: '确定删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
loadingMap[`del_${row.id}`] = true
|
||||
await reimburseApi.delete(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await refreshListAndStats()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
ElMessage.error(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[`del_${row.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
function summaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const totalAmt = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return ['', '', '', lbl, '', '', formatSumMoney(totalAmt), '', '']
|
||||
}
|
||||
|
||||
function viewDetailSummary({ columns, data }: { columns: any[]; data: any[] }) {
|
||||
const sums: string[] = []
|
||||
columns.forEach((_: any, index: number) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '合计'
|
||||
return
|
||||
}
|
||||
if (index === 2) {
|
||||
const total = data.reduce((sum: number, row: any) => sum + Number(row.amount || 0), 0)
|
||||
sums[index] = formatMoneyYuan(total)
|
||||
return
|
||||
}
|
||||
sums[index] = ''
|
||||
})
|
||||
return sums
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detail-table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.detail-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.detail-table th {
|
||||
background: var(--mint-table-head, #f8fafc);
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid var(--mint-border, #d9e8e2);
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.detail-table td {
|
||||
padding: 6px;
|
||||
border-bottom: 1px solid var(--mint-border, #d9e8e2);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.detail-table .col-index {
|
||||
width: 56px;
|
||||
text-align: center;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.detail-table .col-expense {
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.detail-table .col-amount {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.detail-table .col-remark {
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.th-required {
|
||||
color: var(--el-color-danger);
|
||||
margin-left: 2px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-table .col-action {
|
||||
width: 72px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.detail-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 8px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.detail-total {
|
||||
font-size: 14px;
|
||||
color: var(--mint-text, #1e293b);
|
||||
}
|
||||
|
||||
.detail-total b {
|
||||
color: var(--danger, #dc2626);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.view-detail-table :deep(.el-table__footer-wrapper) {
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,857 @@
|
||||
<!-- 报销审批 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">报销审批</h2>
|
||||
</div>
|
||||
|
||||
<div class="panel-tabs">
|
||||
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
|
||||
<!-- 待我审批 -->
|
||||
<el-tab-pane label="待我审批" name="pending">
|
||||
<div class="filter-block">
|
||||
<el-form :model="pendingFilterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="报销单号">
|
||||
<el-input v-model="pendingFilterForm.code" placeholder="请输入报销单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select
|
||||
v-model="pendingFilterForm.applicantId"
|
||||
placeholder="请选择申请人"
|
||||
clearable
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="费用项目">
|
||||
<el-tree-select
|
||||
v-model="pendingFilterForm.expenseName"
|
||||
:data="expenseTree"
|
||||
:props="{ label: 'itemName', value: 'itemName', children: 'children' }"
|
||||
placeholder="请选择费用项目"
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="pendingFilterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div
|
||||
v-show="showMorePendingFilters"
|
||||
id="reimburse-approve-pending-filter-extra"
|
||||
class="filter-extra"
|
||||
>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="当前节点">
|
||||
<el-select v-model="pendingFilterForm.currentNode" placeholder="请选择节点" clearable>
|
||||
<el-option label="发起人主管审批" value="发起人主管审批" />
|
||||
<el-option label="财务复核" value="财务复核" />
|
||||
<el-option label="总经理审批" value="总经理审批" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="金额区间(元)">
|
||||
<el-input v-model="pendingFilterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMorePendingFilters"
|
||||
aria-controls="reimburse-approve-pending-filter-extra"
|
||||
@click="showMorePendingFilters = !showMorePendingFilters"
|
||||
>
|
||||
{{ showMorePendingFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMorePendingFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="pendingLoading" @click="handlePendingReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="pendingLoading" @click="handlePendingSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="handleBatchPass">
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="handleBatchReject">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="pendingRows"
|
||||
v-loading="pendingLoading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="pendingSummaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="报销单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="报销标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="expenseName"
|
||||
label="费用项目"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="报销金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openApproveDialog([row], 'approve')">
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openApproveDialog([row], 'reject')">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ pendingRangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="pendingPage"
|
||||
v-model:page-size="pendingPageSize"
|
||||
:total="pendingTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onPendingSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 我已审批 -->
|
||||
<el-tab-pane label="我已审批" name="approved">
|
||||
<div class="filter-block">
|
||||
<el-form :model="approvedFilterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="报销单号">
|
||||
<el-input v-model="approvedFilterForm.code" placeholder="请输入报销单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select
|
||||
v-model="approvedFilterForm.applicantId"
|
||||
placeholder="请选择申请人"
|
||||
clearable
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="费用项目">
|
||||
<el-tree-select
|
||||
v-model="approvedFilterForm.expenseName"
|
||||
:data="expenseTree"
|
||||
:props="{ label: 'itemName', value: 'itemName', children: 'children' }"
|
||||
placeholder="请选择费用项目"
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="approvedFilterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div
|
||||
v-show="showMoreApprovedFilters"
|
||||
id="reimburse-approve-approved-filter-extra"
|
||||
class="filter-extra"
|
||||
>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="当前节点">
|
||||
<el-select v-model="approvedFilterForm.currentNode" placeholder="请选择节点" clearable>
|
||||
<el-option label="发起人主管审批" value="发起人主管审批" />
|
||||
<el-option label="财务复核" value="财务复核" />
|
||||
<el-option label="总经理审批" value="总经理审批" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="金额区间(元)">
|
||||
<el-input v-model="approvedFilterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMoreApprovedFilters"
|
||||
aria-controls="reimburse-approve-approved-filter-extra"
|
||||
@click="showMoreApprovedFilters = !showMoreApprovedFilters"
|
||||
>
|
||||
{{ showMoreApprovedFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMoreApprovedFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="approvedLoading" @click="handleApprovedReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="approvedLoading" @click="handleApprovedSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="approvedRows"
|
||||
v-loading="approvedLoading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="approvedSummaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="报销单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="报销标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="expenseName"
|
||||
label="费用项目"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="报销金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="openView(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ approvedRangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="approvedPage"
|
||||
v-model:page-size="approvedPageSize"
|
||||
:total="approvedTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onApprovedSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 详情 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.viewDetail"
|
||||
title="报销单详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="statusTagType(viewData.status)" size="small">
|
||||
{{ statusLabel(viewData.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ viewData.applicantName || '-' }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(viewData.currentNode, viewData.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ viewData.applyTime || '-' }}</div>
|
||||
<div class="k">报销说明</div>
|
||||
<div class="v"><BaseClampText :text="viewData.remark" /></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">报销明细</h4>
|
||||
<el-table
|
||||
:data="viewData.details || []"
|
||||
border
|
||||
size="small"
|
||||
show-summary
|
||||
:summary-method="viewDetailSummary"
|
||||
class="view-detail-table"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" />
|
||||
<el-table-column prop="expenseName" label="费用项目" min-width="160" />
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" class-name="col-money">
|
||||
<template #default="{ row }">
|
||||
{{ formatMoneyYuan(row.amount || 0) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="报销事由" min-width="140">
|
||||
<template #default="{ row }">
|
||||
{{ row.remark || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">附件</h4>
|
||||
<BxAttachmentReadonly :files="viewAttachments" />
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewDetail = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 审批确认 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.approve"
|
||||
:title="approveAction === 'approve' ? '审批通过确认' : '审批驳回确认'"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="审批时间">
|
||||
<el-input :model-value="approveTime" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批数量">
|
||||
<el-input :model-value="`${approveRows.length} 条`" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批意见" style="grid-column: 1 / -1">
|
||||
<el-input v-model="approvalOpinion" type="textarea" :rows="4" placeholder="请输入审批意见" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.approve = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
:type="approveAction === 'approve' ? 'primary' : 'danger'"
|
||||
:loading="loadingMap[approveAction === 'approve' ? 'approvePass' : 'approveReject']"
|
||||
@click="handleConfirmApprove"
|
||||
>
|
||||
<el-icon><Check /></el-icon>
|
||||
{{ approveAction === 'approve' ? '确认通过' : '确认驳回' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
View,
|
||||
Check,
|
||||
Close,
|
||||
Search,
|
||||
RefreshLeft,
|
||||
ArrowUpBold,
|
||||
ArrowDownBold
|
||||
} from '@element-plus/icons-vue'
|
||||
import { reimburseApi } from '@/api/bx'
|
||||
import { type BxAttachmentItem, loadBxAttachments } from '@/utils/bx/attachment'
|
||||
import { reimburseApproverStats, refreshApproveMenuBadges } from '@/hooks/bx/useApproveMenuBadge'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatSumMoney,
|
||||
formatMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import { useExpenseItemTree } from '@/hooks/bx/useExpenseItemTree'
|
||||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import BxAttachmentReadonly from '@/components/bx/base/BxAttachmentReadonly.vue'
|
||||
|
||||
type DialogKey = 'viewDetail' | 'approve'
|
||||
|
||||
const showMorePendingFilters = ref(false)
|
||||
const showMoreApprovedFilters = ref(false)
|
||||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||||
const { expenseTree } = useExpenseItemTree()
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
viewDetail: false,
|
||||
approve: false
|
||||
})
|
||||
|
||||
const {
|
||||
rows: pendingRows,
|
||||
total: pendingTotal,
|
||||
currentPage: pendingPage,
|
||||
pageSize: pendingPageSize,
|
||||
rangeText: pendingRangeText,
|
||||
loading: pendingLoading,
|
||||
refresh: refreshPending,
|
||||
search: searchPending,
|
||||
onSizeChange: onPendingSizeChange
|
||||
} = useServerPaged(async (params) => {
|
||||
const res: any = await reimburseApi.pendingApproval(params)
|
||||
return res.data
|
||||
})
|
||||
|
||||
const {
|
||||
rows: approvedRows,
|
||||
total: approvedTotal,
|
||||
currentPage: approvedPage,
|
||||
pageSize: approvedPageSize,
|
||||
rangeText: approvedRangeText,
|
||||
loading: approvedLoading,
|
||||
search: searchApproved,
|
||||
onSizeChange: onApprovedSizeChange
|
||||
} = useServerPaged(async (params) => {
|
||||
const res: any = await reimburseApi.approvedByMe(params)
|
||||
return res.data
|
||||
})
|
||||
|
||||
const tabLoaded = reactive({ pending: false, approved: false })
|
||||
const activeTab = ref('pending')
|
||||
const menuStore = useMenuStore()
|
||||
|
||||
const stats = computed(() => {
|
||||
const s = reimburseApproverStats.value
|
||||
return [
|
||||
{ name: '待审批', value: String(s.pendingTotal) },
|
||||
{ name: '本月审批金额(元)', value: formatMoney(s.monthPendingAmount) }
|
||||
]
|
||||
})
|
||||
|
||||
const viewData = ref<Record<string, any>>({})
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||||
|
||||
const approveAction = ref<'approve' | 'reject'>('approve')
|
||||
const approveRows = ref<any[]>([])
|
||||
const approvalOpinion = ref('')
|
||||
const approveTime = ref('')
|
||||
|
||||
function formatNow() {
|
||||
const d = new Date()
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
||||
}
|
||||
|
||||
function openApproveDialog(rows: any[], action: 'approve' | 'reject') {
|
||||
approveRows.value = rows
|
||||
approveAction.value = action
|
||||
approvalOpinion.value = action === 'approve' ? '审批通过' : '审批驳回'
|
||||
approveTime.value = formatNow()
|
||||
dialogs.approve = true
|
||||
}
|
||||
|
||||
const pendingFilterForm = reactive({
|
||||
code: '',
|
||||
applicantId: undefined as number | undefined,
|
||||
expenseName: '',
|
||||
currentNode: '' as string,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
const approvedFilterForm = reactive({
|
||||
code: '',
|
||||
applicantId: undefined as number | undefined,
|
||||
expenseName: '',
|
||||
currentNode: '' as string,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
function buildPendingQuery() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const code = pendingFilterForm.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (pendingFilterForm.applicantId != null) q.applicantId = pendingFilterForm.applicantId
|
||||
if (pendingFilterForm.applyDate) q.applyDate = pendingFilterForm.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
function buildApprovedQuery() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const code = approvedFilterForm.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (approvedFilterForm.applicantId != null) q.applicantId = approvedFilterForm.applicantId
|
||||
if (approvedFilterForm.applyDate) q.applyDate = approvedFilterForm.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
loadApplicantOptions()
|
||||
await refreshApproveMenuBadges(menuStore.menuList)
|
||||
searchPending()
|
||||
tabLoaded.pending = true
|
||||
})
|
||||
|
||||
function handleTabChange(tab: string | number) {
|
||||
if (tab === 'pending' && !tabLoaded.pending) {
|
||||
searchPending()
|
||||
tabLoaded.pending = true
|
||||
}
|
||||
if (tab === 'approved' && !tabLoaded.approved) {
|
||||
searchApproved()
|
||||
tabLoaded.approved = true
|
||||
}
|
||||
}
|
||||
|
||||
function handlePendingSearch() {
|
||||
searchPending(buildPendingQuery())
|
||||
}
|
||||
|
||||
function handlePendingReset() {
|
||||
Object.assign(pendingFilterForm, {
|
||||
code: '',
|
||||
applicantId: undefined,
|
||||
expenseName: '',
|
||||
currentNode: '',
|
||||
applyDate: null,
|
||||
amountRange: ''
|
||||
})
|
||||
searchPending()
|
||||
}
|
||||
|
||||
function handleApprovedSearch() {
|
||||
searchApproved(buildApprovedQuery())
|
||||
}
|
||||
|
||||
function handleApprovedReset() {
|
||||
Object.assign(approvedFilterForm, {
|
||||
code: '',
|
||||
applicantId: undefined,
|
||||
expenseName: '',
|
||||
currentNode: '',
|
||||
applyDate: null,
|
||||
amountRange: ''
|
||||
})
|
||||
searchApproved()
|
||||
}
|
||||
|
||||
const selectedRows = ref<any[]>([])
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
function handleBatchPass() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要审批的报销单')
|
||||
return
|
||||
}
|
||||
openApproveDialog([...selectedRows.value], 'approve')
|
||||
}
|
||||
|
||||
function handleBatchReject() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要驳回的报销单')
|
||||
return
|
||||
}
|
||||
openApproveDialog([...selectedRows.value], 'reject')
|
||||
}
|
||||
|
||||
async function openView(row: any) {
|
||||
try {
|
||||
const res = await reimburseApi.getById(row.id)
|
||||
viewData.value = res.data || res
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewAttachments.value = []
|
||||
dialogs.viewDetail = true
|
||||
viewFlowLoading.value = true
|
||||
try {
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
reimburseApi.getApprovals(row.id),
|
||||
reimburseApi.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch {
|
||||
// ignore flow fetch error
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
try {
|
||||
viewAttachments.value = await loadBxAttachments('reimburse_apply', row.id)
|
||||
} catch {
|
||||
// ignore attachment fetch error
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function handleConfirmApprove() {
|
||||
const key = approveAction.value === 'approve' ? 'approvePass' : 'approveReject'
|
||||
loadingMap[key] = true
|
||||
const apiFn = approveAction.value === 'approve' ? reimburseApi.approve : reimburseApi.reject
|
||||
const msg = approveAction.value === 'approve' ? '审批通过成功' : '驳回成功'
|
||||
try {
|
||||
for (const row of approveRows.value) {
|
||||
await apiFn(row.id, { approvalOpinion: approvalOpinion.value })
|
||||
}
|
||||
ElMessage.success(approveRows.value.length > 1 ? `批量${msg}` : msg)
|
||||
dialogs.approve = false
|
||||
await refreshPending()
|
||||
await refreshApproveMenuBadges(menuStore.menuList)
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
function pendingSummaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const t = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return ['', '', '', lbl, '', '', '', formatSumMoney(t), '', '']
|
||||
}
|
||||
|
||||
function approvedSummaryMethod(params: { data: any[] }) {
|
||||
const data = params.data
|
||||
const n = data.length
|
||||
const t = data.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
const lbl = `本页合计(${n}单)`
|
||||
return ['', '', '', lbl, '', '', formatSumMoney(t), '', '', '']
|
||||
}
|
||||
|
||||
function viewDetailSummary({ columns, data }: { columns: any[]; data: any[] }) {
|
||||
const sums: string[] = []
|
||||
columns.forEach((_: any, index: number) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '合计'
|
||||
return
|
||||
}
|
||||
if (index === 2) {
|
||||
const total = data.reduce((sum: number, row: any) => sum + Number(row.amount || 0), 0)
|
||||
sums[index] = formatMoneyYuan(total)
|
||||
return
|
||||
}
|
||||
sums[index] = ''
|
||||
})
|
||||
return sums
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.view-detail-table :deep(.el-table__footer-wrapper) {
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,482 @@
|
||||
<!-- 全部申请单(总经理) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">全部申请单</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="单号">
|
||||
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="业务类型">
|
||||
<el-select v-model="filterForm.bizType" placeholder="全部" clearable>
|
||||
<el-option v-for="t in bizTypeOptions" :key="t" :label="t" :value="t" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="filterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="filterForm.status" placeholder="全部" clearable>
|
||||
<el-option v-for="s in statusOptions" :key="s" :label="s" :value="s" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="showMoreFilters" id="all-apply-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="金额区间(元)">
|
||||
<el-input v-model="filterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前节点">
|
||||
<el-select v-model="filterForm.currentNode" placeholder="全部" clearable>
|
||||
<el-option v-for="n in nodeOptions" :key="n" :label="n" :value="n" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMoreFilters"
|
||||
aria-controls="all-apply-filter-extra"
|
||||
@click="toggleMoreFilters"
|
||||
>
|
||||
{{ showMoreFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMoreFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="pager.pagedRows.value"
|
||||
v-loading="loading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="summaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="bizType" label="业务类型" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="bizTypeTagType(row.bizType)" size="small">
|
||||
{{ row.bizType }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="申请标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="openViewDetail(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ pager.rangeText.value }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="pager.currentPage.value"
|
||||
v-model:page-size="pager.pageSize.value"
|
||||
:total="pager.total.value"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="pager.onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.viewDetail"
|
||||
title="申请单详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ currentRow?.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="bizTypeTagType(currentRow?.bizType)" size="small">
|
||||
{{ currentRow?.bizType || '-' }}
|
||||
</el-tag>
|
||||
<el-tag v-if="currentRow?.status" :type="statusTagType(currentRow.status)" size="small">
|
||||
{{ statusLabel(currentRow.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
金额(元):<b class="money-em">{{ formatMoneyYuan(currentRow?.amount || 0) }}</b>
|
||||
· 申请人:{{ currentRow?.applicantName || '-' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请单号</div>
|
||||
<div class="v">{{ currentRow?.applyCode || '-' }}</div>
|
||||
<div class="k">业务类型</div>
|
||||
<div class="v">{{ currentRow?.bizType || '-' }}</div>
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ currentRow?.applicantName || '-' }}</div>
|
||||
<div class="k">申请标题</div>
|
||||
<div class="v"><BaseClampText :text="currentRow?.title" /></div>
|
||||
<div class="k">申请金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(currentRow?.amount || 0) }}</div>
|
||||
<div class="k">状态</div>
|
||||
<div class="v">{{ statusLabel(currentRow?.status) }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(currentRow?.currentNode, currentRow?.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ currentRow?.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewDetail = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { View, Close, Search, RefreshLeft, ArrowUpBold, ArrowDownBold } from '@element-plus/icons-vue'
|
||||
import { advanceApi, reimburseApi } from '@/api/bx'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatSumMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import { usePagedTable } from '@/hooks/bx/usePagedTable'
|
||||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||||
|
||||
type DialogKey = 'viewDetail'
|
||||
|
||||
const showMoreFilters = ref(false)
|
||||
const loading = ref(false)
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
viewDetail: false
|
||||
})
|
||||
|
||||
const mergedRows = ref<any[]>([])
|
||||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||||
|
||||
const filterForm = reactive({
|
||||
code: '',
|
||||
bizType: '' as string,
|
||||
applicantId: undefined as number | undefined,
|
||||
status: '' as string,
|
||||
applyDate: null as string | null,
|
||||
amountRange: '',
|
||||
currentNode: '' as string
|
||||
})
|
||||
|
||||
function filterMergedRows(rows: any[]) {
|
||||
let list = [...rows]
|
||||
const code = filterForm.code.trim()
|
||||
if (code) list = list.filter((r: any) => String(r.applyCode || '').includes(code))
|
||||
if (filterForm.bizType && filterForm.bizType !== '全部') {
|
||||
list = list.filter((r: any) => r.bizType === filterForm.bizType)
|
||||
}
|
||||
if (filterForm.applicantId != null) {
|
||||
list = list.filter((r: any) => Number(r.applicantId) === Number(filterForm.applicantId))
|
||||
}
|
||||
if (filterForm.applyDate) {
|
||||
const d = filterForm.applyDate
|
||||
list = list.filter((r: any) => String(r.applyTime || '').slice(0, 10) === d)
|
||||
}
|
||||
if (filterForm.status && filterForm.status !== '全部') {
|
||||
if (filterForm.status === '已发放') {
|
||||
list = list.filter((r: any) => ['issued', 'paid', 'offset'].includes(r.status))
|
||||
} else {
|
||||
const map: Record<string, string> = {
|
||||
待提交: 'draft',
|
||||
审批中: 'pending',
|
||||
审批通过: 'approved',
|
||||
审批驳回: 'rejected'
|
||||
}
|
||||
const want = map[filterForm.status]
|
||||
if (want) list = list.filter((r: any) => r.status === want)
|
||||
}
|
||||
}
|
||||
if (filterForm.currentNode && filterForm.currentNode !== '全部') {
|
||||
list = list.filter((r: any) => (r.currentNode || '') === filterForm.currentNode)
|
||||
}
|
||||
if (filterForm.amountRange?.trim()) {
|
||||
const parts = filterForm.amountRange.split(/[-–]/).map((x: string) => Number(String(x).trim()))
|
||||
if (parts.length >= 2 && !parts.some((n) => Number.isNaN(n))) {
|
||||
const lo = Math.min(parts[0], parts[1])
|
||||
const hi = Math.max(parts[0], parts[1])
|
||||
list = list.filter((r: any) => {
|
||||
const amt = Number(r.amount || 0)
|
||||
return amt >= lo && amt <= hi
|
||||
})
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
const filteredMergedRows = computed(() => filterMergedRows(mergedRows.value))
|
||||
|
||||
const pager = usePagedTable(() => filteredMergedRows.value, { initialPageSize: 10 })
|
||||
const currentRow = ref<any>(null)
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
|
||||
const stats = ref([
|
||||
{ name: '全部单据', value: '-' },
|
||||
{ name: '审批中', value: '-' },
|
||||
{ name: '已通过', value: '-' },
|
||||
{ name: '已发放', value: '-' },
|
||||
{ name: '已驳回', value: '-' }
|
||||
])
|
||||
|
||||
const bizTypeOptions = ['全部', '报销单', '备用金']
|
||||
const statusOptions = ['全部', '待提交', '审批中', '审批通过', '审批驳回', '已发放']
|
||||
const nodeOptions = ['全部', '草稿', '发起人主管审批', '财务复核', '总经理审批', '已完成', '已驳回', '已发放']
|
||||
|
||||
function bizTypeTagType(bizType: string | undefined): 'primary' | 'info' {
|
||||
return bizType === '报销单' ? 'primary' : 'info'
|
||||
}
|
||||
|
||||
function countStatus(m: Record<string, number> | undefined, key: string) {
|
||||
return Number(m?.[key] ?? 0)
|
||||
}
|
||||
|
||||
function sumStatusMap(m: Record<string, number> | undefined) {
|
||||
if (!m) return 0
|
||||
return Object.values(m).reduce((acc, v) => acc + Number(v || 0), 0)
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const [advRes, reimRes, advCntRes, reimCntRes]: any[] = await Promise.all([
|
||||
advanceApi.list({ page: 1, pageSize: 999 }),
|
||||
reimburseApi.list({ page: 1, pageSize: 999 }),
|
||||
advanceApi.statusCounts(),
|
||||
reimburseApi.statusCounts()
|
||||
])
|
||||
const advRows = (advRes.data?.rows || []).map((r: any) => ({
|
||||
...r,
|
||||
bizType: '备用金',
|
||||
title: r.reason,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
applicantId: r.applicantId
|
||||
}))
|
||||
const reimRows = (reimRes.data?.rows || []).map((r: any) => ({
|
||||
...r,
|
||||
bizType: '报销单',
|
||||
title: r.title,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
applicantId: r.applicantId
|
||||
}))
|
||||
mergedRows.value = [...advRows, ...reimRows]
|
||||
const ac = advCntRes.data as Record<string, number> | undefined
|
||||
const rc = reimCntRes.data as Record<string, number> | undefined
|
||||
const totalAll = sumStatusMap(rc) + sumStatusMap(ac)
|
||||
const pending = countStatus(rc, 'pending') + countStatus(ac, 'pending')
|
||||
const approved = countStatus(rc, 'approved') + countStatus(ac, 'approved')
|
||||
const issued =
|
||||
countStatus(rc, 'processed') +
|
||||
countStatus(rc, 'paid') +
|
||||
countStatus(rc, 'offset') +
|
||||
countStatus(ac, 'issued')
|
||||
const rejected = countStatus(rc, 'rejected') + countStatus(ac, 'rejected')
|
||||
stats.value = [
|
||||
{ name: '全部单据', value: String(totalAll) },
|
||||
{ name: '审批中', value: String(pending) },
|
||||
{ name: '已通过', value: String(approved) },
|
||||
{ name: '已发放', value: String(issued) },
|
||||
{ name: '已驳回', value: String(rejected) }
|
||||
]
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMoreFilters() {
|
||||
showMoreFilters.value = !showMoreFilters.value
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
pager.currentPage.value = 1
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, {
|
||||
code: '',
|
||||
bizType: '',
|
||||
applicantId: undefined,
|
||||
status: '',
|
||||
applyDate: null,
|
||||
amountRange: '',
|
||||
currentNode: ''
|
||||
})
|
||||
pager.currentPage.value = 1
|
||||
}
|
||||
|
||||
function summaryMethod(params: { data: Array<{ amount?: number }> }) {
|
||||
const totalAmount = params.data.reduce((sum, row) => sum + Number(row.amount || 0), 0)
|
||||
return ['', `本页合计(${params.data.length}单)`, '', '', '', '', formatSumMoney(totalAmount), '', '', '']
|
||||
}
|
||||
|
||||
async function openViewDetail(row: any) {
|
||||
currentRow.value = row
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewFlowLoading.value = true
|
||||
dialogs.viewDetail = true
|
||||
try {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
api.getApprovals(row.id),
|
||||
api.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载审批流程失败')
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadApplicantOptions()
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,459 @@
|
||||
<!-- 我的申请单 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">我的申请单</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="单号">
|
||||
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="业务类型">
|
||||
<el-select v-model="filterForm.bizType" placeholder="全部" clearable>
|
||||
<el-option label="报销单" value="报销单" />
|
||||
<el-option label="备用金" value="备用金" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="filterForm.status" placeholder="全部" clearable>
|
||||
<el-option label="待提交" value="draft" />
|
||||
<el-option label="审批中" value="pending" />
|
||||
<el-option label="审批通过" value="approved" />
|
||||
<el-option label="审批驳回" value="rejected" />
|
||||
<el-option label="已发放" value="issued" />
|
||||
<el-option label="已处理" value="processed" />
|
||||
<el-option label="已冲抵" value="offset" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="showMoreFilters" id="mine-apply-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="金额区间(元)">
|
||||
<el-input v-model="filterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMoreFilters"
|
||||
aria-controls="mine-apply-filter-extra"
|
||||
@click="toggleMoreFilters"
|
||||
>
|
||||
{{ showMoreFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMoreFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button native-type="button" class="btn-ghost" :loading="searchLoading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button native-type="button" class="btn-main" type="primary" :loading="searchLoading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="pagedRows"
|
||||
v-loading="tableLoading"
|
||||
stripe
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="bizType" label="业务类型" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="bizTypeTagType(row.bizType)" size="small">
|
||||
{{ row.bizType }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="申请标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="status" label="状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="120" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button class="btn-op-item" @click="openViewDetail(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.viewDetail"
|
||||
title="申请单详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ currentRow?.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="statusTagType(currentRow?.status)" size="small">
|
||||
{{ statusLabel(currentRow?.status) }}
|
||||
</el-tag>
|
||||
<el-tag :type="bizTypeTagType(currentRow?.bizType)" size="small">
|
||||
{{ currentRow?.bizType || '-' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
金额(元):<b class="money-em">{{ formatMoneyYuan(currentRow?.amount || 0) }}</b>
|
||||
</p>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请单号</div>
|
||||
<div class="v">{{ currentRow?.applyCode || '-' }}</div>
|
||||
<div class="k">业务类型</div>
|
||||
<div class="v">{{ currentRow?.bizType || '-' }}</div>
|
||||
<div class="k">申请标题</div>
|
||||
<div class="v"><BaseClampText :text="currentRow?.title" /></div>
|
||||
<div class="k">申请金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(currentRow?.amount || 0) }}</div>
|
||||
<div class="k">状态</div>
|
||||
<div class="v">{{ statusLabel(currentRow?.status) }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(currentRow?.currentNode, currentRow?.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ currentRow?.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewDetail = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { View, Close, Search, RefreshLeft, ArrowUpBold, ArrowDownBold } from '@element-plus/icons-vue'
|
||||
import { advanceApi, reimburseApi } from '@/api/bx'
|
||||
import {
|
||||
statusLabel,
|
||||
statusTagType,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType,
|
||||
shouldShowWorkflowNodeTag
|
||||
} from '@/utils/bx/format'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import { usePagedTable } from '@/hooks/bx/usePagedTable'
|
||||
|
||||
type DialogKey = 'viewDetail'
|
||||
|
||||
const showMoreFilters = ref(false)
|
||||
const tableLoading = ref(false)
|
||||
const searchLoading = ref(false)
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
viewDetail: false
|
||||
})
|
||||
|
||||
const mergedRows = ref<any[]>([])
|
||||
|
||||
const filterForm = reactive({
|
||||
code: '',
|
||||
bizType: '' as string,
|
||||
status: '' as string,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
const appliedFilter = reactive({
|
||||
code: '',
|
||||
bizType: '' as string,
|
||||
status: '' as string,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
function syncAppliedFilter() {
|
||||
Object.assign(appliedFilter, { ...filterForm })
|
||||
}
|
||||
|
||||
function filterMineRows(rows: any[]) {
|
||||
let list = [...rows]
|
||||
if (appliedFilter.bizType) {
|
||||
list = list.filter((r: any) => r.bizType === appliedFilter.bizType)
|
||||
}
|
||||
if (appliedFilter.amountRange?.trim()) {
|
||||
const parts = appliedFilter.amountRange.split(/[-–]/).map((x: string) => Number(String(x).trim()))
|
||||
if (parts.length >= 2 && !parts.some((n) => Number.isNaN(n))) {
|
||||
const lo = Math.min(parts[0], parts[1])
|
||||
const hi = Math.max(parts[0], parts[1])
|
||||
list = list.filter((r: any) => {
|
||||
const amt = Number(r.amount || 0)
|
||||
return amt >= lo && amt <= hi
|
||||
})
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
const filteredMergedRows = computed(() => filterMineRows(mergedRows.value))
|
||||
|
||||
const {
|
||||
pagedRows,
|
||||
total: filteredTotal,
|
||||
currentPage,
|
||||
pageSize,
|
||||
rangeText,
|
||||
onSizeChange
|
||||
} = usePagedTable(() => filteredMergedRows.value, { initialPageSize: 10 })
|
||||
const currentRow = ref<any>(null)
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
|
||||
const stats = ref([
|
||||
{ name: '全部申请', value: '-' },
|
||||
{ name: '审批中', value: '-' },
|
||||
{ name: '已通过', value: '-' },
|
||||
{ name: '已驳回', value: '-' }
|
||||
])
|
||||
|
||||
function buildApiQuery() {
|
||||
const q: Record<string, string> = {}
|
||||
const code = appliedFilter.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (appliedFilter.status) q.status = appliedFilter.status
|
||||
if (appliedFilter.applyDate) q.applyDate = appliedFilter.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
function bizTypeTagType(bizType: string | undefined): 'primary' | 'info' {
|
||||
return bizType === '报销单' ? 'primary' : 'info'
|
||||
}
|
||||
|
||||
function mapAdvanceMineRow(r: any) {
|
||||
return {
|
||||
...r,
|
||||
bizType: '备用金',
|
||||
title: r.reason,
|
||||
applyCode: r.applyCode || r.code
|
||||
}
|
||||
}
|
||||
|
||||
function mapReimburseMineRow(r: any) {
|
||||
return {
|
||||
...r,
|
||||
bizType: '报销单',
|
||||
title: r.title,
|
||||
applyCode: r.applyCode || r.code
|
||||
}
|
||||
}
|
||||
|
||||
function sortMergedRows(rows: any[]) {
|
||||
return [...rows].sort((a, b) => String(b.applyTime || '').localeCompare(String(a.applyTime || '')))
|
||||
}
|
||||
|
||||
async function loadData(options: { buttonLoading?: boolean } = {}) {
|
||||
if (options.buttonLoading) searchLoading.value = true
|
||||
tableLoading.value = true
|
||||
try {
|
||||
const apiQuery = buildApiQuery()
|
||||
const listParams = { page: 1, pageSize: 9999, ...apiQuery }
|
||||
const [advRes, reimRes, advSt, reimSt] = await Promise.allSettled([
|
||||
advanceApi.my(listParams),
|
||||
reimburseApi.my(listParams),
|
||||
advanceApi.myStats(),
|
||||
reimburseApi.myStats()
|
||||
])
|
||||
const advRows =
|
||||
advRes.status === 'fulfilled'
|
||||
? (advRes.value.data?.rows || []).map(mapAdvanceMineRow)
|
||||
: []
|
||||
const reimRows =
|
||||
reimRes.status === 'fulfilled'
|
||||
? (reimRes.value.data?.rows || []).map(mapReimburseMineRow)
|
||||
: []
|
||||
mergedRows.value = sortMergedRows([...advRows, ...reimRows])
|
||||
const a = advSt.status === 'fulfilled' ? advSt.value.data || {} : {}
|
||||
const r = reimSt.status === 'fulfilled' ? reimSt.value.data || {} : {}
|
||||
const totalCount = Number(r.totalCount ?? 0) + Number(a.totalCount ?? 0)
|
||||
const pending = Number(r.pendingCount ?? 0) + Number(a.pendingCount ?? 0)
|
||||
const approved =
|
||||
Number(r.approvedCount ?? 0) + Number(a.approvedPassCount ?? 0) + Number(a.issuedCount ?? 0)
|
||||
const rejected = Number(r.rejectedCount ?? 0) + Number(a.rejectedCount ?? 0)
|
||||
stats.value = [
|
||||
{ name: '全部申请', value: String(totalCount) },
|
||||
{ name: '审批中', value: String(pending) },
|
||||
{ name: '已通过', value: String(approved) },
|
||||
{ name: '已驳回', value: String(rejected) }
|
||||
]
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
if (options.buttonLoading) searchLoading.value = false
|
||||
tableLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMoreFilters() {
|
||||
showMoreFilters.value = !showMoreFilters.value
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
syncAppliedFilter()
|
||||
currentPage.value = 1
|
||||
loadData({ buttonLoading: true })
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, { code: '', bizType: '', status: '', applyDate: null, amountRange: '' })
|
||||
Object.assign(appliedFilter, { code: '', bizType: '', status: '', applyDate: null, amountRange: '' })
|
||||
currentPage.value = 1
|
||||
loadData({ buttonLoading: true })
|
||||
}
|
||||
|
||||
async function openViewDetail(row: any) {
|
||||
currentRow.value = row
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewFlowLoading.value = true
|
||||
dialogs.viewDetail = true
|
||||
try {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
api.getApprovals(row.id),
|
||||
api.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载审批流程失败')
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
onActivated(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,636 @@
|
||||
<!-- 待我审批 -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="stats">
|
||||
<div v-for="item in stats" :key="item.name" class="stat" :class="{ 'stat-money': item.name.includes('金额') }">
|
||||
<p class="k">{{ item.name }}</p>
|
||||
<p class="v">{{ item.value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">待我审批</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="单号">
|
||||
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="业务类型">
|
||||
<el-select v-model="filterForm.bizType" placeholder="全部" clearable>
|
||||
<el-option label="报销单" value="报销单" />
|
||||
<el-option label="备用金" value="备用金" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请人">
|
||||
<el-select v-model="filterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||||
<el-option
|
||||
v-for="opt in applicantOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间">
|
||||
<el-date-picker
|
||||
v-model="filterForm.applyDate"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择日期"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-show="showMoreFilters" id="todo-approve-filter-extra" class="filter-extra">
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="金额区间(元)">
|
||||
<el-input v-model="filterForm.amountRange" placeholder="如 1000-5000" clearable />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-link btn-filter-toggle"
|
||||
:aria-expanded="showMoreFilters"
|
||||
aria-controls="todo-approve-filter-extra"
|
||||
@click="toggleMoreFilters"
|
||||
>
|
||||
{{ showMoreFilters ? '收起更多' : '展开更多' }}
|
||||
<el-icon>
|
||||
<ArrowUpBold v-if="showMoreFilters" />
|
||||
<ArrowDownBold v-else />
|
||||
</el-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-actions-end">
|
||||
<el-button native-type="button" class="btn-ghost" :loading="searchLoading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button native-type="button" class="btn-main" type="primary" :loading="searchLoading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.batchPass" @click="handleBatchPass">
|
||||
<el-icon><Check /></el-icon>批量通过
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.batchReject" @click="handleBatchReject">
|
||||
<el-icon><Close /></el-icon>批量驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<div class="table-scroll table-page-summary">
|
||||
<el-table
|
||||
class="list-table"
|
||||
:data="pagedRows"
|
||||
v-loading="tableLoading"
|
||||
stripe
|
||||
show-summary
|
||||
:summary-method="summaryMethod"
|
||||
:max-height="'min(520px, calc(100vh - 300px))'"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="applyTime"
|
||||
label="申请时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="applyCode"
|
||||
label="申请单号"
|
||||
min-width="140"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="bizType" label="业务类型" min-width="100" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="bizTypeTagType(row.bizType)" size="small">
|
||||
{{ row.bizType }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="applicantName" label="申请人" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="申请标题"
|
||||
min-width="180"
|
||||
align="left"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
label="申请金额(元)"
|
||||
:formatter="moneyTableFormatter"
|
||||
class-name="col-money"
|
||||
min-width="120"
|
||||
align="right"
|
||||
header-align="center"
|
||||
/>
|
||||
<el-table-column prop="currentNode" label="当前节点" min-width="120" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="shouldShowWorkflowNodeTag(row.currentNode, row.status)"
|
||||
:type="workflowNodeTagType(row.currentNode, row.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(row.currentNode, row.status) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="280" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openViewDetail(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-op-item"
|
||||
:loading="loadingMap[`pass_${row.id}`]"
|
||||
@click="handleApprove(row)"
|
||||
>
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="openRejectDialog(row)">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<span class="list-range">{{ rangeText }}</span>
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredTotal"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.viewDetail"
|
||||
title="申请单详情"
|
||||
width="920px"
|
||||
class="dialog-form-layout dialog-view-xl"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="dlg-view">
|
||||
<div class="dlg-view-hero">
|
||||
<div class="dlg-view-hero-top">
|
||||
<h2 class="dlg-view-title">{{ currentRow?.applyCode || '-' }}</h2>
|
||||
<div class="dlg-view-tags">
|
||||
<el-tag :type="bizTypeTagType(currentRow?.bizType)" size="small">
|
||||
{{ currentRow?.bizType || '-' }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="currentRow && shouldShowWorkflowNodeTag(currentRow.currentNode, currentRow.status)"
|
||||
:type="workflowNodeTagType(currentRow.currentNode, currentRow.status)"
|
||||
size="small"
|
||||
>
|
||||
{{ workflowNodeLabel(currentRow.currentNode, currentRow.status) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p class="dlg-view-meta">
|
||||
金额(元):<b class="money-em">{{ formatMoneyYuan(currentRow?.amount || 0) }}</b>
|
||||
· 申请人:{{ currentRow?.applicantName || '-' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<div class="dlg-kv dlg-kv--triple">
|
||||
<div class="k">申请单号</div>
|
||||
<div class="v">{{ currentRow?.applyCode || '-' }}</div>
|
||||
<div class="k">业务类型</div>
|
||||
<div class="v">{{ currentRow?.bizType || '-' }}</div>
|
||||
<div class="k">申请人</div>
|
||||
<div class="v">{{ currentRow?.applicantName || '-' }}</div>
|
||||
<div class="k">申请标题</div>
|
||||
<div class="v"><BaseClampText :text="currentRow?.title" /></div>
|
||||
<div class="k">申请金额(元)</div>
|
||||
<div class="v money-value">{{ formatMoneyYuan(currentRow?.amount || 0) }}</div>
|
||||
<div class="k">当前节点</div>
|
||||
<div class="v">{{ workflowNodeDisplay(currentRow?.currentNode, currentRow?.status) }}</div>
|
||||
<div class="k">申请时间</div>
|
||||
<div class="v">{{ currentRow?.applyTime || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批进度</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalFlowView :nodes="viewFlowNodes" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">审批历史</h4>
|
||||
<div class="flow-scroll">
|
||||
<ApprovalHistoryView :items="viewApprovalHistory" :loading="viewFlowLoading" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.viewDetail = false">
|
||||
<el-icon><Close /></el-icon>关闭
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.approve"
|
||||
title="审批确认"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="审批意见">
|
||||
<el-input v-model="approveOpinion" type="textarea" :rows="4" placeholder="请输入审批意见" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.approve = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.approvePass" @click="handleDialogApprove">
|
||||
<el-icon><Check /></el-icon>通过
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" type="danger" :loading="loadingMap.approveReject" @click="handleDialogReject">
|
||||
<el-icon><Close /></el-icon>驳回
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
View,
|
||||
Check,
|
||||
Close,
|
||||
Search,
|
||||
RefreshLeft,
|
||||
ArrowUpBold,
|
||||
ArrowDownBold
|
||||
} from '@element-plus/icons-vue'
|
||||
import { advanceApi, reimburseApi } from '@/api/bx'
|
||||
import {
|
||||
formatSumMoney,
|
||||
formatMoneyYuan,
|
||||
moneyTableFormatter,
|
||||
workflowNodeDisplay,
|
||||
shouldShowWorkflowNodeTag,
|
||||
workflowNodeLabel,
|
||||
workflowNodeTagType
|
||||
} from '@/utils/bx/format'
|
||||
import ApprovalFlowView from '@/components/bx/base/ApprovalFlowView.vue'
|
||||
import ApprovalHistoryView from '@/components/bx/base/ApprovalHistoryView.vue'
|
||||
import BaseClampText from '@/components/bx/base/BaseClampText.vue'
|
||||
import { usePagedTable } from '@/hooks/bx/usePagedTable'
|
||||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||||
|
||||
type DialogKey = 'viewDetail' | 'approve'
|
||||
|
||||
const showMoreFilters = ref(false)
|
||||
const tableLoading = ref(false)
|
||||
const searchLoading = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
viewDetail: false,
|
||||
approve: false
|
||||
})
|
||||
|
||||
const mergedRows = ref<any[]>([])
|
||||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||||
|
||||
const filterForm = reactive({
|
||||
code: '',
|
||||
bizType: '' as string,
|
||||
applicantId: undefined as string | number | undefined,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
const appliedFilter = reactive({
|
||||
code: '',
|
||||
bizType: '' as string,
|
||||
applicantId: undefined as string | number | undefined,
|
||||
applyDate: null as string | null,
|
||||
amountRange: ''
|
||||
})
|
||||
|
||||
function syncAppliedFilter() {
|
||||
Object.assign(appliedFilter, { ...filterForm })
|
||||
}
|
||||
|
||||
function filterTodoRows(rows: any[]) {
|
||||
let list = [...rows]
|
||||
if (appliedFilter.bizType) {
|
||||
list = list.filter((r: any) => r.bizType === appliedFilter.bizType)
|
||||
}
|
||||
if (appliedFilter.amountRange?.trim()) {
|
||||
const parts = appliedFilter.amountRange.split(/[-–]/).map((x: string) => Number(String(x).trim()))
|
||||
if (parts.length >= 2 && !parts.some((n) => Number.isNaN(n))) {
|
||||
const lo = Math.min(parts[0], parts[1])
|
||||
const hi = Math.max(parts[0], parts[1])
|
||||
list = list.filter((r: any) => {
|
||||
const amt = Number(r.amount || 0)
|
||||
return amt >= lo && amt <= hi
|
||||
})
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
const filteredMergedRows = computed(() => filterTodoRows(mergedRows.value))
|
||||
|
||||
const {
|
||||
pagedRows,
|
||||
total: filteredTotal,
|
||||
currentPage,
|
||||
pageSize,
|
||||
rangeText,
|
||||
onSizeChange
|
||||
} = usePagedTable(() => filteredMergedRows.value, { initialPageSize: 10 })
|
||||
const currentRow = ref<any>(null)
|
||||
const approveOpinion = ref('')
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
|
||||
const stats = ref([
|
||||
{ name: '待审批报销', value: '-' },
|
||||
{ name: '待审批备用金', value: '-' },
|
||||
{ name: '待审批合计', value: '-' },
|
||||
{ name: '紧急单据', value: '0' }
|
||||
])
|
||||
|
||||
|
||||
function buildApiQuery() {
|
||||
const q: Record<string, string | number> = {}
|
||||
const code = appliedFilter.code.trim()
|
||||
if (code) q.keyword = code
|
||||
if (appliedFilter.applicantId != null && appliedFilter.applicantId !== '') {
|
||||
q.applicantId = appliedFilter.applicantId
|
||||
}
|
||||
if (appliedFilter.applyDate) q.applyDate = appliedFilter.applyDate
|
||||
return q
|
||||
}
|
||||
|
||||
function mapAdvanceTodoRow(r: any) {
|
||||
return {
|
||||
...r,
|
||||
bizType: '备用金',
|
||||
title: r.reason,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
applicantId: r.applicantId
|
||||
}
|
||||
}
|
||||
|
||||
function mapReimburseTodoRow(r: any) {
|
||||
return {
|
||||
...r,
|
||||
bizType: '报销单',
|
||||
title: r.title,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
applicantId: r.applicantId
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData(options: { buttonLoading?: boolean } = {}) {
|
||||
if (options.buttonLoading) searchLoading.value = true
|
||||
tableLoading.value = true
|
||||
try {
|
||||
const listParams = { page: 1, pageSize: 9999, ...buildApiQuery() }
|
||||
const [advRes, reimRes] = await Promise.allSettled([
|
||||
advanceApi.pendingApproval(listParams),
|
||||
reimburseApi.pendingApproval(listParams)
|
||||
])
|
||||
const advRows =
|
||||
advRes.status === 'fulfilled' ? (advRes.value.data?.rows || []).map(mapAdvanceTodoRow) : []
|
||||
const reimRows =
|
||||
reimRes.status === 'fulfilled' ? (reimRes.value.data?.rows || []).map(mapReimburseTodoRow) : []
|
||||
mergedRows.value = [...advRows, ...reimRows]
|
||||
const reimTotal =
|
||||
reimRes.status === 'fulfilled' ? Number(reimRes.value.data?.total ?? reimRows.length) : 0
|
||||
const advTotal =
|
||||
advRes.status === 'fulfilled' ? Number(advRes.value.data?.total ?? advRows.length) : 0
|
||||
stats.value = [
|
||||
{ name: '待审批报销', value: String(reimTotal) },
|
||||
{ name: '待审批备用金', value: String(advTotal) },
|
||||
{ name: '待审批合计', value: String(reimTotal + advTotal) },
|
||||
{ name: '紧急单据', value: '0' }
|
||||
]
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
if (options.buttonLoading) searchLoading.value = false
|
||||
tableLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function bizTypeTagType(bizType: string | undefined): 'primary' | 'info' {
|
||||
return bizType === '报销单' ? 'primary' : 'info'
|
||||
}
|
||||
|
||||
async function handleApprove(row: any) {
|
||||
const key = `pass_${row.id}`
|
||||
loadingMap[key] = true
|
||||
try {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
await api.approve(row.id, { approvalOpinion: '' })
|
||||
ElMessage.success('审批通过')
|
||||
await loadData()
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
function openRejectDialog(row: any) {
|
||||
currentRow.value = row
|
||||
approveOpinion.value = ''
|
||||
dialogs.approve = true
|
||||
}
|
||||
|
||||
async function handleDialogApprove() {
|
||||
if (!currentRow.value) return
|
||||
loadingMap.approvePass = true
|
||||
try {
|
||||
const api = currentRow.value.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
await api.approve(currentRow.value.id, { approvalOpinion: approveOpinion.value })
|
||||
ElMessage.success('审批通过')
|
||||
dialogs.approve = false
|
||||
await loadData()
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loadingMap.approvePass = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDialogReject() {
|
||||
if (!currentRow.value) return
|
||||
loadingMap.approveReject = true
|
||||
try {
|
||||
const api = currentRow.value.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
await api.reject(currentRow.value.id, { approvalOpinion: approveOpinion.value })
|
||||
ElMessage.success('已驳回')
|
||||
dialogs.approve = false
|
||||
await loadData()
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loadingMap.approveReject = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMoreFilters() {
|
||||
showMoreFilters.value = !showMoreFilters.value
|
||||
}
|
||||
|
||||
const selectedRows = ref<any[]>([])
|
||||
|
||||
function onSelectionChange(rows: any[]) {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
async function handleBatchPass() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要审批的单据')
|
||||
return
|
||||
}
|
||||
loadingMap.batchPass = true
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
await api.approve(row.id, { approvalOpinion: '' })
|
||||
}
|
||||
ElMessage.success('批量审批通过成功')
|
||||
await loadData()
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loadingMap.batchPass = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBatchReject() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选要驳回的单据')
|
||||
return
|
||||
}
|
||||
loadingMap.batchReject = true
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
await api.reject(row.id, { approvalOpinion: '' })
|
||||
}
|
||||
ElMessage.success('批量驳回成功')
|
||||
await loadData()
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
loadingMap.batchReject = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
syncAppliedFilter()
|
||||
currentPage.value = 1
|
||||
loadData({ buttonLoading: true })
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
Object.assign(filterForm, {
|
||||
code: '',
|
||||
bizType: '',
|
||||
applicantId: undefined,
|
||||
applyDate: null,
|
||||
amountRange: ''
|
||||
})
|
||||
Object.assign(appliedFilter, {
|
||||
code: '',
|
||||
bizType: '',
|
||||
applicantId: undefined,
|
||||
applyDate: null,
|
||||
amountRange: ''
|
||||
})
|
||||
currentPage.value = 1
|
||||
loadData({ buttonLoading: true })
|
||||
}
|
||||
|
||||
function summaryMethod(params: { data: Array<{ amount?: number }> }) {
|
||||
const totalAmount = params.data.reduce((sum, row) => sum + Number(row.amount || 0), 0)
|
||||
return ['', '', `本页合计(${params.data.length}单)`, '', '', '', '', formatSumMoney(totalAmount), '', '']
|
||||
}
|
||||
|
||||
async function openViewDetail(row: any) {
|
||||
currentRow.value = row
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewFlowLoading.value = true
|
||||
dialogs.viewDetail = true
|
||||
try {
|
||||
const api = row.bizType === '备用金' ? advanceApi : reimburseApi
|
||||
const [flowRes, historyRes]: any[] = await Promise.all([
|
||||
api.getApprovals(row.id),
|
||||
api.getApprovalHistory(row.id)
|
||||
])
|
||||
viewFlowNodes.value = (flowRes.data || []).sort((a: any, b: any) => a.nodeOrder - b.nodeOrder)
|
||||
viewApprovalHistory.value = historyRes.data || []
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载审批流程失败')
|
||||
} finally {
|
||||
viewFlowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadApplicantOptions()
|
||||
loadData()
|
||||
})
|
||||
|
||||
onActivated(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,419 @@
|
||||
<!-- 工作流配置(备用金) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">审批流程节点</h2>
|
||||
</div>
|
||||
|
||||
<div class="wf-info-bar">
|
||||
<span><b>流程名称:</b>{{ wfDef.wfName || '-' }}</span>
|
||||
<span>
|
||||
<b>状态:</b>
|
||||
<el-tag :type="statusTagType(wfDef.status)" size="small">
|
||||
{{ statusLabel(wfDef.status) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">0</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="openAddDialog">
|
||||
<el-icon><Plus /></el-icon>新增节点
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.save" @click="saveNodes">
|
||||
<el-icon><Upload /></el-icon>保存配置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="nodes" v-loading="loading" stripe>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="nodeName"
|
||||
label="节点名称"
|
||||
min-width="180"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="nodeOrder" label="节点顺序" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="approverName"
|
||||
label="审批人"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="配置状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="(row.approverId ?? row.approver_id) ? 'success' : 'warning'" size="small">
|
||||
{{ (row.approverId ?? row.approver_id) ? '已配置' : '未配置' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="360" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openEditDialog(row)">
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" :loading="loadingMap.rowDelete" @click="deleteNode(row)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="moveUp(row)">
|
||||
<el-icon><ArrowUp /></el-icon>上移
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="moveDown(row)">
|
||||
<el-icon><ArrowDown /></el-icon>下移
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.addNode"
|
||||
title="新增节点"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="addFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="formData.nodeName" placeholder="请输入节点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点顺序">
|
||||
<el-input-number v-model="formData.nodeOrder" controls-position="right" :min="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人" style="grid-column: 1 / -1">
|
||||
<el-select
|
||||
v-model="formData.approverId"
|
||||
placeholder="请选择审批人"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleApproverChange"
|
||||
>
|
||||
<el-option v-for="u in userOptions" :key="u.id" :label="u.displayName" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.addNode = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addNodeSubmit" @click="submitAddNode">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.editNode"
|
||||
title="编辑节点"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="editFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="formData.nodeName" placeholder="请输入节点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点顺序">
|
||||
<el-input-number v-model="formData.nodeOrder" controls-position="right" :min="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人" style="grid-column: 1 / -1">
|
||||
<el-select
|
||||
v-model="formData.approverId"
|
||||
placeholder="请选择审批人"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleApproverChange"
|
||||
>
|
||||
<el-option v-for="u in userOptions" :key="u.id" :label="u.displayName" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.editNode = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.editNodeSubmit" @click="submitEditNode">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
EditPen,
|
||||
Delete,
|
||||
Close,
|
||||
Check,
|
||||
Upload,
|
||||
ArrowUp,
|
||||
ArrowDown
|
||||
} from '@element-plus/icons-vue'
|
||||
import { workflowApi } from '@/api/bx'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import { statusLabel, statusTagType } from '@/utils/bx/format'
|
||||
|
||||
type DialogKey = 'addNode' | 'editNode'
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
addNode: false,
|
||||
editNode: false
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const wfDef = ref<Record<string, any>>({})
|
||||
const nodes = computed(() => wfDef.value.nodes || [])
|
||||
const userOptions = ref<
|
||||
{ id: string; realName: string; username: string; roles: string; displayName: string }[]
|
||||
>([])
|
||||
|
||||
const formData = reactive({
|
||||
nodeName: '',
|
||||
nodeOrder: 1,
|
||||
approverId: null as string | null,
|
||||
approverName: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
nodeName: [{ required: true, message: '节点名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const addFormRef = ref<FormInstance>()
|
||||
const editFormRef = ref<FormInstance>()
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res = await fetchUserOptions()
|
||||
const data: any = (res as any)?.data ?? res ?? []
|
||||
userOptions.value = (Array.isArray(data) ? data : []).map((u: any) => {
|
||||
const name = u.label || u.nickName || ''
|
||||
const account = u.userNo || ''
|
||||
return {
|
||||
id: String(u.value ?? u.id ?? ''),
|
||||
realName: name,
|
||||
username: account,
|
||||
roles: '',
|
||||
displayName: account ? `${name}(${account})` : name
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadWfDef() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await workflowApi.getByBizType('advance')
|
||||
wfDef.value = res.data ?? {}
|
||||
} catch {
|
||||
wfDef.value = {}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadWfDef()
|
||||
loadUsers()
|
||||
})
|
||||
|
||||
function buildNodePayload(list: Record<string, any>[]) {
|
||||
return list.map((n, i) => ({
|
||||
nodeName: n.nodeName,
|
||||
nodeOrder: i + 1,
|
||||
approverId: n.approverId ?? n.approver_id ?? null,
|
||||
approverName: n.approverName ?? n.approver_name ?? ''
|
||||
}))
|
||||
}
|
||||
|
||||
async function saveNodes() {
|
||||
loadingMap.save = true
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(nodes.value))
|
||||
ElMessage.success('保存成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '保存失败')
|
||||
} finally {
|
||||
loadingMap.save = false
|
||||
}
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
Object.assign(formData, {
|
||||
nodeName: '',
|
||||
nodeOrder: nodes.value.length + 1,
|
||||
approverId: null,
|
||||
approverName: ''
|
||||
})
|
||||
dialogs.addNode = true
|
||||
}
|
||||
|
||||
function openEditDialog(node: Record<string, any>) {
|
||||
Object.assign(formData, {
|
||||
nodeName: node.nodeName,
|
||||
nodeOrder: node.nodeOrder,
|
||||
approverId: node.approverId ?? node.approver_id ?? null,
|
||||
approverName: node.approverName ?? node.approver_name ?? ''
|
||||
})
|
||||
dialogs.editNode = true
|
||||
}
|
||||
|
||||
function handleApproverChange(userId: string | null) {
|
||||
if (userId == null) {
|
||||
formData.approverName = ''
|
||||
return
|
||||
}
|
||||
const found = userOptions.value.find((u) => u.id === userId)
|
||||
formData.approverName = found ? found.realName : ''
|
||||
}
|
||||
|
||||
async function submitAddNode() {
|
||||
const valid = await addFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.addNodeSubmit = true
|
||||
try {
|
||||
const newNodes = [
|
||||
...nodes.value,
|
||||
{
|
||||
nodeName: formData.nodeName,
|
||||
nodeOrder: formData.nodeOrder,
|
||||
approverId: formData.approverId,
|
||||
approverName: formData.approverName
|
||||
}
|
||||
]
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('新增成功')
|
||||
dialogs.addNode = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '新增失败')
|
||||
} finally {
|
||||
loadingMap.addNodeSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitEditNode() {
|
||||
const valid = await editFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.editNodeSubmit = true
|
||||
try {
|
||||
const newNodes = nodes.value.map((n: Record<string, any>) =>
|
||||
n.nodeOrder === formData.nodeOrder
|
||||
? {
|
||||
...n,
|
||||
nodeName: formData.nodeName,
|
||||
approverId: formData.approverId,
|
||||
approverName: formData.approverName
|
||||
}
|
||||
: n
|
||||
)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('编辑成功')
|
||||
dialogs.editNode = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '编辑失败')
|
||||
} finally {
|
||||
loadingMap.editNodeSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteNode(node: Record<string, any>) {
|
||||
await ElMessageBox.confirm(`确定要删除节点「${node.nodeName}」吗?`, '删除确认', {
|
||||
confirmButtonText: '确定删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
loadingMap.rowDelete = true
|
||||
try {
|
||||
const newNodes = nodes.value.filter((n: Record<string, any>) => n.id !== node.id)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('删除成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') ElMessage.error(e.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap.rowDelete = false
|
||||
}
|
||||
}
|
||||
|
||||
async function moveUp(node: Record<string, any>) {
|
||||
const idx = nodes.value.findIndex((n: Record<string, any>) => n.id === node.id)
|
||||
if (idx <= 0) return
|
||||
const arr = [...nodes.value]
|
||||
const temp = arr[idx]
|
||||
arr[idx] = arr[idx - 1]
|
||||
arr[idx - 1] = temp
|
||||
arr.forEach((n: Record<string, any>, i: number) => (n.nodeOrder = i + 1))
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
ElMessage.success('上移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '上移失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function moveDown(node: Record<string, any>) {
|
||||
const arr = [...nodes.value]
|
||||
const idx = arr.findIndex((n: Record<string, any>) => n.id === node.id)
|
||||
if (idx < 0 || idx >= arr.length - 1) return
|
||||
const temp = arr[idx]
|
||||
arr[idx] = arr[idx + 1]
|
||||
arr[idx + 1] = temp
|
||||
arr.forEach((n: Record<string, any>, i: number) => (n.nodeOrder = i + 1))
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
ElMessage.success('下移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '下移失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,419 @@
|
||||
<!-- 工作流配置(报销单) -->
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">审批流程节点</h2>
|
||||
</div>
|
||||
|
||||
<div class="wf-info-bar">
|
||||
<span><b>流程名称:</b>{{ wfDef.wfName || '-' }}</span>
|
||||
<span>
|
||||
<b>状态:</b>
|
||||
<el-tag :type="statusTagType(wfDef.status)" size="small">
|
||||
{{ statusLabel(wfDef.status) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<div class="list-toolbar-selected">
|
||||
已选 <span class="sel-num">0</span> 项
|
||||
</div>
|
||||
<el-button class="btn-main" type="primary" @click="openAddDialog">
|
||||
<el-icon><Plus /></el-icon>新增节点
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loadingMap.save" @click="saveNodes">
|
||||
<el-icon><Upload /></el-icon>保存配置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table class="list-table" :data="nodes" v-loading="loading" stripe>
|
||||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="nodeName"
|
||||
label="节点名称"
|
||||
min-width="180"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="nodeOrder" label="节点顺序" min-width="100" align="center" header-align="center" />
|
||||
<el-table-column
|
||||
prop="approverName"
|
||||
label="审批人"
|
||||
min-width="120"
|
||||
align="center"
|
||||
header-align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="配置状态" min-width="110" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="(row.approverId ?? row.approver_id) ? 'success' : 'warning'" size="small">
|
||||
{{ (row.approverId ?? row.approver_id) ? '已配置' : '未配置' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" min-width="360" fixed="right" align="center" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div style="display: flex; justify-content: center; gap: 8px; flex-wrap: nowrap">
|
||||
<el-button class="btn-op-item" @click="openEditDialog(row)">
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" :loading="loadingMap.rowDelete" @click="deleteNode(row)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="moveUp(row)">
|
||||
<el-icon><ArrowUp /></el-icon>上移
|
||||
</el-button>
|
||||
<el-button class="btn-op-item" @click="moveDown(row)">
|
||||
<el-icon><ArrowDown /></el-icon>下移
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.addNode"
|
||||
title="新增节点"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="addFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="formData.nodeName" placeholder="请输入节点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点顺序">
|
||||
<el-input-number v-model="formData.nodeOrder" controls-position="right" :min="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人" style="grid-column: 1 / -1">
|
||||
<el-select
|
||||
v-model="formData.approverId"
|
||||
placeholder="请选择审批人"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleApproverChange"
|
||||
>
|
||||
<el-option v-for="u in userOptions" :key="u.id" :label="u.displayName" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.addNode = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.addNodeSubmit" @click="submitAddNode">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogs.editNode"
|
||||
title="编辑节点"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form
|
||||
ref="editFormRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-position="top"
|
||||
scroll-to-error
|
||||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||||
>
|
||||
<div class="form-grid-2">
|
||||
<el-form-item label="节点名称" prop="nodeName">
|
||||
<el-input v-model="formData.nodeName" placeholder="请输入节点名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="节点顺序">
|
||||
<el-input-number v-model="formData.nodeOrder" controls-position="right" :min="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人" style="grid-column: 1 / -1">
|
||||
<el-select
|
||||
v-model="formData.approverId"
|
||||
placeholder="请选择审批人"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@change="handleApproverChange"
|
||||
>
|
||||
<el-option v-for="u in userOptions" :key="u.id" :label="u.displayName" :value="u.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.editNode = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.editNodeSubmit" @click="submitEditNode">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
EditPen,
|
||||
Delete,
|
||||
Close,
|
||||
Check,
|
||||
Upload,
|
||||
ArrowUp,
|
||||
ArrowDown
|
||||
} from '@element-plus/icons-vue'
|
||||
import { workflowApi } from '@/api/bx'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import { statusLabel, statusTagType } from '@/utils/bx/format'
|
||||
|
||||
type DialogKey = 'addNode' | 'editNode'
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||||
addNode: false,
|
||||
editNode: false
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const wfDef = ref<Record<string, any>>({})
|
||||
const nodes = computed(() => wfDef.value.nodes || [])
|
||||
const userOptions = ref<
|
||||
{ id: string; realName: string; username: string; roles: string; displayName: string }[]
|
||||
>([])
|
||||
|
||||
const formData = reactive({
|
||||
nodeName: '',
|
||||
nodeOrder: 1,
|
||||
approverId: null as string | null,
|
||||
approverName: ''
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
nodeName: [{ required: true, message: '节点名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const addFormRef = ref<FormInstance>()
|
||||
const editFormRef = ref<FormInstance>()
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res = await fetchUserOptions()
|
||||
const data: any = (res as any)?.data ?? res ?? []
|
||||
userOptions.value = (Array.isArray(data) ? data : []).map((u: any) => {
|
||||
const name = u.label || u.nickName || ''
|
||||
const account = u.userNo || ''
|
||||
return {
|
||||
id: String(u.value ?? u.id ?? ''),
|
||||
realName: name,
|
||||
username: account,
|
||||
roles: '',
|
||||
displayName: account ? `${name}(${account})` : name
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadWfDef() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await workflowApi.getByBizType('reimburse')
|
||||
wfDef.value = res.data ?? {}
|
||||
} catch {
|
||||
wfDef.value = {}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadWfDef()
|
||||
loadUsers()
|
||||
})
|
||||
|
||||
function buildNodePayload(list: Record<string, any>[]) {
|
||||
return list.map((n, i) => ({
|
||||
nodeName: n.nodeName,
|
||||
nodeOrder: i + 1,
|
||||
approverId: n.approverId ?? n.approver_id ?? null,
|
||||
approverName: n.approverName ?? n.approver_name ?? ''
|
||||
}))
|
||||
}
|
||||
|
||||
async function saveNodes() {
|
||||
loadingMap.save = true
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(nodes.value))
|
||||
ElMessage.success('保存成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '保存失败')
|
||||
} finally {
|
||||
loadingMap.save = false
|
||||
}
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
Object.assign(formData, {
|
||||
nodeName: '',
|
||||
nodeOrder: nodes.value.length + 1,
|
||||
approverId: null,
|
||||
approverName: ''
|
||||
})
|
||||
dialogs.addNode = true
|
||||
}
|
||||
|
||||
function openEditDialog(node: Record<string, any>) {
|
||||
Object.assign(formData, {
|
||||
nodeName: node.nodeName,
|
||||
nodeOrder: node.nodeOrder,
|
||||
approverId: node.approverId ?? node.approver_id ?? null,
|
||||
approverName: node.approverName ?? node.approver_name ?? ''
|
||||
})
|
||||
dialogs.editNode = true
|
||||
}
|
||||
|
||||
function handleApproverChange(userId: string | null) {
|
||||
if (userId == null) {
|
||||
formData.approverName = ''
|
||||
return
|
||||
}
|
||||
const found = userOptions.value.find((u) => u.id === userId)
|
||||
formData.approverName = found ? found.realName : ''
|
||||
}
|
||||
|
||||
async function submitAddNode() {
|
||||
const valid = await addFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.addNodeSubmit = true
|
||||
try {
|
||||
const newNodes = [
|
||||
...nodes.value,
|
||||
{
|
||||
nodeName: formData.nodeName,
|
||||
nodeOrder: formData.nodeOrder,
|
||||
approverId: formData.approverId,
|
||||
approverName: formData.approverName
|
||||
}
|
||||
]
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('新增成功')
|
||||
dialogs.addNode = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '新增失败')
|
||||
} finally {
|
||||
loadingMap.addNodeSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitEditNode() {
|
||||
const valid = await editFormRef.value?.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
loadingMap.editNodeSubmit = true
|
||||
try {
|
||||
const newNodes = nodes.value.map((n: Record<string, any>) =>
|
||||
n.nodeOrder === formData.nodeOrder
|
||||
? {
|
||||
...n,
|
||||
nodeName: formData.nodeName,
|
||||
approverId: formData.approverId,
|
||||
approverName: formData.approverName
|
||||
}
|
||||
: n
|
||||
)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('编辑成功')
|
||||
dialogs.editNode = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '编辑失败')
|
||||
} finally {
|
||||
loadingMap.editNodeSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteNode(node: Record<string, any>) {
|
||||
await ElMessageBox.confirm(`确定要删除节点「${node.nodeName}」吗?`, '删除确认', {
|
||||
confirmButtonText: '确定删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
loadingMap.rowDelete = true
|
||||
try {
|
||||
const newNodes = nodes.value.filter((n: Record<string, any>) => n.id !== node.id)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
ElMessage.success('删除成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') ElMessage.error(e.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap.rowDelete = false
|
||||
}
|
||||
}
|
||||
|
||||
async function moveUp(node: Record<string, any>) {
|
||||
const idx = nodes.value.findIndex((n: Record<string, any>) => n.id === node.id)
|
||||
if (idx <= 0) return
|
||||
const arr = [...nodes.value]
|
||||
const temp = arr[idx]
|
||||
arr[idx] = arr[idx - 1]
|
||||
arr[idx - 1] = temp
|
||||
arr.forEach((n: Record<string, any>, i: number) => (n.nodeOrder = i + 1))
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
ElMessage.success('上移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '上移失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function moveDown(node: Record<string, any>) {
|
||||
const arr = [...nodes.value]
|
||||
const idx = arr.findIndex((n: Record<string, any>) => n.id === node.id)
|
||||
if (idx < 0 || idx >= arr.length - 1) return
|
||||
const temp = arr[idx]
|
||||
arr[idx] = arr[idx + 1]
|
||||
arr[idx + 1] = temp
|
||||
arr.forEach((n: Record<string, any>, i: number) => (n.nodeOrder = i + 1))
|
||||
try {
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
ElMessage.success('下移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '下移失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,8 @@
|
||||
<!-- 多级菜单目录节点:仅透传子路由,不重复挂载 AppLayout -->
|
||||
<template>
|
||||
<RouterView />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: 'RouteParent' })
|
||||
</script>
|
||||
Reference in new issue
Block a user