提交
This commit is contained in:
1 parent
f70dc26206
commit
7a0f1554bd
66 files changed
+45771
-2351
No files matched your search
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ActionCard: typeof import('./src/components/mobile/ActionCard.vue')['default']
|
||||
BottomActionBar: typeof import('./src/components/mobile/BottomActionBar.vue')['default']
|
||||
MenuEntryCard: typeof import('./src/components/mobile/MenuEntryCard.vue')['default']
|
||||
MenuNode: typeof import('./src/components/mobile/MenuNode.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
StatusTag: typeof import('./src/components/mobile/StatusTag.vue')['default']
|
||||
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
||||
VanCell: typeof import('vant/es')['Cell']
|
||||
VanCellGroup: typeof import('vant/es')['CellGroup']
|
||||
VanDialog: typeof import('vant/es')['Dialog']
|
||||
VanField: typeof import('vant/es')['Field']
|
||||
VanForm: typeof import('vant/es')['Form']
|
||||
VanIcon: typeof import('vant/es')['Icon']
|
||||
VanList: typeof import('vant/es')['List']
|
||||
VanLoading: typeof import('vant/es')['Loading']
|
||||
VanPicker: typeof import('vant/es')['Picker']
|
||||
VanPopup: typeof import('vant/es')['Popup']
|
||||
VanPullRefresh: typeof import('vant/es')['PullRefresh']
|
||||
VanSwitch: typeof import('vant/es')['Switch']
|
||||
VanTab: typeof import('vant/es')['Tab']
|
||||
VanTabs: typeof import('vant/es')['Tabs']
|
||||
VanUploader: typeof import('vant/es')['Uploader']
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
|
||||
<title>报销系统</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+2202
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "bx-mobile",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"pinia": "^2.1.7",
|
||||
"vant": "^4.8.0",
|
||||
"vue": "^3.4.0",
|
||||
"vue-router": "^4.3.0",
|
||||
"axios": "^1.7.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"@vant/use": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.0",
|
||||
"typescript": "^5.3.0",
|
||||
"unplugin-vue-components": "^0.27.0",
|
||||
"@vant/auto-import-resolver": "^1.2.1",
|
||||
"vite": "^5.4.0",
|
||||
"vue-tsc": "^2.0.0",
|
||||
"@types/node": "^20.11.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
@@ -0,0 +1,64 @@
|
||||
import axios from 'axios'
|
||||
import { showToast } from 'vant'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const client = axios.create({
|
||||
baseURL: '/api',
|
||||
timeout: 0, // 0 = no timeout
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
|
||||
client.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
})
|
||||
|
||||
/**
|
||||
* Business error marker — page-level catch blocks should check this
|
||||
* to avoid double-toasting (interceptor already showed the toast).
|
||||
*/
|
||||
export class BizError extends Error {
|
||||
code?: number
|
||||
constructor(message: string, code?: number) {
|
||||
super(message)
|
||||
this.code = code
|
||||
this.name = 'BizError'
|
||||
}
|
||||
}
|
||||
|
||||
client.interceptors.response.use(
|
||||
(res) => {
|
||||
const body = res.data
|
||||
if (body.code !== 0 && body.code !== undefined) {
|
||||
showToast(body.msg || '请求失败')
|
||||
return Promise.reject(new BizError(body.msg || '请求失败', body.code))
|
||||
}
|
||||
return body
|
||||
},
|
||||
(err) => {
|
||||
if (err.response?.status === 401) {
|
||||
const auth = useAuthStore()
|
||||
auth.logout()
|
||||
showToast('登录已过期,请重新登录')
|
||||
if (window.location.pathname !== '/login') {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
} else if (err.response?.status === 403 && err.response?.data?.detail === '用户已被禁用') {
|
||||
const auth = useAuthStore()
|
||||
auth.logout()
|
||||
showToast('账号已被禁用,请联系管理员')
|
||||
if (window.location.pathname !== '/login') {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
} else {
|
||||
const msg = err.response?.data?.msg || err.response?.data?.detail || err.message || '网络异常'
|
||||
showToast(msg)
|
||||
}
|
||||
return Promise.reject(err)
|
||||
},
|
||||
)
|
||||
|
||||
export default client
|
||||
@@ -0,0 +1,167 @@
|
||||
import client from './client'
|
||||
|
||||
export const authApi = {
|
||||
login: (data: { username: string; password: string }) =>
|
||||
client.post('/auth/login', data),
|
||||
register: (data: { username: string; password: string; realName: string }) =>
|
||||
client.post('/auth/register', data),
|
||||
me: () => client.get('/auth/me'),
|
||||
}
|
||||
|
||||
export const userApi = {
|
||||
list: (params?: Record<string, any>) => client.get('/users/', { params }),
|
||||
dropdown: () => client.get('/users/dropdown'),
|
||||
getById: (id: number) => client.get(`/users/${id}`),
|
||||
create: (data: Record<string, any>) => client.post('/users/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/users/${id}`, data),
|
||||
delete: (id: number) => client.delete(`/users/${id}`),
|
||||
resetPassword: (id: number) => client.put(`/users/${id}/reset-password`),
|
||||
}
|
||||
|
||||
export const roleApi = {
|
||||
list: (params?: Record<string, any>) => client.get('/roles/', { params }),
|
||||
getById: (id: number) => client.get(`/roles/${id}`),
|
||||
create: (data: Record<string, any>) => client.post('/roles/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/roles/${id}`, data),
|
||||
delete: (id: number) => client.delete(`/roles/${id}`),
|
||||
getUsers: (roleId: number) => client.get(`/roles/${roleId}/users`),
|
||||
assignUsers: (id: number, userIds: number[]) =>
|
||||
client.put(`/roles/${id}/users`, { userIds }),
|
||||
assignMenus: (id: number, menuIds: number[]) =>
|
||||
client.put(`/roles/${id}/menus`, { menuIds }),
|
||||
}
|
||||
|
||||
export const menuApi = {
|
||||
mine: () => client.get('/menus/mine'),
|
||||
tree: () => client.get('/menus/tree'),
|
||||
getByRole: (roleId: number) => client.get(`/menus/role/${roleId}`),
|
||||
getById: (id: number) => client.get(`/menus/${id}`),
|
||||
create: (data: Record<string, any>) => client.post('/menus/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/menus/${id}`, data),
|
||||
delete: (id: number) => client.delete(`/menus/${id}`),
|
||||
}
|
||||
|
||||
export const expenseItemApi = {
|
||||
tree: () => client.get('/expense-items/tree'),
|
||||
getById: (id: number) => client.get(`/expense-items/${id}`),
|
||||
create: (data: Record<string, any>) => client.post('/expense-items/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/expense-items/${id}`, data),
|
||||
delete: (id: number) => client.delete(`/expense-items/${id}`),
|
||||
}
|
||||
|
||||
export const workflowApi = {
|
||||
list: (params?: Record<string, any>) => client.get('/workflows/', { params }),
|
||||
getByBizType: (bizType: string) => client.get(`/workflows/biz/${bizType}`),
|
||||
getById: (id: number) => client.get(`/workflows/${id}`),
|
||||
create: (data: Record<string, any>) => client.post('/workflows/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/workflows/${id}`, data),
|
||||
saveNodes: (id: number, nodes: Record<string, any>[]) =>
|
||||
client.put(`/workflows/${id}/nodes`, nodes),
|
||||
delete: (id: number) => client.delete(`/workflows/${id}`),
|
||||
}
|
||||
|
||||
export const advanceApi = {
|
||||
list: (params?: Record<string, any>) => client.get('/advances/', { params }),
|
||||
my: (params?: Record<string, any>) => client.get('/advances/my', { params }),
|
||||
myStats: () => client.get('/advances/my/stats'),
|
||||
pendingApproval: (params?: Record<string, any>) =>
|
||||
client.get('/advances/pending-approval', { params }),
|
||||
approvedByMe: (params?: Record<string, any>) =>
|
||||
client.get('/advances/approved-by-me', { params }),
|
||||
getById: (id: number) => client.get(`/advances/${id}`),
|
||||
getApprovals: (id: number) => client.get(`/advances/${id}/approvals`),
|
||||
create: (data: Record<string, any>) => client.post('/advances/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/advances/${id}`, data),
|
||||
submit: (id: number) => client.post(`/advances/${id}/submit`),
|
||||
approve: (id: number, data: { approvalOpinion?: string }) =>
|
||||
client.post(`/advances/${id}/approve`, data),
|
||||
reject: (id: number, data: { approvalOpinion?: string }) =>
|
||||
client.post(`/advances/${id}/reject`, data),
|
||||
delete: (id: number) => client.delete(`/advances/${id}`),
|
||||
}
|
||||
|
||||
export const reimburseApi = {
|
||||
generateTitle: () => client.get('/reimburses/generate-title'),
|
||||
list: (params?: Record<string, any>) => client.get('/reimburses/', { params }),
|
||||
my: (params?: Record<string, any>) => client.get('/reimburses/my', { params }),
|
||||
myStats: () => client.get('/reimburses/my/stats'),
|
||||
pendingApproval: (params?: Record<string, any>) =>
|
||||
client.get('/reimburses/pending-approval', { params }),
|
||||
approvedByMe: (params?: Record<string, any>) =>
|
||||
client.get('/reimburses/approved-by-me', { params }),
|
||||
getById: (id: number) => client.get(`/reimburses/${id}`),
|
||||
getApprovals: (id: number) => client.get(`/reimburses/${id}/approvals`),
|
||||
create: (data: Record<string, any>) => client.post('/reimburses/', data),
|
||||
update: (id: number, data: Record<string, any>) => client.put(`/reimburses/${id}`, data),
|
||||
submit: (id: number) => client.post(`/reimburses/${id}/submit`),
|
||||
approve: (id: number, data: { approvalOpinion?: string }) =>
|
||||
client.post(`/reimburses/${id}/approve`, data),
|
||||
reject: (id: number, data: { approvalOpinion?: string }) =>
|
||||
client.post(`/reimburses/${id}/reject`, data),
|
||||
delete: (id: number) => client.delete(`/reimburses/${id}`),
|
||||
}
|
||||
|
||||
export const paymentApi = {
|
||||
pending: (params?: Record<string, any>) => client.get('/payments/pending', { params }),
|
||||
pay: (id: number, data?: { payRemark?: string; actualAmount?: number }) =>
|
||||
client.post(`/payments/${id}/pay`, data),
|
||||
offset: (id: number, data: { advanceId: number; offsetAmount: number; remark?: string }) =>
|
||||
client.post(`/payments/${id}/offset`, data),
|
||||
batchOffset: (
|
||||
id: number,
|
||||
data: {
|
||||
items: Array<{ advanceId: number; offsetAmount: number }>
|
||||
payAmount: number
|
||||
remark?: string
|
||||
},
|
||||
) => client.post(`/payments/${id}/batch-offset`, data),
|
||||
advanceIssues: (params?: Record<string, any>) =>
|
||||
client.get('/payments/advance-issues', {
|
||||
params: params
|
||||
? {
|
||||
page: params.page,
|
||||
pageSize: params.pageSize,
|
||||
issue_status: params.issueStatus,
|
||||
keyword: params.keyword,
|
||||
}
|
||||
: undefined,
|
||||
}),
|
||||
exportAdvanceIssues: (params?: Record<string, any>) =>
|
||||
client.get('/payments/advance-issues/export', {
|
||||
params: params
|
||||
? { issue_status: params.issueStatus, keyword: params.keyword }
|
||||
: undefined,
|
||||
responseType: 'blob',
|
||||
}),
|
||||
issueAdvance: (
|
||||
advanceId: number,
|
||||
data: { issueRemark?: string; actualAmount?: number },
|
||||
) => client.post(`/payments/advance/${advanceId}/issue`, data),
|
||||
processed: (params?: Record<string, any>) =>
|
||||
client.get('/payments/processed', { params }),
|
||||
advanceOffsetRecords: (advanceId: number) =>
|
||||
client.get(`/payments/advance/${advanceId}/offset-records`),
|
||||
reimburseOffsetRecords: (reimburseId: number) =>
|
||||
client.get(`/payments/${reimburseId}/offset-records`),
|
||||
}
|
||||
|
||||
export const attachmentApi = {
|
||||
upload: (file: File, bizType: string = '', bizId: number = 0) => {
|
||||
const form = new FormData()
|
||||
form.append('file', file)
|
||||
return client.post('/attachments/upload', form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
params: { biz_type: bizType, biz_id: bizId },
|
||||
})
|
||||
},
|
||||
download: (id: number) => client.get(`/attachments/download/${id}`, { responseType: 'blob' }),
|
||||
preview: (id: number) => client.get(`/attachments/preview/${id}`),
|
||||
delete: (id: number) => client.delete(`/attachments/${id}`),
|
||||
listByBiz: (bizType: string, bizId: number) =>
|
||||
client.get('/attachments/list', { params: { biz_type: bizType, biz_id: bizId } }),
|
||||
bindBiz: (ids: number[], bizType: string, bizId: number) =>
|
||||
client.put('/attachments/bind-biz', null, {
|
||||
params: { ids: ids.join(','), biz_type: bizType, biz_id: bizId },
|
||||
}),
|
||||
downloadUrl: (id: number) => `/api/attachments/download/${id}`,
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<div class="action-card">
|
||||
<div class="ac-head">
|
||||
<div class="ac-main">
|
||||
<div class="ac-title">{{ title }}</div>
|
||||
<div class="ac-sub">{{ subText }}</div>
|
||||
</div>
|
||||
<StatusTag :text="statusText" :variant="statusVariant" />
|
||||
</div>
|
||||
<div class="ac-meta">
|
||||
<span>{{ amountText }}</span>
|
||||
<span>{{ timeText }}</span>
|
||||
</div>
|
||||
<div class="ac-actions">
|
||||
<button type="button" class="btn btn-sm btn-primary" @click="$emit('secondary')">{{ secondaryText }}</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" @click="$emit('primary')">{{ primaryText }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import StatusTag from './StatusTag.vue'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
subText: string
|
||||
statusText: string
|
||||
statusVariant?: 'success' | 'warning' | 'danger' | 'info' | 'processing' | 'muted'
|
||||
amountText: string
|
||||
timeText: string
|
||||
primaryText?: string
|
||||
secondaryText?: string
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
statusVariant: 'info',
|
||||
primaryText: '去处理',
|
||||
secondaryText: '查看',
|
||||
})
|
||||
|
||||
defineEmits<{
|
||||
primary: []
|
||||
secondary: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.action-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--border);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.ac-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ac-main {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.ac-title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.ac-sub {
|
||||
margin-top: 2px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.ac-meta {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.ac-actions {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px dashed var(--border);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div class="bottom-action-bar">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div class="menu-entry-card" @click="$emit('click')">
|
||||
<div class="menu-entry-icon" :style="{ background: iconBg }">
|
||||
<van-icon :name="icon" size="20" color="#fff" />
|
||||
</div>
|
||||
<span v-if="showDot" class="menu-entry-dot"></span>
|
||||
<span class="menu-entry-name">{{ name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
name: string
|
||||
icon: string
|
||||
iconBg: string
|
||||
showDot?: boolean
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
showDot: false,
|
||||
})
|
||||
|
||||
defineEmits<{
|
||||
click: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.menu-entry-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 6px;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.menu-entry-card:active {
|
||||
background: var(--primary-bg);
|
||||
transform: scale(0.96);
|
||||
}
|
||||
|
||||
.menu-entry-icon {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.menu-entry-name {
|
||||
font-size: 12px;
|
||||
color: var(--text);
|
||||
text-align: center;
|
||||
line-height: 1.3;
|
||||
word-break: break-all;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.menu-entry-dot {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 18px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--danger);
|
||||
box-shadow: 0 0 0 2px #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<div :style="{ marginLeft: depth * 20 + 'px' }" style="margin-top: 8px; padding: 0 14px 10px;">
|
||||
<div class="op-card" style="border-left: 3px solid var(--primary);">
|
||||
<div class="op-card-head">
|
||||
<div class="op-card-title" style="font-size: 14px;">{{ node.menuName }}</div>
|
||||
<StatusTag :text="menuTypeLabel(node.menuType)" :variant="menuTypeTone(node.menuType)" />
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); border-radius: var(--rs); padding: 8px 10px; margin-top: 6px;">
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">编码</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ node.menuCode || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">排序</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ node.sortOrder }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="op-card-body">
|
||||
<div class="op-actions">
|
||||
<button class="btn btn-sm btn-primary" @click="$emit('add-child', node.id)">新增子菜单</button>
|
||||
<button class="btn btn-sm btn-primary" @click="$emit('edit', node)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap['delete-' + node.id]" @click="$emit('delete', node)">
|
||||
{{ loadingMap['delete-' + node.id] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="node.children && node.children.length > 0">
|
||||
<MenuNode
|
||||
v-for="child in node.children"
|
||||
:key="child.id"
|
||||
:node="child"
|
||||
:depth="depth + 1"
|
||||
:loading-map="loadingMap"
|
||||
@edit="(n: any) => $emit('edit', n)"
|
||||
@delete="(n: any) => $emit('delete', n)"
|
||||
@add-child="(id: number) => $emit('add-child', id)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { menuTypeLabel } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
|
||||
defineOptions({ name: 'MenuNode' })
|
||||
|
||||
defineProps<{
|
||||
node: Record<string, any>
|
||||
depth: number
|
||||
loadingMap: Record<string, boolean>
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'edit', menu: any): void
|
||||
(e: 'delete', menu: any): void
|
||||
(e: 'add-child', parentId: number): void
|
||||
}>()
|
||||
|
||||
function menuTypeTone(menuType: number): string {
|
||||
if (menuType === 1) return 'processing'
|
||||
if (menuType === 2) return 'success'
|
||||
return 'info'
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<span class="status-tag" :class="variantClass">{{ text }}</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
interface Props {
|
||||
text: string
|
||||
variant?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
variant: 'default',
|
||||
})
|
||||
|
||||
const variantClass = computed(() => {
|
||||
if (props.variant === 'default') return ''
|
||||
return props.variant
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Vant Dialog 删除类确认按钮文字色,与 `src/styles/index.css` 中 `--danger` 保持一致。
|
||||
*/
|
||||
export const DELETE_CONFIRM_BUTTON_COLOR = 'var(--danger)'
|
||||
|
||||
/**
|
||||
* 通用主色确认按钮(与 CSS `--primary` 一致)。
|
||||
* `main.ts` 中 `setDialogDefaultOptions` 已设此为函数式 Dialog 默认色;删除等危险操作须传入 {@link DELETE_CONFIRM_BUTTON_COLOR} 覆盖。
|
||||
*/
|
||||
export const PRIMARY_CONFIRM_BUTTON_COLOR = 'var(--primary)'
|
||||
|
||||
/** 提交审批等正向主操作(同 {@link PRIMARY_CONFIRM_BUTTON_COLOR}) */
|
||||
export const SUBMIT_APPROVE_BUTTON_COLOR = PRIMARY_CONFIRM_BUTTON_COLOR
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
import { ref } from 'vue'
|
||||
import { showToast, showConfirmDialog, showImagePreview } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { attachmentApi } from '@/api'
|
||||
|
||||
export interface AttachmentFile {
|
||||
id: number
|
||||
fileName: string
|
||||
fileType: string
|
||||
fileSize: number
|
||||
previewUrl: string
|
||||
_existing?: boolean
|
||||
}
|
||||
|
||||
export function useAttachment() {
|
||||
const files = ref<AttachmentFile[]>([])
|
||||
const uploading = ref(false)
|
||||
|
||||
function isImage(fileType: string): boolean {
|
||||
return fileType?.startsWith('image/')
|
||||
}
|
||||
|
||||
function fileExt(name: string): string {
|
||||
const ext = name.split('.').pop()
|
||||
return ext ? ext.toUpperCase() : 'FILE'
|
||||
}
|
||||
|
||||
function formatFileSize(bytes: number): string {
|
||||
if (bytes < 1024) return bytes + ' B'
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
|
||||
}
|
||||
|
||||
async function upload(file: File, bizType: string = '', bizId: number = 0) {
|
||||
uploading.value = true
|
||||
try {
|
||||
const res: any = await attachmentApi.upload(file, bizType, bizId)
|
||||
const fileData: AttachmentFile = {
|
||||
id: res.data.id,
|
||||
fileName: res.data.fileName,
|
||||
fileType: res.data.fileType || '',
|
||||
fileSize: res.data.fileSize,
|
||||
previewUrl: '',
|
||||
}
|
||||
if (isImage(fileData.fileType)) {
|
||||
try {
|
||||
const previewRes: any = await attachmentApi.preview(fileData.id)
|
||||
fileData.previewUrl = previewRes.data.url
|
||||
} catch { /* preview not critical */ }
|
||||
}
|
||||
files.value.push(fileData)
|
||||
return fileData
|
||||
} catch (e: any) {
|
||||
showToast(e.message || '上传失败')
|
||||
return null
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(index: number) {
|
||||
const file = files.value[index]
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: '确定删除该附件?',
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
await attachmentApi.delete(file.id)
|
||||
files.value.splice(index, 1)
|
||||
showToast('已删除')
|
||||
} catch { /* cancelled */ }
|
||||
}
|
||||
|
||||
/** 图片:预览;其它类型:带 Token 下载到本地 */
|
||||
async function open(file: AttachmentFile) {
|
||||
if (isImage(file.fileType)) {
|
||||
let url = file.previewUrl
|
||||
if (!url) {
|
||||
try {
|
||||
const res: any = await attachmentApi.preview(file.id)
|
||||
url = res?.data?.url ?? ''
|
||||
if (url) file.previewUrl = url
|
||||
} catch {
|
||||
showToast('暂无法预览')
|
||||
return
|
||||
}
|
||||
}
|
||||
if (url) {
|
||||
showImagePreview({ images: [url] })
|
||||
} else {
|
||||
showToast('暂无法预览')
|
||||
}
|
||||
return
|
||||
}
|
||||
try {
|
||||
const blob = (await attachmentApi.download(file.id)) as unknown as Blob
|
||||
if (!(blob instanceof Blob)) {
|
||||
showToast('下载失败')
|
||||
return
|
||||
}
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = file.fileName || '附件'
|
||||
a.rel = 'noopener'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
} catch {
|
||||
showToast('下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function loadList(bizType: string, bizId: number) {
|
||||
try {
|
||||
const res: any = await attachmentApi.listByBiz(bizType, bizId)
|
||||
const list = (res.data || []).map((a: any) => ({ ...a, previewUrl: '', _existing: true }))
|
||||
const imgPromises = list
|
||||
.filter((a: any) => isImage(a.fileType || ''))
|
||||
.map(async (a: any) => {
|
||||
try {
|
||||
const pRes: any = await attachmentApi.preview(a.id)
|
||||
a.previewUrl = pRes.data.url
|
||||
} catch { /* skip */ }
|
||||
})
|
||||
await Promise.all(imgPromises)
|
||||
files.value = list
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
async function bindNew(bizType: string, bizId: number) {
|
||||
const newFiles = files.value.filter(f => !f._existing)
|
||||
if (newFiles.length) {
|
||||
await attachmentApi.bindBiz(
|
||||
newFiles.map(f => f.id),
|
||||
bizType,
|
||||
bizId,
|
||||
)
|
||||
newFiles.forEach((f) => {
|
||||
f._existing = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function clear() {
|
||||
files.value = []
|
||||
}
|
||||
|
||||
return {
|
||||
files,
|
||||
uploading,
|
||||
isImage,
|
||||
fileExt,
|
||||
formatFileSize,
|
||||
upload,
|
||||
remove,
|
||||
open,
|
||||
loadList,
|
||||
bindNew,
|
||||
clear,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { showToast } from 'vant'
|
||||
import { expenseItemApi } from '@/api'
|
||||
|
||||
export interface ExpenseItem {
|
||||
id: number
|
||||
parentId: number
|
||||
itemName: string
|
||||
itemCode: string
|
||||
level: number
|
||||
sortOrder: number
|
||||
status: number | string
|
||||
childCount: number
|
||||
children?: ExpenseItem[]
|
||||
}
|
||||
|
||||
export function useExpenseItemTree() {
|
||||
const expenseTree = ref<ExpenseItem[]>([])
|
||||
const loading = ref(false)
|
||||
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) {
|
||||
showToast(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
|
||||
}
|
||||
|
||||
export function formatExpenseName(id: number | null | undefined, flatList: ExpenseItem[]): string {
|
||||
if (id == null) return '-'
|
||||
const parts: string[] = []
|
||||
let cur: ExpenseItem | undefined = flatList.find(i => i.id === id)
|
||||
const guard = new Set<number>()
|
||||
while (cur && !guard.has(cur.id)) {
|
||||
guard.add(cur.id)
|
||||
parts.unshift(cur.itemName)
|
||||
const pid = cur.parentId
|
||||
cur =
|
||||
pid != null && pid !== 0 ? flatList.find(i => i.id === pid) : undefined
|
||||
}
|
||||
/** 一级/二级统一为「父/子」,与产品文案一致 */
|
||||
return parts.length ? parts.join('/') : '-'
|
||||
}
|
||||
|
||||
/** 从列表/详情行上常见的 camel/snake 字段取费用项 ID */
|
||||
export function pickExpenseItemId(row: Record<string, any> | null | undefined): number | null {
|
||||
if (!row || typeof row !== 'object') return null
|
||||
const raw = row.expenseId ?? row.expense_id ?? row.expenseItemId ?? row.expense_item_id
|
||||
if (raw == null || raw === '') return null
|
||||
const n = Number(raw)
|
||||
return Number.isFinite(n) && n > 0 ? n : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先用费用树拼出「一级/二级」;无 ID 或树未加载时用接口返回的 expenseName。
|
||||
*/
|
||||
export function resolveExpenseDisplay(row: Record<string, any> | null | undefined, flatList: ExpenseItem[]): string {
|
||||
if (!row) return '-'
|
||||
const id = pickExpenseItemId(row)
|
||||
const nameFb = row.expenseName ?? row.expense_name
|
||||
if (id != null && flatList.length) {
|
||||
const p = formatExpenseName(id, flatList)
|
||||
if (p && p !== '-') return p
|
||||
}
|
||||
const fb = nameFb != null ? String(nameFb).trim() : ''
|
||||
return fb || '-'
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
export interface UseKeywordSearchOptions {
|
||||
/** 输入防抖毫秒,默认 380 */
|
||||
debounceMs?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页关键词:随输入防抖触发 search;clearKeyword 立即清空并触发一次检索;flushSearch 立即检索(如回车)。
|
||||
*/
|
||||
export function useKeywordSearch(search: () => void, options?: UseKeywordSearchOptions) {
|
||||
const keyword = ref('')
|
||||
const debounceMs = options?.debounceMs ?? 380
|
||||
let timer: ReturnType<typeof setTimeout> | null = null
|
||||
let suppressWatch = false
|
||||
|
||||
function cancelTimer() {
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleSearch() {
|
||||
cancelTimer()
|
||||
timer = setTimeout(() => {
|
||||
timer = null
|
||||
search()
|
||||
}, debounceMs)
|
||||
}
|
||||
|
||||
watch(keyword, () => {
|
||||
if (suppressWatch) return
|
||||
scheduleSearch()
|
||||
})
|
||||
|
||||
function clearKeyword() {
|
||||
cancelTimer()
|
||||
suppressWatch = true
|
||||
keyword.value = ''
|
||||
suppressWatch = false
|
||||
search()
|
||||
}
|
||||
|
||||
/** 跳过防抖立即检索(如按下回车) */
|
||||
function flushSearch() {
|
||||
cancelTimer()
|
||||
search()
|
||||
}
|
||||
|
||||
return { keyword, clearKeyword, flushSearch }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { setDialogDefaultOptions } from 'vant'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import 'vant/lib/index.css'
|
||||
import './styles/index.css'
|
||||
|
||||
// 与 Vant --van-dialog-width(320px) 对齐;默认 width 为空串时内联样式会压掉 class 宽度,确认框易显过窄
|
||||
// 删除等危险操作请在调用处传入 confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR 覆盖默认
|
||||
setDialogDefaultOptions({
|
||||
width: 320,
|
||||
confirmButtonColor: PRIMARY_CONFIRM_BUTTON_COLOR,
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
app.mount('#app')
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
component: () => import('@/views/login/LoginPage.vue'),
|
||||
meta: { public: true },
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/views/home/HomeLayout.vue'),
|
||||
children: [
|
||||
{ path: '', name: 'Home', component: () => import('@/views/home/HomePage.vue') },
|
||||
{ path: 'mine', name: 'Mine', component: () => import('@/views/mine/MinePage.vue') },
|
||||
{ path: 'approval', name: 'Approval', component: () => import('@/views/approval/ApprovalPage.vue') },
|
||||
{ path: 'approval/:bizType/:id', name: 'ApprovalDetail', component: () => import('@/views/approval/ApprovalDetailPage.vue') },
|
||||
{ path: 'advance/list', name: 'AdvanceList', component: () => import('@/views/advance/AdvanceListPage.vue') },
|
||||
{ path: 'advance/apply', name: 'AdvanceApply', component: () => import('@/views/advance/AdvanceApplyPage.vue') },
|
||||
/* 须放在 advance/:id 之前,否则 approve/issue 会被当成动态 id */
|
||||
{ path: 'advance/approve', name: 'AdvanceApprove', component: () => import('@/views/advance/AdvanceApprovePage.vue'), meta: { roles: ['ADMIN', 'FINANCE', 'GENERAL_MANAGER'] } },
|
||||
/* 与 bx_menu_role 一致:ADMIN、FINANCE 均分配「备用金发放管理」 */
|
||||
{ path: 'advance/issue', name: 'AdvanceIssue', component: () => import('@/views/advance/AdvanceIssuePage.vue'), meta: { roles: ['ADMIN', 'FINANCE'] } },
|
||||
{ path: 'advance/:id', name: 'AdvanceDetail', component: () => import('@/views/advance/AdvanceDetailPage.vue') },
|
||||
{ path: 'reimburse/list', name: 'ReimburseList', component: () => import('@/views/reimburse/ReimburseListPage.vue') },
|
||||
{ path: 'reimburse/apply', name: 'ReimburseApply', component: () => import('@/views/reimburse/ReimburseApplyPage.vue') },
|
||||
{ path: 'reimburse/approve', name: 'ReimburseApprove', component: () => import('@/views/reimburse/ReimburseApprovePage.vue'), meta: { roles: ['ADMIN', 'FINANCE', 'GENERAL_MANAGER'] } },
|
||||
{ path: 'reimburse/:id', name: 'ReimburseDetail', component: () => import('@/views/reimburse/ReimburseDetailPage.vue') },
|
||||
{ path: 'payment', name: 'Payment', component: () => import('@/views/payment/PaymentPage.vue'), meta: { roles: ['ADMIN', 'FINANCE'] } },
|
||||
{ path: 'all', name: 'All', component: () => import('@/views/all/AllPage.vue'), meta: { roles: ['ADMIN', 'GENERAL_MANAGER'] } },
|
||||
{ path: 'admin', name: 'AdminIndex', component: () => import('@/views/admin/AdminIndexPage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/users', name: 'UserManage', component: () => import('@/views/admin/UserManagePage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/roles', name: 'RoleManage', component: () => import('@/views/admin/RoleManagePage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/menus', name: 'MenuManage', component: () => import('@/views/admin/MenuManagePage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/expenses', name: 'ExpenseProject', component: () => import('@/views/admin/ExpenseProjectPage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/wf-advance', name: 'WfAdvance', component: () => import('@/views/admin/WfAdvancePage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'admin/wf-reimburse', name: 'WfReimburse', component: () => import('@/views/admin/WfReimbursePage.vue'), meta: { roles: ['ADMIN'] } },
|
||||
{ path: 'profile', name: 'Profile', component: () => import('@/views/profile/ProfilePage.vue') },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
})
|
||||
|
||||
router.beforeEach(async (to, _from, next) => {
|
||||
const auth = useAuthStore()
|
||||
if (to.meta?.public) return next()
|
||||
if (!auth.isLoggedIn) return next('/login')
|
||||
if (!auth.user) await auth.fetchUser()
|
||||
const roles = to.meta?.roles as string[] | undefined
|
||||
if (roles?.length && !roles.some((r: string) => auth.roleCodes.includes(r))) {
|
||||
return next('/')
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,98 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { authApi, menuApi } from '@/api'
|
||||
|
||||
export interface UserInfo {
|
||||
id: number
|
||||
username: string
|
||||
realName: string
|
||||
phone?: string
|
||||
email?: string
|
||||
avatar?: string
|
||||
roleList: { id: number; roleName: string; roleCode: string }[]
|
||||
}
|
||||
|
||||
export interface MenuItem {
|
||||
id: number
|
||||
parentId: number
|
||||
menuName: string
|
||||
menuCode: string | null
|
||||
menuType: number
|
||||
path: string | null
|
||||
sortOrder: number
|
||||
status: number
|
||||
children: MenuItem[] | null
|
||||
}
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const token = ref(localStorage.getItem('token') || '')
|
||||
const user = ref<UserInfo | null>(null)
|
||||
const menuList = ref<MenuItem[]>([])
|
||||
|
||||
const isLoggedIn = computed(() => !!token.value)
|
||||
const realName = computed(() => user.value?.realName || '')
|
||||
const roleCodes = computed(() => user.value?.roleList?.map((r) => r.roleCode) || [])
|
||||
|
||||
const isAdmin = computed(() => roleCodes.value.includes('ADMIN'))
|
||||
const isFinance = computed(() => roleCodes.value.includes('FINANCE'))
|
||||
const isGeneralManager = computed(() => roleCodes.value.includes('GENERAL_MANAGER'))
|
||||
|
||||
async function login(username: string, password: string) {
|
||||
const res: any = await authApi.login({ username, password })
|
||||
if (res.code === 0) {
|
||||
token.value = res.data.accessToken
|
||||
localStorage.setItem('token', res.data.accessToken)
|
||||
await fetchUser()
|
||||
return true
|
||||
}
|
||||
throw new Error(res.msg || '登录失败')
|
||||
}
|
||||
|
||||
async function fetchUser() {
|
||||
try {
|
||||
const res: any = await authApi.me()
|
||||
if (res.code === 0) {
|
||||
user.value = res.data
|
||||
}
|
||||
await fetchMenus()
|
||||
} catch {
|
||||
logout()
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchMenus() {
|
||||
try {
|
||||
const res: any = await menuApi.mine()
|
||||
if (res.code === 0) {
|
||||
menuList.value = res.data || []
|
||||
}
|
||||
} catch {
|
||||
menuList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
token.value = ''
|
||||
user.value = null
|
||||
menuList.value = []
|
||||
localStorage.removeItem('token')
|
||||
}
|
||||
|
||||
function hasMenu(code: string): boolean {
|
||||
function check(items: MenuItem[]): boolean {
|
||||
for (const item of items) {
|
||||
if (item.menuCode === code) return true
|
||||
if (item.children?.length && check(item.children)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return check(menuList.value)
|
||||
}
|
||||
|
||||
return {
|
||||
token, user, menuList,
|
||||
isLoggedIn, realName, roleCodes,
|
||||
isAdmin, isFinance, isGeneralManager,
|
||||
login, fetchUser, fetchMenus, logout, hasMenu,
|
||||
}
|
||||
})
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,172 @@
|
||||
/** 业务状态文案(列表筛选 Tab、卡片角标、详情票券头共用) */
|
||||
export function statusLabel(status: string | number | null | undefined): string {
|
||||
if (status == null || status === '') return '-'
|
||||
const map: Record<string | number, string> = {
|
||||
1: '启用',
|
||||
0: '禁用',
|
||||
draft: '待提交',
|
||||
pending: '审批中',
|
||||
approved: '已通过',
|
||||
rejected: '已驳回',
|
||||
withdrawn: '已撤回',
|
||||
issued: '已发放',
|
||||
paid: '已支付',
|
||||
offset: '已冲抵',
|
||||
partial: '部分冲抵',
|
||||
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: 'error',
|
||||
draft: 'info',
|
||||
pending: 'warn',
|
||||
approved: 'done',
|
||||
rejected: 'error',
|
||||
withdrawn: 'warn',
|
||||
issued: 'done',
|
||||
paid: 'done',
|
||||
offset: 'done',
|
||||
partial: 'warn',
|
||||
processed: 'done',
|
||||
}
|
||||
return map[status] ?? 'info'
|
||||
}
|
||||
|
||||
/** 列表卡片 `.status-tag.s-*`,与全局样式一致 */
|
||||
export function workflowListStatusTagClass(status: string | number | null | undefined): string {
|
||||
const raw = status == null || status === '' ? 'draft' : String(status)
|
||||
return `s-${raw}`
|
||||
}
|
||||
|
||||
/** 详情 / 审批弹层票券头角色(advance-ticket-status--*) */
|
||||
export function ticketHeaderStatusToneClass(status: string | number | null | undefined): string {
|
||||
const tone = statusTone(status)
|
||||
const map: Record<string, string> = {
|
||||
info: 'advance-ticket-status--info',
|
||||
warn: 'advance-ticket-status--warn',
|
||||
done: 'advance-ticket-status--done',
|
||||
error: 'advance-ticket-status--err',
|
||||
processing: 'advance-ticket-status--processing',
|
||||
}
|
||||
return map[tone] || 'advance-ticket-status--info'
|
||||
}
|
||||
|
||||
/** 备用金发放列表:issueStatus → 文案(与「待发放/已发放」Tab 一致) */
|
||||
export function advanceIssueRecordStatusLabel(issueStatus: string | null | undefined): string {
|
||||
return issueStatus === 'issued' ? '已发放' : '待发放'
|
||||
}
|
||||
|
||||
/** 备用金发放列表:issueStatus → `.status-tag` 样式类 */
|
||||
export function advanceIssueRecordStatusTagClass(issueStatus: string | null | undefined): string {
|
||||
return issueStatus === 'issued' ? 's-paid' : 's-pending'
|
||||
}
|
||||
|
||||
function paymentRecordRawStatus(item: Record<string, unknown> | null | undefined): string {
|
||||
if (!item || typeof item !== 'object') return ''
|
||||
return String((item as Record<string, unknown>).status ?? (item as Record<string, unknown>).payStatus ?? '').trim()
|
||||
}
|
||||
|
||||
/** 支付管理列表 / 详情:与「待处理 / 已处理」Tab 语义一致(不与报销申请列表的「已支付」混用) */
|
||||
export function paymentRecordStatusTagClass(item: Record<string, unknown> | null | undefined): string {
|
||||
const status = paymentRecordRawStatus(item)
|
||||
if (status === 'offset') return 's-offset'
|
||||
if (status === 'paid' || status === 'issued' || status === 'processed') return 's-paid'
|
||||
if (status === 'approved') return 's-pending'
|
||||
if (status === 'rejected') return 's-rejected'
|
||||
return 's-draft'
|
||||
}
|
||||
|
||||
export function paymentRecordStatusLabel(item: Record<string, unknown> | null | undefined): string {
|
||||
const status = paymentRecordRawStatus(item)
|
||||
if (status === 'offset') return '已冲抵'
|
||||
if (status === 'paid' || status === 'issued' || status === 'processed') return '已处理'
|
||||
if (status === 'approved') return '待处理'
|
||||
if (!status) return '-'
|
||||
return statusLabel(status)
|
||||
}
|
||||
|
||||
/** 支付详情票券头 tone(依赖 paymentRecordStatusTagClass) */
|
||||
export function paymentDetailTicketToneClass(item: Record<string, unknown> | null | undefined): string {
|
||||
const cls = paymentRecordStatusTagClass(item)
|
||||
if (cls === 's-paid') return 'advance-ticket-status--done'
|
||||
if (cls === 's-offset') return 'advance-ticket-status--processing'
|
||||
if (cls === 's-pending') return 'advance-ticket-status--warn'
|
||||
if (cls === 's-rejected') return 'advance-ticket-status--err'
|
||||
return 'advance-ticket-status--info'
|
||||
}
|
||||
|
||||
export function statusColor(status: string | number): string {
|
||||
const tone = statusTone(status)
|
||||
const map: Record<string, string> = {
|
||||
info: '#94a3b8',
|
||||
warn: '#d97706',
|
||||
done: '#0f766e',
|
||||
error: '#dc2626',
|
||||
processing: '#00a874',
|
||||
}
|
||||
return map[tone] || '#475569'
|
||||
}
|
||||
|
||||
export function statusTagClass(status: string | number | null | undefined): string {
|
||||
const tone = statusTone(status)
|
||||
const map: Record<string, string> = {
|
||||
info: 'info',
|
||||
warn: 'warning',
|
||||
done: 'success',
|
||||
error: 'danger',
|
||||
processing: 'processing',
|
||||
}
|
||||
return map[tone] || 'info'
|
||||
}
|
||||
|
||||
export function menuTypeLabel(type: number): string {
|
||||
const map: Record<number, string> = { 1: '目录', 2: '菜单', 3: '按钮' }
|
||||
return map[type] ?? String(type)
|
||||
}
|
||||
|
||||
export function formatAmount(amount: number | string): string {
|
||||
const n = typeof amount === 'string' ? parseFloat(amount) : amount
|
||||
if (isNaN(n)) return '0.00'
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
}
|
||||
|
||||
export function formatDate(dateStr: string | null | undefined): string {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 10)
|
||||
}
|
||||
|
||||
export function formatDateTime(dateStr: string | null | undefined): string {
|
||||
if (!dateStr) return '-'
|
||||
return dateStr.substring(0, 16).replace('T', ' ')
|
||||
}
|
||||
|
||||
/**
|
||||
* bx-backend(Pydantic to_camel)将实体的 create_time 输出为 applyTime。
|
||||
* 兼容直连 JSON、历史字段:createTime、apply_time、create_time。
|
||||
*/
|
||||
export function pickApplyTime(row: Record<string, any> | null | undefined): string | undefined {
|
||||
if (!row || typeof row !== 'object') return undefined
|
||||
const v =
|
||||
row.applyTime ?? row.createTime ?? row.apply_time ?? row.create_time
|
||||
if (v == null || v === '') return undefined
|
||||
return String(v)
|
||||
}
|
||||
|
||||
export function formatApplyDateTime(row: Record<string, any> | null | undefined): string {
|
||||
return formatDateTime(pickApplyTime(row))
|
||||
}
|
||||
|
||||
export function formatApplyDate(row: Record<string, any> | null | undefined): string {
|
||||
return formatDate(pickApplyTime(row))
|
||||
}
|
||||
|
||||
export function formatFileSize(bytes: number): string {
|
||||
if (bytes < 1024) return bytes + ' B'
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<!-- Topbar(与备用金申请等页统一) -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">系统管理</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<div class="admin-grid" style="margin-top: 16px;">
|
||||
<div
|
||||
v-for="item in menus"
|
||||
:key="item.path"
|
||||
class="admin-item"
|
||||
@click="router.push(item.path)"
|
||||
>
|
||||
<div class="admin-icon">
|
||||
<van-icon :name="item.icon" size="22" />
|
||||
</div>
|
||||
<span>{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const menus = [
|
||||
{ label: '用户管理', path: '/admin/users', icon: 'friends-o' },
|
||||
{ label: '角色管理', path: '/admin/roles', icon: 'shield-o' },
|
||||
{ label: '菜单管理', path: '/admin/menus', icon: 'bars' },
|
||||
{ label: '费用项目', path: '/admin/expenses', icon: 'balance-list-o' },
|
||||
{ label: '备用金流程', path: '/admin/wf-advance', icon: 'todo-list-o' },
|
||||
{ label: '报销流程', path: '/admin/wf-reimburse', icon: 'orders-o' },
|
||||
]
|
||||
</script>
|
||||
@@ -0,0 +1,378 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">费用项目管理</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增费用项目" @click="openAddDialog()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<div v-if="loading && expenseTree.length === 0" class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<template v-if="expenseTree.length > 0">
|
||||
<div class="section-title">费用项目</div>
|
||||
<div class="card-list">
|
||||
<div v-for="item in expenseTree" :key="item.id" class="tree-card">
|
||||
<!-- Level 1 Header -->
|
||||
<div class="tree-head" @click="toggleExpand(item.id)">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span :class="['tree-node', '', expandedIds.includes(item.id) ? 'expanded' : '']" style="padding: 0;">
|
||||
<span class="twisty" style="background: rgba(16, 185, 129, .10); width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center;">
|
||||
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="var(--primary-dark)" stroke-width="2" :style="{ transform: expandedIds.includes(item.id) ? 'rotate(90deg)' : '', transition: '.15s' }"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</span>
|
||||
</span>
|
||||
<span class="title">{{ item.itemName }}</span>
|
||||
</div>
|
||||
<div style="display: flex; gap: 4px; align-items: center;">
|
||||
<span class="tag tag-neutral">一级</span>
|
||||
<StatusTag :text="statusLabel(item.status)" :variant="item.status === 1 ? 'success' : 'muted'" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Level 1 Details -->
|
||||
<div v-show="expandedIds.includes(item.id)">
|
||||
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 14px; background: var(--bg);">
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">项目编码</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ item.itemCode || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">排序号</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ item.sortOrder }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">子项数量</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ item.childCount ?? (item.children?.length ?? 0) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="op-card-body" style="padding: 10px 14px 10px;">
|
||||
<div class="op-actions">
|
||||
<button class="btn btn-sm btn-primary" @click="openAddChildDialog(item)">新增子项</button>
|
||||
<button class="btn btn-sm btn-primary" @click="openEditDialog(item)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap[`delete-${item.id}`]" @click="handleDelete(item)">
|
||||
{{ loadingMap[`delete-${item.id}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Children (Level 2) -->
|
||||
<template v-if="item.children && item.children.length > 0">
|
||||
<div
|
||||
v-for="child in item.children"
|
||||
:key="child.id"
|
||||
class="op-card"
|
||||
style="margin: 0 14px 10px; border-left: 3px solid var(--primary);"
|
||||
>
|
||||
<div class="op-card-head">
|
||||
<div class="op-card-title" style="font-size: 14px;">{{ item.itemName }}/{{ child.itemName }}</div>
|
||||
<div style="display: flex; gap: 4px;">
|
||||
<span class="tag tag-neutral">二级</span>
|
||||
<StatusTag :text="statusLabel(child.status)" :variant="child.status === 1 ? 'success' : 'muted'" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="op-card-sub">
|
||||
<span>编码:{{ child.itemCode || '-' }}</span>
|
||||
<span>排序:{{ child.sortOrder }}</span>
|
||||
</div>
|
||||
<div class="op-card-body">
|
||||
<div class="op-actions">
|
||||
<button class="btn btn-sm btn-primary" @click="openEditDialog(child)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap[`delete-${child.id}`]" @click="handleDelete(child)">
|
||||
{{ loadingMap[`delete-${child.id}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="!loading && expenseTree.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="gold-coin-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无费用项目数据</p>
|
||||
</div>
|
||||
</van-pull-refresh>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<!-- Add/Edit Popup -->
|
||||
<van-popup
|
||||
v-model:show="showForm"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '85vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ dialogTitle }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">项目名称<span class="req">*</span></label>
|
||||
<input v-model="form.itemName" class="form-input" placeholder="请输入项目名称" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">项目编码</label>
|
||||
<input v-model="form.itemCode" class="form-input" placeholder="请输入项目编码" />
|
||||
</div>
|
||||
<div v-if="form.level === 2" class="field">
|
||||
<label class="field-label">上级项目</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
:value="parentDisplay"
|
||||
class="form-input"
|
||||
readonly
|
||||
placeholder="请选择上级项目"
|
||||
@click="showParentPicker = true"
|
||||
/>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">排序号</label>
|
||||
<input v-model="form.sortOrder" type="number" class="form-input" placeholder="请输入排序号" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">备注</label>
|
||||
<textarea v-model="form.remark" class="form-textarea" rows="2" placeholder="请输入备注(可选)" maxlength="200"></textarea>
|
||||
<div class="form-textarea-counter">{{ form.remark.length }}/200</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">状态</label>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<van-switch v-model="statusSwitch" size="20px" />
|
||||
<span style="font-size: 13px; color: var(--text-sec);">{{ form.status === 1 ? '启用' : '禁用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Parent Picker -->
|
||||
<van-popup v-model:show="showParentPicker" position="bottom" round>
|
||||
<van-picker
|
||||
:columns="parentColumns"
|
||||
@confirm="onParentConfirm"
|
||||
@cancel="showParentPicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { expenseItemApi } from '@/api'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { statusLabel } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const expenseTree = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const expandedIds = ref<number[]>([])
|
||||
|
||||
const showForm = ref(false)
|
||||
const showParentPicker = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const dialogMode = ref<'add' | 'addChild' | 'edit'>('add')
|
||||
|
||||
const form = reactive({
|
||||
id: 0,
|
||||
itemName: '',
|
||||
itemCode: '',
|
||||
level: 1,
|
||||
parentId: 0,
|
||||
sortOrder: '1',
|
||||
status: 1,
|
||||
remark: '',
|
||||
})
|
||||
|
||||
const statusSwitch = computed({
|
||||
get: () => form.status === 1,
|
||||
set: (v: boolean) => { form.status = v ? 1 : 0 },
|
||||
})
|
||||
|
||||
const parentOptions = computed(() => expenseTree.value.filter(r => r.level === 1))
|
||||
const parentColumns = computed(() =>
|
||||
parentOptions.value.map(p => ({ text: p.itemName, value: p.id }))
|
||||
)
|
||||
|
||||
const parentDisplay = computed(() => {
|
||||
if (form.parentId === 0) return ''
|
||||
return parentOptions.value.find(p => p.id === form.parentId)?.itemName ?? ''
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => {
|
||||
if (dialogMode.value === 'add') return '新增一级项目'
|
||||
if (dialogMode.value === 'addChild') return '新增二级项目'
|
||||
return '编辑项目'
|
||||
})
|
||||
|
||||
function toggleExpand(id: number) {
|
||||
const idx = expandedIds.value.indexOf(id)
|
||||
if (idx === -1) {
|
||||
expandedIds.value.push(id)
|
||||
} else {
|
||||
expandedIds.value.splice(idx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
id: 0, itemName: '', itemCode: '', level: 1,
|
||||
parentId: 0, sortOrder: '1', status: 1, remark: '',
|
||||
})
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
dialogMode.value = 'add'
|
||||
isEdit.value = false
|
||||
resetForm()
|
||||
form.level = 1
|
||||
form.parentId = 0
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openAddChildDialog(parent: any) {
|
||||
dialogMode.value = 'addChild'
|
||||
isEdit.value = false
|
||||
resetForm()
|
||||
form.level = 2
|
||||
form.parentId = parent.id
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(item: any) {
|
||||
dialogMode.value = 'edit'
|
||||
isEdit.value = true
|
||||
Object.assign(form, {
|
||||
id: item.id,
|
||||
itemName: item.itemName ?? '',
|
||||
itemCode: item.itemCode ?? '',
|
||||
level: item.level ?? 1,
|
||||
parentId: item.parentId ?? 0,
|
||||
sortOrder: String(item.sortOrder ?? 1),
|
||||
status: item.status ?? 1,
|
||||
remark: item.remark ?? '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function onParentConfirm({ selectedOptions }: any) {
|
||||
if (selectedOptions.length > 0) {
|
||||
form.parentId = selectedOptions[0].value
|
||||
}
|
||||
showParentPicker.value = false
|
||||
}
|
||||
|
||||
async function loadTree() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await expenseItemApi.tree()
|
||||
expenseTree.value = res.data ?? []
|
||||
expandedIds.value = expenseTree.value.map(m => m.id)
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载数据失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
loadTree()
|
||||
}
|
||||
|
||||
function validateExpenseItemForm(): boolean {
|
||||
if (!String(form.itemName ?? '').trim()) {
|
||||
showToast('请输入项目名称')
|
||||
return false
|
||||
}
|
||||
if (form.level === 2 && (!form.parentId || form.parentId === 0)) {
|
||||
showToast('请选择上级项目')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateExpenseItemForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
const sortParsed = parseInt(String(form.sortOrder).trim(), 10)
|
||||
const sortOrder = Number.isFinite(sortParsed) ? sortParsed : 1
|
||||
const payload = {
|
||||
itemName: form.itemName,
|
||||
itemCode: form.itemCode,
|
||||
level: form.level,
|
||||
parentId: form.parentId,
|
||||
sortOrder,
|
||||
status: form.status,
|
||||
remark: form.remark,
|
||||
}
|
||||
if (isEdit.value) {
|
||||
await expenseItemApi.update(form.id, payload)
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
await expenseItemApi.create(payload)
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(item: any) {
|
||||
const key = `delete-${item.id}`
|
||||
try {
|
||||
await showDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除费用项目「${item.itemName || item.itemCode}」吗?`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await expenseItemApi.delete(item.id)
|
||||
showToast('删除成功')
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
showToast(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadTree)
|
||||
</script>
|
||||
@@ -0,0 +1,315 @@
|
||||
<template>
|
||||
<div class="page menu-page">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">菜单管理</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增菜单" @click="openAddDialog()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<div v-if="loading && menuTree.length === 0" class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<template v-if="menuTree.length > 0">
|
||||
<div class="section-title">菜单结构</div>
|
||||
<div class="card-list">
|
||||
<div v-for="menu in menuTree" :key="menu.id" class="tree-card">
|
||||
<div class="tree-head">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0;"></div>
|
||||
<span class="title">{{ menu.menuName }}</span>
|
||||
</div>
|
||||
<div style="display: flex; gap: 4px;">
|
||||
<StatusTag :text="menuTypeLabel(menu.menuType)" :variant="menuTypeTone(menu.menuType)" />
|
||||
<StatusTag :text="statusLabel(menu.status)" :variant="menu.status === 1 ? 'success' : 'muted'" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 14px; background: var(--bg);">
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">编码</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ menu.menuCode || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">路由</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ menu.path || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">排序</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ menu.sortOrder }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="op-card-body" style="padding: 10px 14px 14px;">
|
||||
<div class="op-actions">
|
||||
<button class="btn btn-sm btn-primary" @click="openAddDialog(menu.id)">新增子菜单</button>
|
||||
<button class="btn btn-sm btn-primary" @click="openEditDialog(menu)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap[`delete-${menu.id}`]" @click="handleDelete(menu)">
|
||||
{{ loadingMap[`delete-${menu.id}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recursive children rendering -->
|
||||
<template v-if="menu.children && menu.children.length > 0">
|
||||
<menu-node
|
||||
v-for="child in menu.children"
|
||||
:key="child.id"
|
||||
:node="child"
|
||||
:depth="1"
|
||||
@edit="openEditDialog"
|
||||
@delete="handleDelete"
|
||||
@add-child="openAddDialog"
|
||||
:loading-map="loadingMap"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="!loading && menuTree.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="apps-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无菜单数据</p>
|
||||
</div>
|
||||
</van-pull-refresh>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<van-popup v-model:show="showForm" position="bottom" round :style="{ maxHeight: '85vh' }">
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ isEdit ? '编辑菜单' : '新增菜单' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">菜单名称<span class="req">*</span></label>
|
||||
<input v-model="form.menuName" class="form-input" placeholder="请输入菜单名称" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">菜单编码</label>
|
||||
<input v-model="form.menuCode" class="form-input" placeholder="请输入菜单编码" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">菜单类型</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
:value="menuTypeDisplay"
|
||||
class="form-input"
|
||||
readonly
|
||||
placeholder="请选择"
|
||||
@click="showTypePicker = true"
|
||||
/>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">路由</label>
|
||||
<input v-model="form.path" class="form-input" placeholder="请输入路由" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">排序号</label>
|
||||
<input v-model="form.sortOrder" type="number" class="form-input" placeholder="请输入排序号" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">状态</label>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<van-switch v-model="statusSwitch" size="20px" />
|
||||
<span style="font-size: 13px; color: var(--text-sec);">{{ form.status === 1 ? '启用' : '禁用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<van-popup v-model:show="showTypePicker" position="bottom" round>
|
||||
<van-picker
|
||||
:columns="menuTypeColumns"
|
||||
@confirm="onTypeConfirm"
|
||||
@cancel="showTypePicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { menuApi } from '@/api'
|
||||
import { menuTypeLabel, statusLabel } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
import MenuNode from '@/components/mobile/MenuNode.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const menuTree = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
|
||||
const showForm = ref(false)
|
||||
const showTypePicker = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const editingId = ref<number | null>(null)
|
||||
|
||||
const menuTypeOptions = [
|
||||
{ label: '目录', value: 1 },
|
||||
{ label: '菜单', value: 2 },
|
||||
{ label: '按钮', value: 3 },
|
||||
]
|
||||
const menuTypeColumns = menuTypeOptions.map(t => ({ text: t.label, value: t.value }))
|
||||
|
||||
const form = reactive({
|
||||
parentId: 0,
|
||||
menuName: '',
|
||||
menuCode: '',
|
||||
menuType: 2,
|
||||
path: '',
|
||||
sortOrder: '1',
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const statusSwitch = computed({
|
||||
get: () => form.status === 1,
|
||||
set: (v: boolean) => { form.status = v ? 1 : 0 },
|
||||
})
|
||||
|
||||
const menuTypeDisplay = computed(() => {
|
||||
return menuTypeOptions.find(t => t.value === form.menuType)?.label ?? ''
|
||||
})
|
||||
|
||||
function menuTypeTone(menuType: number): string {
|
||||
if (menuType === 1) return 'processing'
|
||||
if (menuType === 2) return 'success'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
parentId: 0, menuName: '', menuCode: '', menuType: 2,
|
||||
path: '', sortOrder: '1', status: 1,
|
||||
})
|
||||
}
|
||||
|
||||
function openAddDialog(parentId?: number) {
|
||||
isEdit.value = false
|
||||
editingId.value = null
|
||||
resetForm()
|
||||
if (parentId !== undefined) form.parentId = parentId
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(menu: any) {
|
||||
isEdit.value = true
|
||||
editingId.value = menu.id
|
||||
Object.assign(form, {
|
||||
parentId: menu.parentId ?? 0,
|
||||
menuName: menu.menuName ?? '',
|
||||
menuCode: menu.menuCode ?? '',
|
||||
menuType: menu.menuType ?? 2,
|
||||
path: menu.path ?? '',
|
||||
sortOrder: String(menu.sortOrder ?? 1),
|
||||
status: menu.status ?? 1,
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function onTypeConfirm({ selectedOptions }: any) {
|
||||
if (selectedOptions.length > 0) {
|
||||
form.menuType = selectedOptions[0].value
|
||||
}
|
||||
showTypePicker.value = false
|
||||
}
|
||||
|
||||
async function loadTree() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await menuApi.tree()
|
||||
menuTree.value = res.data ?? []
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载菜单失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
loadTree()
|
||||
}
|
||||
|
||||
function validateMenuForm(): boolean {
|
||||
if (!String(form.menuName ?? '').trim()) {
|
||||
showToast('请输入菜单名称')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateMenuForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
const payload = {
|
||||
...form,
|
||||
sortOrder: parseInt(form.sortOrder, 10) || 1,
|
||||
}
|
||||
if (isEdit.value) {
|
||||
await menuApi.update(editingId.value!, payload)
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
await menuApi.create(payload)
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(menu: any) {
|
||||
const key = `delete-${menu.id}`
|
||||
try {
|
||||
await showDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除菜单「${menu.menuName || menu.menuCode}」吗?`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await menuApi.delete(menu.id)
|
||||
showToast('删除成功')
|
||||
await loadTree()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
showToast(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadTree)
|
||||
</script>
|
||||
@@ -0,0 +1,633 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-medium">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">角色管理</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增角色" @click="openAddDialog">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索角色名称/编码"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
finished-text="没有更多了"
|
||||
@load="loadMore"
|
||||
>
|
||||
<div class="card-list">
|
||||
<div v-for="role in roleList" :key="role.id" class="op-card" @click="openEditDialog(role)">
|
||||
<div class="op-card-head">
|
||||
<div class="op-card-title">{{ role.roleName }}</div>
|
||||
<StatusTag :text="statusLabel(role.status)" :variant="role.status === 1 ? 'success' : 'muted'" />
|
||||
</div>
|
||||
<div class="op-card-sub">
|
||||
<span>编码:{{ role.roleCode }}</span>
|
||||
<span>排序:{{ role.sortOrder }}</span>
|
||||
</div>
|
||||
<div v-if="role.remark" style="margin-top: 6px; font-size: 13px; color: var(--text-sec);">{{ role.remark }}</div>
|
||||
|
||||
<div class="op-card-body">
|
||||
<div class="op-actions">
|
||||
<button
|
||||
class="btn btn-sm btn-secondary"
|
||||
:disabled="loadingMap[`assignUser-${role.id}`]"
|
||||
@click.stop="openAssignUserDialog(role)"
|
||||
>
|
||||
{{ loadingMap[`assignUser-${role.id}`] ? '加载中...' : '分配用户' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-secondary"
|
||||
:disabled="loadingMap[`assignMenu-${role.id}`]"
|
||||
@click.stop="openAssignMenuDialog(role)"
|
||||
>
|
||||
{{ loadingMap[`assignMenu-${role.id}`] ? '加载中...' : '分配菜单' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:disabled="loadingMap[`delete-${role.id}`]"
|
||||
@click.stop="handleDelete(role)"
|
||||
>
|
||||
{{ loadingMap[`delete-${role.id}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loading && roleList.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="cluster-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无角色数据</p>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<!-- Add/Edit Popup -->
|
||||
<van-popup
|
||||
v-model:show="showForm"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '85vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ isEdit ? '编辑角色' : '新增角色' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">角色名称<span class="req">*</span></label>
|
||||
<input v-model="form.roleName" class="form-input" placeholder="请输入角色名称" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">角色编码<span class="req">*</span></label>
|
||||
<input v-model="form.roleCode" class="form-input" placeholder="请输入角色编码" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">排序号</label>
|
||||
<input v-model="form.sortOrder" type="number" class="form-input" placeholder="请输入排序号" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">备注</label>
|
||||
<textarea v-model="form.remark" class="form-textarea" rows="2" placeholder="请输入备注"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">状态</label>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<van-switch v-model="statusSwitch" size="20px" />
|
||||
<span style="font-size: 13px; color: var(--text-sec);">{{ form.status === 1 ? '启用' : '禁用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Assign Users Popup:头尾固定,中间用户列表纵向滚动 -->
|
||||
<van-popup
|
||||
v-model:show="showAssignUser"
|
||||
position="bottom"
|
||||
round
|
||||
>
|
||||
<div class="assign-user-sheet">
|
||||
<div class="assign-user-sheet__head">
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">分配用户</div>
|
||||
</div>
|
||||
<div style="padding: 0 16px; font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 12px;">
|
||||
为角色「{{ selectedRole?.roleName }}」配置关联用户
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="assign-user-sheet__body">
|
||||
<div v-if="loadingMap.userLoad" class="page-body-loading--embed">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div style="padding: 0 16px 12px;">
|
||||
<div class="check-group" style="flex-direction: column;">
|
||||
<div
|
||||
v-for="u in allUsers"
|
||||
:key="u.id"
|
||||
:class="['check-item', selectedUserIds.includes(u.id) ? 'selected' : '']"
|
||||
@click="toggleUserCheck(u.id)"
|
||||
>
|
||||
<div style="flex: 1; min-width: 0;">
|
||||
<div style="font-size: 14px; font-weight: 500;">{{ u.realName ? `${u.realName}(${u.username})` : u.username }}</div>
|
||||
<div v-if="u.phone" style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">{{ u.phone }}</div>
|
||||
</div>
|
||||
<svg v-if="selectedUserIds.includes(u.id)" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="var(--primary-dark)" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="allUsers.length === 0" class="empty-state empty-state--embed">
|
||||
<van-icon name="friends-o" :size="48" color="var(--text-muted)" />
|
||||
<p>暂无可分配用户</p>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="assign-user-sheet__foot bottom-action-bar">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showAssignUser = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.assignUserSubmit" @click="handleAssignUserSubmit">
|
||||
{{ loadingMap.assignUserSubmit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Assign Menus Popup -->
|
||||
<van-popup
|
||||
v-model:show="showAssignMenu"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '85vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">分配菜单</div>
|
||||
</div>
|
||||
<div style="padding: 0 16px; font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 12px;">
|
||||
为角色「{{ selectedRole?.roleName }}」配置可访问的菜单权限
|
||||
</div>
|
||||
|
||||
<div v-if="loadingMap.menuTreeLoad" class="page-body-loading--embed">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div v-if="menuTreeData.length > 0" style="margin: 0 16px; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--rs); background: var(--bg);">
|
||||
<template v-for="menu in menuTreeData" :key="menu.id">
|
||||
<MenuTreeNode
|
||||
:node="menu"
|
||||
:checked-ids="selectedMenuIds"
|
||||
@toggle="toggleMenuCheck"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else class="empty-state empty-state--embed">
|
||||
<van-icon name="apps-o" :size="48" color="var(--text-muted)" />
|
||||
<p>暂无菜单数据</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showAssignMenu = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.menuAssignSubmit" @click="handleMenuAssignSubmit">
|
||||
{{ loadingMap.menuAssignSubmit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, h, defineComponent } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { roleApi, menuApi, userApi } from '@/api'
|
||||
import { BizError } from '@/api/client'
|
||||
import { statusLabel } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
|
||||
// ---------- Menu Tree Node Component (inline) ----------
|
||||
const MenuTreeNode = defineComponent({
|
||||
name: 'MenuTreeNode',
|
||||
props: {
|
||||
node: { type: Object, required: true },
|
||||
checkedIds: { type: Array as () => number[], required: true },
|
||||
depth: { type: Number, default: 0 },
|
||||
},
|
||||
emits: ['toggle'],
|
||||
setup(props, { emit }) {
|
||||
const expanded = ref(true)
|
||||
const isChecked = computed(() => props.checkedIds.includes(props.node.id))
|
||||
const hasChildren = computed(() => props.node.children && props.node.children.length > 0)
|
||||
|
||||
function toggle() {
|
||||
emit('toggle', props.node.id)
|
||||
}
|
||||
|
||||
function toggleExpand() {
|
||||
expanded.value = !expanded.value
|
||||
}
|
||||
|
||||
return () => {
|
||||
const children = hasChildren.value && expanded.value
|
||||
? props.node.children.map((child: any) =>
|
||||
h(MenuTreeNode, {
|
||||
node: child,
|
||||
checkedIds: props.checkedIds,
|
||||
depth: props.depth + 1,
|
||||
'onToggle': (id: number) => emit('toggle', id),
|
||||
})
|
||||
)
|
||||
: null
|
||||
|
||||
return h('div', { class: 'menu-tree-node' }, [
|
||||
h('div', {
|
||||
class: ['menu-tree-row', isChecked.value && 'is-checked'],
|
||||
style: { paddingLeft: `${props.depth * 20 + 12}px` },
|
||||
}, [
|
||||
h('span', {
|
||||
class: ['tree-expand-icon', hasChildren.value && 'has-children'],
|
||||
onClick: hasChildren.value ? toggleExpand : undefined,
|
||||
}, hasChildren.value ? (expanded.value ? '▼' : '▶') : ''),
|
||||
h('input', {
|
||||
type: 'checkbox',
|
||||
class: 'tree-checkbox',
|
||||
checked: isChecked.value,
|
||||
onClick: (e: Event) => { e.stopPropagation(); toggle() },
|
||||
}),
|
||||
h('span', { class: 'tree-label' }, props.node.menuName || props.node.name || `菜单${props.node.id}`),
|
||||
]),
|
||||
children,
|
||||
])
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// ---------- State ----------
|
||||
const router = useRouter()
|
||||
|
||||
function handleSearch() {
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loadRoles(1)
|
||||
currentPage.value = 2
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(handleSearch)
|
||||
|
||||
const roleList = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
const showForm = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const editingId = ref<number | null>(null)
|
||||
|
||||
const form = reactive({
|
||||
roleName: '',
|
||||
roleCode: '',
|
||||
sortOrder: '1',
|
||||
status: 1,
|
||||
remark: '',
|
||||
})
|
||||
|
||||
const statusSwitch = computed({
|
||||
get: () => form.status === 1,
|
||||
set: (v: boolean) => { form.status = v ? 1 : 0 },
|
||||
})
|
||||
|
||||
// Assign User state
|
||||
const showAssignUser = ref(false)
|
||||
const selectedRole = ref<any>(null)
|
||||
const allUsers = ref<any[]>([])
|
||||
const selectedUserIds = ref<number[]>([])
|
||||
|
||||
// Assign Menu state
|
||||
const showAssignMenu = ref(false)
|
||||
const menuTreeData = ref<any[]>([])
|
||||
const selectedMenuIds = ref<number[]>([])
|
||||
|
||||
// ---------- Form helpers ----------
|
||||
function resetForm() {
|
||||
Object.assign(form, { roleName: '', roleCode: '', sortOrder: '1', status: 1, remark: '' })
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
isEdit.value = false
|
||||
editingId.value = null
|
||||
resetForm()
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(role: any) {
|
||||
isEdit.value = true
|
||||
editingId.value = role.id
|
||||
Object.assign(form, {
|
||||
roleName: role.roleName ?? '',
|
||||
roleCode: role.roleCode ?? '',
|
||||
sortOrder: String(role.sortOrder ?? 1),
|
||||
status: role.status ?? 1,
|
||||
remark: role.remark ?? '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
// ---------- Data loading ----------
|
||||
async function loadRoles(page: number) {
|
||||
loading.value = true
|
||||
try {
|
||||
const params: Record<string, any> = { page, pageSize }
|
||||
if (keyword.value) params.keyword = keyword.value
|
||||
const res: any = await roleApi.list(params)
|
||||
const rows = res.data?.rows ?? res.data ?? []
|
||||
if (page === 1) {
|
||||
roleList.value = rows
|
||||
} else {
|
||||
roleList.value.push(...rows)
|
||||
}
|
||||
finished.value = rows.length < pageSize
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '加载失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
loadRoles(currentPage.value)
|
||||
currentPage.value++
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loadRoles(1)
|
||||
currentPage.value = 2
|
||||
}
|
||||
|
||||
function validateRoleForm(): boolean {
|
||||
if (!String(form.roleName ?? '').trim()) {
|
||||
showToast('请输入角色名称')
|
||||
return false
|
||||
}
|
||||
if (!String(form.roleCode ?? '').trim()) {
|
||||
showToast('请输入角色编码')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ---------- CRUD ----------
|
||||
async function handleSubmit() {
|
||||
if (!validateRoleForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
const payload = {
|
||||
...form,
|
||||
sortOrder: parseInt(form.sortOrder, 10) || 1,
|
||||
}
|
||||
if (isEdit.value) {
|
||||
await roleApi.update(editingId.value!, payload)
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
await roleApi.create(payload)
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '操作失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(role: any) {
|
||||
const key = `delete-${role.id}`
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除角色「${role.roleName}」吗?`,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await roleApi.delete(role.id)
|
||||
showToast('删除成功')
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (e === 'cancel') return
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Assign Users ----------
|
||||
function toggleUserCheck(userId: number) {
|
||||
const idx = selectedUserIds.value.indexOf(userId)
|
||||
if (idx === -1) {
|
||||
selectedUserIds.value.push(userId)
|
||||
} else {
|
||||
selectedUserIds.value.splice(idx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
async function openAssignUserDialog(role: any) {
|
||||
selectedRole.value = role
|
||||
selectedUserIds.value = []
|
||||
allUsers.value = []
|
||||
showAssignUser.value = true
|
||||
loadingMap.userLoad = true
|
||||
try {
|
||||
const [usersRes, roleUsersRes]: any[] = await Promise.all([
|
||||
userApi.list({ page: 1, pageSize: 999 }),
|
||||
roleApi.getUsers(role.id),
|
||||
])
|
||||
allUsers.value = usersRes.data?.rows ?? usersRes.data ?? []
|
||||
selectedUserIds.value = (roleUsersRes.data ?? []).map((u: any) => u.id)
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '加载用户数据失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.userLoad = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAssignUserSubmit() {
|
||||
if (!selectedRole.value) return
|
||||
loadingMap.assignUserSubmit = true
|
||||
try {
|
||||
await roleApi.assignUsers(selectedRole.value.id, selectedUserIds.value)
|
||||
showToast('用户分配成功')
|
||||
showAssignUser.value = false
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '操作失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.assignUserSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Assign Menus ----------
|
||||
function toggleMenuCheck(menuId: number) {
|
||||
const idx = selectedMenuIds.value.indexOf(menuId)
|
||||
if (idx === -1) {
|
||||
selectedMenuIds.value.push(menuId)
|
||||
} else {
|
||||
selectedMenuIds.value.splice(idx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/** Recursively collect all menu IDs from the tree (for half-check emulation) */
|
||||
function collectAllParentIds(tree: any[], checkedIds: number[]): number[] {
|
||||
const result: number[] = [...checkedIds]
|
||||
function walk(nodes: any[]) {
|
||||
for (const node of nodes) {
|
||||
if (node.children && node.children.length > 0) {
|
||||
const childIds = node.children.map((c: any) => c.id)
|
||||
const hasCheckedChild = childIds.some((id: number) => result.includes(id))
|
||||
if (hasCheckedChild && !result.includes(node.id)) {
|
||||
result.push(node.id)
|
||||
}
|
||||
walk(node.children)
|
||||
}
|
||||
}
|
||||
}
|
||||
walk(tree)
|
||||
return result
|
||||
}
|
||||
|
||||
async function openAssignMenuDialog(role: any) {
|
||||
selectedRole.value = role
|
||||
menuTreeData.value = []
|
||||
selectedMenuIds.value = []
|
||||
showAssignMenu.value = true
|
||||
loadingMap.menuTreeLoad = true
|
||||
try {
|
||||
const [treeRes, roleMenusRes]: any[] = await Promise.all([
|
||||
menuApi.tree(),
|
||||
menuApi.getByRole(role.id),
|
||||
])
|
||||
menuTreeData.value = treeRes.data ?? []
|
||||
selectedMenuIds.value = (roleMenusRes.data ?? []).map((m: any) => m.id)
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '加载菜单数据失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.menuTreeLoad = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMenuAssignSubmit() {
|
||||
if (!selectedRole.value) return
|
||||
loadingMap.menuAssignSubmit = true
|
||||
try {
|
||||
// Collect parent IDs (half-checked equivalent) plus directly checked
|
||||
const allIds = collectAllParentIds(menuTreeData.value, selectedMenuIds.value)
|
||||
await roleApi.assignMenus(selectedRole.value.id, allIds)
|
||||
showToast('菜单分配成功')
|
||||
showAssignMenu.value = false
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '操作失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.menuAssignSubmit = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Init ----------
|
||||
onMounted(() => {
|
||||
loadRoles(1)
|
||||
currentPage.value = 2
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 布局只在内容容器上:勿在 van-popup 根节点写 display:!important,否则会压过 v-show 的 display:none,弹窗无法关闭 */
|
||||
.assign-user-sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 85vh;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.assign-user-sheet__head {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.assign-user-sheet__body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.assign-user-sheet__foot {
|
||||
position: static !important;
|
||||
flex-shrink: 0;
|
||||
width: 100%;
|
||||
box-shadow: none;
|
||||
border-top: 1px solid var(--border);
|
||||
padding: 12px 16px;
|
||||
padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,503 @@
|
||||
<template>
|
||||
<div class="page user-manage-page page--empty-chrome-medium">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">用户管理</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增用户" @click="openAddDialog">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索用户名/姓名/手机号"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
finished-text="没有更多了"
|
||||
@load="loadMore"
|
||||
>
|
||||
<div class="card-list">
|
||||
<div v-for="user in userList" :key="user.id" class="op-card" @click="openEditDialog(user)">
|
||||
<div class="op-card-head">
|
||||
<div class="op-card-title">{{ user.realName || user.username }}</div>
|
||||
<StatusTag :text="statusLabel(user.status)" :variant="user.status === 1 ? 'success' : 'muted'" />
|
||||
</div>
|
||||
<div class="op-card-sub">
|
||||
<span>用户名:{{ user.username }}</span>
|
||||
<span>手机号:{{ user.phone || '-' }}</span>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 10px; border-radius: var(--rs); background: var(--bg);">
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">角色</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ user.roles || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 11px; color: var(--text-muted);">邮箱</div>
|
||||
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{{ user.email || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="op-card-body">
|
||||
<div class="op-actions">
|
||||
<button class="btn btn-sm btn-primary" @click.stop="openEditDialog(user)">编辑</button>
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
:class="user.status === 1 ? 'btn-warning' : 'btn-primary'"
|
||||
:disabled="loadingMap[`toggle-${user.id}`]"
|
||||
@click.stop="handleToggleStatus(user)"
|
||||
>
|
||||
{{ loadingMap[`toggle-${user.id}`] ? '处理中...' : (user.status === 1 ? '禁用' : '启用') }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-warning"
|
||||
:disabled="loadingMap[`resetPwd-${user.id}`]"
|
||||
@click.stop="handleResetPassword(user)"
|
||||
>
|
||||
{{ loadingMap[`resetPwd-${user.id}`] ? '处理中...' : '重置密码' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:disabled="loadingMap[`delete-${user.id}`]"
|
||||
@click.stop="handleDelete(user)"
|
||||
>
|
||||
{{ loadingMap[`delete-${user.id}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loading && userList.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="friends-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无用户数据</p>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<!-- Add/Edit Popup -->
|
||||
<van-popup
|
||||
v-model:show="showForm"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '85vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ isEdit ? '编辑用户' : '新增用户' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">用户名<span class="req">*</span></label>
|
||||
<input v-model="form.username" class="form-input" placeholder="请输入用户名" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">姓名<span class="req">*</span></label>
|
||||
<input v-model="form.realName" class="form-input" placeholder="请输入姓名" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">手机号</label>
|
||||
<input v-model="form.phone" class="form-input" placeholder="请输入手机号" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">邮箱</label>
|
||||
<input
|
||||
v-model="form.email"
|
||||
class="form-input"
|
||||
placeholder="请输入邮箱"
|
||||
autocomplete="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">密码</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
v-model="form.password"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
class="form-input"
|
||||
:placeholder="isEdit ? '留空则不修改' : '请输入初始密码'"
|
||||
:autocomplete="isEdit ? 'off' : 'new-password'"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="form-input-pwd-toggle"
|
||||
:aria-label="showPassword ? '隐藏密码' : '显示密码'"
|
||||
:aria-pressed="showPassword"
|
||||
@click.stop="showPassword = !showPassword"
|
||||
>
|
||||
<svg v-if="!showPassword" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</svg>
|
||||
<svg v-else viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" />
|
||||
<line x1="1" y1="1" x2="23" y2="23" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">角色</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
:value="roleDisplay"
|
||||
class="form-input"
|
||||
readonly
|
||||
placeholder="请选择角色"
|
||||
@click="showRolePicker = true"
|
||||
/>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">状态</label>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<van-switch v-model="statusSwitch" size="20px" />
|
||||
<span style="font-size: 13px; color: var(--text-sec);">{{ form.status === 1 ? '启用' : '禁用' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Role Multi-Select Popup -->
|
||||
<van-popup v-model:show="showRolePicker" position="bottom" round>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">选择角色</div>
|
||||
</div>
|
||||
<div style="padding: 0 16px;">
|
||||
<div class="check-group role-picker-check-group" style="flex-direction: column;">
|
||||
<div
|
||||
v-for="role in roleOptions"
|
||||
:key="role.id"
|
||||
:class="['check-item', 'role-picker-item', form.roleIds.includes(role.id) ? 'selected' : '']"
|
||||
@click="toggleRoleCheck(role.id)"
|
||||
>
|
||||
<span>{{ role.roleName }}</span>
|
||||
<svg v-if="form.roleIds.includes(role.id)" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="var(--primary-dark)" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-primary btn-block" @click="showRolePicker = false">确定</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { userApi, roleApi } from '@/api'
|
||||
import { BizError } from '@/api/client'
|
||||
import { statusLabel } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
function handleSearch() {
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loadUsers(1)
|
||||
currentPage.value = 2
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(handleSearch)
|
||||
|
||||
const userList = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
const showForm = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
const editingId = ref<number | null>(null)
|
||||
|
||||
const showRolePicker = ref(false)
|
||||
const showPassword = ref(false)
|
||||
const roleOptions = ref<{ id: number; roleName: string }[]>([])
|
||||
|
||||
const form = reactive({
|
||||
username: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
password: '',
|
||||
roleIds: [] as number[],
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const statusSwitch = computed({
|
||||
get: () => form.status === 1,
|
||||
set: (v: boolean) => { form.status = v ? 1 : 0 },
|
||||
})
|
||||
|
||||
const roleDisplay = computed(() => {
|
||||
if (form.roleIds.length === 0) return ''
|
||||
return form.roleIds
|
||||
.map(id => roleOptions.value.find(r => r.id === id)?.roleName ?? '')
|
||||
.filter(Boolean)
|
||||
.join('、')
|
||||
})
|
||||
|
||||
function toggleRoleCheck(roleId: number) {
|
||||
const idx = form.roleIds.indexOf(roleId)
|
||||
if (idx === -1) {
|
||||
form.roleIds.push(roleId)
|
||||
} else {
|
||||
form.roleIds.splice(idx, 1)
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
showPassword.value = false
|
||||
Object.assign(form, {
|
||||
username: '', realName: '', phone: '', email: '',
|
||||
password: '', roleIds: [], status: 1,
|
||||
})
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
isEdit.value = false
|
||||
editingId.value = null
|
||||
resetForm()
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(user: any) {
|
||||
showPassword.value = false
|
||||
isEdit.value = true
|
||||
editingId.value = user.id
|
||||
Object.assign(form, {
|
||||
username: user.username ?? '',
|
||||
realName: user.realName ?? '',
|
||||
phone: user.phone ?? '',
|
||||
email: user.email ?? '',
|
||||
password: '',
|
||||
roleIds: user.roleList?.map((r: any) => r.id) ?? [],
|
||||
status: user.status ?? 1,
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
async function loadRoles() {
|
||||
try {
|
||||
const res: any = await roleApi.list({ page: 1, pageSize: 999 })
|
||||
const raw = res.data?.rows ?? res.data ?? []
|
||||
const list = Array.isArray(raw) ? raw : []
|
||||
roleOptions.value = list.map((r: any) => ({
|
||||
id: r.id,
|
||||
roleName: r.roleName ?? r.role_name ?? r.name ?? '',
|
||||
}))
|
||||
} catch {
|
||||
roleOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUsers(page: number) {
|
||||
loading.value = true
|
||||
try {
|
||||
const params: Record<string, any> = { page, pageSize }
|
||||
if (keyword.value) params.keyword = keyword.value
|
||||
const res: any = await userApi.list(params)
|
||||
const rows = res.data?.rows ?? res.data ?? []
|
||||
if (page === 1) {
|
||||
userList.value = rows
|
||||
} else {
|
||||
userList.value.push(...rows)
|
||||
}
|
||||
finished.value = rows.length < pageSize
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '加载失败')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function loadMore() {
|
||||
loadUsers(currentPage.value)
|
||||
currentPage.value++
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loadUsers(1)
|
||||
currentPage.value = 2
|
||||
}
|
||||
|
||||
function validateUserForm(): boolean {
|
||||
if (!String(form.username ?? '').trim()) {
|
||||
showToast('请输入用户名')
|
||||
return false
|
||||
}
|
||||
if (!String(form.realName ?? '').trim()) {
|
||||
showToast('请输入姓名')
|
||||
return false
|
||||
}
|
||||
if (!isEdit.value && !String(form.password ?? '').trim()) {
|
||||
showToast('请输入初始密码')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateUserForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
const payload: Record<string, any> = { ...form }
|
||||
if (isEdit.value) {
|
||||
if (!payload.password) delete payload.password
|
||||
await userApi.update(editingId.value!, payload)
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
await userApi.create(payload)
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '操作失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(user: any) {
|
||||
const key = `delete-${user.id}`
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除用户「${user.realName || user.username}」吗?`,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await userApi.delete(user.id)
|
||||
showToast('删除成功')
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (e === 'cancel') return
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleResetPassword(user: any) {
|
||||
const key = `resetPwd-${user.id}`
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '重置密码确认',
|
||||
message: `确定要重置用户「${user.realName || user.username}」的密码为默认密码 123456 吗?`,
|
||||
confirmButtonText: '确定重置',
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await userApi.resetPassword(user.id)
|
||||
showToast('密码已重置为 123456')
|
||||
} catch (e: unknown) {
|
||||
if (e === 'cancel') return
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || '重置密码失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToggleStatus(user: any) {
|
||||
const key = `toggle-${user.id}`
|
||||
const action = user.status === 1 ? '禁用' : '启用'
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: `${action}确认`,
|
||||
message: `确定要${action}用户「${user.realName || user.username}」吗?`,
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
await userApi.update(user.id, { status: user.status === 1 ? 0 : 1 })
|
||||
showToast(`${action}成功`)
|
||||
handleSearch()
|
||||
} catch (e: unknown) {
|
||||
if (e === 'cancel') return
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast((e as Error)?.message || `${action}失败`)
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadRoles()
|
||||
loadUsers(1)
|
||||
currentPage.value = 2
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 用户管理-角色多选弹窗:加高每行,便于点击 */
|
||||
.role-picker-check-group {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.role-picker-item {
|
||||
min-height: 48px;
|
||||
padding: 14px 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,343 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-wf">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">工作流配置(备用金)</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增节点" @click="openAddDialog">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="page-padded">
|
||||
<!-- Workflow info -->
|
||||
<div class="detail-grid" style="margin-top: 12px;">
|
||||
<div class="detail-item">
|
||||
<div class="di-label">流程名称</div>
|
||||
<div class="di-value">{{ wfDef.wfName || '-' }}</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="di-label">状态</div>
|
||||
<div class="di-value">
|
||||
<StatusTag :text="statusLabel(wfDef.status)" :variant="statusTagClass(wfDef.status)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<template v-if="!loading">
|
||||
<div v-if="nodes.length > 0" class="section-title">审批节点</div>
|
||||
|
||||
<div class="flow-card">
|
||||
<div
|
||||
v-for="(node, index) in nodes"
|
||||
:key="node.id ?? index"
|
||||
class="flow-step"
|
||||
>
|
||||
<div class="flow-avatar av-done">{{ index + 1 }}</div>
|
||||
<div class="flow-info" style="flex: 1;">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; gap: 8px;">
|
||||
<div class="flow-name">{{ node.nodeName }}</div>
|
||||
<StatusTag :text="(node.approverId ?? node.approver_id) ? '已配置' : '未配置'" :variant="(node.approverId ?? node.approver_id) ? 'success' : 'warning'" />
|
||||
</div>
|
||||
<div class="flow-role">审批人:{{ node.approverName ?? node.approver_name ?? '-' }}</div>
|
||||
<div class="flow-time">节点顺序:{{ node.nodeOrder }}</div>
|
||||
<div class="op-actions" style="margin-top: 8px;">
|
||||
<button class="btn btn-sm btn-primary" @click="openEditDialog(node)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap[`delete-${nodeKey(node)}`]" @click="handleDelete(node)">
|
||||
{{ loadingMap[`delete-${nodeKey(node)}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
<button class="btn btn-sm btn-secondary" :disabled="index === 0 || !!loadingMap[`up-${nodeKey(node)}`]" @click="moveUp(node)">
|
||||
{{ loadingMap[`up-${nodeKey(node)}`] ? '...' : '上移' }}
|
||||
</button>
|
||||
<button class="btn btn-sm btn-secondary" :disabled="index === nodes.length - 1 || !!loadingMap[`down-${nodeKey(node)}`]" @click="moveDown(node)">
|
||||
{{ loadingMap[`down-${nodeKey(node)}`] ? '...' : '下移' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="nodes.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="guide-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无流程节点,点击右下角新增</p>
|
||||
</div>
|
||||
</template>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<!-- Add/Edit Popup -->
|
||||
<van-popup
|
||||
v-model:show="showForm"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '80vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ isEdit ? '编辑节点' : '新增节点' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">节点名称<span class="req">*</span></label>
|
||||
<input v-model="formData.nodeName" class="form-input" placeholder="请输入节点名称" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">审批人</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
:value="approverDisplay"
|
||||
class="form-input"
|
||||
readonly
|
||||
placeholder="请选择审批人"
|
||||
@click="showApproverPicker = true"
|
||||
/>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Approver Picker -->
|
||||
<van-popup v-model:show="showApproverPicker" position="bottom" round>
|
||||
<van-picker
|
||||
:columns="userColumns"
|
||||
@confirm="onApproverConfirm"
|
||||
@cancel="showApproverPicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { workflowApi, userApi } from '@/api'
|
||||
import { statusLabel, statusTagClass } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const wfDef = ref<Record<string, any>>({})
|
||||
const nodes = computed(() => wfDef.value.nodes || [])
|
||||
const loading = ref(false)
|
||||
|
||||
const showForm = ref(false)
|
||||
const showApproverPicker = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
const userOptions = ref<{ id: number; realName: string; displayName: string }[]>([])
|
||||
const userColumns = computed(() =>
|
||||
userOptions.value.map(u => ({ text: u.displayName, value: u.id }))
|
||||
)
|
||||
|
||||
const formData = reactive({
|
||||
editingNodeId: null as number | null,
|
||||
nodeName: '',
|
||||
approverId: null as number | null,
|
||||
approverName: '',
|
||||
})
|
||||
|
||||
const approverDisplay = computed(() => {
|
||||
if (formData.approverId == null) return ''
|
||||
return userOptions.value.find(u => u.id === formData.approverId)?.displayName ?? formData.approverName
|
||||
})
|
||||
|
||||
function nodeKey(node: Record<string, any>): string {
|
||||
return String(node.id ?? node.nodeOrder ?? node.nodeName ?? Date.now())
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res: any = await userApi.dropdown()
|
||||
const data = res.data ?? res
|
||||
userOptions.value = (data || []).map((u: any) => {
|
||||
const name = u.realName || u.username
|
||||
const roles = u.roles || ''
|
||||
return {
|
||||
id: u.id,
|
||||
realName: name,
|
||||
displayName: roles ? `${name}(${roles})` : name,
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadWfDef() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await workflowApi.getByBizType('advance')
|
||||
wfDef.value = res.data || res
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载工作流失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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 ?? '',
|
||||
}))
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
isEdit.value = false
|
||||
Object.assign(formData, {
|
||||
editingNodeId: null,
|
||||
nodeName: '',
|
||||
approverId: null,
|
||||
approverName: '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(node: Record<string, any>) {
|
||||
isEdit.value = true
|
||||
Object.assign(formData, {
|
||||
editingNodeId: node.id ?? null,
|
||||
nodeName: node.nodeName ?? '',
|
||||
approverId: node.approverId ?? node.approver_id ?? null,
|
||||
approverName: node.approverName ?? node.approver_name ?? '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function onApproverConfirm({ selectedOptions }: any) {
|
||||
if (selectedOptions.length > 0) {
|
||||
formData.approverId = selectedOptions[0].value
|
||||
formData.approverName = selectedOptions[0].text.split('(')[0]
|
||||
}
|
||||
showApproverPicker.value = false
|
||||
}
|
||||
|
||||
function validateWfNodeForm(): boolean {
|
||||
if (!String(formData.nodeName ?? '').trim()) {
|
||||
showToast('请输入节点名称')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateWfNodeForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
if (isEdit.value && formData.editingNodeId != null) {
|
||||
const newNodes = nodes.value.map((n: Record<string, any>) =>
|
||||
n.id === formData.editingNodeId
|
||||
? { ...n, nodeName: formData.nodeName, approverId: formData.approverId, approverName: formData.approverName }
|
||||
: n
|
||||
)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
const newNodes = [
|
||||
...nodes.value,
|
||||
{ nodeName: formData.nodeName, approverId: formData.approverId, approverName: formData.approverName },
|
||||
]
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(node: Record<string, any>) {
|
||||
const key = `delete-${nodeKey(node)}`
|
||||
try {
|
||||
await showDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除节点「${node.nodeName}」吗?`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
const newNodes = nodes.value.filter((n: Record<string, any>) => n.id !== node.id)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('删除成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
showToast(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = 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
|
||||
const key = `up-${nodeKey(node)}`
|
||||
try {
|
||||
loadingMap[key] = true
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
showToast('上移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '上移失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
const key = `down-${nodeKey(node)}`
|
||||
try {
|
||||
loadingMap[key] = true
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
showToast('下移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '下移失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadWfDef()
|
||||
loadUsers()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,343 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-wf">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">工作流配置(报销单)</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增节点" @click="openAddDialog">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<div class="page-padded">
|
||||
<!-- Workflow info -->
|
||||
<div class="detail-grid" style="margin-top: 12px;">
|
||||
<div class="detail-item">
|
||||
<div class="di-label">流程名称</div>
|
||||
<div class="di-value">{{ wfDef.wfName || '-' }}</div>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<div class="di-label">状态</div>
|
||||
<div class="di-value">
|
||||
<StatusTag :text="statusLabel(wfDef.status)" :variant="statusTagClass(wfDef.status)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<template v-if="!loading">
|
||||
<div v-if="nodes.length > 0" class="section-title">审批节点</div>
|
||||
|
||||
<div class="flow-card">
|
||||
<div
|
||||
v-for="(node, index) in nodes"
|
||||
:key="node.id ?? index"
|
||||
class="flow-step"
|
||||
>
|
||||
<div class="flow-avatar av-done">{{ index + 1 }}</div>
|
||||
<div class="flow-info" style="flex: 1;">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; gap: 8px;">
|
||||
<div class="flow-name">{{ node.nodeName }}</div>
|
||||
<StatusTag :text="(node.approverId ?? node.approver_id) ? '已配置' : '未配置'" :variant="(node.approverId ?? node.approver_id) ? 'success' : 'warning'" />
|
||||
</div>
|
||||
<div class="flow-role">审批人:{{ node.approverName ?? node.approver_name ?? '-' }}</div>
|
||||
<div class="flow-time">节点顺序:{{ node.nodeOrder }}</div>
|
||||
<div class="op-actions" style="margin-top: 8px;">
|
||||
<button class="btn btn-sm btn-primary" @click="openEditDialog(node)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" :disabled="loadingMap[`delete-${nodeKey(node)}`]" @click="handleDelete(node)">
|
||||
{{ loadingMap[`delete-${nodeKey(node)}`] ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
<button class="btn btn-sm btn-secondary" :disabled="index === 0 || !!loadingMap[`up-${nodeKey(node)}`]" @click="moveUp(node)">
|
||||
{{ loadingMap[`up-${nodeKey(node)}`] ? '...' : '上移' }}
|
||||
</button>
|
||||
<button class="btn btn-sm btn-secondary" :disabled="index === nodes.length - 1 || !!loadingMap[`down-${nodeKey(node)}`]" @click="moveDown(node)">
|
||||
{{ loadingMap[`down-${nodeKey(node)}`] ? '...' : '下移' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="nodes.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="guide-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无流程节点,点击右下角新增</p>
|
||||
</div>
|
||||
</template>
|
||||
</div><!-- /page-padded -->
|
||||
|
||||
<!-- Add/Edit Popup -->
|
||||
<van-popup
|
||||
v-model:show="showForm"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '80vh' }"
|
||||
>
|
||||
<div class="popup-sheet-title-wrap">
|
||||
<div class="section-title">{{ isEdit ? '编辑节点' : '新增节点' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="margin: 0 16px;">
|
||||
<div class="field">
|
||||
<label class="field-label">节点名称<span class="req">*</span></label>
|
||||
<input v-model="formData.nodeName" class="form-input" placeholder="请输入节点名称" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">审批人</label>
|
||||
<div class="form-input-icon">
|
||||
<input
|
||||
:value="approverDisplay"
|
||||
class="form-input"
|
||||
readonly
|
||||
placeholder="请选择审批人"
|
||||
@click="showApproverPicker = true"
|
||||
/>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m9 18 6-6-6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-action-bar" style="position: static; box-shadow: none; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));">
|
||||
<button class="btn btn-secondary" style="flex: 1;" @click="showForm = false">取消</button>
|
||||
<button class="btn btn-primary" style="flex: 1;" :disabled="loadingMap.submit" @click="handleSubmit">
|
||||
{{ loadingMap.submit ? '保存中...' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- Approver Picker -->
|
||||
<van-popup v-model:show="showApproverPicker" position="bottom" round>
|
||||
<van-picker
|
||||
:columns="userColumns"
|
||||
@confirm="onApproverConfirm"
|
||||
@cancel="showApproverPicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { workflowApi, userApi } from '@/api'
|
||||
import { statusLabel, statusTagClass } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const wfDef = ref<Record<string, any>>({})
|
||||
const nodes = computed(() => wfDef.value.nodes || [])
|
||||
const loading = ref(false)
|
||||
|
||||
const showForm = ref(false)
|
||||
const showApproverPicker = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
const userOptions = ref<{ id: number; realName: string; displayName: string }[]>([])
|
||||
const userColumns = computed(() =>
|
||||
userOptions.value.map(u => ({ text: u.displayName, value: u.id }))
|
||||
)
|
||||
|
||||
const formData = reactive({
|
||||
editingNodeId: null as number | null,
|
||||
nodeName: '',
|
||||
approverId: null as number | null,
|
||||
approverName: '',
|
||||
})
|
||||
|
||||
const approverDisplay = computed(() => {
|
||||
if (formData.approverId == null) return ''
|
||||
return userOptions.value.find(u => u.id === formData.approverId)?.displayName ?? formData.approverName
|
||||
})
|
||||
|
||||
function nodeKey(node: Record<string, any>): string {
|
||||
return String(node.id ?? node.nodeOrder ?? node.nodeName ?? Date.now())
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const res: any = await userApi.dropdown()
|
||||
const data = res.data ?? res
|
||||
userOptions.value = (data || []).map((u: any) => {
|
||||
const name = u.realName || u.username
|
||||
const roles = u.roles || ''
|
||||
return {
|
||||
id: u.id,
|
||||
realName: name,
|
||||
displayName: roles ? `${name}(${roles})` : name,
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
userOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadWfDef() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await workflowApi.getByBizType('reimburse')
|
||||
wfDef.value = res.data || res
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载工作流失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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 ?? '',
|
||||
}))
|
||||
}
|
||||
|
||||
function openAddDialog() {
|
||||
isEdit.value = false
|
||||
Object.assign(formData, {
|
||||
editingNodeId: null,
|
||||
nodeName: '',
|
||||
approverId: null,
|
||||
approverName: '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEditDialog(node: Record<string, any>) {
|
||||
isEdit.value = true
|
||||
Object.assign(formData, {
|
||||
editingNodeId: node.id ?? null,
|
||||
nodeName: node.nodeName ?? '',
|
||||
approverId: node.approverId ?? node.approver_id ?? null,
|
||||
approverName: node.approverName ?? node.approver_name ?? '',
|
||||
})
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function onApproverConfirm({ selectedOptions }: any) {
|
||||
if (selectedOptions.length > 0) {
|
||||
formData.approverId = selectedOptions[0].value
|
||||
formData.approverName = selectedOptions[0].text.split('(')[0]
|
||||
}
|
||||
showApproverPicker.value = false
|
||||
}
|
||||
|
||||
function validateWfNodeForm(): boolean {
|
||||
if (!String(formData.nodeName ?? '').trim()) {
|
||||
showToast('请输入节点名称')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!validateWfNodeForm()) return
|
||||
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
if (isEdit.value && formData.editingNodeId != null) {
|
||||
const newNodes = nodes.value.map((n: Record<string, any>) =>
|
||||
n.id === formData.editingNodeId
|
||||
? { ...n, nodeName: formData.nodeName, approverId: formData.approverId, approverName: formData.approverName }
|
||||
: n
|
||||
)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('编辑成功')
|
||||
} else {
|
||||
const newNodes = [
|
||||
...nodes.value,
|
||||
{ nodeName: formData.nodeName, approverId: formData.approverId, approverName: formData.approverName },
|
||||
]
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('新增成功')
|
||||
}
|
||||
showForm.value = false
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(node: Record<string, any>) {
|
||||
const key = `delete-${nodeKey(node)}`
|
||||
try {
|
||||
await showDialog({
|
||||
title: '删除确认',
|
||||
message: `确定要删除节点「${node.nodeName}」吗?`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[key] = true
|
||||
const newNodes = nodes.value.filter((n: Record<string, any>) => n.id !== node.id)
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(newNodes))
|
||||
showToast('删除成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
showToast(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[key] = 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
|
||||
const key = `up-${nodeKey(node)}`
|
||||
try {
|
||||
loadingMap[key] = true
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
showToast('上移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '上移失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
const key = `down-${nodeKey(node)}`
|
||||
try {
|
||||
loadingMap[key] = true
|
||||
await workflowApi.saveNodes(wfDef.value.id, buildNodePayload(arr))
|
||||
showToast('下移成功')
|
||||
await loadWfDef()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '下移失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadWfDef()
|
||||
loadUsers()
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,383 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">备用金申请</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<form class="apply-form" @submit.prevent="onSubmit">
|
||||
<!-- 基本信息 -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>备用金信息</h3>
|
||||
<span class="form-badge">{{ isEdit ? '编辑' : '新建' }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 申请原因 -->
|
||||
<div class="field">
|
||||
<label class="field-label">申请原因<span class="req">*</span></label>
|
||||
<textarea
|
||||
:class="['form-textarea', { error: fieldErr.reason }]"
|
||||
rows="3"
|
||||
placeholder="请输入申请原因"
|
||||
v-model="form.reason"
|
||||
@input="fieldErr.reason = false"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 申请金额 -->
|
||||
<div class="field">
|
||||
<label class="field-label">申请金额<span class="req">*</span></label>
|
||||
<div class="form-input-prefix">
|
||||
<input
|
||||
:class="['form-input', { error: fieldErr.amount }]"
|
||||
type="number"
|
||||
placeholder="请输入金额"
|
||||
v-model="form.amount"
|
||||
@input="fieldErr.amount = false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 备注 -->
|
||||
<div class="field">
|
||||
<label class="field-label">备注</label>
|
||||
<textarea
|
||||
class="form-textarea"
|
||||
rows="2"
|
||||
placeholder="选填"
|
||||
v-model="form.remark"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 附件 -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>附件</h3>
|
||||
</div>
|
||||
<div class="uploader-slot-btn advance-attachment-upload">
|
||||
<van-uploader
|
||||
:after-read="onAfterRead"
|
||||
:before-read="beforeReadAttachment"
|
||||
multiple
|
||||
result-type="file"
|
||||
:accept="attachmentAccept"
|
||||
>
|
||||
<button type="button" class="btn btn-primary btn-sm">上传附件</button>
|
||||
</van-uploader>
|
||||
</div>
|
||||
<div v-if="attachment.files.value.length" class="att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="(file, idx) in attachment.files.value"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="attachment.open(file)"
|
||||
@keydown.enter.prevent="attachment.open(file)"
|
||||
>
|
||||
<img
|
||||
v-if="attachment.isImage(file.fileType) && file.previewUrl"
|
||||
:src="file.previewUrl"
|
||||
:alt="file.fileName"
|
||||
/>
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ attachment.fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
<button type="button" class="del" @click.stop="attachment.remove(idx)">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<BottomActionBar>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-block"
|
||||
:class="{ 'btn-loading': submitting }"
|
||||
@click="onSubmit"
|
||||
>
|
||||
保存
|
||||
</button>
|
||||
</BottomActionBar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { advanceApi } from '@/api'
|
||||
import { BizError } from '@/api/client'
|
||||
import { useAttachment } from '@/hooks/useAttachment'
|
||||
import { SUBMIT_APPROVE_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import BottomActionBar from '@/components/mobile/BottomActionBar.vue'
|
||||
|
||||
const MAX_ATTACHMENTS = 10
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
/** 与原生文件选择器 accept 对齐:图片 + 常用文档(扩展名兼容 iOS/Android) */
|
||||
const attachmentAccept =
|
||||
[
|
||||
'image/*',
|
||||
'application/pdf',
|
||||
'application/msword',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'text/plain',
|
||||
'text/csv',
|
||||
'application/rtf',
|
||||
'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
'application/x-rar-compressed',
|
||||
'application/x-7z-compressed',
|
||||
'.pdf',
|
||||
'.doc',
|
||||
'.docx',
|
||||
'.xls',
|
||||
'.xlsx',
|
||||
'.ppt',
|
||||
'.pptx',
|
||||
'.txt',
|
||||
'.csv',
|
||||
'.rtf',
|
||||
'.wps',
|
||||
'.et',
|
||||
'.dps',
|
||||
'.zip',
|
||||
'.rar',
|
||||
'.7z',
|
||||
].join(',')
|
||||
|
||||
const attachment = useAttachment()
|
||||
|
||||
const isEdit = computed(() => !!route.query.id)
|
||||
const savedId = ref<number | null>(null)
|
||||
const submitting = ref(false)
|
||||
|
||||
const form = ref({
|
||||
reason: '',
|
||||
amount: '',
|
||||
remark: '',
|
||||
})
|
||||
|
||||
/** 与校验提示联动:未填「申请原因 / 申请金额」时红框提示 */
|
||||
const fieldErr = reactive({ reason: false, amount: false })
|
||||
|
||||
/** 保存草稿前校验(与表单项 * 一致) */
|
||||
function validateAdvanceApplyForm(): boolean {
|
||||
fieldErr.reason = false
|
||||
fieldErr.amount = false
|
||||
if (!form.value.reason?.trim()) {
|
||||
fieldErr.reason = true
|
||||
showToast('请输入申请原因')
|
||||
return false
|
||||
}
|
||||
const raw = String(form.value.amount ?? '').trim()
|
||||
if (!raw) {
|
||||
fieldErr.amount = true
|
||||
showToast('请输入申请金额')
|
||||
return false
|
||||
}
|
||||
const amt = Number(raw)
|
||||
if (Number.isNaN(amt) || amt <= 0) {
|
||||
fieldErr.amount = true
|
||||
showToast('请输入大于 0 的申请金额')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function beforeReadAttachment(file: File | File[]) {
|
||||
const batch = Array.isArray(file) ? file : [file]
|
||||
const remain = MAX_ATTACHMENTS - attachment.files.value.length
|
||||
if (remain <= 0) {
|
||||
showToast(`最多上传 ${MAX_ATTACHMENTS} 个附件`)
|
||||
return false
|
||||
}
|
||||
if (batch.length > remain) {
|
||||
showToast(`还可上传 ${remain} 个附件,超出部分已忽略`)
|
||||
return Promise.resolve(batch.slice(0, remain))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function onAfterRead(uploadFile: any) {
|
||||
const files = Array.isArray(uploadFile) ? uploadFile : [uploadFile]
|
||||
for (const f of files) {
|
||||
if (!f?.file) continue
|
||||
await attachment.upload(f.file)
|
||||
}
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
if (!validateAdvanceApplyForm()) return
|
||||
|
||||
submitting.value = true
|
||||
const isEditingAction = isEdit.value || !!savedId.value
|
||||
try {
|
||||
const data: Record<string, any> = {
|
||||
reason: form.value.reason.trim(),
|
||||
amount: Number(form.value.amount),
|
||||
remark: form.value.remark,
|
||||
}
|
||||
|
||||
let id: number
|
||||
if (isEdit.value || savedId.value) {
|
||||
id = savedId.value || Number(route.query.id)
|
||||
await advanceApi.update(id, data)
|
||||
await attachment.bindNew('advance', id)
|
||||
} else {
|
||||
const res: any = await advanceApi.create(data)
|
||||
id = Number(res?.data?.id ?? res?.id ?? 0)
|
||||
if (!id) {
|
||||
throw new Error('保存成功但未返回申请单ID')
|
||||
}
|
||||
await attachment.bindNew('advance', id)
|
||||
savedId.value = id
|
||||
}
|
||||
showToast('保存成功')
|
||||
|
||||
showDialog({
|
||||
title: isEditingAction ? '保存成功' : '创建成功',
|
||||
message: '备用金申请已保存为草稿',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '提交审批',
|
||||
confirmButtonColor: SUBMIT_APPROVE_BUTTON_COLOR,
|
||||
cancelButtonText: '继续编辑',
|
||||
}).then(() => {
|
||||
// 用户点击"提交审批"
|
||||
advanceApi.submit(id).then(() => {
|
||||
showToast('提交成功')
|
||||
router.back()
|
||||
}).catch((e: any) => {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast(e?.message || '提交失败')
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
// 用户点击"继续编辑" — 留在当前页
|
||||
})
|
||||
} catch (e: any) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast(e?.message || '保存失败')
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function pickRemark(data: Record<string, unknown>): string {
|
||||
const v = data.remark
|
||||
if (v == null) return ''
|
||||
return String(v)
|
||||
}
|
||||
|
||||
async function loadEditData() {
|
||||
if (!isEdit.value) return
|
||||
try {
|
||||
const id = Number(route.query.id)
|
||||
const res: any = await advanceApi.getById(id)
|
||||
const data = res?.data as Record<string, unknown> | undefined
|
||||
if (data) {
|
||||
form.value = {
|
||||
reason: (data.reason as string) || '',
|
||||
amount: data.amount != null ? String(data.amount) : '',
|
||||
remark: pickRemark(data),
|
||||
}
|
||||
await attachment.loadList('advance', id)
|
||||
}
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 从详情「重新提交」会写入 bx_edit_resubmit;已进入编辑页即视为完成跳转,
|
||||
// 若保留标记,用户点顶栏返回详情时仍会误触发「是否立即提交」弹窗。
|
||||
sessionStorage.removeItem('bx_edit_resubmit')
|
||||
await loadEditData()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => route.query.id,
|
||||
async (id, prev) => {
|
||||
if (!id) return
|
||||
if (String(id) === String(prev ?? '')) return
|
||||
await loadEditData()
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.apply-form .form-card + .form-card {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
/* 附件:上传入口为紧凑按钮;下方列表与按钮间距 5px */
|
||||
.advance-attachment-upload {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.advance-att-grid {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.advance-att-tile {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.advance-att-tile:active {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
/* 附件网格中文档缩略(非图片) */
|
||||
.att-img .att-file-icon.att-doc-thumb {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-shrink: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.att-doc-thumb__ext {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.att-doc-thumb__name {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.25;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,907 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<!-- 顶部导航 -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M15 18l-6-6 6-6" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">备用金详情</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<template v-if="detail">
|
||||
<!-- 票券式头部:蓝底 + 分栏 + 虚线圆缺口 + 原因 + 大号金额 -->
|
||||
<div class="advance-ticket-shell">
|
||||
<div class="advance-ticket-stack">
|
||||
<div class="advance-ticket-top">
|
||||
<span class="advance-ticket-code" :title="detail.applyCode || undefined">{{
|
||||
detail.applyCode || '—'
|
||||
}}</span>
|
||||
<span
|
||||
class="advance-ticket-status"
|
||||
:class="ticketHeaderStatusToneClass(detail.status)"
|
||||
>{{ statusLabel(detail.status) }}</span>
|
||||
</div>
|
||||
<div class="advance-ticket-tear" aria-hidden="true">
|
||||
<div class="advance-ticket-tear__line"></div>
|
||||
</div>
|
||||
<div class="advance-ticket-bottom">
|
||||
<p class="advance-ticket-reason">{{ detail.reason || '—' }}</p>
|
||||
<div class="advance-ticket-amount-wrap">
|
||||
<span class="advance-ticket-amount">{{ formatAmount(detail.amount) }}</span>
|
||||
<svg
|
||||
class="advance-ticket-watermark"
|
||||
viewBox="0 0 64 64"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
d="M16 8h20l12 12v32a4 4 0 0 1-4 4H16a4 4 0 0 1-4-4V12a4 4 0 0 1 4-4Z"
|
||||
fill="currentColor"
|
||||
opacity="0.2"
|
||||
/>
|
||||
<path
|
||||
d="M24 28h20M24 36h20M24 44h12"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
stroke-linecap="round"
|
||||
opacity="0.35"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-tabs v-model:active="detailTab" class="advance-detail-tabs" sticky offset-top="58">
|
||||
<van-tab title="基础信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<section class="detail-info-card" aria-label="申请信息">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请单号</div>
|
||||
<div class="adv-field__value">{{ detail.applyCode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请原因</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.reason || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">实际发放金额</div>
|
||||
<div
|
||||
class="adv-field__value"
|
||||
:class="{ 'adv-field__value--accent': detail.actualAmount != null }"
|
||||
>
|
||||
{{
|
||||
detail.actualAmount != null
|
||||
? '¥ ' + formatAmount(detail.actualAmount)
|
||||
: '—'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请人</div>
|
||||
<div class="adv-field__value">{{ detail.applicantName || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">当前节点</div>
|
||||
<div class="adv-field__value">{{ detail.currentNode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请时间</div>
|
||||
<div class="adv-field__value">{{ formatApplyDateTime(detail) }}</div>
|
||||
</div>
|
||||
<div v-if="detail.remark" class="adv-field">
|
||||
<div class="adv-field__label">备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.remark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="申请附件">
|
||||
<div class="detail-info-card__title">申请附件</div>
|
||||
<template v-if="attachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in attachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="onPreviewFile(file)"
|
||||
@keydown.enter.prevent="onPreviewFile(file)"
|
||||
>
|
||||
<img
|
||||
v-if="isImageFile(file.fileType) && file.previewUrl"
|
||||
:src="file.previewUrl"
|
||||
:alt="file.fileName"
|
||||
/>
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无申请附件</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="审批信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<section class="detail-info-card detail-info-card--timeline" aria-label="审批流程">
|
||||
<template v-if="approvals.length > 0">
|
||||
<div class="adv-approval-flow">
|
||||
<div v-for="(a, i) in approvals" :key="a.id ?? i" class="flow-step">
|
||||
<div
|
||||
:class="[
|
||||
'flow-avatar',
|
||||
a.approvalStatus === 'approved' || a.status === 'approved'
|
||||
? 'av-done'
|
||||
: a.approvalStatus === 'pending' || a.status === 'pending'
|
||||
? 'av-current'
|
||||
: a.approvalStatus === 'rejected' || a.status === 'rejected'
|
||||
? 'av-reject'
|
||||
: 'av-pending'
|
||||
]"
|
||||
>
|
||||
{{ (a.approverName || a.nodeName || a.nodeLabel || '审')[0] }}
|
||||
</div>
|
||||
<div class="flow-info">
|
||||
<div class="flow-name">{{ a.nodeName || a.nodeLabel || a.approverName || '—' }}</div>
|
||||
<div v-if="a.approverName" class="flow-role">{{ a.approverName }}</div>
|
||||
<div v-if="a.approvalTime" class="flow-time">{{ formatDateTime(a.approvalTime) }}</div>
|
||||
<div v-if="a.approvalOpinion" class="adv-flow-opinion">{{ a.approvalOpinion }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无审批记录</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="发放信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<template v-if="isAdvanceIssued">
|
||||
<section class="detail-info-card" aria-label="发放记录">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">发放时间</div>
|
||||
<div class="adv-field__value">{{ formatDateTime(detail.issueTime) || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">发放操作人</div>
|
||||
<div class="adv-field__value">{{ detail.issueUserName || '—' }}</div>
|
||||
</div>
|
||||
<div v-if="detail.issueRemark" class="adv-field">
|
||||
<div class="adv-field__label">发放备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.issueRemark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="发放凭证">
|
||||
<div class="detail-info-card__title">发放凭证</div>
|
||||
<template v-if="issueAttachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in issueAttachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="onPreviewFile(file)"
|
||||
@keydown.enter.prevent="onPreviewFile(file)"
|
||||
>
|
||||
<img
|
||||
v-if="isImageFile(file.fileType) && file.previewUrl"
|
||||
:src="file.previewUrl"
|
||||
:alt="file.fileName"
|
||||
/>
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无发放凭证</p>
|
||||
</section>
|
||||
</template>
|
||||
<section v-else class="detail-info-card detail-info-card--empty-state" aria-label="发放状态">
|
||||
<p class="detail-section-empty detail-section-empty--in-card">尚未发放</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="冲抵信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<section class="detail-info-card" aria-label="冲抵汇总">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">已冲抵合计</div>
|
||||
<div class="adv-field__value adv-field__value--accent">¥ {{ offsetTotalDisplay }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p class="adv-offset-meta">冲抵记录 {{ offsetRecords.length }} 条</p>
|
||||
|
||||
<template v-if="offsetRecords.length > 0">
|
||||
<section
|
||||
v-for="(rec, idx) in offsetRecords"
|
||||
:key="rec.id ?? idx"
|
||||
class="detail-info-card detail-info-card--nest"
|
||||
>
|
||||
<div class="adv-offset-block__title">
|
||||
<span class="adv-offset-block__idx">#{{ idx + 1 }}</span>
|
||||
<span class="adv-offset-block__code">{{ rec.reimburseApplyCode || '—' }}</span>
|
||||
<span class="adv-offset-block__amt">¥ {{ formatAmount(rec.offsetAmount) }}</span>
|
||||
</div>
|
||||
<div v-if="rec.reimburseApplicantName" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">报销申请人</div>
|
||||
<div class="adv-field__value">{{ rec.reimburseApplicantName }}</div>
|
||||
</div>
|
||||
<div class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">冲抵时间</div>
|
||||
<div class="adv-field__value">{{ formatDateTime(rec.createTime ?? rec.create_time) || '—' }}</div>
|
||||
</div>
|
||||
<div v-if="rec.operator" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">操作人</div>
|
||||
<div class="adv-field__value">{{ rec.operator }}</div>
|
||||
</div>
|
||||
<div v-if="rec.remark" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ rec.remark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
<section v-else class="detail-info-card detail-info-card--empty-state" aria-label="冲抵记录">
|
||||
<p class="detail-section-empty detail-section-empty--in-card">暂无冲抵记录</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
</van-tabs>
|
||||
</template>
|
||||
|
||||
<div v-else class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<!-- 底部操作栏 -->
|
||||
<div v-if="showActions" class="bottom-action-bar">
|
||||
<template v-if="detail?.status === 'draft'">
|
||||
<button type="button" class="btn btn-primary" style="flex:1" :class="{ 'btn-loading': actionLoading.submit }" :disabled="actionLoading.submit" @click="handleSubmit">提交审批</button>
|
||||
<button type="button" class="btn btn-danger" style="flex:1" :class="{ 'btn-loading': actionLoading.delete }" :disabled="actionLoading.delete" @click="handleDelete">删除</button>
|
||||
</template>
|
||||
<template v-if="detail?.status === 'rejected'">
|
||||
<button type="button" class="btn btn-primary" style="flex:1" @click="handleResubmit">重新提交</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, reactive, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { showToast, showDialog, showConfirmDialog, showImagePreview } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { advanceApi, attachmentApi, paymentApi } from '@/api'
|
||||
import { statusLabel, ticketHeaderStatusToneClass, formatAmount, formatDateTime, formatApplyDateTime } from '@/utils/format'
|
||||
|
||||
interface AttachmentInfo {
|
||||
id: number
|
||||
fileName: string
|
||||
fileType: string
|
||||
fileSize: number
|
||||
previewUrl: string
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const detail = ref<any>(null)
|
||||
const detailTab = ref(0)
|
||||
const approvals = ref<any[]>([])
|
||||
const attachments = ref<AttachmentInfo[]>([])
|
||||
const issueAttachments = ref<AttachmentInfo[]>([])
|
||||
const offsetRecords = ref<any[]>([])
|
||||
const actionLoading = reactive<Record<string, boolean>>({})
|
||||
|
||||
const isAdvanceIssued = computed(() => {
|
||||
const d = detail.value
|
||||
return !!(d && (d.issueStatus === 'issued' || d.status === 'issued'))
|
||||
})
|
||||
|
||||
const offsetTotalDisplay = computed(() => {
|
||||
const d = detail.value
|
||||
const apiVal = d?.offsetAmount ?? d?.offset_amount
|
||||
if (apiVal != null && apiVal !== '' && Number.isFinite(Number(apiVal))) {
|
||||
return formatAmount(apiVal)
|
||||
}
|
||||
const sum = offsetRecords.value.reduce(
|
||||
(s, r) => s + Number(r?.offsetAmount ?? r?.offset_amount ?? 0),
|
||||
0,
|
||||
)
|
||||
return formatAmount(sum)
|
||||
})
|
||||
|
||||
const showActions = computed(() => {
|
||||
if (!detail.value) return false
|
||||
const status = detail.value.status
|
||||
return status === 'draft' || status === 'rejected'
|
||||
})
|
||||
|
||||
function isImageFile(fileType: string): boolean {
|
||||
return fileType?.startsWith('image/')
|
||||
}
|
||||
|
||||
/** 与备用金申请页附件 tile 一致 */
|
||||
function fileExt(name: string): string {
|
||||
const ext = name.split('.').pop()
|
||||
return ext ? ext.toUpperCase() : 'FILE'
|
||||
}
|
||||
|
||||
async function onPreviewFile(file: AttachmentInfo) {
|
||||
if (isImageFile(file.fileType) && file.previewUrl) {
|
||||
showImagePreview({ images: [file.previewUrl] })
|
||||
} else {
|
||||
await downloadFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
/** 经 axios 携带 Token,避免直接打开 /api/... 导致 401 */
|
||||
async function downloadFile(file: AttachmentInfo) {
|
||||
try {
|
||||
const blob = (await attachmentApi.download(file.id)) as unknown as Blob
|
||||
if (!(blob instanceof Blob)) {
|
||||
showToast('下载失败')
|
||||
return
|
||||
}
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = file.fileName || '附件'
|
||||
a.rel = 'noopener'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
} catch {
|
||||
showToast('下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDetail() {
|
||||
const id = Number(route.params.id)
|
||||
try {
|
||||
const res: any = await advanceApi.getById(id)
|
||||
detail.value = res.data
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载详情失败')
|
||||
return
|
||||
}
|
||||
|
||||
// 加载审批流程
|
||||
try {
|
||||
const apprRes: any = await advanceApi.getApprovals(id)
|
||||
const nodes = apprRes.data || []
|
||||
approvals.value = nodes.sort(
|
||||
(a: any, b: any) => (a.nodeOrder ?? 0) - (b.nodeOrder ?? 0)
|
||||
)
|
||||
} catch {
|
||||
// 审批流程加载失败不影响详情
|
||||
}
|
||||
|
||||
// 加载附件
|
||||
try {
|
||||
const attRes: any = await attachmentApi.listByBiz('advance', id)
|
||||
const list: AttachmentInfo[] = (attRes.data || []).map(
|
||||
(a: any) => ({ ...a, previewUrl: '' })
|
||||
)
|
||||
const imgPromises = list
|
||||
.filter(a => isImageFile(a.fileType || ''))
|
||||
.map(async (a) => {
|
||||
try {
|
||||
const pRes: any = await attachmentApi.preview(a.id)
|
||||
a.previewUrl = pRes.data.url
|
||||
} catch {
|
||||
// preview not critical
|
||||
}
|
||||
})
|
||||
await Promise.all(imgPromises)
|
||||
attachments.value = list
|
||||
} catch {
|
||||
// 附件加载失败不影响详情
|
||||
}
|
||||
|
||||
// 加载冲抵记录
|
||||
try {
|
||||
const offsetRes: any = await paymentApi.advanceOffsetRecords(id)
|
||||
offsetRecords.value = offsetRes.data || []
|
||||
} catch {
|
||||
// 冲抵记录加载失败不影响详情
|
||||
}
|
||||
|
||||
issueAttachments.value = []
|
||||
if (isAdvanceIssued.value) {
|
||||
try {
|
||||
const issueAttRes: any = await attachmentApi.listByBiz('advance_issue', id)
|
||||
const list: AttachmentInfo[] = (issueAttRes.data || []).map(
|
||||
(a: any) => ({ ...a, previewUrl: '' }),
|
||||
)
|
||||
const imgPromises = list
|
||||
.filter(a => isImageFile(a.fileType || ''))
|
||||
.map(async (a) => {
|
||||
try {
|
||||
const pRes: any = await attachmentApi.preview(a.id)
|
||||
a.previewUrl = pRes.data.url
|
||||
} catch { /* skip */ }
|
||||
})
|
||||
await Promise.all(imgPromises)
|
||||
issueAttachments.value = list
|
||||
} catch {
|
||||
issueAttachments.value = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!detail.value) return
|
||||
actionLoading.submit = true
|
||||
try {
|
||||
await advanceApi.submit(detail.value.id)
|
||||
showToast('提交成功')
|
||||
await loadDetail()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '提交失败')
|
||||
} finally {
|
||||
actionLoading.submit = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!detail.value) return
|
||||
try {
|
||||
await showDialog({
|
||||
title: '确认删除',
|
||||
message: '确定要删除该备用金申请吗?删除后不可恢复。',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
actionLoading.delete = true
|
||||
await advanceApi.delete(detail.value.id)
|
||||
showToast('删除成功')
|
||||
router.back()
|
||||
} catch {
|
||||
// cancelled
|
||||
} finally {
|
||||
actionLoading.delete = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleResubmit() {
|
||||
if (!detail.value) return
|
||||
sessionStorage.setItem('bx_edit_resubmit', String(detail.value.id))
|
||||
router.push({ path: '/advance/apply', query: { id: String(detail.value.id) } })
|
||||
}
|
||||
|
||||
async function checkResubmitPrompt() {
|
||||
const pendingId = sessionStorage.getItem('bx_edit_resubmit')
|
||||
if (!pendingId || !detail.value) return
|
||||
sessionStorage.removeItem('bx_edit_resubmit')
|
||||
if (String(detail.value.id) === pendingId && detail.value.status === 'rejected') {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提交确认',
|
||||
message: '是否立即提交审批?',
|
||||
confirmButtonText: '是',
|
||||
cancelButtonText: '否',
|
||||
})
|
||||
actionLoading.submit = true
|
||||
await advanceApi.submit(detail.value.id)
|
||||
showToast('提交成功')
|
||||
await loadDetail()
|
||||
} catch {
|
||||
// user cancelled or submit failed
|
||||
} finally {
|
||||
actionLoading.submit = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadDetail()
|
||||
await checkResubmitPrompt()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* —— 票券式金额头:主色绿底 + 浅绿卡面 + 虚线圆缺口(:root 薄荷 token) —— */
|
||||
.advance-ticket-shell {
|
||||
--ticket-bg: var(--primary);
|
||||
--ticket-skin: var(--primary-light);
|
||||
--ticket-dash: rgba(0, 201, 141, 0.45);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 16px 14px;
|
||||
background: var(--ticket-bg);
|
||||
}
|
||||
|
||||
.advance-ticket-stack {
|
||||
width: 100%;
|
||||
max-width: 430px;
|
||||
margin: 0 auto;
|
||||
filter: drop-shadow(0 10px 24px rgba(0, 168, 116, 0.3));
|
||||
}
|
||||
|
||||
.advance-ticket-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 48px;
|
||||
padding: 14px 16px 12px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 14px 14px 0 0;
|
||||
}
|
||||
|
||||
.advance-ticket-code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.02em;
|
||||
color: #475569;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status {
|
||||
flex-shrink: 0;
|
||||
padding: 4px 11px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status--warn {
|
||||
background: #ea580c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--done {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--err {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--info {
|
||||
background: #64748b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--processing {
|
||||
background: #6366f1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* 撕边:两侧圆缺口 + 虚线 */
|
||||
.advance-ticket-tear {
|
||||
position: relative;
|
||||
height: 14px;
|
||||
background: var(--ticket-skin);
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before,
|
||||
.advance-ticket-tear::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-top: -7px;
|
||||
border-radius: 50%;
|
||||
background: var(--ticket-bg);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before {
|
||||
left: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::after {
|
||||
right: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear__line {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
top: 50%;
|
||||
margin-top: -0.5px;
|
||||
border-top: 1px dashed var(--ticket-dash);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.advance-ticket-bottom {
|
||||
position: relative;
|
||||
padding: 10px 16px 20px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 0 0 14px 14px;
|
||||
}
|
||||
|
||||
.advance-ticket-reason {
|
||||
margin: 0 0 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.45;
|
||||
color: #64748b;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.advance-ticket-amount-wrap {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-start;
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.advance-ticket-amount {
|
||||
font-size: clamp(30px, 9.5vw, 40px);
|
||||
font-weight: 800;
|
||||
line-height: 1.05;
|
||||
letter-spacing: -0.03em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #0f172a;
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, 'PingFang SC', 'Helvetica Neue', Arial,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.advance-ticket-watermark {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: -4px;
|
||||
width: 76px;
|
||||
height: 76px;
|
||||
color: var(--ticket-bg);
|
||||
opacity: 0.16;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.advance-detail-tabs :deep(.van-tabs__content) {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
/* Tab 内容区:卡片纵向留出呼吸间距 */
|
||||
.advance-detail-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding-top: 12px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
/* 分组卡片:白底 + 轻边框阴影,信息层级更清晰 */
|
||||
.detail-info-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--r);
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 6px 16px 10px;
|
||||
}
|
||||
|
||||
.detail-info-card--media {
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--timeline {
|
||||
padding: 10px 16px 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--nest {
|
||||
padding: 12px 16px 10px;
|
||||
}
|
||||
|
||||
.detail-info-card--empty-state {
|
||||
padding: 28px 16px;
|
||||
}
|
||||
|
||||
.detail-info-card__title {
|
||||
margin: 6px 0 14px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
/* 键值:移动端更适合「上标签 / 下内容」,标签弱化、内容为主 */
|
||||
.adv-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.adv-field + .adv-field {
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.adv-field:first-child {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.adv-field:last-child {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.adv-field--compact {
|
||||
gap: 4px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.detail-info-card--nest .adv-offset-block__title + .adv-field {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.adv-field__label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.adv-field__value {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.adv-field__value--multiline {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
color: var(--text-sec);
|
||||
}
|
||||
|
||||
.adv-field__value--accent {
|
||||
color: var(--primary-dark);
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 卡片内空态:与全局 dashed 空态区分,更轻 */
|
||||
.detail-section-empty--in-card {
|
||||
margin-top: 4px;
|
||||
background: var(--primary-light);
|
||||
border-style: solid;
|
||||
border-color: rgba(0, 201, 141, 0.12);
|
||||
}
|
||||
|
||||
/* 附件网格:与 AdvanceApplyPage 同款(申请 / 发放) */
|
||||
.advance-detail-att-grid {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.advance-att-tile) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.advance-att-tile:active) {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-img .att-file-icon.att-doc-thumb) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-shrink: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__ext) {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__name) {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.25;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* 审批:时间线(全局 .flow-step 线)放在卡片内,层次更集中 */
|
||||
.adv-approval-flow {
|
||||
padding: 4px 0 2px;
|
||||
}
|
||||
|
||||
.adv-flow-opinion {
|
||||
font-size: 12px;
|
||||
color: var(--text-sec);
|
||||
margin-top: 6px;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* 冲抵:列表说明文案(卡片之间) */
|
||||
.adv-offset-meta {
|
||||
margin: 0;
|
||||
padding: 2px 4px 0;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.adv-offset-block__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 14px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.adv-offset-block__idx {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.adv-offset-block__code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.adv-offset-block__amt {
|
||||
flex-shrink: 0;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,353 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-tall">
|
||||
<!-- Topbar -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">备用金申请</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="fab-add"
|
||||
aria-label="新增备用金申请"
|
||||
@click="router.push('/advance/apply')"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<!-- Search(与「我的申请」一致:检索在上) -->
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索备用金申请"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态筛选(与「我的申请」同款 filter-tag) -->
|
||||
<div class="search-wrap" style="padding-top: 0;">
|
||||
<div class="search-filter search-filter--scroll">
|
||||
<div
|
||||
v-for="tab in tabs"
|
||||
:key="tab.value === '' ? '__all' : tab.value"
|
||||
:class="['filter-tag', { active: activeTab === tab.value }]"
|
||||
@click="activeTab = tab.value; onTabChange()"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- List -->
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
:finished-text="list.length ? '没有更多了' : ''"
|
||||
@load="onLoad"
|
||||
>
|
||||
<div v-if="list.length === 0 && !loading" class="empty-state empty-state--fill">
|
||||
<van-icon name="cash-back-record" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无备用金记录</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="router.push(`/advance/${item.id}`)"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type advance-list-card__title-wrap">
|
||||
<span class="advance-list-card__title">{{ item.reason || '—' }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">申请金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="advance-card-subs">
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际发放金额</span>
|
||||
<span class="v">¥ {{ actualIssuedDisplay(item) }}</span>
|
||||
</div>
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际冲抵</span>
|
||||
<span class="v">¥ {{ formatAmount(offsetTotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDate(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom advance-list-card__bottom">
|
||||
<div class="op-actions" v-if="item.status === 'draft' || item.status === 'rejected'">
|
||||
<template v-if="item.status === 'draft'">
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`del_${item.id}`] }"
|
||||
@click.stop="handleDelete(item)"
|
||||
>删除</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/advance/apply?id=${item.id}`)"
|
||||
>编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`submit_${item.id}`] }"
|
||||
@click.stop="handleSubmit(item)"
|
||||
>提交</button>
|
||||
</template>
|
||||
<template v-else-if="item.status === 'rejected'">
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/advance/${item.id}`)"
|
||||
>查看</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/advance/apply?id=${item.id}`)"
|
||||
>编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`submit_${item.id}`] }"
|
||||
@click.stop="handleSubmit(item)"
|
||||
>提交</button>
|
||||
</template>
|
||||
</div>
|
||||
<div class="op-actions" v-else>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/advance/${item.id}`)"
|
||||
>查看</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { advanceApi } from '@/api'
|
||||
import { statusLabel, workflowListStatusTagClass, formatAmount, formatApplyDate } from '@/utils/format'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const tabs = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待提交', value: 'draft' },
|
||||
{ label: '审批中', value: 'pending' },
|
||||
{ label: '已通过', value: 'approved' },
|
||||
{ label: '已驳回', value: 'rejected' },
|
||||
{ label: '已发放', value: 'issued' },
|
||||
]
|
||||
|
||||
const activeTab = ref<string | number>('')
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const finished = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const currentPage = ref(1)
|
||||
const pageSize = 10
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
/** 接口 camelCase / 少数场景 snake_case */
|
||||
function actualIssuedDisplay(item: Record<string, unknown>): string {
|
||||
const raw = item.actualAmount ?? item.actual_amount
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n)) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function offsetTotal(item: Record<string, unknown>): number {
|
||||
const raw = item.offsetAmount ?? item.offset_amount ?? 0
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
return Number.isNaN(n) ? 0 : n
|
||||
}
|
||||
|
||||
async function fetchPage() {
|
||||
try {
|
||||
const params: Record<string, any> = {
|
||||
page: currentPage.value,
|
||||
pageSize,
|
||||
}
|
||||
if (activeTab.value) {
|
||||
params.status = activeTab.value
|
||||
}
|
||||
if (keyword.value.trim()) {
|
||||
params.keyword = keyword.value.trim()
|
||||
}
|
||||
const res: any = await advanceApi.my(params)
|
||||
const rows = res.data?.rows || []
|
||||
const total = res.data?.total || 0
|
||||
|
||||
if (currentPage.value === 1) {
|
||||
list.value = rows
|
||||
} else {
|
||||
list.value.push(...rows)
|
||||
}
|
||||
currentPage.value++
|
||||
finished.value = rows.length < pageSize || list.value.length >= total
|
||||
} catch {
|
||||
finished.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(() => onRefresh())
|
||||
|
||||
function onTabChange() {
|
||||
list.value = []
|
||||
currentPage.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
async function handleSubmit(item: any) {
|
||||
loadingMap[`submit_${item.id}`] = true
|
||||
try {
|
||||
await advanceApi.submit(item.id)
|
||||
showToast('提交成功')
|
||||
onRefresh()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`submit_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(item: any) {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: '确定要删除该申请单吗?删除后不可恢复。',
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
loadingMap[`del_${item.id}`] = true
|
||||
await advanceApi.delete(item.id)
|
||||
showToast('删除成功')
|
||||
onRefresh()
|
||||
} catch (e: any) {
|
||||
if (e !== 'cancel') {
|
||||
showToast(e?.message || '删除失败')
|
||||
}
|
||||
} finally {
|
||||
loadingMap[`del_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 标题:申请原因,过长省略 */
|
||||
.advance-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.advance-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 底部仅操作区时右对齐(原左侧为申请原因摘要) */
|
||||
.advance-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.advance-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.advance-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,539 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-tall">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">全部申请单</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<!-- 与「我的申请」一致:业务切换居中卡片 -->
|
||||
<div class="mine-type-tabs stat-scroll mine-type-tabs--triple">
|
||||
<div
|
||||
:class="['stat-card', { active: activeTab === 0 }]"
|
||||
@click="onBizTab(0)"
|
||||
>
|
||||
<span class="label">全部</span>
|
||||
</div>
|
||||
<div
|
||||
:class="['stat-card', { active: activeTab === 1 }]"
|
||||
@click="onBizTab(1)"
|
||||
>
|
||||
<span class="label">备用金</span>
|
||||
</div>
|
||||
<div
|
||||
:class="['stat-card', { active: activeTab === 2 }]"
|
||||
@click="onBizTab(2)"
|
||||
>
|
||||
<span class="label">报销申请</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索单号 / 申请人"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrap" style="padding-top: 0;">
|
||||
<div class="search-filter search-filter--scroll">
|
||||
<div
|
||||
v-for="opt in statusFilters"
|
||||
:key="opt.value === '' ? '__all' : opt.value"
|
||||
:class="['filter-tag', { active: filterStatus === opt.value }]"
|
||||
@click="onStatusFilter(opt.value)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loadingMore"
|
||||
:finished="finished"
|
||||
finished-text=""
|
||||
@load="onLoadMore"
|
||||
>
|
||||
<div
|
||||
v-for="item in displayList"
|
||||
:key="item.id + '-' + item.bizType"
|
||||
class="expense-card"
|
||||
@click="goDetail(item)"
|
||||
>
|
||||
<template v-if="item.bizType === '备用金'">
|
||||
<div class="ec-top">
|
||||
<span class="ec-type advance-list-card__title-wrap">
|
||||
<span class="advance-list-card__title">{{ allAdvanceCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span
|
||||
class="advance-ticket-status"
|
||||
:class="ticketHeaderStatusToneClass(item.status)"
|
||||
>{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">申请金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="advance-card-subs">
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际发放金额</span>
|
||||
<span class="v">¥ {{ actualIssuedDisplay(item) }}</span>
|
||||
</div>
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际冲抵</span>
|
||||
<span class="v">¥ {{ formatAmount(advanceOffsetTotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="item.departmentName" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">部门</span>
|
||||
<span class="list-card-kv__v">{{ item.departmentName }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type reimburse-list-card__title-wrap">
|
||||
<span class="reimburse-list-card__title">{{ allReimburseCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">报销金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="reimburse-card-subs">
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">冲抵金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.offsetAmount ?? item.offset_amount) }}</span>
|
||||
</div>
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">实付金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.payAmount ?? item.actualAmount ?? item.actual_amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="item.departmentName" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">部门</span>
|
||||
<span class="list-card-kv__v">{{ item.departmentName }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div v-if="resolveExpenseDisplay(item, flatList) !== '-'" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">费用项目</span>
|
||||
<span class="list-card-kv__v">{{ resolveExpenseDisplay(item, flatList) }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">发票 / 附件</span>
|
||||
<span class="list-card-kv__v">{{ item.invoiceCount ?? 0 }} 张 · {{ item.attachCount ?? 0 }} 个</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom all-list-card__bottom">
|
||||
<div class="op-actions">
|
||||
<button type="button" class="btn btn-sm btn-primary" @click.stop="goDetail(item)">查看</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loadingMore && !refreshing && displayList.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="records" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无记录</p>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { advanceApi, reimburseApi } from '@/api'
|
||||
import {
|
||||
statusLabel,
|
||||
ticketHeaderStatusToneClass,
|
||||
workflowListStatusTagClass,
|
||||
formatAmount,
|
||||
formatApplyDateTime,
|
||||
pickApplyTime,
|
||||
} from '@/utils/format'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
|
||||
const router = useRouter()
|
||||
const { flatList } = useExpenseItemTree()
|
||||
|
||||
const activeTab = ref(0)
|
||||
const allRows = ref<any[]>([])
|
||||
const loadingMore = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
|
||||
const displayPage = ref(1)
|
||||
const displayPageSize = 20
|
||||
|
||||
const filterStatus = ref('')
|
||||
|
||||
const statusFilters = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待提交', value: 'draft' },
|
||||
{ label: '审批中', value: 'pending' },
|
||||
{ label: '已通过', value: 'approved' },
|
||||
{ label: '已驳回', value: 'rejected' },
|
||||
{ label: '已发放', value: 'issued' },
|
||||
{ label: '已支付', value: 'paid' },
|
||||
{ label: '已冲抵', value: 'offset' },
|
||||
]
|
||||
|
||||
function allAdvanceCardTitle(item: Record<string, unknown>): string {
|
||||
const r = (item.reason ?? '').toString().trim()
|
||||
if (r) return r
|
||||
const p = (item.purpose ?? '').toString().trim()
|
||||
return p || '—'
|
||||
}
|
||||
|
||||
function actualIssuedDisplay(item: Record<string, unknown>): string {
|
||||
const raw = item.actualAmount ?? item.actual_amount
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n)) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function advanceOffsetTotal(item: Record<string, unknown>): number {
|
||||
const raw = item.offsetAmount ?? item.offset_amount ?? 0
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
return Number.isNaN(n) ? 0 : n
|
||||
}
|
||||
|
||||
function allReimburseLineSubtitle(item: Record<string, any>) {
|
||||
const ex = resolveExpenseDisplay(item, flatList.value)
|
||||
return item.title || (ex !== '-' ? ex : '-')
|
||||
}
|
||||
|
||||
function allReimburseCardTitle(item: Record<string, any>) {
|
||||
const t = (item.title ?? '').toString().trim()
|
||||
if (t) return t
|
||||
return allReimburseLineSubtitle(item)
|
||||
}
|
||||
|
||||
function moneyOrDash(raw: unknown): string {
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n) || n === 0) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function mapAdvances(rows: any[]): any[] {
|
||||
return rows.map((r: any) => ({
|
||||
...r,
|
||||
bizType: '备用金',
|
||||
title: r.reason,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
}))
|
||||
}
|
||||
|
||||
function mapReimburses(rows: any[]): any[] {
|
||||
return rows.map((r: any) => ({
|
||||
...r,
|
||||
bizType: '报销申请',
|
||||
title: r.title,
|
||||
applyCode: r.applyCode || r.code,
|
||||
applicantName: r.applicantName || r.user,
|
||||
}))
|
||||
}
|
||||
|
||||
function extractRows(res: any): any[] {
|
||||
return res?.data?.rows || res?.data?.items || []
|
||||
}
|
||||
|
||||
const filteredList = computed(() => allRows.value)
|
||||
|
||||
const displayList = computed(() => {
|
||||
const end = displayPage.value * displayPageSize
|
||||
return filteredList.value.slice(0, end)
|
||||
})
|
||||
|
||||
const hasMore = computed(() => displayList.value.length < filteredList.value.length)
|
||||
|
||||
async function loadAllData() {
|
||||
const kw = keyword.value.trim()
|
||||
const params: Record<string, unknown> = { page: 1, pageSize: 280 }
|
||||
if (filterStatus.value) params.status = filterStatus.value
|
||||
if (kw) params.keyword = kw
|
||||
|
||||
try {
|
||||
if (activeTab.value === 1) {
|
||||
const advRes: any = await advanceApi.list(params)
|
||||
allRows.value = mapAdvances(extractRows(advRes))
|
||||
return
|
||||
}
|
||||
if (activeTab.value === 2) {
|
||||
const reimRes: any = await reimburseApi.list(params)
|
||||
allRows.value = mapReimburses(extractRows(reimRes))
|
||||
return
|
||||
}
|
||||
const [advRes, reimRes]: any[] = await Promise.all([
|
||||
advanceApi.list(params),
|
||||
reimburseApi.list(params),
|
||||
])
|
||||
const merged = [...mapAdvances(extractRows(advRes)), ...mapReimburses(extractRows(reimRes))]
|
||||
merged.sort((a: any, b: any) => {
|
||||
const tA = new Date(pickApplyTime(a) || 0).getTime()
|
||||
const tB = new Date(pickApplyTime(b) || 0).getTime()
|
||||
return tB - tA
|
||||
})
|
||||
allRows.value = merged
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
function syncFinished() {
|
||||
finished.value = !hasMore.value
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
displayPage.value = 1
|
||||
await loadAllData()
|
||||
syncFinished()
|
||||
}
|
||||
|
||||
function onKeywordReload() {
|
||||
void reload()
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(onKeywordReload)
|
||||
|
||||
async function onRefresh() {
|
||||
await reload()
|
||||
refreshing.value = false
|
||||
}
|
||||
|
||||
function onLoadMore() {
|
||||
if (hasMore.value) {
|
||||
displayPage.value++
|
||||
loadingMore.value = false
|
||||
syncFinished()
|
||||
} else {
|
||||
loadingMore.value = false
|
||||
finished.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function onBizTab(tab: number) {
|
||||
if (activeTab.value === tab) return
|
||||
activeTab.value = tab
|
||||
displayPage.value = 1
|
||||
loadingMore.value = true
|
||||
await loadAllData()
|
||||
loadingMore.value = false
|
||||
syncFinished()
|
||||
}
|
||||
|
||||
async function onStatusFilter(value: string) {
|
||||
filterStatus.value = value
|
||||
displayPage.value = 1
|
||||
loadingMore.value = true
|
||||
await loadAllData()
|
||||
loadingMore.value = false
|
||||
syncFinished()
|
||||
}
|
||||
|
||||
function goDetail(item: any) {
|
||||
if (item.bizType === '备用金') {
|
||||
router.push({ name: 'AdvanceDetail', params: { id: item.id } })
|
||||
} else {
|
||||
router.push({ name: 'ReimburseDetail', params: { id: item.id } })
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
loadingMore.value = true
|
||||
await loadAllData()
|
||||
loadingMore.value = false
|
||||
syncFinished()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.advance-list-card__title-wrap,
|
||||
.reimburse-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.advance-list-card__title,
|
||||
.reimburse-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.all-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.advance-card-subs,
|
||||
.reimburse-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.advance-card-sub-row,
|
||||
.reimburse-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .k,
|
||||
.reimburse-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .v,
|
||||
.reimburse-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.mine-type-tabs.stat-scroll {
|
||||
justify-content: center;
|
||||
overflow-x: visible;
|
||||
padding: 10px 16px 8px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card {
|
||||
width: auto;
|
||||
min-width: 120px;
|
||||
padding: 14px 18px;
|
||||
border: none;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.mine-type-tabs--triple .stat-card {
|
||||
min-width: 100px;
|
||||
padding: 14px 14px;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card .label {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active .label {
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
/* 备用金列表状态角标:与备用金详情票券头 advance-ticket-status 一致 */
|
||||
.advance-ticket-status {
|
||||
flex-shrink: 0;
|
||||
padding: 4px 11px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status--warn {
|
||||
background: #ea580c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--done {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--err {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--info {
|
||||
background: #64748b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--processing {
|
||||
background: #6366f1;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,864 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M15 18l-6-6 6-6" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">审批详情</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<template v-if="detail">
|
||||
<!-- 票券头(对齐备用金 / 报销详情) -->
|
||||
<div class="advance-ticket-shell">
|
||||
<div class="advance-ticket-stack">
|
||||
<div class="advance-ticket-top">
|
||||
<span class="advance-ticket-code" :title="detail.applyCode || undefined">{{ detail.applyCode || '—' }}</span>
|
||||
<span class="advance-ticket-status" :class="ticketHeaderStatusToneClass(detail.status)">{{ statusLabel(detail.status) }}</span>
|
||||
</div>
|
||||
<div class="advance-ticket-tear" aria-hidden="true">
|
||||
<div class="advance-ticket-tear__line"></div>
|
||||
</div>
|
||||
<div class="advance-ticket-bottom">
|
||||
<p class="advance-ticket-reason">{{ bizType === 'advance' ? (detail.reason || detail.purpose || '—') : (detail.title || '—') }}</p>
|
||||
<div class="advance-ticket-amount-wrap">
|
||||
<span class="advance-ticket-amount">{{ formatAmount(detail.amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-tabs v-model:active="detailTab" class="advance-detail-tabs" sticky offset-top="58">
|
||||
<van-tab title="基础信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<template v-if="bizType === 'advance'">
|
||||
<section class="detail-info-card" aria-label="申请信息">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请单号</div>
|
||||
<div class="adv-field__value">{{ detail.applyCode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请原因</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.reason || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">实际发放金额</div>
|
||||
<div class="adv-field__value" :class="{ 'adv-field__value--accent': detail.actualAmount != null }">
|
||||
{{ detail.actualAmount != null ? '¥ ' + formatAmount(detail.actualAmount) : '—' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请人</div>
|
||||
<div class="adv-field__value">{{ detail.applicantName || detail.createByName || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">部门</div>
|
||||
<div class="adv-field__value">{{ detail.departmentName || '—' }}</div>
|
||||
</div>
|
||||
<div v-if="detail.purpose" class="adv-field">
|
||||
<div class="adv-field__label">用途说明</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.purpose }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">当前节点</div>
|
||||
<div class="adv-field__value">{{ detail.currentNode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请时间</div>
|
||||
<div class="adv-field__value">{{ formatApplyDateTime(detail) }}</div>
|
||||
</div>
|
||||
<div v-if="detail.remark" class="adv-field">
|
||||
<div class="adv-field__label">备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.remark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="申请附件">
|
||||
<div class="detail-info-card__title">申请附件</div>
|
||||
<template v-if="attachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in attachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="open(file)"
|
||||
@keydown.enter.prevent="open(file)"
|
||||
>
|
||||
<img v-if="isImage(file.fileType) && file.previewUrl" :src="file.previewUrl" :alt="file.fileName" />
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无申请附件</p>
|
||||
</section>
|
||||
</template>
|
||||
<template v-else>
|
||||
<section class="detail-info-card" aria-label="基础信息">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请单号</div>
|
||||
<div class="adv-field__value">{{ detail.applyCode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">报销标题</div>
|
||||
<div class="adv-field__value">{{ detail.title || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请人</div>
|
||||
<div class="adv-field__value">{{ detail.applicantName || detail.createByName || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">部门</div>
|
||||
<div class="adv-field__value">{{ detail.departmentName || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">费用项目</div>
|
||||
<div class="adv-field__value">{{ reimburseExpenseSummary }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">当前节点</div>
|
||||
<div class="adv-field__value">{{ detail.currentNode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请时间</div>
|
||||
<div class="adv-field__value">{{ formatApplyDateTime(detail) }}</div>
|
||||
</div>
|
||||
<div v-if="detail.remark" class="adv-field">
|
||||
<div class="adv-field__label">备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.remark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="申请附件">
|
||||
<div class="detail-info-card__title">申请附件</div>
|
||||
<template v-if="attachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in attachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="open(file)"
|
||||
@keydown.enter.prevent="open(file)"
|
||||
>
|
||||
<img v-if="isImage(file.fileType) && file.previewUrl" :src="file.previewUrl" :alt="file.fileName" />
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无申请附件</p>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="审批信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<section class="detail-info-card detail-info-card--timeline" aria-label="审批流程">
|
||||
<template v-if="approvals.length > 0">
|
||||
<div class="adv-approval-flow">
|
||||
<div v-for="(a, i) in approvals" :key="a.id ?? i" class="flow-step">
|
||||
<div
|
||||
:class="[
|
||||
'flow-avatar',
|
||||
a.approvalStatus === 'approved' || a.status === 'approved'
|
||||
? 'av-done'
|
||||
: a.approvalStatus === 'pending' || a.status === 'pending'
|
||||
? 'av-current'
|
||||
: a.approvalStatus === 'rejected' || a.status === 'rejected'
|
||||
? 'av-reject'
|
||||
: 'av-pending'
|
||||
]"
|
||||
>
|
||||
{{ (a.approverName || a.nodeName || a.nodeLabel || '审')[0] }}
|
||||
</div>
|
||||
<div class="flow-info">
|
||||
<div class="flow-name">{{ a.nodeName || a.nodeLabel || a.approverName || '—' }}</div>
|
||||
<div v-if="a.approverName" class="flow-role">{{ a.approverName }}</div>
|
||||
<div v-if="a.approvalTime" class="flow-time">{{ formatDateTime(a.approvalTime) }}</div>
|
||||
<div v-if="a.approvalOpinion" class="adv-flow-opinion">{{ a.approvalOpinion }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无审批记录</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<template v-if="bizType === 'advance'">
|
||||
<van-tab title="发放信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<template v-if="isAdvanceIssuedApprovalDetail">
|
||||
<section class="detail-info-card" aria-label="发放记录">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">发放时间</div>
|
||||
<div class="adv-field__value">{{ formatDateTime(detail.issueTime) || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">发放操作人</div>
|
||||
<div class="adv-field__value">{{ detail.issueUserName || '—' }}</div>
|
||||
</div>
|
||||
<div v-if="detail.issueRemark" class="adv-field">
|
||||
<div class="adv-field__label">发放备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detail.issueRemark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="发放凭证">
|
||||
<div class="detail-info-card__title">发放凭证</div>
|
||||
<template v-if="issueAttachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in issueAttachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="openIssueFile(file)"
|
||||
@keydown.enter.prevent="openIssueFile(file)"
|
||||
>
|
||||
<img v-if="isImage(file.fileType) && file.previewUrl" :src="file.previewUrl" :alt="file.fileName" />
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExtIssue(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无发放凭证</p>
|
||||
</section>
|
||||
</template>
|
||||
<section v-else class="detail-info-card detail-info-card--empty-state" aria-label="发放状态">
|
||||
<p class="detail-section-empty detail-section-empty--in-card">尚未发放</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
|
||||
<van-tab title="冲抵信息">
|
||||
<div class="page-padded advance-detail-stack">
|
||||
<section class="detail-info-card" aria-label="冲抵汇总">
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">已冲抵合计</div>
|
||||
<div class="adv-field__value adv-field__value--accent">¥ {{ advanceOffsetTotalDisplay }}</div>
|
||||
</div>
|
||||
</section>
|
||||
<p class="adv-offset-meta">冲抵记录 {{ advanceOffsetRecords.length }} 条</p>
|
||||
<template v-if="advanceOffsetRecords.length > 0">
|
||||
<section
|
||||
v-for="(rec, idx) in advanceOffsetRecords"
|
||||
:key="rec.id ?? idx"
|
||||
class="detail-info-card detail-info-card--nest"
|
||||
>
|
||||
<div class="adv-offset-block__title">
|
||||
<span class="adv-offset-block__idx">#{{ idx + 1 }}</span>
|
||||
<span class="adv-offset-block__code">{{ rec.reimburseApplyCode || '—' }}</span>
|
||||
<span class="adv-offset-block__amt">¥ {{ formatAmount(rec.offsetAmount ?? rec.offset_amount) }}</span>
|
||||
</div>
|
||||
<div v-if="rec.reimburseApplicantName" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">报销申请人</div>
|
||||
<div class="adv-field__value">{{ rec.reimburseApplicantName }}</div>
|
||||
</div>
|
||||
<div class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">冲抵时间</div>
|
||||
<div class="adv-field__value">{{ formatDateTime(rec.createTime ?? rec.create_time) || '—' }}</div>
|
||||
</div>
|
||||
<div v-if="rec.operator" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">操作人</div>
|
||||
<div class="adv-field__value">{{ rec.operator }}</div>
|
||||
</div>
|
||||
<div v-if="rec.remark" class="adv-field adv-field--compact">
|
||||
<div class="adv-field__label">备注</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ rec.remark }}</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
<section v-else class="detail-info-card detail-info-card--empty-state" aria-label="冲抵记录">
|
||||
<p class="detail-section-empty detail-section-empty--in-card">暂无冲抵记录</p>
|
||||
</section>
|
||||
</div>
|
||||
</van-tab>
|
||||
</template>
|
||||
</van-tabs>
|
||||
</template>
|
||||
|
||||
<div v-else-if="loading" class="page-body-loading">
|
||||
<van-loading size="24px" vertical>加载中...</van-loading>
|
||||
</div>
|
||||
|
||||
<!-- Bottom action bar (only for pending status) -->
|
||||
<div v-if="detail && detail.status === 'pending'" class="bottom-action-bar">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger btn-block"
|
||||
:class="{ 'btn-loading': loadingMap.reject }"
|
||||
:disabled="loadingMap.reject"
|
||||
@click="handleReject"
|
||||
>
|
||||
驳回
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-block"
|
||||
:class="{ 'btn-loading': loadingMap.approve }"
|
||||
:disabled="loadingMap.approve"
|
||||
@click="handleApprove"
|
||||
>
|
||||
通过
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Approval dialog -->
|
||||
<van-dialog
|
||||
v-model:show="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
show-cancel-button
|
||||
:confirm-button-color="PRIMARY_CONFIRM_BUTTON_COLOR"
|
||||
:confirm-button-disabled="dialogSubmitting"
|
||||
:cancel-button-disabled="dialogSubmitting"
|
||||
:before-close="onBeforeClose"
|
||||
>
|
||||
<div class="dialog-form-body">
|
||||
<van-field
|
||||
v-model="opinion"
|
||||
type="textarea"
|
||||
placeholder="请输入审批意见(可选)"
|
||||
rows="3"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
/>
|
||||
</div>
|
||||
</van-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { advanceApi, reimburseApi, paymentApi } from '@/api'
|
||||
import { statusLabel, ticketHeaderStatusToneClass, formatAmount, formatDateTime, formatApplyDateTime } from '@/utils/format'
|
||||
import { useAttachment } from '@/hooks/useAttachment'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
|
||||
const route = useRoute()
|
||||
const { flatList } = useExpenseItemTree()
|
||||
const router = useRouter()
|
||||
|
||||
const bizType = route.params.bizType as string
|
||||
const id = Number(route.params.id)
|
||||
|
||||
const detail = ref<any>(null)
|
||||
const detailTab = ref(0)
|
||||
const approvals = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({
|
||||
approve: false,
|
||||
reject: false,
|
||||
})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const opinion = ref('')
|
||||
const actionType = ref<'approve' | 'reject'>('approve')
|
||||
const dialogSubmitting = ref(false)
|
||||
|
||||
const { files: attachments, isImage, fileExt, loadList: loadAttachments, open } = useAttachment()
|
||||
const issueAtt = useAttachment()
|
||||
const issueAttachments = issueAtt.files
|
||||
|
||||
const advanceOffsetRecords = ref<any[]>([])
|
||||
|
||||
const reimburseExpenseSummary = computed(() => {
|
||||
const d = detail.value
|
||||
if (!d || bizType !== 'reimburse') return '-'
|
||||
return resolveExpenseDisplay(d, flatList.value)
|
||||
})
|
||||
|
||||
const isAdvanceIssuedApprovalDetail = computed(() => {
|
||||
const d = detail.value
|
||||
return !!(d && bizType === 'advance' && (d.issueStatus === 'issued' || d.status === 'issued'))
|
||||
})
|
||||
|
||||
const advanceOffsetTotalDisplay = computed(() => {
|
||||
const d = detail.value
|
||||
if (bizType !== 'advance' || !d) return formatAmount(0)
|
||||
const apiVal = d.offsetAmount ?? d.offset_amount
|
||||
if (apiVal != null && apiVal !== '' && Number.isFinite(Number(apiVal))) {
|
||||
return formatAmount(apiVal)
|
||||
}
|
||||
const sum = advanceOffsetRecords.value.reduce(
|
||||
(s, r) => s + Number(r?.offsetAmount ?? r?.offset_amount ?? 0),
|
||||
0,
|
||||
)
|
||||
return formatAmount(sum)
|
||||
})
|
||||
|
||||
function openIssueFile(file: Parameters<typeof issueAtt.open>[0]) {
|
||||
issueAtt.open(file)
|
||||
}
|
||||
|
||||
function fileExtIssue(name: string) {
|
||||
return issueAtt.fileExt(name)
|
||||
}
|
||||
|
||||
const api = bizType === 'advance' ? advanceApi : reimburseApi
|
||||
|
||||
async function loadDetail() {
|
||||
loading.value = true
|
||||
advanceOffsetRecords.value = []
|
||||
issueAtt.clear()
|
||||
try {
|
||||
const res: any = await api.getById(id)
|
||||
if (res.code === 200 || res.data) {
|
||||
detail.value = res.data || res
|
||||
}
|
||||
|
||||
// Load approval flow
|
||||
const apprRes: any = await api.getApprovals(id)
|
||||
if (apprRes?.code === 200 || apprRes?.data) {
|
||||
const nodes = apprRes.data || apprRes
|
||||
approvals.value = Array.isArray(nodes)
|
||||
? nodes.sort((a: any, b: any) => (a.nodeOrder ?? 0) - (b.nodeOrder ?? 0))
|
||||
: []
|
||||
}
|
||||
|
||||
// Load attachments(申请)
|
||||
await loadAttachments(bizType, id)
|
||||
|
||||
if (bizType === 'advance') {
|
||||
try {
|
||||
const offRes: any = await paymentApi.advanceOffsetRecords(id)
|
||||
advanceOffsetRecords.value = offRes.data || []
|
||||
} catch {
|
||||
advanceOffsetRecords.value = []
|
||||
}
|
||||
const d = detail.value
|
||||
if (d && (d.issueStatus === 'issued' || d.status === 'issued')) {
|
||||
try {
|
||||
await issueAtt.loadList('advance_issue', id)
|
||||
} catch {
|
||||
issueAtt.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
showToast(e.message || '加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleApprove() {
|
||||
actionType.value = 'approve'
|
||||
dialogTitle.value = '确认通过'
|
||||
opinion.value = ''
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
function handleReject() {
|
||||
actionType.value = 'reject'
|
||||
dialogTitle.value = '确认驳回'
|
||||
opinion.value = ''
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
async function onBeforeClose(action: string, done: () => void): Promise<boolean> {
|
||||
if (action !== 'confirm') {
|
||||
done()
|
||||
return true
|
||||
}
|
||||
dialogSubmitting.value = true
|
||||
const key = actionType.value
|
||||
loadingMap[key] = true
|
||||
try {
|
||||
const payload = { approvalOpinion: opinion.value }
|
||||
if (actionType.value === 'approve') {
|
||||
await api.approve(id, payload)
|
||||
showToast({ message: '已通过', type: 'success' })
|
||||
} else {
|
||||
await api.reject(id, payload)
|
||||
showToast({ message: '已驳回', type: 'success' })
|
||||
}
|
||||
done()
|
||||
router.back()
|
||||
return true
|
||||
} catch (e: any) {
|
||||
showToast(e.message || '操作失败')
|
||||
return false
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
dialogSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadDetail)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.advance-ticket-shell {
|
||||
--ticket-bg: var(--primary);
|
||||
--ticket-skin: var(--primary-light);
|
||||
--ticket-dash: rgba(0, 201, 141, 0.45);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 10px 16px 14px;
|
||||
background: var(--ticket-bg);
|
||||
}
|
||||
|
||||
.advance-ticket-stack {
|
||||
width: 100%;
|
||||
max-width: 430px;
|
||||
margin: 0 auto;
|
||||
filter: drop-shadow(0 10px 24px rgba(0, 168, 116, 0.3));
|
||||
}
|
||||
|
||||
.advance-ticket-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 48px;
|
||||
padding: 14px 16px 12px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 14px 14px 0 0;
|
||||
}
|
||||
|
||||
.advance-ticket-code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.02em;
|
||||
color: #475569;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status {
|
||||
flex-shrink: 0;
|
||||
padding: 4px 11px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status--warn {
|
||||
background: #ea580c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--done {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--err {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--info {
|
||||
background: #64748b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--processing {
|
||||
background: #6366f1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-tear {
|
||||
position: relative;
|
||||
height: 14px;
|
||||
background: var(--ticket-skin);
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before,
|
||||
.advance-ticket-tear::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-top: -7px;
|
||||
border-radius: 50%;
|
||||
background: var(--ticket-bg);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before {
|
||||
left: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::after {
|
||||
right: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear__line {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
top: 50%;
|
||||
margin-top: -0.5px;
|
||||
border-top: 1px dashed var(--ticket-dash);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.advance-ticket-bottom {
|
||||
position: relative;
|
||||
padding: 10px 16px 20px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 0 0 14px 14px;
|
||||
}
|
||||
|
||||
.advance-ticket-reason {
|
||||
margin: 0 0 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.45;
|
||||
color: #64748b;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.advance-ticket-amount-wrap {
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.advance-ticket-amount {
|
||||
font-size: clamp(30px, 9.5vw, 40px);
|
||||
font-weight: 800;
|
||||
line-height: 1.05;
|
||||
letter-spacing: -0.03em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.advance-detail-tabs :deep(.van-tabs__content) {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.advance-detail-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding-top: 12px;
|
||||
padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
|
||||
.detail-info-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--r);
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 6px 16px 10px;
|
||||
}
|
||||
|
||||
.detail-info-card--media {
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--timeline {
|
||||
padding: 10px 16px 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--nest {
|
||||
padding: 12px 16px 10px;
|
||||
}
|
||||
|
||||
.detail-info-card--empty-state {
|
||||
padding: 28px 16px;
|
||||
}
|
||||
|
||||
.detail-info-card__title {
|
||||
margin: 6px 0 14px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.adv-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.adv-field + .adv-field {
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.adv-field:first-child {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.adv-field:last-child {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.adv-field--compact {
|
||||
gap: 4px;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.detail-info-card--nest .adv-offset-block__title + .adv-field {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.adv-field__label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.35;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.adv-field__value {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.adv-field__value--multiline {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
color: var(--text-sec);
|
||||
}
|
||||
|
||||
.adv-field__value--accent {
|
||||
color: var(--primary-dark);
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.detail-section-empty--in-card {
|
||||
margin-top: 4px;
|
||||
background: var(--primary-light);
|
||||
border-style: solid;
|
||||
border-color: rgba(0, 201, 141, 0.12);
|
||||
}
|
||||
|
||||
.advance-detail-att-grid {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.advance-att-tile:active) {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-img .att-file-icon.att-doc-thumb) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-shrink: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__ext) {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__name) {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.25;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.adv-approval-flow {
|
||||
padding: 4px 0 2px;
|
||||
}
|
||||
|
||||
.adv-flow-opinion {
|
||||
font-size: 12px;
|
||||
color: var(--text-sec);
|
||||
margin-top: 6px;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.adv-offset-meta {
|
||||
margin: 0;
|
||||
padding: 2px 4px 0;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.adv-offset-block__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 14px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.adv-offset-block__idx {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.adv-offset-block__code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.adv-offset-block__amt {
|
||||
flex-shrink: 0;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,529 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-medium">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">待我审批</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<!-- 业务切换:与「我的申请」同款居中卡片 -->
|
||||
<div class="mine-type-tabs stat-scroll">
|
||||
<div
|
||||
:class="['stat-card', { active: bizKind === 0 }]"
|
||||
@click="onBizKindChange(0)"
|
||||
>
|
||||
<span class="label">备用金</span>
|
||||
</div>
|
||||
<div
|
||||
:class="['stat-card', { active: bizKind === 1 }]"
|
||||
@click="onBizKindChange(1)"
|
||||
>
|
||||
<span class="label">报销申请</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索单号 / 申请人"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-tabs v-model:active="listTab" sticky offset-top="58" @change="onListTabChange">
|
||||
<van-tab title="待我审批" />
|
||||
<van-tab title="我已审批" />
|
||||
</van-tabs>
|
||||
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
:finished-text="list.length ? '没有更多了' : ''"
|
||||
@load="onLoad"
|
||||
>
|
||||
<div class="page-padded list-block">
|
||||
<div
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="goDetail(item)"
|
||||
>
|
||||
<template v-if="bizKind === 0">
|
||||
<div class="ec-top">
|
||||
<span class="ec-type advance-list-card__title-wrap">
|
||||
<span class="advance-list-card__title">{{ advanceCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">申请金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="advance-card-subs">
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际发放金额</span>
|
||||
<span class="v">¥ {{ actualIssuedDisplay(item) }}</span>
|
||||
</div>
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际冲抵</span>
|
||||
<span class="v">¥ {{ formatAmount(advanceOffsetTotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || item.code || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div v-if="item.purpose" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">用途说明</span>
|
||||
<span class="list-card-kv__v">{{ item.purpose }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type reimburse-list-card__title-wrap">
|
||||
<span class="reimburse-list-card__title">{{ reimburseCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">报销金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="reimburse-card-subs">
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">冲抵金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.offsetAmount ?? item.offset_amount) }}</span>
|
||||
</div>
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">实付金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.payAmount ?? item.actualAmount ?? item.actual_amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || item.code || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="resolveExpenseDisplay(item, flatList) !== '-'" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">费用项目</span>
|
||||
<span class="list-card-kv__v">{{ resolveExpenseDisplay(item, flatList) }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">发票 / 附件</span>
|
||||
<span class="list-card-kv__v">{{ item.invoiceCount ?? 0 }} 张 · {{ item.attachCount ?? 0 }} 个</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom" :class="bizKind === 0 ? 'advance-list-card__bottom' : 'reimburse-list-card__bottom'">
|
||||
<div class="op-actions" @click.stop>
|
||||
<template v-if="listTab === 0">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`reject_${item.id}`] }"
|
||||
@click="openAction(item, 'reject')"
|
||||
>驳回</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`approve_${item.id}`] }"
|
||||
@click="openAction(item, 'approve')"
|
||||
>通过</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button type="button" class="btn btn-sm btn-primary" @click="goDetail(item)">查看</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loading && !refreshing && list.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon :name="bizKind === 0 ? 'cash-back-record' : 'description'" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无{{ listTab === 0 ? '待审批' : '已审批' }}{{ bizKind === 0 ? '备用金' : '报销' }}申请</p>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
|
||||
<van-dialog
|
||||
v-model:show="showActionDialog"
|
||||
:title="actionType === 'approve' ? '审批通过' : '审批驳回'"
|
||||
show-cancel-button
|
||||
:confirm-button-color="PRIMARY_CONFIRM_BUTTON_COLOR"
|
||||
:confirm-button-loading="actionLoading"
|
||||
@confirm="confirmAction"
|
||||
:before-close="beforeClose"
|
||||
>
|
||||
<div class="dialog-form-body">
|
||||
<div class="action-status-bar">
|
||||
<StatusTag :text="actionType === 'approve' ? '通过后进入下一节点' : '驳回后退回申请人'" :variant="actionType === 'approve' ? 'success' : 'danger'" />
|
||||
</div>
|
||||
<van-field
|
||||
v-model="opinion"
|
||||
class="approval-opinion-field"
|
||||
type="textarea"
|
||||
placeholder="请输入审批意见"
|
||||
rows="3"
|
||||
:border="false"
|
||||
/>
|
||||
</div>
|
||||
</van-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { advanceApi, reimburseApi } from '@/api'
|
||||
import { statusLabel, workflowListStatusTagClass, formatAmount, formatApplyDateTime } from '@/utils/format'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
|
||||
const router = useRouter()
|
||||
const { flatList } = useExpenseItemTree()
|
||||
|
||||
const bizKind = ref<0 | 1>(0)
|
||||
const listTab = ref(0)
|
||||
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
const page = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
const showActionDialog = ref(false)
|
||||
const opinion = ref('')
|
||||
const actionType = ref<'approve' | 'reject'>('approve')
|
||||
const currentItem = ref<any>(null)
|
||||
const actionLoading = ref(false)
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
function advanceCardTitle(item: Record<string, unknown>): string {
|
||||
const r = (item.reason ?? '').toString().trim()
|
||||
if (r) return r
|
||||
const p = (item.purpose ?? '').toString().trim()
|
||||
return p || '—'
|
||||
}
|
||||
|
||||
function actualIssuedDisplay(item: Record<string, unknown>): string {
|
||||
const raw = item.actualAmount ?? item.actual_amount
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n)) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function advanceOffsetTotal(item: Record<string, unknown>): number {
|
||||
const raw = item.offsetAmount ?? item.offset_amount ?? 0
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
return Number.isNaN(n) ? 0 : n
|
||||
}
|
||||
|
||||
function reimburseLineSubtitle(item: Record<string, any>) {
|
||||
const ex = resolveExpenseDisplay(item, flatList.value)
|
||||
return item.title || (ex !== '-' ? ex : '-')
|
||||
}
|
||||
|
||||
function reimburseCardTitle(item: Record<string, any>) {
|
||||
const t = (item.title ?? '').toString().trim()
|
||||
if (t) return t
|
||||
return reimburseLineSubtitle(item)
|
||||
}
|
||||
|
||||
function moneyOrDash(raw: unknown): string {
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n) || n === 0) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function onKeywordSearch() {
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
void fetchPage()
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(onKeywordSearch)
|
||||
|
||||
function onBizKindChange(kind: 0 | 1) {
|
||||
if (bizKind.value === kind) return
|
||||
bizKind.value = kind
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
void fetchPage()
|
||||
}
|
||||
|
||||
function onListTabChange() {
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
void fetchPage()
|
||||
}
|
||||
|
||||
async function fetchPage() {
|
||||
try {
|
||||
const pendingFn = bizKind.value === 0 ? advanceApi.pendingApproval : reimburseApi.pendingApproval
|
||||
const approvedFn = bizKind.value === 0 ? advanceApi.approvedByMe : reimburseApi.approvedByMe
|
||||
const apiFn = listTab.value === 0 ? pendingFn : approvedFn
|
||||
|
||||
const params: Record<string, unknown> = { page: page.value, pageSize }
|
||||
const kw = keyword.value.trim()
|
||||
if (kw) params.keyword = kw
|
||||
|
||||
const res: any = await apiFn(params)
|
||||
const items = res.data?.rows || res.data?.items || res.data?.list || (Array.isArray(res.data) ? res.data : [])
|
||||
const total = res.data?.total ?? items.length ?? 0
|
||||
|
||||
if (page.value === 1) {
|
||||
list.value = items
|
||||
} else {
|
||||
list.value.push(...items)
|
||||
}
|
||||
page.value++
|
||||
finished.value = items.length < pageSize || list.value.length >= total
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载失败')
|
||||
finished.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
void fetchPage()
|
||||
}
|
||||
|
||||
async function onRefresh() {
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
list.value = []
|
||||
loading.value = true
|
||||
await fetchPage()
|
||||
}
|
||||
|
||||
function goDetail(item: any) {
|
||||
if (bizKind.value === 0) {
|
||||
router.push({ name: 'AdvanceDetail', params: { id: item.id } })
|
||||
} else {
|
||||
router.push({ name: 'ReimburseDetail', params: { id: item.id } })
|
||||
}
|
||||
}
|
||||
|
||||
function openAction(item: any, action: 'approve' | 'reject') {
|
||||
currentItem.value = item
|
||||
actionType.value = action
|
||||
opinion.value = action === 'approve' ? '审批通过' : '审批驳回'
|
||||
showActionDialog.value = true
|
||||
}
|
||||
|
||||
async function beforeClose(action: string) {
|
||||
if (action === 'confirm') return false
|
||||
return true
|
||||
}
|
||||
|
||||
async function confirmAction() {
|
||||
const item = currentItem.value
|
||||
if (!item) return
|
||||
const key = `${actionType.value}_${item.id}`
|
||||
loadingMap[key] = true
|
||||
actionLoading.value = true
|
||||
try {
|
||||
const approveFn = bizKind.value === 0 ? advanceApi.approve : reimburseApi.approve
|
||||
const rejectFn = bizKind.value === 0 ? advanceApi.reject : reimburseApi.reject
|
||||
const apiFn = actionType.value === 'approve' ? approveFn : rejectFn
|
||||
await apiFn(item.id, { approvalOpinion: opinion.value })
|
||||
showToast(actionType.value === 'approve' ? '已通过' : '已驳回')
|
||||
showActionDialog.value = false
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
list.value = []
|
||||
loading.value = true
|
||||
await fetchPage()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
actionLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.list-block {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.advance-list-card__title-wrap,
|
||||
.reimburse-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.advance-list-card__title,
|
||||
.reimburse-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-list-card__bottom,
|
||||
.reimburse-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.advance-card-subs,
|
||||
.reimburse-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.advance-card-sub-row,
|
||||
.reimburse-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .k,
|
||||
.reimburse-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .v,
|
||||
.reimburse-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.action-status-bar {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field.van-cell) {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field.van-cell::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field textarea.van-field__control) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 88px;
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--text);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field textarea.van-field__control::placeholder) {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.mine-type-tabs.stat-scroll {
|
||||
justify-content: center;
|
||||
overflow-x: visible;
|
||||
padding: 10px 16px 8px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card {
|
||||
width: auto;
|
||||
min-width: 120px;
|
||||
padding: 16px 22px;
|
||||
border: none;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card .label {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active .label {
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="fade" mode="out-in">
|
||||
<component :is="Component" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<div class="page home-page">
|
||||
<div style="padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 0">
|
||||
<!-- Hero -->
|
||||
<div class="home-hero">
|
||||
<div class="home-hero-main">
|
||||
<div class="hello">{{ greeting }},欢迎回来</div>
|
||||
<div class="name">{{ auth.realName || '用户' }}</div>
|
||||
<div class="home-hero-stats-row">
|
||||
<div class="meta">
|
||||
<span class="chip">本月提交 {{ stats.submittedThisMonth }}</span>
|
||||
<span class="chip">待审批 {{ stats.pendingCount }}</span>
|
||||
<span class="chip">已完成 {{ stats.approvedCount }}</span>
|
||||
</div>
|
||||
<button type="button" class="home-hero-logout" @click="handleLogout">退出登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Todo card(置于功能菜单上方) -->
|
||||
<div class="home-panels" style="margin-top:12px;display:flex;flex-direction:column;gap:10px">
|
||||
<div class="todo-card">
|
||||
<div v-if="todoItems.length" class="todo-head todo-head--badge-only">
|
||||
<span class="badge">{{ todoItems.length }}</span>
|
||||
</div>
|
||||
<template v-if="todoItems.length">
|
||||
<div v-for="item in todoItems" :key="item.id" class="todo-item">
|
||||
<div class="left">
|
||||
<div class="name">{{ item.title }}</div>
|
||||
<div class="meta">{{ item.subText }} · {{ item.timeText }}</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-sm" @click="router.push(item.primaryRoute)">去处理</button>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="empty-state empty-state--embed">
|
||||
<van-icon name="todo-list-o" :size="48" color="var(--text-muted)" />
|
||||
<p class="home-todo-empty__text">暂无待办事项</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Menu groups(无子项则不展示该分组;「首页」不展示一级标题,其子项仍显示) -->
|
||||
<div v-for="group in groupsWithItems" :key="group.id">
|
||||
<div v-if="(group.menuName || '').trim() !== '首页'" class="section-title">{{ group.menuName }}</div>
|
||||
<div class="menu-grid">
|
||||
<div
|
||||
v-for="item in getItems(group)"
|
||||
:key="item.id"
|
||||
class="menu-item"
|
||||
@click="navigateTo(item.menuCode)"
|
||||
>
|
||||
<div
|
||||
class="icon"
|
||||
:style="{
|
||||
background: getColor(item.menuCode) + '18',
|
||||
color: getColor(item.menuCode),
|
||||
}"
|
||||
>
|
||||
<van-icon :name="getIcon(item.menuCode)" size="22" />
|
||||
</div>
|
||||
<span v-if="hasDot(item.menuCode)" class="msg-dot"></span>
|
||||
<div class="txt">{{ menuDisplayName(item) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="groupsWithItems.length === 0" class="empty-state empty-state--embed">
|
||||
<van-icon name="apps-o" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无可用菜单</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="height: 20px;"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showConfirmDialog } from 'vant'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { useAuthStore, type MenuItem } from '@/stores/auth'
|
||||
import { advanceApi, reimburseApi } from '@/api'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
|
||||
/* ───── Reactive Stats ───── */
|
||||
const stats = ref({
|
||||
submittedThisMonth: 0,
|
||||
pendingCount: 0,
|
||||
approvedCount: 0,
|
||||
totalAmount: 0,
|
||||
totalCount: 0,
|
||||
})
|
||||
|
||||
const pendingApprovalCounts = ref<Record<string, number>>({})
|
||||
|
||||
interface TodoItem {
|
||||
id: number
|
||||
title: string
|
||||
subText: string
|
||||
statusText: string
|
||||
statusVariant: 'success' | 'warning' | 'danger' | 'info' | 'processing' | 'muted'
|
||||
amountText: string
|
||||
timeText: string
|
||||
primaryRoute: string
|
||||
secondaryRoute: string
|
||||
}
|
||||
|
||||
const todoItems = ref<TodoItem[]>([])
|
||||
|
||||
onMounted(async () => {
|
||||
if (!auth.menuList.length) {
|
||||
await auth.fetchMenus()
|
||||
}
|
||||
await fetchHomeData()
|
||||
})
|
||||
|
||||
/* ───── Fetch & Compute Stats ───── */
|
||||
function pagedRows(res: any): any[] {
|
||||
const d = res?.data
|
||||
if (!d) return []
|
||||
return d.rows ?? d.items ?? d.list ?? (Array.isArray(d) ? d : [])
|
||||
}
|
||||
|
||||
async function fetchHomeData() {
|
||||
try {
|
||||
const [advStatsRes, reimStatsRes] = await Promise.all([
|
||||
advanceApi.myStats().catch(() => null),
|
||||
reimburseApi.myStats().catch(() => null),
|
||||
])
|
||||
|
||||
const a = (advStatsRes as any)?.data ?? {}
|
||||
const r = (reimStatsRes as any)?.data ?? {}
|
||||
const submittedThisMonth = Number(r.monthApplyCount ?? 0) + Number(a.monthApplyCount ?? 0)
|
||||
const pendingCount = Number(r.pendingCount ?? 0) + Number(a.pendingCount ?? 0)
|
||||
const approvedCount =
|
||||
Number(r.approvedCount ?? 0) + Number(a.approvedPassCount ?? 0) + Number(a.issuedCount ?? 0)
|
||||
const totalCount = Number(r.totalCount ?? 0) + Number(a.totalCount ?? 0)
|
||||
const totalAmount = 0
|
||||
|
||||
stats.value = { submittedThisMonth, pendingCount, approvedCount, totalAmount, totalCount }
|
||||
|
||||
// Fetch pending approvals for todo area & red dots
|
||||
const [pendingAdvanceRes, pendingReimburseRes] = await Promise.all([
|
||||
advanceApi.pendingApproval({ page: 1, pageSize: 5 }).catch(() => null),
|
||||
reimburseApi.pendingApproval({ page: 1, pageSize: 5 }).catch(() => null),
|
||||
])
|
||||
|
||||
const pendingAdvanceItems: any[] = pagedRows(pendingAdvanceRes)
|
||||
const pendingReimburseItems: any[] = pagedRows(pendingReimburseRes)
|
||||
const pendingAdvanceTotal = (pendingAdvanceRes as any)?.data?.total || 0
|
||||
const pendingReimburseTotal = (pendingReimburseRes as any)?.data?.total || 0
|
||||
|
||||
pendingApprovalCounts.value = {
|
||||
'advance-approve': pendingAdvanceTotal,
|
||||
'reimburse-approve': pendingReimburseTotal,
|
||||
todo: pendingAdvanceTotal + pendingReimburseTotal,
|
||||
mine: pendingCount,
|
||||
}
|
||||
|
||||
// Build todo items
|
||||
const items: TodoItem[] = []
|
||||
|
||||
for (const item of pendingAdvanceItems) {
|
||||
items.push({
|
||||
id: item.id,
|
||||
title: item.title || '备用金单待审批',
|
||||
subText: [item.title, item.applicantName, item.departmentName].filter(Boolean).join(' · '),
|
||||
statusText: '待处理',
|
||||
statusVariant: 'warning',
|
||||
amountText: `金额 ¥${Number(item.amount || 0).toFixed(2)}`,
|
||||
timeText: formatTime(item.createdAt),
|
||||
primaryRoute: '/approval',
|
||||
secondaryRoute: '/approval',
|
||||
})
|
||||
}
|
||||
|
||||
for (const item of pendingReimburseItems) {
|
||||
items.push({
|
||||
id: item.id,
|
||||
title: item.title || '报销申请待审批',
|
||||
subText: [item.title, item.applicantName, item.departmentName].filter(Boolean).join(' · '),
|
||||
statusText: '待处理',
|
||||
statusVariant: 'warning',
|
||||
amountText: `金额 ¥${Number(item.amount || 0).toFixed(2)}`,
|
||||
timeText: formatTime(item.createdAt),
|
||||
primaryRoute: '/approval',
|
||||
secondaryRoute: '/approval',
|
||||
})
|
||||
}
|
||||
|
||||
items.sort((a, b) => b.timeText.localeCompare(a.timeText))
|
||||
todoItems.value = items.slice(0, 5)
|
||||
} catch {
|
||||
// Keep default empty state
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(dateStr: string): string {
|
||||
if (!dateStr) return ''
|
||||
const d = new Date(dateStr)
|
||||
if (isNaN(d.getTime())) return dateStr
|
||||
const now = new Date()
|
||||
const hh = d.getHours().toString().padStart(2, '0')
|
||||
const mm = d.getMinutes().toString().padStart(2, '0')
|
||||
const diffDays = Math.floor((now.getTime() - d.getTime()) / (1000 * 60 * 60 * 24))
|
||||
if (diffDays === 0) return `今天 ${hh}:${mm}`
|
||||
if (diffDays === 1) return `昨天 ${hh}:${mm}`
|
||||
return `${d.getMonth() + 1}/${d.getDate()} ${hh}:${mm}`
|
||||
}
|
||||
|
||||
/* ───── Computed for Template ───── */
|
||||
const greeting = computed(() => {
|
||||
const h = new Date().getHours()
|
||||
if (h < 6) return '凌晨好'
|
||||
if (h < 12) return '上午好'
|
||||
if (h < 14) return '中午好'
|
||||
if (h < 18) return '下午好'
|
||||
return '晚上好'
|
||||
})
|
||||
|
||||
/* ───── Menu Logic ───── */
|
||||
function getItems(group: MenuItem): MenuItem[] {
|
||||
if (!group.children?.length) return []
|
||||
const result: MenuItem[] = []
|
||||
for (const child of group.children) {
|
||||
if (child.children?.length) {
|
||||
result.push(...child.children.filter(c => c.menuCode))
|
||||
} else if (child.menuCode) {
|
||||
result.push(child)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 仅包含有可展示子菜单卡片的一级分组 */
|
||||
const groupsWithItems = computed(() => (auth.menuList || []).filter((g) => getItems(g).length > 0))
|
||||
|
||||
/** 与列表顶栏命名统一;后端菜单名可能是旧文案(如「我的报销」)时覆盖展示 */
|
||||
const MOBILE_MENU_DISPLAY: Record<string, string> = {
|
||||
'reimburse-apply': '报销申请',
|
||||
'advance-issue': '备用金\n发放管理',
|
||||
payment: '发放/冲抵\n支付管理',
|
||||
}
|
||||
|
||||
function menuDisplayName(item: MenuItem): string {
|
||||
const code = item.menuCode || ''
|
||||
return MOBILE_MENU_DISPLAY[code] ?? item.menuName
|
||||
}
|
||||
|
||||
const ROUTE_MAP: Record<string, string> = {
|
||||
'advance-apply': '/advance/list',
|
||||
'advance-approve': '/advance/approve',
|
||||
'advance-issue': '/advance/issue',
|
||||
'reimburse-apply': '/reimburse/list',
|
||||
'reimburse-approve': '/reimburse/approve',
|
||||
payment: '/payment',
|
||||
mine: '/mine',
|
||||
todo: '/approval',
|
||||
all: '/all',
|
||||
'user-manage': '/admin/users',
|
||||
'role-manage': '/admin/roles',
|
||||
'menu-manage': '/admin/menus',
|
||||
project: '/admin/expenses',
|
||||
'wf-advance': '/admin/wf-advance',
|
||||
'wf-reimburse': '/admin/wf-reimburse',
|
||||
demo: '/advance/list',
|
||||
}
|
||||
|
||||
function navigateTo(code: string | null) {
|
||||
if (!code) return
|
||||
const path = ROUTE_MAP[code]
|
||||
if (path) router.push(path)
|
||||
}
|
||||
|
||||
const ICON_MAP: Record<string, string> = {
|
||||
'advance-apply': 'cash-back-record',
|
||||
'advance-approve': 'checked',
|
||||
'advance-issue': 'paid',
|
||||
'reimburse-apply': 'description',
|
||||
'reimburse-approve': 'todo-list-o',
|
||||
payment: 'balance-pay',
|
||||
mine: 'records',
|
||||
todo: 'clock-o',
|
||||
all: 'list-switch',
|
||||
'user-manage': 'manager-o',
|
||||
'role-manage': 'shield-o',
|
||||
'menu-manage': 'apps-o',
|
||||
project: 'label-o',
|
||||
'wf-advance': 'exchange',
|
||||
'wf-reimburse': 'exchange',
|
||||
demo: 'smile-o',
|
||||
}
|
||||
|
||||
function getIcon(code: string | null): string {
|
||||
return (code && ICON_MAP[code]) || 'bookmark-o'
|
||||
}
|
||||
|
||||
const COLOR_MAP: Record<string, string> = {
|
||||
'advance-apply': '#10b981',
|
||||
'advance-approve': '#3b82f6',
|
||||
'advance-issue': '#8b5cf6',
|
||||
'reimburse-apply': '#f59e0b',
|
||||
'reimburse-approve': '#ef4444',
|
||||
payment: '#06b6d4',
|
||||
mine: '#6366f1',
|
||||
todo: '#f97316',
|
||||
all: '#64748b',
|
||||
'user-manage': '#3b82f6',
|
||||
'role-manage': '#8b5cf6',
|
||||
'menu-manage': '#10b981',
|
||||
project: '#f59e0b',
|
||||
'wf-advance': '#06b6d4',
|
||||
'wf-reimburse': '#ec4899',
|
||||
demo: '#94a3b8',
|
||||
}
|
||||
|
||||
function getColor(code: string | null): string {
|
||||
return (code && COLOR_MAP[code]) || '#64748b'
|
||||
}
|
||||
|
||||
function hasDot(code: string | null): boolean {
|
||||
if (!code) return false
|
||||
return (pendingApprovalCounts.value[code] || 0) > 0
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: '确定退出登录?',
|
||||
confirmButtonColor: PRIMARY_CONFIRM_BUTTON_COLOR,
|
||||
})
|
||||
auth.logout()
|
||||
router.push('/login')
|
||||
} catch {
|
||||
/* cancelled */
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-todo-empty__text {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<div class="login-page">
|
||||
<div class="login-page-inner">
|
||||
<div class="login-brand-block">
|
||||
<img class="brand-logo-img" src="@/assets/logo.gif" alt="山峡化工" />
|
||||
<div class="brand-sub">报销系统</div>
|
||||
</div>
|
||||
|
||||
<div class="login-card">
|
||||
<div class="login-title">账号登录</div>
|
||||
<van-form @submit="handleLogin">
|
||||
<div class="login-input" :class="{ error: !!errorText }">
|
||||
<van-icon name="manager-o" size="17" color="var(--text-muted)" />
|
||||
<input
|
||||
v-model="form.username"
|
||||
type="text"
|
||||
placeholder="请输入工号/手机号"
|
||||
autocomplete="username"
|
||||
@input="clearError"
|
||||
/>
|
||||
</div>
|
||||
<div class="login-input login-input--password" :class="{ error: !!errorText }">
|
||||
<van-icon name="lock" size="17" color="var(--text-muted)" />
|
||||
<input
|
||||
v-model="form.password"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
placeholder="请输入密码"
|
||||
autocomplete="current-password"
|
||||
@input="clearError"
|
||||
/>
|
||||
<button
|
||||
class="login-eye"
|
||||
type="button"
|
||||
:aria-label="showPassword ? '隐藏密码' : '显示密码'"
|
||||
@click="showPassword = !showPassword"
|
||||
>
|
||||
<van-icon :name="showPassword ? 'closed-eye' : 'eye-o'" size="16" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="login-error-msg" :class="{ show: !!errorText }">{{ errorText }}</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary btn-block"
|
||||
:class="{ 'btn-loading': loading }"
|
||||
:disabled="loading"
|
||||
>
|
||||
{{ loading ? '登录中' : '登录系统' }}
|
||||
</button>
|
||||
</van-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { BizError } from '@/api/client'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const loading = ref(false)
|
||||
const form = ref({ username: '', password: '' })
|
||||
const errorText = ref('')
|
||||
const showPassword = ref(false)
|
||||
|
||||
async function handleLogin() {
|
||||
clearError()
|
||||
if (!form.value.username || !form.value.password) {
|
||||
errorText.value = !form.value.username ? '请输入账号' : '请输入密码'
|
||||
showToast(errorText.value)
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
await auth.login(form.value.username, form.value.password)
|
||||
showToast('登录成功')
|
||||
router.replace('/')
|
||||
} catch (e: any) {
|
||||
const detail = e?.response?.data?.detail || e?.response?.data?.msg || ''
|
||||
errorText.value = detail || e.message || '账号或密码错误'
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast(errorText.value)
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function clearError() {
|
||||
errorText.value = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<template>
|
||||
<div>
|
||||
<van-pull-refresh :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" @refresh="$emit('refresh')">
|
||||
<div v-if="items.length === 0 && !loading" class="empty-state empty-state--embed">
|
||||
<van-icon name="records" :size="48" color="var(--text-muted)" />
|
||||
<p>暂无申请记录</p>
|
||||
</div>
|
||||
<div v-else class="apply-list-cards">
|
||||
<div
|
||||
v-for="item in items"
|
||||
:key="item.id + '-' + item.bizType"
|
||||
class="expense-card apply-list-card"
|
||||
@click="$emit('click-item', item)"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type apply-list-card__title-wrap">
|
||||
<span class="apply-list-card__title">{{ cardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">{{ isAdvanceItem(item) ? '申请金额' : '报销金额' }}</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="item.applicantName" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDate(item) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { statusLabel, workflowListStatusTagClass, formatAmount, formatApplyDate } from '@/utils/format'
|
||||
|
||||
defineProps<{
|
||||
items: any[]
|
||||
loading: boolean
|
||||
modelValue: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
refresh: []
|
||||
'click-item': [item: any]
|
||||
'update:modelValue': [value: boolean]
|
||||
}>()
|
||||
|
||||
function isAdvanceItem(item: Record<string, any>): boolean {
|
||||
const t = String(item.bizType ?? '').toLowerCase()
|
||||
return t === 'advance' || t === '备用金' || t === '0'
|
||||
}
|
||||
|
||||
function cardTitle(item: Record<string, any>): string {
|
||||
const r = (item.title ?? item.reason ?? '').toString().trim()
|
||||
return r || '—'
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.apply-list-cards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.apply-list-card:active {
|
||||
opacity: 0.96;
|
||||
}
|
||||
|
||||
.apply-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.apply-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,705 @@
|
||||
<template>
|
||||
<div class="page mine-page page--empty-chrome-tall">
|
||||
<!-- Topbar -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">我的申请</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="fab-add" aria-label="新增申请" @click="showAddMenu = true">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<van-action-sheet
|
||||
v-model:show="showAddMenu"
|
||||
:actions="addActions"
|
||||
cancel-text="取消"
|
||||
@select="onAddSelect"
|
||||
/>
|
||||
|
||||
<!-- Tabs: 备用金 / 报销申请(检索栏上方,整块居中) -->
|
||||
<div class="mine-type-tabs stat-scroll">
|
||||
<div
|
||||
:class="['stat-card', { active: activeTab === 0 }]"
|
||||
@click="activeTab = 0; onTabChange()"
|
||||
>
|
||||
<span class="label">备用金</span>
|
||||
</div>
|
||||
<div
|
||||
:class="['stat-card', { active: activeTab === 1 }]"
|
||||
@click="activeTab = 1; onTabChange()"
|
||||
>
|
||||
<span class="label">报销申请</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search -->
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索单号/标题/原因"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Advance tab content -->
|
||||
<template v-if="activeTab === 0">
|
||||
<!-- Status sub-filters -->
|
||||
<div class="search-wrap" style="padding-top: 0;">
|
||||
<div class="search-filter search-filter--scroll">
|
||||
<div
|
||||
v-for="opt in statusFilters"
|
||||
:key="opt.value === '' ? '__all' : opt.value"
|
||||
:class="['filter-tag', { active: advanceStatus === opt.value }]"
|
||||
@click="advanceStatus = opt.value; resetAndLoad('advance')"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="advanceRefreshing" @refresh="onRefreshAdvance">
|
||||
<van-list
|
||||
v-model:loading="advanceLoadingMore"
|
||||
:finished="advanceFinished"
|
||||
finished-text=""
|
||||
@load="onLoadAdvance"
|
||||
>
|
||||
<div v-if="advanceList.length === 0 && !advanceLoadingMore && !advanceRefreshing" class="empty-state empty-state--fill">
|
||||
<van-icon name="cash-back-record" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无备用金申请</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="item in advanceList"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="goDetail(item, 'advance')"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type advance-list-card__title-wrap">
|
||||
<span class="advance-list-card__title">{{ mineAdvanceCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">申请金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="advance-card-subs">
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际发放金额</span>
|
||||
<span class="v">¥ {{ actualIssuedDisplay(item) }}</span>
|
||||
</div>
|
||||
<div class="advance-card-sub-row">
|
||||
<span class="k">实际冲抵</span>
|
||||
<span class="v">¥ {{ formatAmount(advanceOffsetTotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || item.code || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div v-if="item.purpose" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">用途说明</span>
|
||||
<span class="list-card-kv__v">{{ item.purpose }}</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom advance-list-card__bottom">
|
||||
<div class="op-actions" v-if="item.status === 'draft'">
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`adv_del_${item.id}`] }"
|
||||
@click.stop="handleAdvanceDelete(item)"
|
||||
>删除</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`adv_submit_${item.id}`] }"
|
||||
@click.stop="handleAdvanceSubmit(item)"
|
||||
>提交</button>
|
||||
</div>
|
||||
<div class="op-actions" v-else-if="item.status === 'rejected'">
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="goDetail(item, 'advance')"
|
||||
>查看</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`adv_submit_${item.id}`] }"
|
||||
@click.stop="handleAdvanceSubmit(item)"
|
||||
>重新提交</button>
|
||||
</div>
|
||||
<div class="op-actions" v-else>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="goDetail(item, 'advance')"
|
||||
>查看</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Reimburse tab content -->
|
||||
<template v-if="activeTab === 1">
|
||||
<!-- Status sub-filters -->
|
||||
<div class="search-wrap" style="padding-top: 0;">
|
||||
<div class="search-filter search-filter--scroll">
|
||||
<div
|
||||
v-for="opt in statusFilters"
|
||||
:key="opt.value === '' ? '__all' : opt.value"
|
||||
:class="['filter-tag', { active: reimburseStatus === opt.value }]"
|
||||
@click="reimburseStatus = opt.value; resetAndLoad('reimburse')"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="reimburseRefreshing" @refresh="onRefreshReimburse">
|
||||
<van-list
|
||||
v-model:loading="reimburseLoadingMore"
|
||||
:finished="reimburseFinished"
|
||||
finished-text=""
|
||||
@load="onLoadReimburse"
|
||||
>
|
||||
<div v-if="reimburseList.length === 0 && !reimburseLoadingMore && !reimburseRefreshing" class="empty-state empty-state--fill">
|
||||
<van-icon name="description" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无报销申请</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="item in reimburseList"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="goDetail(item, 'reimburse')"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type reimburse-list-card__title-wrap">
|
||||
<span class="reimburse-list-card__title">{{ mineReimburseCardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">报销金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="reimburse-card-subs">
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">冲抵金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.offsetAmount ?? item.offset_amount) }}</span>
|
||||
</div>
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">实付金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.payAmount ?? item.actualAmount ?? item.actual_amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || item.code || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '—' }}</span>
|
||||
</div>
|
||||
<div v-if="resolveExpenseDisplay(item, flatList) !== '-'" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">费用项目</span>
|
||||
<span class="list-card-kv__v">{{ resolveExpenseDisplay(item, flatList) }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">发票 / 附件</span>
|
||||
<span class="list-card-kv__v">{{ item.invoiceCount ?? 0 }} 张 · {{ item.attachCount ?? 0 }} 个</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom reimburse-list-card__bottom">
|
||||
<div class="op-actions" v-if="item.status === 'draft'">
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`reim_del_${item.id}`] }"
|
||||
@click.stop="handleReimburseDelete(item)"
|
||||
>删除</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`reim_submit_${item.id}`] }"
|
||||
@click.stop="handleReimburseSubmit(item)"
|
||||
>提交</button>
|
||||
</div>
|
||||
<div class="op-actions" v-else-if="item.status === 'rejected'">
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="goDetail(item, 'reimburse')"
|
||||
>查看</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`reim_submit_${item.id}`] }"
|
||||
@click.stop="handleReimburseSubmit(item)"
|
||||
>重新提交</button>
|
||||
</div>
|
||||
<div class="op-actions" v-else>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="goDetail(item, 'reimburse')"
|
||||
>查看</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { advanceApi, reimburseApi } from '@/api'
|
||||
import { statusLabel, workflowListStatusTagClass, formatAmount, formatApplyDateTime } from '@/utils/format'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
|
||||
const router = useRouter()
|
||||
const { flatList } = useExpenseItemTree()
|
||||
|
||||
const activeTab = ref(0)
|
||||
const showAddMenu = ref(false)
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
const statusFilters = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待提交', value: 'draft' },
|
||||
{ label: '审批中', value: 'pending' },
|
||||
{ label: '已通过', value: 'approved' },
|
||||
{ label: '已驳回', value: 'rejected' },
|
||||
{ label: '已发放', value: 'issued' },
|
||||
{ label: '已支付', value: 'paid' },
|
||||
{ label: '已冲抵', value: 'offset' },
|
||||
]
|
||||
|
||||
const addActions = [
|
||||
{ name: '备用金申请', value: '/advance/apply' },
|
||||
{ name: '报销申请', value: '/reimburse/apply' },
|
||||
]
|
||||
|
||||
// --- Advance state ---
|
||||
const advanceList = ref<any[]>([])
|
||||
const advancePage = ref(1)
|
||||
const advanceStatus = ref('')
|
||||
const advanceRefreshing = ref(false)
|
||||
const advanceLoadingMore = ref(false)
|
||||
const advanceFinished = ref(false)
|
||||
|
||||
// --- Reimburse state ---
|
||||
const reimburseList = ref<any[]>([])
|
||||
const reimbursePage = ref(1)
|
||||
const reimburseStatus = ref('')
|
||||
const reimburseRefreshing = ref(false)
|
||||
const reimburseLoadingMore = ref(false)
|
||||
const reimburseFinished = ref(false)
|
||||
|
||||
/** 与备用金申请列表页一致:接口 camelCase / 少数 snake_case */
|
||||
function actualIssuedDisplay(item: Record<string, unknown>): string {
|
||||
const raw = item.actualAmount ?? item.actual_amount
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n)) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function advanceOffsetTotal(item: Record<string, unknown>): number {
|
||||
const raw = item.offsetAmount ?? item.offset_amount ?? 0
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
return Number.isNaN(n) ? 0 : n
|
||||
}
|
||||
|
||||
function mineAdvanceCardTitle(item: Record<string, unknown>): string {
|
||||
const r = (item.reason ?? '').toString().trim()
|
||||
if (r) return r
|
||||
const p = (item.purpose ?? '').toString().trim()
|
||||
return p || '—'
|
||||
}
|
||||
|
||||
function mineReimburseLineSubtitle(item: Record<string, any>) {
|
||||
const ex = resolveExpenseDisplay(item, flatList.value)
|
||||
return item.title || (ex !== '-' ? ex : '-')
|
||||
}
|
||||
|
||||
function mineReimburseCardTitle(item: Record<string, any>) {
|
||||
const t = (item.title ?? '').toString().trim()
|
||||
if (t) return t
|
||||
return mineReimburseLineSubtitle(item)
|
||||
}
|
||||
|
||||
function moneyOrDash(raw: unknown): string {
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n) || n === 0) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function onAddSelect(action: { value?: string }) {
|
||||
showAddMenu.value = false
|
||||
if (action.value) {
|
||||
router.push(action.value)
|
||||
}
|
||||
}
|
||||
|
||||
function onTabChange() {
|
||||
// Tab change handled by van-list @load automatically
|
||||
}
|
||||
|
||||
function onKeywordSearch() {
|
||||
resetAndLoad(activeTab.value === 0 ? 'advance' : 'reimburse')
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(onKeywordSearch)
|
||||
|
||||
function resetAndLoad(type: 'advance' | 'reimburse') {
|
||||
if (type === 'advance') {
|
||||
advanceList.value = []
|
||||
advancePage.value = 1
|
||||
advanceFinished.value = false
|
||||
advanceLoadingMore.value = true
|
||||
fetchAdvanceList()
|
||||
} else {
|
||||
reimburseList.value = []
|
||||
reimbursePage.value = 1
|
||||
reimburseFinished.value = false
|
||||
reimburseLoadingMore.value = true
|
||||
fetchReimburseList()
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchAdvanceList() {
|
||||
try {
|
||||
const params: Record<string, unknown> = {
|
||||
page: advancePage.value,
|
||||
pageSize: PAGE_SIZE,
|
||||
}
|
||||
if (advanceStatus.value) {
|
||||
params.status = advanceStatus.value
|
||||
}
|
||||
if (keyword.value) {
|
||||
params.keyword = keyword.value
|
||||
}
|
||||
const res: any = await advanceApi.my(params)
|
||||
const rows = res?.data?.rows || []
|
||||
if (advancePage.value === 1) {
|
||||
advanceList.value = rows
|
||||
} else {
|
||||
advanceList.value.push(...rows)
|
||||
}
|
||||
const total = res?.data?.total || 0
|
||||
advanceFinished.value = advanceList.value.length >= total
|
||||
advancePage.value++
|
||||
} catch (e) {
|
||||
showToast('加载失败')
|
||||
advanceFinished.value = true
|
||||
} finally {
|
||||
advanceLoadingMore.value = false
|
||||
advanceRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchReimburseList() {
|
||||
try {
|
||||
const params: Record<string, unknown> = {
|
||||
page: reimbursePage.value,
|
||||
pageSize: PAGE_SIZE,
|
||||
}
|
||||
if (reimburseStatus.value) {
|
||||
params.status = reimburseStatus.value
|
||||
}
|
||||
if (keyword.value) {
|
||||
params.keyword = keyword.value
|
||||
}
|
||||
const res: any = await reimburseApi.my(params)
|
||||
const rows = res?.data?.rows || []
|
||||
if (reimbursePage.value === 1) {
|
||||
reimburseList.value = rows
|
||||
} else {
|
||||
reimburseList.value.push(...rows)
|
||||
}
|
||||
const total = res?.data?.total || 0
|
||||
reimburseFinished.value = reimburseList.value.length >= total
|
||||
reimbursePage.value++
|
||||
} catch (e) {
|
||||
showToast('加载失败')
|
||||
reimburseFinished.value = true
|
||||
} finally {
|
||||
reimburseLoadingMore.value = false
|
||||
reimburseRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onLoadAdvance() {
|
||||
fetchAdvanceList()
|
||||
}
|
||||
|
||||
function onLoadReimburse() {
|
||||
fetchReimburseList()
|
||||
}
|
||||
|
||||
function onRefreshAdvance() {
|
||||
advancePage.value = 1
|
||||
advanceFinished.value = false
|
||||
fetchAdvanceList()
|
||||
}
|
||||
|
||||
function onRefreshReimburse() {
|
||||
reimbursePage.value = 1
|
||||
reimburseFinished.value = false
|
||||
fetchReimburseList()
|
||||
}
|
||||
|
||||
function goDetail(item: Record<string, any>, bizType: string) {
|
||||
const route = bizType === 'advance' ? 'AdvanceDetail' : 'ReimburseDetail'
|
||||
router.push({ name: route, params: { id: item.id } })
|
||||
}
|
||||
|
||||
async function handleAdvanceSubmit(item: Record<string, any>) {
|
||||
loadingMap[`adv_submit_${item.id}`] = true
|
||||
try {
|
||||
await advanceApi.submit(item.id)
|
||||
showToast('提交成功')
|
||||
resetAndLoad('advance')
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`adv_submit_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAdvanceDelete(item: Record<string, any>) {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: '确定要删除该备用金申请吗?删除后不可恢复。',
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
loadingMap[`adv_del_${item.id}`] = true
|
||||
try {
|
||||
await advanceApi.delete(item.id)
|
||||
showToast('删除成功')
|
||||
resetAndLoad('advance')
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap[`adv_del_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReimburseSubmit(item: Record<string, any>) {
|
||||
loadingMap[`reim_submit_${item.id}`] = true
|
||||
try {
|
||||
await reimburseApi.submit(item.id)
|
||||
showToast('提交成功')
|
||||
resetAndLoad('reimburse')
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`reim_submit_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReimburseDelete(item: Record<string, any>) {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: '确定要删除该报销单吗?删除后不可恢复。',
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
loadingMap[`reim_del_${item.id}`] = true
|
||||
try {
|
||||
await reimburseApi.delete(item.id)
|
||||
showToast('删除成功')
|
||||
resetAndLoad('reimburse')
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap[`reim_del_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// van-list will trigger initial load automatically
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 「我的申请」类型切换:双卡片居中、无描边、字号加大(仅本页) */
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.advance-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.advance-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.advance-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.advance-list-card__title-wrap,
|
||||
.reimburse-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.advance-list-card__title,
|
||||
.reimburse-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-list-card__bottom,
|
||||
.reimburse-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.reimburse-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.mine-type-tabs.stat-scroll {
|
||||
justify-content: center;
|
||||
overflow-x: visible;
|
||||
padding: 10px 16px 8px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card {
|
||||
width: auto;
|
||||
min-width: 120px;
|
||||
padding: 16px 22px;
|
||||
border: none;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card .label {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.mine-type-tabs .stat-card.active .label {
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,252 @@
|
||||
<template>
|
||||
<div class="page profile-page">
|
||||
<!-- Topbar(与备用金申请等页统一;个人中心无返回) -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left"></div>
|
||||
<span class="topbar-title">我的</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<!-- User info card -->
|
||||
<div class="profile-card card profile-top">
|
||||
<div class="profile-avatar">
|
||||
<span class="avatar-text">{{ avatarChar }}</span>
|
||||
</div>
|
||||
<div class="profile-info">
|
||||
<div class="profile-name">{{ auth.realName || '未登录' }}</div>
|
||||
<div class="profile-dept">{{ auth.user?.username || '' }}</div>
|
||||
<div class="profile-role">{{ roleText }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Menu groups -->
|
||||
<van-cell-group inset class="group-block">
|
||||
<van-cell title="个人信息" icon="user-o" is-link />
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group inset class="group-block">
|
||||
<van-cell title="修改密码" icon="lock" is-link @click="showPasswordDialog = true" />
|
||||
</van-cell-group>
|
||||
|
||||
<!-- Finance / approver actions -->
|
||||
<template v-if="isApprover">
|
||||
<van-cell-group inset class="group-block" title="审批管理">
|
||||
<van-cell title="备用金审批" icon="cash-back-record" is-link to="/advance/approve" />
|
||||
<van-cell title="报销审批" icon="description" is-link to="/reimburse/approve" />
|
||||
<van-cell title="发放管理" icon="balance-list-o" is-link to="/advance/issue" />
|
||||
<van-cell title="全部记录" icon="records" is-link to="/all" />
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<!-- Admin section -->
|
||||
<template v-if="auth.isAdmin">
|
||||
<van-cell-group inset class="group-block" title="系统">
|
||||
<van-cell title="系统管理" icon="setting-o" is-link to="/admin" />
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<!-- About & logout -->
|
||||
<van-cell-group inset class="group-block">
|
||||
<van-cell title="关于系统" icon="info-o" is-link @click="showAboutDialog = true" />
|
||||
</van-cell-group>
|
||||
|
||||
<BottomActionBar>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger btn-block"
|
||||
:class="{ 'btn-loading': logoutLoading }"
|
||||
:disabled="logoutLoading"
|
||||
@click="handleLogout"
|
||||
>
|
||||
退出登录
|
||||
</button>
|
||||
</BottomActionBar>
|
||||
|
||||
<!-- About dialog -->
|
||||
<van-dialog
|
||||
v-model:show="showAboutDialog"
|
||||
title="关于系统"
|
||||
show-confirm-button
|
||||
:confirm-button-color="PRIMARY_CONFIRM_BUTTON_COLOR"
|
||||
>
|
||||
<div class="dialog-form-body" style="text-align: center; color: var(--text-secondary); line-height: 1.8;">
|
||||
<p style="font-size: 16px; font-weight: 600; color: var(--text);">山峡化工报销系统</p>
|
||||
<p>版本 1.0.0</p>
|
||||
</div>
|
||||
</van-dialog>
|
||||
|
||||
<!-- Change password dialog -->
|
||||
<van-dialog
|
||||
v-model:show="showPasswordDialog"
|
||||
title="修改密码"
|
||||
show-confirm-button
|
||||
:confirm-button-color="PRIMARY_CONFIRM_BUTTON_COLOR"
|
||||
:before-close="onPasswordBeforeClose"
|
||||
>
|
||||
<div class="dialog-form-body">
|
||||
<van-field
|
||||
v-model="passwordForm.oldPassword"
|
||||
type="password"
|
||||
label="原密码"
|
||||
placeholder="请输入原密码"
|
||||
/>
|
||||
<van-field
|
||||
v-model="passwordForm.newPassword"
|
||||
type="password"
|
||||
label="新密码"
|
||||
placeholder="请输入新密码"
|
||||
/>
|
||||
<van-field
|
||||
v-model="passwordForm.confirmPassword"
|
||||
type="password"
|
||||
label="确认密码"
|
||||
placeholder="请再次输入新密码"
|
||||
/>
|
||||
</div>
|
||||
</van-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showConfirmDialog, showToast } from 'vant'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import BottomActionBar from '@/components/mobile/BottomActionBar.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
|
||||
const logoutLoading = ref(false)
|
||||
const showAboutDialog = ref(false)
|
||||
const showPasswordDialog = ref(false)
|
||||
|
||||
const passwordForm = reactive({
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: '',
|
||||
})
|
||||
|
||||
const APPROVER_ROLES = ['ADMIN', 'FINANCE', 'GENERAL_MANAGER']
|
||||
|
||||
const isApprover = computed(() =>
|
||||
APPROVER_ROLES.some((r) => auth.roleCodes.includes(r)),
|
||||
)
|
||||
|
||||
const avatarChar = computed(() => {
|
||||
const name = auth.realName || auth.user?.username || '用'
|
||||
return name.charAt(0)
|
||||
})
|
||||
|
||||
const roleText = computed(() => {
|
||||
const codes = auth.roleCodes
|
||||
const parts: string[] = []
|
||||
if (codes.includes('ADMIN')) parts.push('管理员')
|
||||
if (codes.includes('GENERAL_MANAGER')) parts.push('总经理')
|
||||
if (codes.includes('FINANCE')) parts.push('财务人员')
|
||||
if (codes.includes('EMPLOYEE')) parts.push('员工')
|
||||
return parts.join('、') || '未分配角色'
|
||||
})
|
||||
|
||||
async function handleLogout() {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '确认退出',
|
||||
message: '确定要退出登录吗?',
|
||||
confirmButtonColor: PRIMARY_CONFIRM_BUTTON_COLOR,
|
||||
})
|
||||
logoutLoading.value = true
|
||||
auth.logout()
|
||||
router.replace('/login')
|
||||
} catch {
|
||||
// user cancelled
|
||||
} finally {
|
||||
logoutLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onPasswordBeforeClose(action: string): boolean | Promise<boolean> {
|
||||
if (action !== 'confirm') {
|
||||
Object.assign(passwordForm, { oldPassword: '', newPassword: '', confirmPassword: '' })
|
||||
return true
|
||||
}
|
||||
|
||||
if (!passwordForm.oldPassword) {
|
||||
showToast('请输入原密码')
|
||||
return false
|
||||
}
|
||||
if (!passwordForm.newPassword) {
|
||||
showToast('请输入新密码')
|
||||
return false
|
||||
}
|
||||
if (passwordForm.newPassword !== passwordForm.confirmPassword) {
|
||||
showToast('两次密码不一致')
|
||||
return false
|
||||
}
|
||||
if (passwordForm.newPassword.length < 6) {
|
||||
showToast('密码长度不能少于6位')
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: call password change API when available
|
||||
showToast('密码修改成功')
|
||||
Object.assign(passwordForm, { oldPassword: '', newPassword: '', confirmPassword: '' })
|
||||
return true
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.profile-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.profile-top {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.group-block {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.profile-avatar {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
background: var(--primary);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.avatar-text {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.profile-name {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.profile-dept {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.profile-role {
|
||||
font-size: 12px;
|
||||
color: var(--primary-dark);
|
||||
margin-top: 4px;
|
||||
padding: 2px 8px;
|
||||
background: var(--primary-bg);
|
||||
border-radius: 10px;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,798 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">报销申请</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<div class="page-padded">
|
||||
<form class="apply-form" @submit.prevent="onSubmit">
|
||||
<!-- 报销标题 -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>报销信息</h3>
|
||||
<span class="form-badge">{{ editingId ? '编辑' : '新建' }}</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field-label">报销标题</label>
|
||||
<input
|
||||
class="form-input"
|
||||
type="text"
|
||||
placeholder="不填则自动生成"
|
||||
v-model="form.title"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 报销明细 -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>报销明细</h3>
|
||||
<span class="form-badge">{{ form.details.length }}行</span>
|
||||
</div>
|
||||
|
||||
<div v-for="(line, idx) in form.details" :key="idx" class="detail-line">
|
||||
<div v-if="idx > 0" class="detail-divider"></div>
|
||||
|
||||
<!-- 费用项目 -->
|
||||
<div class="field">
|
||||
<label class="field-label">
|
||||
费用项目<span v-if="form.details.length > 1" class="detail-line-no">(第 {{ idx + 1 }} 条)</span><span class="req">*</span>
|
||||
</label>
|
||||
<div class="picker-trigger" @click="openExpensePicker(idx)">
|
||||
<div class="left">
|
||||
<div class="value" :class="{ ph: !lineExpenseDisplay(line.expenseItemId) }">
|
||||
{{ lineExpenseDisplay(line.expenseItemId) || '请选择费用项目' }}
|
||||
</div>
|
||||
</div>
|
||||
<van-icon name="arrow" class="arrow" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 金额 -->
|
||||
<div class="field">
|
||||
<label class="field-label">金额(元)<span class="req">*</span></label>
|
||||
<div class="form-input-prefix">
|
||||
<input
|
||||
class="form-input"
|
||||
type="number"
|
||||
placeholder="0.00"
|
||||
v-model="line.amount"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 报销事由 -->
|
||||
<div class="field">
|
||||
<label class="field-label">报销事由<span class="req">*</span></label>
|
||||
<input
|
||||
class="form-input"
|
||||
type="text"
|
||||
placeholder="请输入报销事由"
|
||||
v-model="line.remark"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 删除行 -->
|
||||
<div v-if="form.details.length > 1" class="detail-line-actions">
|
||||
<button type="button" class="btn btn-sm btn-danger" @click="removeDetailLine(idx)">删除此行</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增明细行 + 合计 -->
|
||||
<div class="detail-actions">
|
||||
<button type="button" class="btn btn-primary btn-sm" @click="addDetailLine">+ 新增明细行</button>
|
||||
<span class="total-amount">
|
||||
合计:<b>¥{{ detailTotalAmount }}</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 附件(与备用金申请页结构、样式一致) -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>附件</h3>
|
||||
</div>
|
||||
<div class="uploader-slot-btn advance-attachment-upload">
|
||||
<van-uploader
|
||||
:after-read="onAfterRead"
|
||||
:before-read="beforeReadAttachment"
|
||||
multiple
|
||||
result-type="file"
|
||||
:accept="attachmentAccept"
|
||||
>
|
||||
<button type="button" class="btn btn-primary btn-sm">上传附件</button>
|
||||
</van-uploader>
|
||||
</div>
|
||||
<div v-if="attachment.files.value.length" class="att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="(file, aidx) in attachment.files.value"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="attachment.open(file)"
|
||||
@keydown.enter.prevent="attachment.open(file)"
|
||||
>
|
||||
<img
|
||||
v-if="attachment.isImage(file.fileType) && file.previewUrl"
|
||||
:src="file.previewUrl"
|
||||
:alt="file.fileName"
|
||||
/>
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ attachment.fileExt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
<button type="button" class="del" @click.stop="attachment.remove(aidx)">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 报销说明 -->
|
||||
<div class="form-card">
|
||||
<div class="form-header">
|
||||
<h3>报销说明</h3>
|
||||
</div>
|
||||
<div class="field">
|
||||
<textarea
|
||||
class="form-textarea"
|
||||
rows="3"
|
||||
placeholder="请输入报销说明"
|
||||
v-model="form.remark"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 底部提交 -->
|
||||
<BottomActionBar>
|
||||
<button
|
||||
class="btn btn-primary btn-block"
|
||||
:class="{ 'btn-loading': submitting }"
|
||||
@click="onSubmit"
|
||||
>
|
||||
{{ editingId ? '保存修改' : '保存' }}
|
||||
</button>
|
||||
</BottomActionBar>
|
||||
|
||||
<!-- 费用项目:左一级 / 右二级 双栏联动(与备用金申请一致) -->
|
||||
<van-popup
|
||||
v-model:show="showExpensePicker"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ height: '62vh', maxHeight: '520px' }"
|
||||
class="expense-picker-popup"
|
||||
>
|
||||
<div class="expense-two-col-sheet">
|
||||
<div class="expense-two-col-sheet__head">
|
||||
<span class="expense-two-col-sheet__title">选择费用项目</span>
|
||||
<button type="button" class="expense-two-col-sheet__close" aria-label="关闭" @click="showExpensePicker = false">
|
||||
<van-icon name="cross" size="20" color="var(--text-muted)" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="expense-two-col-sheet__cols">
|
||||
<div class="expense-col expense-col--left">
|
||||
<div class="expense-col__caption">一级</div>
|
||||
<div class="expense-col__scroll">
|
||||
<button
|
||||
v-for="item in leftItems"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
:class="['expense-col__row', { 'is-active': item.id === selectedLeftId }]"
|
||||
@click="onPickLeft(item)"
|
||||
>
|
||||
{{ item.itemName }}
|
||||
</button>
|
||||
<div v-if="!leftItems.length" class="expense-col__empty">暂无费用大类</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="expense-col expense-col--right">
|
||||
<div class="expense-col__caption">二级</div>
|
||||
<div class="expense-col__scroll">
|
||||
<template v-if="selectedLeft">
|
||||
<template v-if="rightItems.length">
|
||||
<button
|
||||
v-for="child in rightItems"
|
||||
:key="child.id"
|
||||
type="button"
|
||||
:class="['expense-col__row', { 'is-active': child.id === highlightRightId }]"
|
||||
@click="confirmExpensePick(child.id)"
|
||||
>
|
||||
{{ selectedLeft ? `${selectedLeft.itemName}/${child.itemName}` : child.itemName }}
|
||||
</button>
|
||||
</template>
|
||||
<div v-else class="expense-col__leaf-hint">
|
||||
<p class="expense-col__leaf-text">该大类下暂无明细项,可直接选用本级。</p>
|
||||
<button type="button" class="btn btn-primary btn-block btn-sm" @click="confirmExpensePick(selectedLeft.id)">
|
||||
选用「{{ selectedLeft.itemName }}」
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="expense-col__empty">请先选择左侧大类</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, watch, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { showToast, showDialog } from 'vant'
|
||||
import { reimburseApi } from '@/api'
|
||||
import { BizError } from '@/api/client'
|
||||
import {
|
||||
useExpenseItemTree,
|
||||
formatExpenseName,
|
||||
type ExpenseItem,
|
||||
} from '@/hooks/useExpenseItemTree'
|
||||
import { useAttachment } from '@/hooks/useAttachment'
|
||||
import { SUBMIT_APPROVE_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import BottomActionBar from '@/components/mobile/BottomActionBar.vue'
|
||||
|
||||
const MAX_ATTACHMENTS = 10
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
/** 与备用金申请附件 accept 一致 */
|
||||
const attachmentAccept =
|
||||
[
|
||||
'image/*',
|
||||
'application/pdf',
|
||||
'application/msword',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'text/plain',
|
||||
'text/csv',
|
||||
'application/rtf',
|
||||
'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
'application/x-rar-compressed',
|
||||
'application/x-7z-compressed',
|
||||
'.pdf',
|
||||
'.doc',
|
||||
'.docx',
|
||||
'.xls',
|
||||
'.xlsx',
|
||||
'.ppt',
|
||||
'.pptx',
|
||||
'.txt',
|
||||
'.csv',
|
||||
'.rtf',
|
||||
'.wps',
|
||||
'.et',
|
||||
'.dps',
|
||||
'.zip',
|
||||
'.rar',
|
||||
'.7z',
|
||||
].join(',')
|
||||
|
||||
interface DetailLine {
|
||||
expenseItemId: number | string
|
||||
amount: string
|
||||
remark: string
|
||||
}
|
||||
|
||||
const form = reactive({
|
||||
title: '',
|
||||
remark: '',
|
||||
details: [{ expenseItemId: '' as string | number, amount: '', remark: '' }] as DetailLine[],
|
||||
})
|
||||
|
||||
const submitting = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const showExpensePicker = ref(false)
|
||||
const pickingLineIndex = ref(0)
|
||||
const selectedLeftId = ref<number | null>(null)
|
||||
|
||||
const { expenseTree, flatList, load: loadExpenseItems } = useExpenseItemTree()
|
||||
const attachment = useAttachment()
|
||||
|
||||
const detailTotalAmount = computed(() => {
|
||||
const total = form.details.reduce((sum: number, d) => sum + Number(d.amount || 0), 0)
|
||||
return total.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
})
|
||||
|
||||
function lineExpenseDisplay(id: number | string): string {
|
||||
if (id === '' || id == null) return ''
|
||||
const n = Number(id)
|
||||
if (!Number.isFinite(n) || n <= 0) return ''
|
||||
return formatExpenseName(n, flatList.value)
|
||||
}
|
||||
|
||||
function isExpenseEnabled(item: ExpenseItem): boolean {
|
||||
return item.status === 1 || item.status === '1'
|
||||
}
|
||||
|
||||
const leftItems = computed(() =>
|
||||
[...expenseTree.value].filter(isExpenseEnabled).sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0)),
|
||||
)
|
||||
|
||||
const selectedLeft = computed(() => leftItems.value.find((i) => i.id === selectedLeftId.value) ?? null)
|
||||
|
||||
const rightItems = computed(() => {
|
||||
const raw = selectedLeft.value?.children
|
||||
if (!Array.isArray(raw) || !raw.length) return []
|
||||
return [...raw].filter(isExpenseEnabled).sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0))
|
||||
})
|
||||
|
||||
const highlightRightId = computed(() => {
|
||||
const line = form.details[pickingLineIndex.value]
|
||||
const id = line ? Number(line.expenseItemId) : NaN
|
||||
if (!Number.isFinite(id) || !rightItems.value.some((c) => c.id === id)) return null
|
||||
return id
|
||||
})
|
||||
|
||||
function findRootForItem(itemId: number): ExpenseItem | null {
|
||||
const node = flatList.value.find((i) => i.id === itemId)
|
||||
if (!node) return null
|
||||
let cur: ExpenseItem | null = node
|
||||
const guard = new Set<number>()
|
||||
while (cur !== null && !guard.has(cur.id)) {
|
||||
guard.add(cur.id)
|
||||
if (!cur.parentId || cur.parentId === 0) return cur
|
||||
const pid: number = cur.parentId
|
||||
cur = flatList.value.find((i) => i.id === pid) ?? null
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
function syncExpensePickerSelection() {
|
||||
const line = form.details[pickingLineIndex.value]
|
||||
const rawId = line?.expenseItemId
|
||||
const id = rawId === '' || rawId == null ? null : Number(rawId)
|
||||
if (!leftItems.value.length) {
|
||||
selectedLeftId.value = null
|
||||
return
|
||||
}
|
||||
if (id == null || !Number.isFinite(id) || id <= 0) {
|
||||
selectedLeftId.value = leftItems.value[0].id
|
||||
return
|
||||
}
|
||||
const root = findRootForItem(id)
|
||||
const match = root && leftItems.value.some((x) => x.id === root.id) ? root : null
|
||||
selectedLeftId.value = match?.id ?? leftItems.value[0].id
|
||||
}
|
||||
|
||||
watch(showExpensePicker, (open) => {
|
||||
if (open) syncExpensePickerSelection()
|
||||
})
|
||||
|
||||
function onPickLeft(item: ExpenseItem) {
|
||||
selectedLeftId.value = item.id
|
||||
}
|
||||
|
||||
function confirmExpensePick(id: number) {
|
||||
form.details[pickingLineIndex.value].expenseItemId = id
|
||||
showExpensePicker.value = false
|
||||
}
|
||||
|
||||
function openExpensePicker(idx: number) {
|
||||
pickingLineIndex.value = idx
|
||||
showExpensePicker.value = true
|
||||
}
|
||||
|
||||
function addDetailLine() {
|
||||
form.details.push({ expenseItemId: '', amount: '', remark: '' })
|
||||
}
|
||||
|
||||
function removeDetailLine(index: number) {
|
||||
form.details.splice(index, 1)
|
||||
}
|
||||
|
||||
function beforeReadAttachment(file: File | File[]) {
|
||||
const batch = Array.isArray(file) ? file : [file]
|
||||
const remain = MAX_ATTACHMENTS - attachment.files.value.length
|
||||
if (remain <= 0) {
|
||||
showToast(`最多上传 ${MAX_ATTACHMENTS} 个附件`)
|
||||
return false
|
||||
}
|
||||
if (batch.length > remain) {
|
||||
showToast(`还可上传 ${remain} 个附件,超出部分已忽略`)
|
||||
return Promise.resolve(batch.slice(0, remain))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function onAfterRead(uploadFile: any) {
|
||||
const files = Array.isArray(uploadFile) ? uploadFile : [uploadFile]
|
||||
for (const f of files) {
|
||||
if (!f?.file) continue
|
||||
await attachment.upload(f.file, 'reimburse_apply', 0)
|
||||
}
|
||||
}
|
||||
|
||||
/** 与明细行 * 一致:逐行校验,避免漏填仍被 filter 静默丢弃;失败返回 null */
|
||||
function validateReimburseApplyForm(): DetailLine[] | null {
|
||||
for (let i = 0; i < form.details.length; i++) {
|
||||
const d = form.details[i]
|
||||
const row = i + 1
|
||||
const hasExpense = d.expenseItemId !== '' && d.expenseItemId != null
|
||||
const amountStr = String(d.amount ?? '').trim()
|
||||
const hasAmount = amountStr !== ''
|
||||
const amt = Number(amountStr)
|
||||
const amountOk = hasAmount && !Number.isNaN(amt) && amt > 0
|
||||
const hasRemark = !!d.remark?.trim()
|
||||
|
||||
if (!hasExpense && !hasAmount && !hasRemark) continue
|
||||
|
||||
if (!hasExpense) {
|
||||
showToast(`第 ${row} 行:请选择费用项目`)
|
||||
return null
|
||||
}
|
||||
if (!amountOk) {
|
||||
showToast(`第 ${row} 行:请输入大于 0 的金额`)
|
||||
return null
|
||||
}
|
||||
if (!d.remark?.trim()) {
|
||||
showToast(`第 ${row} 行:请填写报销事由`)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const validDetails = form.details.filter((d) => {
|
||||
const hasExpense = d.expenseItemId !== '' && d.expenseItemId != null
|
||||
const amt = Number(String(d.amount ?? '').trim())
|
||||
return hasExpense && !Number.isNaN(amt) && amt > 0
|
||||
})
|
||||
if (validDetails.length === 0) {
|
||||
showToast('请至少填写一条完整的报销明细(费用项目与金额)')
|
||||
return null
|
||||
}
|
||||
return validDetails
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
const validDetails = validateReimburseApplyForm()
|
||||
if (!validDetails) return
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const payload = {
|
||||
title: form.title || undefined,
|
||||
remark: form.remark || undefined,
|
||||
details: validDetails.map(d => ({
|
||||
expenseItemId: Number(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim(),
|
||||
})),
|
||||
}
|
||||
|
||||
let id: number
|
||||
const isEditingAction = !!editingId.value
|
||||
if (editingId.value) {
|
||||
id = editingId.value
|
||||
await reimburseApi.update(id, payload)
|
||||
await attachment.bindNew('reimburse_apply', id)
|
||||
showToast('保存成功')
|
||||
} else {
|
||||
const res: any = await reimburseApi.create(payload)
|
||||
id = Number(res?.data?.id ?? res?.id ?? 0)
|
||||
if (!id) {
|
||||
throw new Error('保存成功但未返回报销单ID')
|
||||
}
|
||||
await attachment.bindNew('reimburse_apply', id)
|
||||
editingId.value = id
|
||||
showToast('保存成功')
|
||||
}
|
||||
|
||||
showDialog({
|
||||
title: isEditingAction ? '保存成功' : '创建成功',
|
||||
message: '报销单已保存为草稿',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '提交审批',
|
||||
confirmButtonColor: SUBMIT_APPROVE_BUTTON_COLOR,
|
||||
cancelButtonText: '继续编辑',
|
||||
}).then(() => {
|
||||
// 用户点击"提交审批"
|
||||
reimburseApi.submit(id).then(() => {
|
||||
showToast('提交成功')
|
||||
router.back()
|
||||
}).catch((e: any) => {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast(e?.message || '提交失败')
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
// 用户点击"继续编辑" — 留在当前页
|
||||
})
|
||||
} catch (e: any) {
|
||||
if (!(e instanceof BizError)) {
|
||||
showToast(e?.message || '保存失败')
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEditData() {
|
||||
const id = route.query.id
|
||||
if (!id) {
|
||||
editingId.value = null
|
||||
attachment.clear()
|
||||
return
|
||||
}
|
||||
editingId.value = Number(id)
|
||||
|
||||
try {
|
||||
const res: any = await reimburseApi.getById(editingId.value)
|
||||
const data = res.data || res
|
||||
form.title = data.title || ''
|
||||
form.remark = data.remark || ''
|
||||
form.details = (data.details || []).map((d: any) => ({
|
||||
expenseItemId: d.expenseId ?? d.expenseItemId ?? '',
|
||||
amount: String(d.amount ?? ''),
|
||||
remark: d.remark || '',
|
||||
}))
|
||||
if (form.details.length === 0) {
|
||||
form.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
}
|
||||
await attachment.loadList('reimburse_apply', editingId.value)
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载数据失败')
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query.id,
|
||||
async (id, prev) => {
|
||||
if (!id) {
|
||||
editingId.value = null
|
||||
attachment.clear()
|
||||
return
|
||||
}
|
||||
if (String(id) === String(prev ?? '')) return
|
||||
await loadEditData()
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
sessionStorage.removeItem('bx_edit_resubmit')
|
||||
await loadExpenseItems()
|
||||
await loadEditData()
|
||||
if (!editingId.value && !form.title) {
|
||||
try {
|
||||
const res: any = await reimburseApi.generateTitle()
|
||||
if (res.data) {
|
||||
form.title = typeof res.data === 'string' ? res.data : res.data.title || ''
|
||||
}
|
||||
} catch { /* skip */ }
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.detail-line-no {
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.apply-form .form-card + .form-card {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.detail-line .detail-divider {
|
||||
height: 1px;
|
||||
background: var(--border);
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.detail-line-actions {
|
||||
text-align: right;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.detail-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed var(--border);
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-size: 14px;
|
||||
color: var(--text-sec);
|
||||
}
|
||||
|
||||
.total-amount b {
|
||||
color: var(--primary-dark);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.advance-attachment-upload {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.advance-att-grid {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.advance-att-tile {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.advance-att-tile:active {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.att-img .att-file-icon.att-doc-thumb {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-shrink: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.att-doc-thumb__ext {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.att-doc-thumb__name {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.25;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.expense-picker-popup.van-popup--bottom.van-popup--round {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.expense-two-col-sheet {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 280px;
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.expense-two-col-sheet__head {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 16px 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.expense-two-col-sheet__title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.expense-two-col-sheet__close {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin: -8px -8px -8px 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.expense-two-col-sheet__close:active {
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.expense-two-col-sheet__cols {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.expense-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.expense-col:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.expense-col--left {
|
||||
flex: 0 0 42%;
|
||||
max-width: 46%;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.expense-col--right {
|
||||
flex: 1;
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.expense-col__caption {
|
||||
flex-shrink: 0;
|
||||
padding: 8px 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.06em;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.expense-col__scroll {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 6px 0 12px;
|
||||
}
|
||||
|
||||
.expense-col__row {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 12px 14px;
|
||||
font-size: 14px;
|
||||
line-height: 1.35;
|
||||
color: var(--text);
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
|
||||
.expense-col__row:active {
|
||||
background: rgba(16, 185, 129, 0.08);
|
||||
}
|
||||
|
||||
.expense-col__row.is-active {
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.expense-col__empty {
|
||||
padding: 24px 14px;
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.expense-col__leaf-hint {
|
||||
padding: 16px 14px;
|
||||
}
|
||||
|
||||
.expense-col__leaf-text {
|
||||
font-size: 13px;
|
||||
color: var(--text-sec);
|
||||
line-height: 1.5;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,972 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-medium">
|
||||
<!-- Topbar(与备用金申请等列表页统一) -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">报销审批</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索单号 / 申请人"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-tabs v-model:active="activeTab" sticky offset-top="58" @change="onTabChange">
|
||||
<van-tab title="待我审批" />
|
||||
<van-tab title="我已审批" />
|
||||
</van-tabs>
|
||||
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
:finished-text="list.length ? '没有更多了' : ''"
|
||||
@load="onLoad"
|
||||
>
|
||||
<div class="page-padded list-block" style="padding-top: 8px;">
|
||||
<div
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="openDetail(item)"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type reimburse-list-card__title-wrap">
|
||||
<span class="reimburse-list-card__title">{{ cardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">报销金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="reimburse-card-subs">
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">冲抵金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.offsetAmount ?? item.offset_amount) }}</span>
|
||||
</div>
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">实付金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.payAmount ?? item.actualAmount ?? item.actual_amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || item.code || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="resolveExpenseDisplay(item, flatList) !== '-'" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">费用项目</span>
|
||||
<span class="list-card-kv__v">{{ resolveExpenseDisplay(item, flatList) }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">发票 / 附件</span>
|
||||
<span class="list-card-kv__v">{{ item.invoiceCount ?? 0 }} 张 · {{ item.attachCount ?? 0 }} 个</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom reimburse-list-card__bottom">
|
||||
<div class="op-actions" @click.stop>
|
||||
<template v-if="activeTab === 0">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`reject_${item.id}`] }"
|
||||
@click="openAction(item, 'reject')"
|
||||
>驳回</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`approve_${item.id}`] }"
|
||||
@click="openAction(item, 'approve')"
|
||||
>通过</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button type="button" class="btn btn-sm btn-primary" @click="openDetail(item)">查看</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loading && !refreshing && list.length === 0" class="empty-state empty-state--fill">
|
||||
<van-icon name="description" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无{{ activeTab === 0 ? '待审批' : '已审批' }}报销申请</p>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
|
||||
<!-- Approve/Reject Dialog -->
|
||||
<van-dialog
|
||||
v-model:show="showActionDialog"
|
||||
:title="actionType === 'approve' ? '审批通过' : '审批驳回'"
|
||||
show-cancel-button
|
||||
:confirm-button-color="PRIMARY_CONFIRM_BUTTON_COLOR"
|
||||
:confirm-button-loading="actionLoading"
|
||||
@confirm="confirmAction"
|
||||
:before-close="beforeClose"
|
||||
>
|
||||
<div class="dialog-form-body">
|
||||
<div class="action-status-bar">
|
||||
<StatusTag :text="actionType === 'approve' ? '通过后进入下一节点' : '驳回后退回申请人'" :variant="actionType === 'approve' ? 'success' : 'danger'" />
|
||||
</div>
|
||||
<van-field
|
||||
v-model="opinion"
|
||||
class="approval-opinion-field"
|
||||
type="textarea"
|
||||
placeholder="请输入审批意见"
|
||||
rows="3"
|
||||
:border="false"
|
||||
/>
|
||||
</div>
|
||||
</van-dialog>
|
||||
|
||||
<!-- Detail Popup -->
|
||||
<van-popup
|
||||
v-model:show="showDetail"
|
||||
position="bottom"
|
||||
round
|
||||
:style="{ maxHeight: '85vh' }"
|
||||
class="approve-detail-popup"
|
||||
>
|
||||
<div class="approve-detail-sheet">
|
||||
<div class="approve-detail-sheet__header">
|
||||
<span class="approve-detail-sheet__title">报销单详情</span>
|
||||
<van-icon name="cross" size="20" color="var(--text-muted)" @click="showDetail = false" />
|
||||
</div>
|
||||
|
||||
<div v-if="detailData" class="approve-detail-sheet__scroll">
|
||||
<div class="advance-ticket-shell advance-ticket-shell--in-popup">
|
||||
<div class="advance-ticket-stack">
|
||||
<div class="advance-ticket-top">
|
||||
<span class="advance-ticket-code" :title="detailData.applyCode || undefined">{{
|
||||
detailData.applyCode || '—'
|
||||
}}</span>
|
||||
<span
|
||||
class="advance-ticket-status"
|
||||
:class="ticketHeaderStatusToneClass(detailData.status)"
|
||||
>{{ statusLabel(detailData.status) }}</span>
|
||||
</div>
|
||||
<div class="advance-ticket-tear" aria-hidden="true">
|
||||
<div class="advance-ticket-tear__line"></div>
|
||||
</div>
|
||||
<div class="advance-ticket-bottom">
|
||||
<p class="advance-ticket-reason">{{ detailData.title || '—' }}</p>
|
||||
<div class="advance-ticket-amount-wrap">
|
||||
<span class="advance-ticket-amount">{{ formatAmount(detailData.amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="popup-advance-stack">
|
||||
<section class="detail-info-card" aria-label="基础信息">
|
||||
<div class="detail-info-card__title">基础信息</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请单号</div>
|
||||
<div class="adv-field__value">{{ detailData.applyCode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">报销标题</div>
|
||||
<div class="adv-field__value">{{ detailData.title || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请人</div>
|
||||
<div class="adv-field__value">{{ detailData.applicantName || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">费用项目</div>
|
||||
<div class="adv-field__value">{{ resolveExpenseDisplay(detailData, flatList) }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">当前节点</div>
|
||||
<div class="adv-field__value">{{ detailData.currentNode || '—' }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">申请时间</div>
|
||||
<div class="adv-field__value">{{ formatApplyDateTime(detailData) }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">报销说明</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ detailData.remark || '—' }}</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="detailData.details && detailData.details.length > 0"
|
||||
class="detail-info-card detail-info-card--details-bill"
|
||||
aria-label="费用明细"
|
||||
>
|
||||
<div class="detail-info-card__title">费用项明细</div>
|
||||
<div
|
||||
v-for="(d, idx) in detailData.details"
|
||||
:key="idx"
|
||||
class="reimburse-popup-detail-group"
|
||||
>
|
||||
<div v-if="detailData.details.length > 1" class="reimburse-popup-detail-head">明细 {{ idx + 1 }}</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">费用项目</div>
|
||||
<div class="adv-field__value">{{ resolveExpenseDisplay(d, flatList) }}</div>
|
||||
</div>
|
||||
<div class="adv-field">
|
||||
<div class="adv-field__label">金额</div>
|
||||
<div class="adv-field__value adv-field__value--accent">¥ {{ formatAmount(d.amount) }}</div>
|
||||
</div>
|
||||
<div v-if="d.remark" class="adv-field">
|
||||
<div class="adv-field__label">报销事由</div>
|
||||
<div class="adv-field__value adv-field__value--multiline">{{ d.remark }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="detail-info-card detail-info-card--media" aria-label="申请附件">
|
||||
<div class="detail-info-card__title">申请附件</div>
|
||||
<template v-if="viewAttachments.length > 0">
|
||||
<div class="advance-detail-att-grid att-grid advance-att-grid">
|
||||
<div
|
||||
v-for="file in viewAttachments"
|
||||
:key="file.id"
|
||||
class="att-img advance-att-tile"
|
||||
:title="file.fileName"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="onPreviewPopupFile(file, viewAttachments)"
|
||||
@keydown.enter.prevent="onPreviewPopupFile(file, viewAttachments)"
|
||||
>
|
||||
<img
|
||||
v-if="isImageAtt(file.fileType) && file.previewUrl"
|
||||
:src="file.previewUrl"
|
||||
:alt="file.fileName"
|
||||
/>
|
||||
<div v-else class="att-file-icon att-doc-thumb">
|
||||
<span class="att-doc-thumb__ext">{{ fileExtAtt(file.fileName) }}</span>
|
||||
<span class="att-doc-thumb__name">{{ file.fileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="detail-section-empty detail-section-empty--in-card">暂无申请附件</p>
|
||||
</section>
|
||||
|
||||
<section v-if="flowNodes.length" class="detail-info-card detail-info-card--timeline" aria-label="审批流程">
|
||||
<div class="adv-approval-flow">
|
||||
<div v-for="node in flowNodes" :key="node.id || node.nodeOrder" class="flow-step">
|
||||
<div
|
||||
:class="[
|
||||
'flow-avatar',
|
||||
node.approvalStatus === 'approved' || node.status === 'approved'
|
||||
? 'av-done'
|
||||
: node.approvalStatus === 'pending' || node.status === 'pending'
|
||||
? 'av-current'
|
||||
: node.approvalStatus === 'rejected' || node.status === 'rejected'
|
||||
? 'av-reject'
|
||||
: 'av-pending'
|
||||
]"
|
||||
>
|
||||
{{ (node.approverName || node.nodeName || node.nodeLabel || '审')[0] }}
|
||||
</div>
|
||||
<div class="flow-info">
|
||||
<div class="flow-name">{{ node.nodeName || node.nodeLabel || '—' }}</div>
|
||||
<div v-if="node.approverName" class="flow-role">{{ node.approverName }}</div>
|
||||
<div v-if="node.approvalTime" class="flow-time">{{ formatDateTime(node.approvalTime) }}</div>
|
||||
<div v-if="node.approvalOpinion" class="adv-flow-opinion">{{ node.approvalOpinion }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showImagePreview } from 'vant'
|
||||
import { PRIMARY_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { reimburseApi, attachmentApi } from '@/api'
|
||||
import {
|
||||
statusLabel,
|
||||
ticketHeaderStatusToneClass,
|
||||
workflowListStatusTagClass,
|
||||
formatAmount,
|
||||
formatDateTime,
|
||||
formatApplyDateTime,
|
||||
} from '@/utils/format'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
import StatusTag from '@/components/mobile/StatusTag.vue'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
function onKeywordSearch() {
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
void fetchPage()
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(onKeywordSearch)
|
||||
const { flatList } = useExpenseItemTree()
|
||||
|
||||
const activeTab = ref(0)
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
const page = ref(1)
|
||||
const pageSize = 20
|
||||
|
||||
// Action dialog
|
||||
const showActionDialog = ref(false)
|
||||
const opinion = ref('')
|
||||
const actionType = ref<'approve' | 'reject'>('approve')
|
||||
const currentItem = ref<any>(null)
|
||||
const actionLoading = ref(false)
|
||||
|
||||
// Detail popup
|
||||
const showDetail = ref(false)
|
||||
const detailData = ref<any>(null)
|
||||
const flowNodes = ref<any[]>([])
|
||||
const viewAttachments = ref<any[]>([])
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
function reimburseLineSubtitle(item: Record<string, any>) {
|
||||
const ex = resolveExpenseDisplay(item, flatList.value)
|
||||
return item.title || (ex !== '-' ? ex : '-')
|
||||
}
|
||||
|
||||
function cardTitle(item: Record<string, any>) {
|
||||
const t = (item.title ?? '').toString().trim()
|
||||
if (t) return t
|
||||
return reimburseLineSubtitle(item)
|
||||
}
|
||||
|
||||
function moneyOrDash(raw: unknown): string {
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n) || n === 0) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function isImageAtt(fileType: string): boolean {
|
||||
return fileType?.startsWith('image/')
|
||||
}
|
||||
|
||||
function fileExtAtt(name: string): string {
|
||||
const ext = name?.split('.').pop()
|
||||
return ext ? ext.toUpperCase() : 'FILE'
|
||||
}
|
||||
|
||||
async function loadAttWithPreview(biz: string, id: number): Promise<any[]> {
|
||||
const res: any = await attachmentApi.listByBiz(biz, id)
|
||||
const files = (res.data || []).map((a: any) => ({ ...a, previewUrl: '' }))
|
||||
await Promise.all(
|
||||
files
|
||||
.filter((a: any) => isImageAtt(a.fileType || ''))
|
||||
.map(async (a: any) => {
|
||||
try {
|
||||
const pRes: any = await attachmentApi.preview(a.id)
|
||||
a.previewUrl = pRes.data.url
|
||||
} catch { /* skip */ }
|
||||
}),
|
||||
)
|
||||
return files
|
||||
}
|
||||
|
||||
async function onPreviewPopupFile(file: { id: number; fileName: string; fileType: string; previewUrl?: string }, list: any[]) {
|
||||
if (isImageAtt(file.fileType) && file.previewUrl) {
|
||||
const images = list
|
||||
.filter((f: any) => isImageAtt(f.fileType) && f.previewUrl)
|
||||
.map((f: any) => f.previewUrl)
|
||||
const startIdx = images.indexOf(file.previewUrl)
|
||||
showImagePreview({ images, startPosition: Math.max(0, startIdx) })
|
||||
} else {
|
||||
try {
|
||||
const blob = (await attachmentApi.download(file.id)) as unknown as Blob
|
||||
if (!(blob instanceof Blob)) {
|
||||
showToast('下载失败')
|
||||
return
|
||||
}
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = file.fileName || '附件'
|
||||
a.rel = 'noopener'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
} catch {
|
||||
showToast('下载失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchPage() {
|
||||
try {
|
||||
const params: Record<string, unknown> = { page: page.value, pageSize }
|
||||
const kw = keyword.value.trim()
|
||||
if (kw) params.keyword = kw
|
||||
const apiFn = activeTab.value === 0 ? reimburseApi.pendingApproval : reimburseApi.approvedByMe
|
||||
const res: any = await apiFn(params)
|
||||
const items = res.data?.rows || res.data?.items || res.data?.list || (Array.isArray(res.data) ? res.data : [])
|
||||
const total = res.data?.total ?? items.length ?? 0
|
||||
if (page.value === 1) {
|
||||
list.value = items
|
||||
} else {
|
||||
list.value.push(...items)
|
||||
}
|
||||
page.value++
|
||||
finished.value = items.length < pageSize || list.value.length >= total
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载失败')
|
||||
finished.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
async function onRefresh() {
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
list.value = []
|
||||
loading.value = true
|
||||
await fetchPage()
|
||||
}
|
||||
|
||||
function onTabChange() {
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
fetchPage()
|
||||
}
|
||||
|
||||
function openAction(item: any, action: 'approve' | 'reject') {
|
||||
currentItem.value = item
|
||||
actionType.value = action
|
||||
opinion.value = action === 'approve' ? '审批通过' : '审批驳回'
|
||||
showActionDialog.value = true
|
||||
}
|
||||
|
||||
function beforeClose(action: string): boolean {
|
||||
if (action === 'confirm') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function confirmAction() {
|
||||
const item = currentItem.value
|
||||
if (!item) return
|
||||
const key = `${actionType.value}_${item.id}`
|
||||
loadingMap[key] = true
|
||||
actionLoading.value = true
|
||||
try {
|
||||
const apiFn = actionType.value === 'approve' ? reimburseApi.approve : reimburseApi.reject
|
||||
await apiFn(item.id, { approvalOpinion: opinion.value })
|
||||
showToast(actionType.value === 'approve' ? '已通过' : '已驳回')
|
||||
showActionDialog.value = false
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
list.value = []
|
||||
loading.value = true
|
||||
await fetchPage()
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '操作失败')
|
||||
} finally {
|
||||
loadingMap[key] = false
|
||||
actionLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openDetail(item: any) {
|
||||
detailData.value = item
|
||||
flowNodes.value = []
|
||||
viewAttachments.value = []
|
||||
showDetail.value = true
|
||||
|
||||
// Load full detail
|
||||
try {
|
||||
const res: any = await reimburseApi.getById(item.id)
|
||||
detailData.value = res.data || res
|
||||
} catch {
|
||||
// use list item data
|
||||
}
|
||||
|
||||
// Load approval flow
|
||||
try {
|
||||
const flowRes: any = await reimburseApi.getApprovals(item.id)
|
||||
const nodes = (flowRes.data || []).sort((a: any, b: any) => (a.nodeOrder ?? 0) - (b.nodeOrder ?? 0))
|
||||
flowNodes.value = nodes
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
try {
|
||||
viewAttachments.value = await loadAttWithPreview('reimburse_apply', item.id)
|
||||
} catch {
|
||||
viewAttachments.value = []
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.reimburse-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.reimburse-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.reimburse-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.reimburse-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.approve-detail-sheet {
|
||||
padding: 0 0 16px;
|
||||
box-sizing: border-box;
|
||||
max-height: 85vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.approve-detail-sheet__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
padding: 14px 16px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.approve-detail-sheet__title {
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.approve-detail-sheet__scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-bottom: env(safe-area-inset-bottom, 0);
|
||||
}
|
||||
|
||||
.advance-ticket-shell--in-popup {
|
||||
padding: 8px 16px 10px;
|
||||
}
|
||||
|
||||
.advance-ticket-shell {
|
||||
--ticket-bg: var(--primary);
|
||||
--ticket-skin: var(--primary-light);
|
||||
--ticket-dash: rgba(0, 201, 141, 0.45);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
background: var(--ticket-bg);
|
||||
}
|
||||
|
||||
.advance-ticket-stack {
|
||||
width: 100%;
|
||||
max-width: 430px;
|
||||
margin: 0 auto;
|
||||
filter: drop-shadow(0 8px 20px rgba(0, 168, 116, 0.22));
|
||||
}
|
||||
|
||||
.advance-ticket-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-height: 44px;
|
||||
padding: 12px 14px 10px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 14px 14px 0 0;
|
||||
}
|
||||
|
||||
.advance-ticket-code {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #475569;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status {
|
||||
flex-shrink: 0;
|
||||
padding: 4px 11px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.advance-ticket-status--warn {
|
||||
background: #ea580c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--done {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--err {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--info {
|
||||
background: #64748b;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-status--processing {
|
||||
background: #6366f1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.advance-ticket-tear {
|
||||
position: relative;
|
||||
height: 14px;
|
||||
background: var(--ticket-skin);
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before,
|
||||
.advance-ticket-tear::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin-top: -7px;
|
||||
border-radius: 50%;
|
||||
background: var(--ticket-bg);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::before {
|
||||
left: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear::after {
|
||||
right: -7px;
|
||||
}
|
||||
|
||||
.advance-ticket-tear__line {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
top: 50%;
|
||||
margin-top: -0.5px;
|
||||
border-top: 1px dashed var(--ticket-dash);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.advance-ticket-bottom {
|
||||
padding: 8px 14px 16px;
|
||||
background: var(--ticket-skin);
|
||||
border-radius: 0 0 14px 14px;
|
||||
}
|
||||
|
||||
.advance-ticket-reason {
|
||||
margin: 0 0 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.45;
|
||||
color: #64748b;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.advance-ticket-amount-wrap {
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.advance-ticket-amount {
|
||||
font-size: clamp(26px, 8vw, 34px);
|
||||
font-weight: 800;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.popup-advance-stack {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 12px 16px 8px;
|
||||
}
|
||||
|
||||
.detail-info-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--r);
|
||||
border: 1px solid var(--border);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 6px 16px 10px;
|
||||
}
|
||||
|
||||
.detail-info-card--media {
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--timeline {
|
||||
padding: 10px 16px 14px;
|
||||
}
|
||||
|
||||
.detail-info-card--details-bill {
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.detail-info-card__title {
|
||||
margin: 6px 0 14px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.reimburse-popup-detail-group + .reimburse-popup-detail-group {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.reimburse-popup-detail-head {
|
||||
margin: 0 0 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.adv-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.adv-field + .adv-field {
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.adv-field:first-child {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.adv-field:last-child {
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.adv-field__label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.adv-field__value {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.adv-field__value--multiline {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
color: var(--text-sec);
|
||||
}
|
||||
|
||||
.adv-field__value--accent {
|
||||
color: var(--primary-dark);
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.detail-section-empty--in-card {
|
||||
margin-top: 4px;
|
||||
background: var(--primary-light);
|
||||
border-style: solid;
|
||||
border-color: rgba(0, 201, 141, 0.12);
|
||||
}
|
||||
|
||||
.advance-detail-att-grid {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.advance-att-tile:active) {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-img .att-file-icon.att-doc-thumb) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
padding: 6px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__ext) {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: var(--primary-dark);
|
||||
}
|
||||
|
||||
.advance-detail-att-grid :deep(.att-doc-thumb__name) {
|
||||
font-size: 10px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.25;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.adv-approval-flow {
|
||||
padding: 4px 0 2px;
|
||||
}
|
||||
|
||||
.adv-flow-opinion {
|
||||
font-size: 12px;
|
||||
color: var(--text-sec);
|
||||
margin-top: 6px;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.action-status-bar {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field.van-cell) {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field.van-cell::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field textarea.van-field__control) {
|
||||
display: block;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 88px;
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--text);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
:deep(.approval-opinion-field textarea.van-field__control::placeholder) {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
:deep(.van-popup--bottom) {
|
||||
border-radius: 14px 14px 0 0;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,396 @@
|
||||
<template>
|
||||
<div class="page page--empty-chrome-tall">
|
||||
<!-- Topbar -->
|
||||
<div class="topbar">
|
||||
<div class="topbar-left">
|
||||
<div class="topbar-back" @click="router.back()">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<span class="topbar-title">报销申请</span>
|
||||
<div class="topbar-right"></div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="fab-add"
|
||||
aria-label="新增报销申请"
|
||||
@click="router.push('/reimburse/apply')"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 5v14M5 12h14"/></svg>
|
||||
</button>
|
||||
|
||||
<!-- Search(与「我的申请」一致:检索在上) -->
|
||||
<div class="search-wrap">
|
||||
<div class="search-box">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<input
|
||||
v-model="keyword"
|
||||
placeholder="搜索报销单"
|
||||
enterkeyhint="search"
|
||||
@keyup.enter="flushSearch"
|
||||
/>
|
||||
<button
|
||||
v-show="keyword.trim()"
|
||||
type="button"
|
||||
class="search-box__clear"
|
||||
aria-label="清除关键词"
|
||||
@click="clearKeyword"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态筛选(与「我的申请」同款 filter-tag) -->
|
||||
<div class="search-wrap" style="padding-top: 0;">
|
||||
<div class="search-filter search-filter--scroll">
|
||||
<div
|
||||
v-for="tab in tabs"
|
||||
:key="tab.value === '' ? '__all' : tab.value"
|
||||
:class="['filter-tag', { active: activeTab === tab.value }]"
|
||||
@click="activeTab = tab.value; onTabChange()"
|
||||
>
|
||||
{{ tab.label }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- List -->
|
||||
<div class="page-padded">
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
:finished-text="list.length ? '没有更多了' : ''"
|
||||
@load="onLoad"
|
||||
>
|
||||
<div v-if="list.length === 0 && !loading" class="empty-state empty-state--fill">
|
||||
<van-icon name="description" :size="56" color="var(--text-muted)" />
|
||||
<p>暂无报销记录</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="expense-card"
|
||||
@click="router.push(`/reimburse/${item.id}`)"
|
||||
>
|
||||
<div class="ec-top">
|
||||
<span class="ec-type reimburse-list-card__title-wrap">
|
||||
<span class="reimburse-list-card__title">{{ cardTitle(item) }}</span>
|
||||
</span>
|
||||
<span class="status-tag" :class="workflowListStatusTagClass(item.status)">{{ statusLabel(item.status) }}</span>
|
||||
</div>
|
||||
<div class="ec-amount-label">报销金额</div>
|
||||
<div class="ec-amount">{{ formatAmount(item.amount) }}</div>
|
||||
<div class="reimburse-card-subs">
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">冲抵金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.offsetAmount ?? item.offset_amount) }}</span>
|
||||
</div>
|
||||
<div class="reimburse-card-sub-row">
|
||||
<span class="k">实付金额</span>
|
||||
<span class="v">¥ {{ moneyOrDash(item.payAmount ?? item.actualAmount ?? item.actual_amount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-card-kv">
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请单号</span>
|
||||
<span class="list-card-kv__v">{{ item.applyCode || '—' }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">申请人</span>
|
||||
<span class="list-card-kv__v">{{ item.applicantName || '-' }}</span>
|
||||
</div>
|
||||
<div v-if="resolveExpenseDisplay(item, flatList) !== '-'" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">费用项目</span>
|
||||
<span class="list-card-kv__v">{{ resolveExpenseDisplay(item, flatList) }}</span>
|
||||
</div>
|
||||
<div v-if="item.currentNode" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">当前环节</span>
|
||||
<span class="list-card-kv__v">{{ item.currentNode }}</span>
|
||||
</div>
|
||||
<div class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">发票 / 附件</span>
|
||||
<span class="list-card-kv__v">{{ item.invoiceCount ?? 0 }} 张 · {{ item.attachCount ?? 0 }} 个</span>
|
||||
</div>
|
||||
<div v-if="item.remark" class="list-card-kv__row">
|
||||
<span class="list-card-kv__k">备注</span>
|
||||
<span class="list-card-kv__v">{{ item.remark }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ec-meta">
|
||||
<span>{{ formatApplyDateTime(item) }}</span>
|
||||
</div>
|
||||
<div class="ec-bottom reimburse-list-card__bottom">
|
||||
<div class="op-actions" v-if="item.status === 'draft' || item.status === 'rejected'">
|
||||
<template v-if="item.status === 'draft'">
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
:class="{ 'btn-loading': loadingMap[`del_${item.id}`] }"
|
||||
@click.stop="handleDelete(item)"
|
||||
>删除</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/reimburse/apply?id=${item.id}`)"
|
||||
>编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`submit_${item.id}`] }"
|
||||
@click.stop="handleSubmit(item)"
|
||||
>提交</button>
|
||||
</template>
|
||||
<template v-else-if="item.status === 'rejected'">
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/reimburse/${item.id}`)"
|
||||
>查看</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/reimburse/apply?id=${item.id}`)"
|
||||
>编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
:class="{ 'btn-loading': loadingMap[`submit_${item.id}`] }"
|
||||
@click.stop="handleSubmit(item)"
|
||||
>提交</button>
|
||||
</template>
|
||||
</div>
|
||||
<div class="op-actions" v-else>
|
||||
<button
|
||||
class="btn btn-sm btn-primary"
|
||||
@click.stop="router.push(`/reimburse/${item.id}`)"
|
||||
>查看</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</van-pull-refresh>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { DELETE_CONFIRM_BUTTON_COLOR } from '@/constants/dialog'
|
||||
import { reimburseApi } from '@/api'
|
||||
import { statusLabel, workflowListStatusTagClass, formatAmount, formatApplyDateTime } from '@/utils/format'
|
||||
import { useKeywordSearch } from '@/hooks/useKeywordSearch'
|
||||
import { useExpenseItemTree, resolveExpenseDisplay } from '@/hooks/useExpenseItemTree'
|
||||
|
||||
const router = useRouter()
|
||||
const { flatList } = useExpenseItemTree()
|
||||
|
||||
interface TabItem {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
|
||||
const tabs: TabItem[] = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待提交', value: 'draft' },
|
||||
{ label: '审批中', value: 'pending' },
|
||||
{ label: '已通过', value: 'approved' },
|
||||
{ label: '已驳回', value: 'rejected' },
|
||||
{ label: '已支付', value: 'paid' },
|
||||
]
|
||||
|
||||
const activeTab = ref<string | number>('')
|
||||
const list = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
const page = ref(1)
|
||||
const pageSize = 10
|
||||
const loadingMap = reactive<Record<string, boolean>>({})
|
||||
|
||||
function reimburseLineSubtitle(item: Record<string, any>) {
|
||||
const ex = resolveExpenseDisplay(item, flatList.value)
|
||||
return item.title || (ex !== '-' ? ex : '-')
|
||||
}
|
||||
|
||||
/** 卡片标题:与备用金列表「申请原因」位置一致,优先报销标题 */
|
||||
function cardTitle(item: Record<string, any>) {
|
||||
const t = (item.title ?? '').toString().trim()
|
||||
if (t) return t
|
||||
return reimburseLineSubtitle(item)
|
||||
}
|
||||
|
||||
/** 列表金额副行:无或 0 显示 — */
|
||||
function moneyOrDash(raw: unknown): string {
|
||||
if (raw == null || raw === '') return '—'
|
||||
const n = typeof raw === 'string' ? parseFloat(raw) : Number(raw)
|
||||
if (Number.isNaN(n) || n === 0) return '—'
|
||||
return formatAmount(n)
|
||||
}
|
||||
|
||||
function currentStatus(): string {
|
||||
return typeof activeTab.value === 'string' ? activeTab.value : (tabs[activeTab.value as number]?.value ?? '')
|
||||
}
|
||||
|
||||
async function fetchList(isRefresh: boolean = false) {
|
||||
try {
|
||||
const params: Record<string, any> = {
|
||||
page: page.value,
|
||||
pageSize,
|
||||
}
|
||||
const status = currentStatus()
|
||||
if (status) {
|
||||
params.status = status
|
||||
}
|
||||
if (keyword.value.trim()) {
|
||||
params.keyword = keyword.value.trim()
|
||||
}
|
||||
const res: any = await reimburseApi.my(params)
|
||||
const items = res.data?.rows || res.data?.items || res.data?.list || res.data || []
|
||||
const total = res.data?.total ?? items.length ?? 0
|
||||
|
||||
if (isRefresh) {
|
||||
list.value = items
|
||||
} else {
|
||||
list.value.push(...items)
|
||||
}
|
||||
|
||||
if (list.value.length >= total || items.length < pageSize) {
|
||||
finished.value = true
|
||||
} else {
|
||||
finished.value = false
|
||||
}
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '加载失败')
|
||||
finished.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function onLoad() {
|
||||
loading.value = true
|
||||
await fetchList(false)
|
||||
loading.value = false
|
||||
page.value++
|
||||
}
|
||||
|
||||
async function onRefresh() {
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
await fetchList(true)
|
||||
refreshing.value = false
|
||||
page.value = 2
|
||||
}
|
||||
|
||||
const { keyword, clearKeyword, flushSearch } = useKeywordSearch(() => {
|
||||
void onRefresh()
|
||||
})
|
||||
|
||||
function onTabChange() {
|
||||
list.value = []
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
loading.value = true
|
||||
fetchList(true).finally(() => {
|
||||
loading.value = false
|
||||
page.value = 2
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSubmit(item: Record<string, any>) {
|
||||
loadingMap[`submit_${item.id}`] = true
|
||||
try {
|
||||
await reimburseApi.submit(item.id)
|
||||
showToast('提交成功')
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
await fetchList(true)
|
||||
page.value = 2
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '提交失败')
|
||||
} finally {
|
||||
loadingMap[`submit_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(item: Record<string, any>) {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '删除确认',
|
||||
message: '确定要删除该报销单吗?删除后不可恢复。',
|
||||
confirmButtonText: '确定删除',
|
||||
confirmButtonColor: DELETE_CONFIRM_BUTTON_COLOR,
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
loadingMap[`del_${item.id}`] = true
|
||||
try {
|
||||
await reimburseApi.delete(item.id)
|
||||
showToast('删除成功')
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
await fetchList(true)
|
||||
page.value = 2
|
||||
} catch (e: any) {
|
||||
showToast(e?.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap[`del_${item.id}`] = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 标题:报销标题,过长省略(对齐备用金列表) */
|
||||
.reimburse-list-card__title-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.reimburse-list-card__title {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.reimburse-list-card__bottom {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.ec-amount-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.reimburse-card-subs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 0 2px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .k {
|
||||
color: var(--text-sec);
|
||||
flex-shrink: 0;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.reimburse-card-sub-row .v {
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"status": "failed",
|
||||
"failedTests": []
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "preserve",
|
||||
"strict": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { VantResolver } from '@vant/auto-import-resolver'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
Components({
|
||||
resolvers: [VantResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5174,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8011',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 50736 (5.7.36)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 03/08/2026 21:29:44
|
||||
Date: 09/08/2026 14:54:11
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
-- 合同类型:框架合同 → 框架销售合同 / 框架采购合同
|
||||
-- 幂等可重复执行
|
||||
|
||||
-- 1) 停用旧「框架合同」
|
||||
UPDATE sys_dict_data
|
||||
SET del_flag = 1,
|
||||
update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type'
|
||||
AND dict_value = 'framework'
|
||||
AND tenant_no = 'shanxia2.0'
|
||||
AND del_flag = 0;
|
||||
|
||||
-- 2) 新增/恢复两类
|
||||
INSERT INTO sys_dict_data (
|
||||
id, dict_label, dict_value, tag_type, dict_type, tenant_no, order_num, remark,
|
||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||
) VALUES (
|
||||
'SXDC0000020260804FS01', '框架销售合同', 'framework_sale', '', 'crm_contract_type', 'shanxia2.0', 3,
|
||||
'原框架合同拆分:供方为本公司时',
|
||||
'1', '', NOW(), NULL, NOW(), 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
dict_label = VALUES(dict_label),
|
||||
order_num = 3,
|
||||
remark = VALUES(remark),
|
||||
del_flag = 0,
|
||||
update_time = NOW();
|
||||
|
||||
INSERT INTO sys_dict_data (
|
||||
id, dict_label, dict_value, tag_type, dict_type, tenant_no, order_num, remark,
|
||||
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||
) VALUES (
|
||||
'SXDC0000020260804FP01', '框架采购合同', 'framework_purchase', '', 'crm_contract_type', 'shanxia2.0', 4,
|
||||
'原框架合同拆分:供方非本公司时',
|
||||
'1', '', NOW(), NULL, NOW(), 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
dict_label = VALUES(dict_label),
|
||||
order_num = 4,
|
||||
remark = VALUES(remark),
|
||||
del_flag = 0,
|
||||
update_time = NOW();
|
||||
|
||||
-- 3) 固定后续排序(避免重复执行时 order_num 漂移)
|
||||
UPDATE sys_dict_data SET order_num = 1, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'sale' AND del_flag = 0;
|
||||
UPDATE sys_dict_data SET order_num = 2, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'purchase' AND del_flag = 0;
|
||||
UPDATE sys_dict_data SET order_num = 5, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'service';
|
||||
UPDATE sys_dict_data SET order_num = 6, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'lease';
|
||||
UPDATE sys_dict_data SET order_num = 7, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'other';
|
||||
UPDATE sys_dict_data SET order_num = 8, update_time = NOW()
|
||||
WHERE dict_type = 'crm_contract_type' AND tenant_no = 'shanxia2.0' AND dict_value = 'supplement';
|
||||
|
||||
-- 4) 业务数据:供方为本公司 → 框架销售
|
||||
-- 含用户口述「安庆市山峡有限公司」及库内全称「安庆市山峡化工有限公司」
|
||||
UPDATE crm_contract
|
||||
SET contract_type = 'framework_sale',
|
||||
update_time = NOW()
|
||||
WHERE tenant_no = 'shanxia2.0'
|
||||
AND contract_type = 'framework'
|
||||
AND TRIM(IFNULL(party_a, '')) IN (
|
||||
'安庆市山峡有限公司',
|
||||
'安庆市山峡化工有限公司',
|
||||
'安徽云栋化工有限公司'
|
||||
);
|
||||
|
||||
-- 5) 其余原框架合同 → 框架采购
|
||||
UPDATE crm_contract
|
||||
SET contract_type = 'framework_purchase',
|
||||
update_time = NOW()
|
||||
WHERE tenant_no = 'shanxia2.0'
|
||||
AND contract_type = 'framework';
|
||||
@@ -1,37 +0,0 @@
|
||||
-- 产品/客户名称拼音首字母(小写)
|
||||
-- 若列已存在会报 Duplicate column;可忽略或先查 information_schema。
|
||||
-- 建议仅执行一次。
|
||||
|
||||
-- crm_product.name_pinyin_abbr
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'crm_product'
|
||||
AND COLUMN_NAME = 'name_pinyin_abbr'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE `crm_product` ADD COLUMN `name_pinyin_abbr` varchar(100) DEFAULT NULL COMMENT ''产品名称拼音首字母(小写)'' AFTER `product_name`',
|
||||
'SELECT ''crm_product.name_pinyin_abbr already exists, skip'''
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- crm_customer.name_pinyin_abbr
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'crm_customer'
|
||||
AND COLUMN_NAME = 'name_pinyin_abbr'
|
||||
);
|
||||
SET @sql := IF(
|
||||
@col_exists = 0,
|
||||
'ALTER TABLE `crm_customer` ADD COLUMN `name_pinyin_abbr` varchar(100) DEFAULT NULL COMMENT ''客户名称拼音首字母(小写)'' AFTER `customer_name`',
|
||||
'SELECT ''crm_customer.name_pinyin_abbr already exists, skip'''
|
||||
);
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -1,12 +0,0 @@
|
||||
-- 软隐藏 CRM「产品分类」侧栏菜单(能力改由产品管理弹窗维护)
|
||||
-- 菜单 id: CRM00000000000000000000000000002
|
||||
-- 幂等:可重复执行
|
||||
-- 注意:web-admin 开发环境默认 VITE_ACCESS_MODE=frontend,侧栏还依赖
|
||||
-- web-admin/src/router/modules/sqxp.ts 中该路由 meta.isHide=true,需前后端一并生效。
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `visible` = '0',
|
||||
`update_time` = NOW()
|
||||
WHERE `id` = 'CRM00000000000000000000000000002'
|
||||
AND `del_flag` = 0
|
||||
AND `visible` <> '0';
|
||||
@@ -1,82 +0,0 @@
|
||||
-- 合并 CRM「报价单/合同审批人设置」为系统管理下「报价、合同审批人设置」
|
||||
-- 1) 插入新菜单 SYS_APPROVER_SETTING
|
||||
-- 2) 软隐藏旧 CRM 菜单 CRM…0015 / CRM…0026
|
||||
-- 3) 曾拥有任一旧菜单的角色,自动挂上新菜单(幂等)
|
||||
-- 注意:web-admin 开发环境默认 VITE_ACCESS_MODE=frontend,侧栏还依赖
|
||||
-- web-admin/src/router/modules/sqxp.ts 中新路由与旧路由 isHide=true。
|
||||
|
||||
-- 新菜单:系统管理 → 报价、合同审批人设置
|
||||
INSERT INTO `sys_menu` (
|
||||
`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
|
||||
`is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
) VALUES (
|
||||
'SYS_APPROVER_SETTING',
|
||||
'报价、合同审批人设置',
|
||||
'SYSM000000000000000000000000000001',
|
||||
'C',
|
||||
'approver-setting',
|
||||
'/system/approver-setting/index',
|
||||
'system:approverSetting',
|
||||
1, '1', '1', 'shanxia2.0', 9,
|
||||
'租户级默认报价/合同审批人(合并页)',
|
||||
'system', '', NOW(), NULL, NOW(), 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`menu_name` = VALUES(`menu_name`),
|
||||
`parent_id` = VALUES(`parent_id`),
|
||||
`path` = VALUES(`path`),
|
||||
`component` = VALUES(`component`),
|
||||
`perms` = VALUES(`perms`),
|
||||
`visible` = '1',
|
||||
`status` = '1',
|
||||
`order_num` = VALUES(`order_num`),
|
||||
`remark` = VALUES(`remark`),
|
||||
`del_flag` = 0,
|
||||
`update_time` = NOW();
|
||||
|
||||
-- 软隐藏旧 CRM 菜单
|
||||
UPDATE `sys_menu`
|
||||
SET `visible` = '0',
|
||||
`update_time` = NOW()
|
||||
WHERE `id` IN (
|
||||
'CRM3000000000000000000000000015',
|
||||
'CRM3000000000000000000000000026'
|
||||
)
|
||||
AND `del_flag` = 0
|
||||
AND `visible` <> '0';
|
||||
|
||||
-- 角色菜单迁移:拥有任一旧菜单 → 挂上新菜单
|
||||
INSERT INTO `sys_role_menu` (
|
||||
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
)
|
||||
SELECT
|
||||
UPPER(REPLACE(UUID(), '-', '')),
|
||||
t.`role_id`,
|
||||
'SYS_APPROVER_SETTING',
|
||||
t.`tenant_no`,
|
||||
0,
|
||||
'migrated from quote/contract approver setting menus',
|
||||
'system',
|
||||
'',
|
||||
NOW(),
|
||||
NULL,
|
||||
NOW(),
|
||||
0
|
||||
FROM (
|
||||
SELECT DISTINCT `role_id`, `tenant_no`
|
||||
FROM `sys_role_menu`
|
||||
WHERE `menu_id` IN (
|
||||
'CRM3000000000000000000000000015',
|
||||
'CRM3000000000000000000000000026'
|
||||
)
|
||||
AND `del_flag` = 0
|
||||
) t
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_role_menu` x
|
||||
WHERE x.`role_id` = t.`role_id`
|
||||
AND x.`menu_id` = 'SYS_APPROVER_SETTING'
|
||||
AND x.`del_flag` = 0
|
||||
);
|
||||
@@ -1,53 +0,0 @@
|
||||
-- 将「线索管理」「商机管理」「公海池」从 CRM管理 挪到 系统管理
|
||||
-- 菜单 id:
|
||||
-- CRM1000000000000000000000000010 线索管理
|
||||
-- CRM2000000000000000000000000010 商机管理
|
||||
-- CRM1000000000000000000000000003 公海池
|
||||
-- 关联隐藏页(线索详情 / 商机详情)一并调整 parent_id,按钮子菜单仍挂在业务菜单下。
|
||||
-- 幂等:可重复执行
|
||||
-- 注意:web-admin 开发环境默认 VITE_ACCESS_MODE=frontend,侧栏还依赖
|
||||
-- web-admin/src/router/modules/sqxp.ts 中上述路由挂在系统管理 children 下。
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `parent_id` = 'SYSM000000000000000000000000000001',
|
||||
`order_num` = 11,
|
||||
`update_time` = NOW()
|
||||
WHERE `id` = 'CRM1000000000000000000000000010'
|
||||
AND `del_flag` = 0
|
||||
AND (
|
||||
`parent_id` <> 'SYSM000000000000000000000000000001'
|
||||
OR `order_num` <> 11
|
||||
);
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `parent_id` = 'SYSM000000000000000000000000000001',
|
||||
`order_num` = 12,
|
||||
`update_time` = NOW()
|
||||
WHERE `id` = 'CRM2000000000000000000000000010'
|
||||
AND `del_flag` = 0
|
||||
AND (
|
||||
`parent_id` <> 'SYSM000000000000000000000000000001'
|
||||
OR `order_num` <> 12
|
||||
);
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `parent_id` = 'SYSM000000000000000000000000000001',
|
||||
`order_num` = 13,
|
||||
`update_time` = NOW()
|
||||
WHERE `id` = 'CRM1000000000000000000000000003'
|
||||
AND `del_flag` = 0
|
||||
AND (
|
||||
`parent_id` <> 'SYSM000000000000000000000000000001'
|
||||
OR `order_num` <> 13
|
||||
);
|
||||
|
||||
-- 侧栏不展示的详情页:挂到系统管理下,与列表同模块
|
||||
UPDATE `sys_menu`
|
||||
SET `parent_id` = 'SYSM000000000000000000000000000001',
|
||||
`update_time` = NOW()
|
||||
WHERE `id` IN (
|
||||
'CRM1000000000000000000000000011',
|
||||
'CRM2000000000000000000000000011'
|
||||
)
|
||||
AND `del_flag` = 0
|
||||
AND `parent_id` <> 'SYSM000000000000000000000000000001';
|
||||
@@ -1,16 +0,0 @@
|
||||
-- 将「主体危化品能力」从 CRM管理 挪到 系统管理
|
||||
-- 菜单 id: CRM3000000000000000000000000040(及按钮子菜单 CRM…0041 仍挂在其下)
|
||||
-- 幂等:可重复执行
|
||||
-- 注意:web-admin 开发环境默认 VITE_ACCESS_MODE=frontend,侧栏还依赖
|
||||
-- web-admin/src/router/modules/sqxp.ts 中该路由挂在系统管理 children 下。
|
||||
|
||||
UPDATE `sys_menu`
|
||||
SET `parent_id` = 'SYSM000000000000000000000000000001',
|
||||
`order_num` = 10,
|
||||
`update_time` = NOW()
|
||||
WHERE `id` = 'CRM3000000000000000000000000040'
|
||||
AND `del_flag` = 0
|
||||
AND (
|
||||
`parent_id` <> 'SYSM000000000000000000000000000001'
|
||||
OR `order_num` <> 10
|
||||
);
|
||||
@@ -1,146 +0,0 @@
|
||||
-- 报价单/合同:审批视图拆为独立菜单
|
||||
-- 1) 插入「报价单审批」「合同审批」
|
||||
-- 2) 调整 CRM 侧栏 order_num,使审批紧挨对应管理菜单
|
||||
-- 3) 曾拥有 list 菜单的角色,幂等挂上 approve(权限仍可在角色管理中单独收回)
|
||||
-- 注意:web-admin 开发环境默认 VITE_ACCESS_MODE=frontend,侧栏还依赖
|
||||
-- web-admin/src/router/modules/sqxp.ts 中的新路由。
|
||||
|
||||
-- 报价单审批(紧挨报价单管理)
|
||||
INSERT INTO `sys_menu` (
|
||||
`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
|
||||
`is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
) VALUES (
|
||||
'CRM3000000000000000000000000016',
|
||||
'报价单审批',
|
||||
'CRM00000000000000000000000000001',
|
||||
'C',
|
||||
'quote-approval',
|
||||
'/crm/quote/approval/index',
|
||||
'crm:quote:approve',
|
||||
1, '1', '1', 'shanxia2.0', 6,
|
||||
'报价单待审批/已审批独立入口',
|
||||
'system', '', NOW(), NULL, NOW(), 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`menu_name` = VALUES(`menu_name`),
|
||||
`parent_id` = VALUES(`parent_id`),
|
||||
`path` = VALUES(`path`),
|
||||
`component` = VALUES(`component`),
|
||||
`perms` = VALUES(`perms`),
|
||||
`visible` = '1',
|
||||
`status` = '1',
|
||||
`order_num` = VALUES(`order_num`),
|
||||
`remark` = VALUES(`remark`),
|
||||
`del_flag` = 0,
|
||||
`update_time` = NOW();
|
||||
|
||||
-- 合同审批(紧挨合同管理;合同管理 order_num 同步调整为 7)
|
||||
INSERT INTO `sys_menu` (
|
||||
`id`, `menu_name`, `parent_id`, `menu_type`, `path`, `component`, `perms`,
|
||||
`is_frame`, `visible`, `status`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
) VALUES (
|
||||
'CRM3000000000000000000000000021',
|
||||
'合同审批',
|
||||
'CRM00000000000000000000000000001',
|
||||
'C',
|
||||
'contract-approval',
|
||||
'/crm/contract/approval/index',
|
||||
'crm:contract:approve',
|
||||
1, '1', '1', 'shanxia2.0', 8,
|
||||
'合同待审批/已审批独立入口',
|
||||
'system', '', NOW(), NULL, NOW(), 0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`menu_name` = VALUES(`menu_name`),
|
||||
`parent_id` = VALUES(`parent_id`),
|
||||
`path` = VALUES(`path`),
|
||||
`component` = VALUES(`component`),
|
||||
`perms` = VALUES(`perms`),
|
||||
`visible` = '1',
|
||||
`status` = '1',
|
||||
`order_num` = VALUES(`order_num`),
|
||||
`remark` = VALUES(`remark`),
|
||||
`del_flag` = 0,
|
||||
`update_time` = NOW();
|
||||
|
||||
-- 侧栏顺序:报价管理 5、报价审批 6、合同管理 7、合同审批 8、调价函 9、客户 10、主体危化品 11
|
||||
UPDATE `sys_menu` SET `order_num` = 5, `update_time` = NOW()
|
||||
WHERE `id` = 'CRM3000000000000000000000000010' AND `del_flag` = 0;
|
||||
|
||||
UPDATE `sys_menu` SET `order_num` = 7, `update_time` = NOW()
|
||||
WHERE `id` = 'CRM3000000000000000000000000020' AND `del_flag` = 0;
|
||||
|
||||
UPDATE `sys_menu` SET `order_num` = 9, `update_time` = NOW()
|
||||
WHERE `id` = 'CRM3000000000000000000000000030' AND `del_flag` = 0;
|
||||
|
||||
UPDATE `sys_menu` SET `order_num` = 10, `update_time` = NOW()
|
||||
WHERE `id` = 'CRM1000000000000000000000000002' AND `del_flag` = 0;
|
||||
|
||||
UPDATE `sys_menu` SET `order_num` = 11, `update_time` = NOW()
|
||||
WHERE `id` = 'CRM3000000000000000000000000040' AND `del_flag` = 0;
|
||||
|
||||
-- 角色:拥有报价单管理 → 挂上报价单审批
|
||||
INSERT INTO `sys_role_menu` (
|
||||
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
)
|
||||
SELECT
|
||||
CONCAT('RMQ16_', UPPER(MD5(CONCAT(t.`role_id`, '|CRM3000000000000000000000000016')))),
|
||||
t.`role_id`,
|
||||
'CRM3000000000000000000000000016',
|
||||
t.`tenant_no`,
|
||||
0,
|
||||
'migrated from crm:quote:list for quote approval menu',
|
||||
'system',
|
||||
'',
|
||||
NOW(),
|
||||
NULL,
|
||||
NOW(),
|
||||
0
|
||||
FROM (
|
||||
SELECT DISTINCT `role_id`, `tenant_no`
|
||||
FROM `sys_role_menu`
|
||||
WHERE `menu_id` = 'CRM3000000000000000000000000010'
|
||||
AND `del_flag` = 0
|
||||
) t
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_role_menu` x
|
||||
WHERE x.`role_id` = t.`role_id`
|
||||
AND x.`menu_id` = 'CRM3000000000000000000000000016'
|
||||
AND x.`del_flag` = 0
|
||||
);
|
||||
|
||||
-- 角色:拥有合同管理 → 挂上合同审批
|
||||
INSERT INTO `sys_role_menu` (
|
||||
`id`, `role_id`, `menu_id`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
)
|
||||
SELECT
|
||||
CONCAT('RMC21_', UPPER(MD5(CONCAT(t.`role_id`, '|CRM3000000000000000000000000021')))),
|
||||
t.`role_id`,
|
||||
'CRM3000000000000000000000000021',
|
||||
t.`tenant_no`,
|
||||
0,
|
||||
'migrated from crm:contract:list for contract approval menu',
|
||||
'system',
|
||||
'',
|
||||
NOW(),
|
||||
NULL,
|
||||
NOW(),
|
||||
0
|
||||
FROM (
|
||||
SELECT DISTINCT `role_id`, `tenant_no`
|
||||
FROM `sys_role_menu`
|
||||
WHERE `menu_id` = 'CRM3000000000000000000000000020'
|
||||
AND `del_flag` = 0
|
||||
) t
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_role_menu` x
|
||||
WHERE x.`role_id` = t.`role_id`
|
||||
AND x.`menu_id` = 'CRM3000000000000000000000000021'
|
||||
AND x.`del_flag` = 0
|
||||
);
|
||||
@@ -1,20 +0,0 @@
|
||||
-- 用户菜单收藏(门户首页启动器)
|
||||
-- 幂等:表已存在则跳过
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sys_user_menu_favorite` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键ID',
|
||||
`user_id` varchar(64) NOT NULL COMMENT '用户ID',
|
||||
`menu_path` varchar(512) NOT NULL COMMENT '菜单路由 path',
|
||||
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
|
||||
`order_num` int(11) DEFAULT NULL COMMENT '排序号(越小越靠前)',
|
||||
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
|
||||
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人id',
|
||||
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人id',
|
||||
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||
`del_flag` smallint(6) NOT NULL DEFAULT '0' COMMENT '删除标记 0正常 1已删除',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_fav_user_tenant` (`user_id`, `tenant_no`, `del_flag`),
|
||||
KEY `idx_fav_path` (`menu_path`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户菜单收藏';
|
||||
+23926
-1907
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 50736 (5.7.36)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 03/08/2026 21:30:04
|
||||
Date: 09/08/2026 14:56:05
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,278 @@
|
||||
# bx-mobile 适配 shanxia2.0 — 设计文档
|
||||
|
||||
> **日期**: 2026-08-09
|
||||
> **状态**: 待用户审阅
|
||||
> **仓库**: shanxia2.0(`bx-mobile/` + 共用 `backend/`)
|
||||
> **权威对照**: `docs/sql/shanxia2.0.sql`、`docs/business-inventory/03-报销业务明细.md`、`docs/superpowers/specs/2026-07-25-invoice-wallet-reimburse-design.md`、`web-admin/src/views/bx/`、`web-admin/src/api/bx/index.ts`
|
||||
|
||||
## 背景
|
||||
|
||||
原报销移动端 `bx-mobile` 基于独立报销库模型(`docs/sql/sx.sql`:含 `bx_user` / `bx_role` / `bx_menu*`)。山峡一体化后,报销已迁入 shanxia2.0:统一门户鉴权、`bx_*` 业务表对齐门户公共字段,并新增发票夹额度能力。Web 管理端(`web-admin`)已对接新后端;`bx-mobile` 尚未迁入。
|
||||
|
||||
客户要求:
|
||||
|
||||
1. 基于 `shanxia2.0.sql` 改造 `bx-mobile`,对接同一 `backend`。
|
||||
2. **保持现有 Vant H5 交互与 UI 模式**(布局不要求与 PC 一致)。
|
||||
3. **约定范围内功能与 Web 报销管理一致**(同一业务规则与能力)。
|
||||
|
||||
## 已确认决策
|
||||
|
||||
| # | 决策 |
|
||||
|---|------|
|
||||
| D1 | 继续使用现有 `bx-mobile`(Vant H5),不迁入 `miniprogram` |
|
||||
| D2 | 对接 shanxia2.0 `backend`,与 web-admin 共用 |
|
||||
| D3 | 改造策略采用「适配层渐进改造」:保留页面壳,改 API/鉴权/字段与能力缺口 |
|
||||
| D4 | 去掉用户 / 角色 / 菜单管理(走门户系统管理) |
|
||||
| D5 | 发票夹完整对齐 PC:我的发票夹 + 报销选票/余额;有权限含发票夹管理 |
|
||||
| D6 | 一并对齐:撤回、代申请、报销日期/标题序号、审批历史 |
|
||||
| D7 | 登录与权限完全门户化;入口按 Web「报销管理」菜单的 `menuCode` 映射 H5 |
|
||||
| D8 | H5 配置类仅:费用项目 + 备用金/报销工作流 |
|
||||
| D9 | 分三阶段上线:P1 鉴权+核心单据 → P2 发票夹闭环 → P3 撤回/代申请/标题/审批历史/配置 |
|
||||
| D10 | 布局不检;功能一致可验收(除 D4 明确排除项) |
|
||||
|
||||
## 方案选择
|
||||
|
||||
**采用方案 1:适配层渐进改造(推荐已确认)**
|
||||
|
||||
- 保留现有 Vant 页面与交互习惯。
|
||||
- 重写 HTTP 客户端、鉴权 store、菜单→路由映射。
|
||||
- 业务规则以 backend + 既有 PC/设计文档为准,不复制 Element 组件。
|
||||
|
||||
不采用:抽大型共享包优先(拖慢 P1)、按 PC 逐页重写 UI(违背保持现状交互)。
|
||||
|
||||
---
|
||||
|
||||
## 一、架构与阶段边界
|
||||
|
||||
### 1.1 目标形态
|
||||
|
||||
```
|
||||
┌─────────────┐ JWT + /api/* ┌──────────────────┐
|
||||
│ bx-mobile │ ───────────────────▶ │ shanxia2.0 │
|
||||
│ (Vant H5) │ 与 web-admin 同源 │ backend │
|
||||
└─────────────┘ │ /web/auth/* │
|
||||
▲ │ /api/advances… │
|
||||
│ menuCode → H5 route │ /api/invoices… │
|
||||
│ └──────────────────┘
|
||||
门户 Web 菜单「报销管理」叶子
|
||||
(权限过滤后映射;无独立 H5 菜单根)
|
||||
```
|
||||
|
||||
- **后端**:不新增移动专用业务服务;复用 `backend/app/api/bx/*`。
|
||||
- **登录**:门户 `/web/auth/*`(含 RSA),token 与 web-admin 同体系。
|
||||
- **业务 API**:bx 协议 `{ code: 0, msg, data }`(与 `web-admin` 的 `bxRequest` 一致)。
|
||||
- **UI**:不改视觉体系;只改 API、鉴权、字段与能力缺口。
|
||||
- **不做**:用户 / 角色 / 菜单管理页。
|
||||
|
||||
### 1.2 菜单映射原则
|
||||
|
||||
| Web 叶子(示例) | menuCode(示例) | H5 路由 | 阶段 |
|
||||
|------------------|------------------|---------|------|
|
||||
| 备用金申请 | `bx:advanceApply:list` | `/advance/list`、apply | P1 |
|
||||
| 备用金审批 | `bx:advanceApprove:list` | `/advance/approve` 或审批聚合 | P1 |
|
||||
| 备用金发放 | `bx:advanceIssue:list` | `/advance/issue` | P1 |
|
||||
| 报销申请 | `bx:reimburseApply:list` | `/reimburse/list`、apply | P1(发票交互 P2) |
|
||||
| 报销审批 | `bx:reimburseApprove:list` | `/reimburse/approve` 或审批聚合 | P1 |
|
||||
| 支付发放冲抵 | `bx:payment:list` | `/payment` | P1 |
|
||||
| 我的申请单 / 待我审批 / 全部 | `bx:viewMine:list` 等 | `/mine`、`/approval`、`/all` | P1 |
|
||||
| 我的发票夹 / 发票夹管理 | `bx:invoiceWallet:mine` / `admin` | 新增发票夹页 | P2 |
|
||||
| 费用项目 / 工作流 | `bx:expenseItem:list` 等 | `admin/expenses`、`wf-*` | P3 |
|
||||
|
||||
实施时以 `web-admin` 路由 `meta.menuCode` 与库内 `sys_menu` 为准建立完整映射表。无权限不展示;未到阶段的入口即使有权限也**不展示**(避免半成品)。
|
||||
|
||||
### 1.3 三阶段验收目标
|
||||
|
||||
| 阶段 | 可验收结果 |
|
||||
|------|------------|
|
||||
| **P1** | 门户登录;首页按菜单显隐;备用金/报销/审批/发放/支付/视图中心可走通(报销发票可暂用旧附件过渡) |
|
||||
| **P2** | 我的发票夹 + 发票夹管理;报销改为选票关联 + 余额校验;提交扣/驳回退;申请单不再本地传发票 |
|
||||
| **P3** | 撤回、代申请、报销日期/标题序号、审批历史;费用项目 + 两套工作流配置 |
|
||||
|
||||
### 1.4 工程落点(bx-mobile)
|
||||
|
||||
- `vite` 代理:原 `8011` → shanxia2.0 backend(与本地 web-admin 同源)。
|
||||
- 重写:`api/client.ts`、`stores/auth.ts`、菜单→路由映射模块。
|
||||
- 删除或停用:`admin/users|roles|menus` 路由与入口。
|
||||
- 新增(P2):发票夹 API 与页面。
|
||||
|
||||
---
|
||||
|
||||
## 二、鉴权 / 菜单 / 路由守卫
|
||||
|
||||
### 2.1 登录与会话
|
||||
|
||||
不再使用旧 `/auth/login`、`/auth/me`、`/menus/mine`。
|
||||
|
||||
| 步骤 | 接口 |
|
||||
|------|------|
|
||||
| 取公钥 | `GET /api/web/auth/login-rsa-public-key` |
|
||||
| 登录 | `POST /api/web/auth/login`(RSA 加密载荷) |
|
||||
| 用户信息 | `GET /api/web/auth/current-user`(`id` 为 UUID 字符串) |
|
||||
| 权限码 | `GET /api/web/auth/menu-codes` |
|
||||
| 刷新 | `POST /api/web/auth/refresh-token` |
|
||||
| 登出 | `POST /api/web/auth/logout` |
|
||||
|
||||
本地存储:`accessToken` + `refreshToken`;可读旧 `token` 一次后清理。
|
||||
|
||||
`auth` store 改为门户模型:`userId: string`、`roles[]`、`menuCodes`、`isSuperAdmin`;**删除** `ADMIN` / `FINANCE` / `GENERAL_MANAGER` 等旧 `roleCode` 硬编码。
|
||||
|
||||
### 2.2 HTTP 客户端
|
||||
|
||||
1. **portalClient**:登录/用户/菜单码;响应解析对齐 web-admin 门户 `request`。
|
||||
2. **bxClient**:业务 API;`{ code:0 }`;集合根 URL 补尾斜杠;`FormData` 不强制 JSON Content-Type。
|
||||
|
||||
API 加解密:portal 请求跟随 web-admin 加密策略;bx 业务请求与现网 PC `bxRequest` 保持一致(当前未套加密信封则 H5 同期不加,避免双端不一致)。
|
||||
|
||||
### 2.3 菜单 → 首页入口
|
||||
|
||||
1. 内置「报销 H5 入口目录」:`menuCode`、标题、图标、H5 `path`、所属阶段。
|
||||
2. 登录后拉 `menu-codes`;`isSuperAdmin || all` 显示全部**已实现且已到阶段**的入口,否则按 `menuCodes` 过滤。
|
||||
3. 权限:`can(code) => isSuperAdmin || all || menuCodes.has(code)`。
|
||||
|
||||
### 2.4 路由守卫
|
||||
|
||||
```ts
|
||||
meta: {
|
||||
menuCodes?: string[] // 任一命中可进入;空 = 仅需登录
|
||||
}
|
||||
```
|
||||
|
||||
- 未登录 → `/login`
|
||||
- 已登录但无权限 → 回首页并提示
|
||||
- 按钮级权限与 PC 的 `bx:*` 码对齐
|
||||
|
||||
### 2.5 明确删除
|
||||
|
||||
- 路由与页:`/admin/users`、`/admin/roles`、`/admin/menus`
|
||||
- API:`authApi.register`、旧 `userApi` / `roleApi` / `menuApi`(bx 自建)
|
||||
- `meta.roles` 旧角色码守卫
|
||||
|
||||
---
|
||||
|
||||
## 三、页面 / 能力与数据流
|
||||
|
||||
### 3.1 总则
|
||||
|
||||
- 规则源:shanxia2.0 backend + PC 已落地行为。
|
||||
- 布局:沿用现有 Vant;不要求与 PC 像素一致。
|
||||
- 业务主键:**字符串 UUID**。
|
||||
- 功能一致范围:Web「报销管理」下业务能力(含 D5/D6/D8),排除 D4。
|
||||
|
||||
### 3.2 分阶段能力矩阵
|
||||
|
||||
| 能力 | H5 落点 | P1 | P2 | P3 |
|
||||
|------|---------|----|----|----|
|
||||
| 门户登录 / menuCodes 入口 | login + home | ✅ | | |
|
||||
| 备用金申请 / 审批 / 发放 | advance/* | ✅ | | |
|
||||
| 报销申请(新 API;发票过渡附件) | reimburse/apply | ✅ 过渡 | | |
|
||||
| 报销审批 / 支付冲抵 | approve, payment | ✅ | 展示关联发票 | |
|
||||
| 视图:我的 / 待办 / 全部 | mine, approval, all | ✅ | | |
|
||||
| 我的发票夹 / 发票夹管理 | 新页 | | ✅ | |
|
||||
| 报销选票 + 余额校验 + 提交扣额 | apply | | ✅ | |
|
||||
| 驳回退额(展示) | approve / detail | | ✅ | |
|
||||
| 撤回 / 代申请 / 日期标题 / 审批历史 | apply, detail | | | ✅ |
|
||||
| 费用项目 / 工作流配置 | admin/expenses, wf-* | | | ✅ |
|
||||
|
||||
**P1→P2**:P2 起禁止报销单内本地上传发票,改为发票夹流程。
|
||||
|
||||
### 3.3 核心数据流
|
||||
|
||||
**备用金(P1)**
|
||||
草稿 → submit → 多级审批 → issue →(可选)报销冲抵。
|
||||
|
||||
**报销目标态(P2 起)**
|
||||
|
||||
```
|
||||
发票夹上传(credit) → 填单(可选 invoiceIds,草稿不扣)
|
||||
→ submit(余额≥合计则 debit) → 审批
|
||||
→ 驳回 / 撤回(P3) → credit_release
|
||||
→ 支付/冲抵(不改额度公式)
|
||||
```
|
||||
|
||||
发票夹 API 与 PC 相同:`/invoice-wallets`、`/invoices`、`/invoice-ledgers`。
|
||||
|
||||
### 3.4 页面改造要点
|
||||
|
||||
**报销申请**
|
||||
|
||||
| 项 | P1 | P2+ |
|
||||
|----|----|-----|
|
||||
| 明细 / 费用树 | 新 UUID API | 同左 |
|
||||
| 发票区 | 暂可本地附件 | 选票 + 余额提示;可选关联 |
|
||||
| 提交 | `submit(id)` | body 含 `invoiceIds` / `invoiceLinks` |
|
||||
| 申请人 / 报销日期 | 可先固定本人 | P3:可改选 + 日期驱动标题 |
|
||||
|
||||
**详情 / 审批 / 列表**:P2 起区分普通附件与关联发票;P3 接 `approval-history` 与撤回。
|
||||
|
||||
**发票夹页(新建,Vant)**:我的(三数字 + 上传 + 列表 + 流水);管理(员工汇总 → 代传/删票)。
|
||||
|
||||
**配置页(P3)**:复用现有费用项/工作流页交互,改 API 与权限。
|
||||
|
||||
### 3.5 API 面
|
||||
|
||||
- 保留改造:`expenseItem`、`workflow`、`advance`、`reimburse`、`payment`、`attachment`
|
||||
- 新增:`invoiceApi`、`invoiceWalletApi`
|
||||
- 删除:旧 `user` / `role` / `menu` / `register`
|
||||
- `reimburseApi` 补齐:`withdraw`、带参 `generateTitle`、`getApprovalHistory`、`submit` 带 body
|
||||
|
||||
### 3.6 边界
|
||||
|
||||
- 余额不足、删票失败:展示后端 `msg`
|
||||
- 已支付单作废退额度:不做
|
||||
- OCR / 验真 / 按票核销:不做
|
||||
|
||||
---
|
||||
|
||||
## 四、错误处理、验收、风险与非目标
|
||||
|
||||
### 4.1 错误处理
|
||||
|
||||
| 场景 | 行为 |
|
||||
|------|------|
|
||||
| 401 | 尝试 refresh;失败清会话回登录 |
|
||||
| 403 / 无 menuCode | 提示无权限,回首页 |
|
||||
| bx `code !== 0` | toast `msg` |
|
||||
| 网络错误 | 通用提示;提交防重复 |
|
||||
| 双 toast | 沿用 `BizError` 约定 |
|
||||
|
||||
前端余额展示为弱提示;提交校验以服务端为准。
|
||||
|
||||
### 4.2 验收清单
|
||||
|
||||
**P1**:门户登录刷新登出;入口按权限;备用金与报销(过渡附件)闭环;视图新 API;无用户角色菜单入口。
|
||||
|
||||
**P2**:发票夹我的+管理;报销无本地发票上传;余额不足不可提交;驳回退余额;详情可见关联发票。
|
||||
|
||||
**P3**:撤回、代申请、日期/标题、审批历史;费用项目与两套工作流可配置。
|
||||
|
||||
对照:同一账号在 web-admin 与 H5 对同一单据,状态与额度结果一致。
|
||||
|
||||
### 4.3 风险与对策
|
||||
|
||||
| 风险 | 对策 |
|
||||
|------|------|
|
||||
| P1→P2 旧草稿含本地发票 | 与 PC 对齐清理/引导策略;上线说明 |
|
||||
| menuCode 映射遗漏 | 与 Web 叶子一一核对映射表 |
|
||||
| 残留 number id | 全量 string;页面联调覆盖 |
|
||||
| 登录/环境与 PC 不一致 | 同 RSA、同 backend、同 proxy 目标 |
|
||||
| 范围膨胀 | 见非目标 |
|
||||
|
||||
### 4.4 非目标
|
||||
|
||||
- 迁入小程序 / 重做视觉
|
||||
- 用户、角色、菜单管理
|
||||
- 发票 OCR、验真、按票核销
|
||||
- 已支付单作废退额度
|
||||
- 历史独立 bx 库迁移方案(另案)
|
||||
- 无必要的移动专用后端 API
|
||||
|
||||
### 4.5 文档后续
|
||||
|
||||
- 实施计划:本设计审阅通过后,用 writing-plans 拆 P1/P2/P3 任务
|
||||
- 实施中可更新 `docs/business-inventory/03-报销业务明细.md` 中「bx-mobile 未迁入」表述
|
||||
|
||||
---
|
||||
|
||||
## 成功标准
|
||||
|
||||
在 D4 排除项之外,Web「报销管理」业务能力在 `bx-mobile` 上可用,且与 PC **业务结果一致**(状态机、发票额度、权限可见性);交互保持现有 Vant 模式。
|
||||
Reference in new issue
Block a user