feat(bx): invoice wallet UI and reimburse apply invoice select
Add mine/admin wallet pages, select dialog, routes/icons, and switch apply form from local invoice upload to optional wallet association with balance gate; approve detail shows linked invoices. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6092b685de
commit
dadf903bff
8 files changed
+1000
-58
No files matched your search
@@ -171,14 +171,20 @@ export const reimburseApi = {
|
||||
getApprovalHistory(id: BxId) {
|
||||
return bxRequest.get(`/reimburses/${id}/approval-history`)
|
||||
},
|
||||
/** body 可含 invoiceIds: string[] 关联发票夹发票(草稿保存时同步关联) */
|
||||
create(data: Record<string, any>) {
|
||||
return bxRequest.post('/reimburses/', data)
|
||||
},
|
||||
/** body 可含 invoiceIds: string[] 关联发票夹发票(草稿保存时同步关联) */
|
||||
update(id: BxId, data: Record<string, any>) {
|
||||
return bxRequest.put(`/reimburses/${id}`, data)
|
||||
},
|
||||
submit(id: BxId) {
|
||||
return bxRequest.post(`/reimburses/${id}/submit`)
|
||||
/** body 可含 invoiceIds: string[] 提交时同步关联并扣减发票余额 */
|
||||
submit(id: BxId, data?: Record<string, any>) {
|
||||
return bxRequest.post(`/reimburses/${id}/submit`, data)
|
||||
},
|
||||
withdraw(id: BxId) {
|
||||
return bxRequest.post(`/reimburses/${id}/withdraw`)
|
||||
},
|
||||
approve(id: BxId, data: { approvalOpinion?: string }) {
|
||||
return bxRequest.post(`/reimburses/${id}/approve`, data)
|
||||
@@ -276,6 +282,33 @@ export const paymentApi = {
|
||||
}
|
||||
}
|
||||
|
||||
export const invoiceWalletApi = {
|
||||
mineSummary() {
|
||||
return bxRequest.get('/invoice-wallets/mine/summary')
|
||||
},
|
||||
list(params: { page: number; pageSize: number; keyword?: string }) {
|
||||
return bxRequest.get('/invoice-wallets', { params })
|
||||
}
|
||||
}
|
||||
|
||||
export const invoiceApi = {
|
||||
list(params: { page?: number; pageSize?: number; userId?: BxId }) {
|
||||
return bxRequest.get('/invoices', { params })
|
||||
},
|
||||
/** FormData 字段:file, amount, remark?, targetUserId?(管理员代传) */
|
||||
upload(formData: FormData) {
|
||||
return bxRequest.post('/invoices', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
},
|
||||
delete(id: BxId) {
|
||||
return bxRequest.delete(`/invoices/${id}`)
|
||||
},
|
||||
ledgers(params?: { userId?: BxId }) {
|
||||
return bxRequest.get('/invoice-ledgers', { params })
|
||||
}
|
||||
}
|
||||
|
||||
export const attachmentApi = {
|
||||
upload(file: File, bizType: string = '', bizId: BxId = 0) {
|
||||
const formData = new FormData()
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
title="从发票夹选择"
|
||||
width="720px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
@open="loadList"
|
||||
>
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
v-loading="loading"
|
||||
class="list-table"
|
||||
:data="rows"
|
||||
stripe
|
||||
row-key="id"
|
||||
max-height="420"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" min-width="48" />
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fileName" label="附件" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fileName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="上传时间" min-width="160" />
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="visible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" @click="confirm">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from 'vue'
|
||||
import { Close, Check } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { invoiceApi } from '@/api/bx'
|
||||
import { formatMoneyYuan } from '@/utils/bx/format'
|
||||
import { pickBxPageResult } from '@/utils/http/bx'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
selectedIds?: string[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', v: boolean): void
|
||||
(e: 'confirm', rows: any[]): void
|
||||
}>()
|
||||
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const rows = ref<any[]>([])
|
||||
const selected = ref<any[]>([])
|
||||
const tableRef = ref<any>(null)
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(v) => {
|
||||
visible.value = v
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(visible, (v) => {
|
||||
emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await invoiceApi.list({ page: 1, pageSize: 200 })
|
||||
const page = pickBxPageResult<any>(res)
|
||||
rows.value = page.list
|
||||
await nextTick()
|
||||
const idSet = new Set((props.selectedIds || []).map(String))
|
||||
selected.value = []
|
||||
rows.value.forEach((row) => {
|
||||
if (idSet.has(String(row.id))) {
|
||||
tableRef.value?.toggleRowSelection?.(row, true)
|
||||
}
|
||||
})
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载发票失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectionChange(list: any[]) {
|
||||
selected.value = list
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
emit('confirm', selected.value.slice())
|
||||
visible.value = false
|
||||
}
|
||||
</script>
|
||||
@@ -166,6 +166,28 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:payment:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000020',
|
||||
name: 'BxInvoiceWalletAdmin',
|
||||
path: 'invoice-wallet-admin',
|
||||
component: '/bx/invoice-wallet/admin/index',
|
||||
meta: {
|
||||
title: '发票夹管理',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:invoiceWallet:admin'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'BX00000000000000000000000000021',
|
||||
name: 'BxInvoiceWalletMine',
|
||||
path: 'invoice-wallet-mine',
|
||||
component: '/bx/invoice-wallet/mine/index',
|
||||
meta: {
|
||||
title: '我的发票夹',
|
||||
keepAlive: true,
|
||||
menuCode: 'bx:invoiceWallet:mine'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -99,6 +99,8 @@ export const SIDEBAR_MENU_ICON_BY_CODE: Record<string, string> = {
|
||||
'bx:reimburseApply:list': 'ri:file-edit-line',
|
||||
'bx:reimburseApprove:list': 'ri:checkbox-circle-line',
|
||||
'bx:payment:list': 'ri:bank-card-line',
|
||||
'bx:invoiceWallet:admin': 'ri:folder-shared-line',
|
||||
'bx:invoiceWallet:mine': 'ri:wallet-3-line',
|
||||
'bx:viewMine:list': 'ri:user-line',
|
||||
'bx:viewTodo:list': 'ri:time-line',
|
||||
'bx:viewAll:list': 'ri:file-list-3-line',
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
<!-- 发票夹管理(管理员) -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">发票夹管理</h2>
|
||||
</div>
|
||||
|
||||
<div class="filter-block">
|
||||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||||
<div class="filter-grid">
|
||||
<el-form-item label="员工姓名">
|
||||
<el-input
|
||||
v-model="filterForm.keyword"
|
||||
placeholder="请输入员工姓名"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<div class="filter-actions-start" />
|
||||
<div class="filter-actions-end">
|
||||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||||
<el-icon><RefreshLeft /></el-icon>重置
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||||
<el-icon><Search /></el-icon>搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table v-loading="loading" class="list-table" :data="rows" stripe>
|
||||
<el-table-column prop="ownerUserName" label="员工" min-width="120" />
|
||||
<el-table-column prop="totalAmount" label="总额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.totalAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="usedAmount" label="已报销占用(元)" min-width="140" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.usedAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="balance" label="余额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.balance) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="invoiceCount" label="发票张数" min-width="100" align="center" />
|
||||
<el-table-column label="操作" fixed="right" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="openDetail(row)">
|
||||
<el-icon><View /></el-icon>查看
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pagination list-pager-bar">
|
||||
<el-pagination
|
||||
v-model:current-page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
@size-change="handleSearch"
|
||||
@current-change="loadList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<el-drawer v-model="detailVisible" size="720px" :title="`发票夹 · ${current?.ownerUserName || ''}`">
|
||||
<div v-if="current" class="detail-wrap">
|
||||
<div class="wallet-summary">
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">总额</div>
|
||||
<div class="wallet-summary-value">{{ formatMoneyYuan(current.totalAmount) }}</div>
|
||||
</div>
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">已占用</div>
|
||||
<div class="wallet-summary-value">{{ formatMoneyYuan(current.usedAmount) }}</div>
|
||||
</div>
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">余额</div>
|
||||
<div class="wallet-summary-value is-primary">{{ formatMoneyYuan(current.balance) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar-row" style="margin-bottom: 12px">
|
||||
<el-button class="btn-main" type="primary" @click="openUpload">
|
||||
<el-icon><Upload /></el-icon>代传发票
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="detailLoading" @click="reloadDetail">
|
||||
<el-icon><Refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<h4 class="section-title">发票列表</h4>
|
||||
<el-table v-loading="detailLoading" class="list-table" :data="invoiceRows" stripe>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="110" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fileName" label="附件" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="时间" min-width="160" />
|
||||
<el-table-column label="操作" fixed="right" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button type="danger" link :loading="loadingMap[`del_${row.id}`]" @click="handleDelete(row)">
|
||||
<el-icon><Delete /></el-icon>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<h4 class="section-title">额度流水</h4>
|
||||
<el-table v-loading="detailLoading" class="list-table" :data="ledgerRows" stripe>
|
||||
<el-table-column prop="createTime" label="时间" min-width="160" />
|
||||
<el-table-column prop="entryType" label="类型" min-width="130">
|
||||
<template #default="{ row }">{{ ledgerTypeLabel(row.entryType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="110" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog
|
||||
v-model="uploadVisible"
|
||||
title="代传发票"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="员工">
|
||||
<el-input :model-value="current?.ownerUserName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="发票金额(元)" required>
|
||||
<el-input-number
|
||||
v-model="uploadForm.amount"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
:step="100"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发票文件" required>
|
||||
<input ref="fileInputRef" type="file" @change="onFileChange" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="uploadForm.remark" type="textarea" :rows="3" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="uploadVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.upload" @click="submitUpload">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
Search,
|
||||
RefreshLeft,
|
||||
View,
|
||||
Upload,
|
||||
Refresh,
|
||||
Delete,
|
||||
Close,
|
||||
Check
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { invoiceApi, invoiceWalletApi } from '@/api/bx'
|
||||
import { formatMoneyYuan } from '@/utils/bx/format'
|
||||
import { pickBxList, pickBxPageResult } from '@/utils/http/bx'
|
||||
|
||||
const loading = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const rows = ref<any[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const filterForm = reactive({ keyword: '' })
|
||||
const detailVisible = ref(false)
|
||||
const current = ref<any>(null)
|
||||
const invoiceRows = ref<any[]>([])
|
||||
const ledgerRows = ref<any[]>([])
|
||||
const uploadVisible = ref(false)
|
||||
const uploadForm = reactive({ amount: undefined as number | undefined, remark: '' })
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const loadingMap = reactive<Record<string, boolean>>({ upload: false })
|
||||
|
||||
function ledgerTypeLabel(t: string) {
|
||||
const map: Record<string, string> = {
|
||||
credit_upload: '上传入账',
|
||||
debit_delete: '删除冲减',
|
||||
debit_reimburse: '报销占用',
|
||||
credit_release: '驳回/撤回退回'
|
||||
}
|
||||
return map[t] || t
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await invoiceWalletApi.list({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
keyword: filterForm.keyword || undefined
|
||||
})
|
||||
const pageData = pickBxPageResult(res)
|
||||
rows.value = pageData.list
|
||||
total.value = pageData.total
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
page.value = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
filterForm.keyword = ''
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
async function openDetail(row: any) {
|
||||
current.value = { ...row }
|
||||
detailVisible.value = true
|
||||
await reloadDetail()
|
||||
}
|
||||
|
||||
async function reloadDetail() {
|
||||
if (!current.value?.ownerUserId) return
|
||||
detailLoading.value = true
|
||||
try {
|
||||
const [invRes, ledRes, listRes]: any[] = await Promise.all([
|
||||
invoiceApi.list({ page: 1, pageSize: 200, userId: current.value.ownerUserId }),
|
||||
invoiceApi.ledgers({ userId: current.value.ownerUserId }),
|
||||
invoiceWalletApi.list({ page: 1, pageSize: 100, keyword: current.value.ownerUserName })
|
||||
])
|
||||
invoiceRows.value = pickBxPageResult(invRes).list
|
||||
ledgerRows.value = pickBxList(ledRes)
|
||||
const refreshed = pickBxPageResult(listRes).list.find(
|
||||
(r: any) => String(r.ownerUserId) === String(current.value.ownerUserId)
|
||||
)
|
||||
if (refreshed) current.value = refreshed
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '加载详情失败')
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openUpload() {
|
||||
uploadForm.amount = undefined
|
||||
uploadForm.remark = ''
|
||||
selectedFile.value = null
|
||||
if (fileInputRef.value) fileInputRef.value.value = ''
|
||||
uploadVisible.value = true
|
||||
}
|
||||
|
||||
function onFileChange(e: Event) {
|
||||
const input = e.target as HTMLInputElement
|
||||
selectedFile.value = input.files?.[0] || null
|
||||
}
|
||||
|
||||
async function submitUpload() {
|
||||
if (!current.value?.ownerUserId) return
|
||||
if (!uploadForm.amount || Number(uploadForm.amount) <= 0) {
|
||||
ElMessage.warning('请填写发票金额')
|
||||
return
|
||||
}
|
||||
if (!selectedFile.value) {
|
||||
ElMessage.warning('请选择发票文件')
|
||||
return
|
||||
}
|
||||
loadingMap.upload = true
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', selectedFile.value)
|
||||
fd.append('amount', String(uploadForm.amount))
|
||||
fd.append('targetUserId', String(current.value.ownerUserId))
|
||||
if (uploadForm.remark) fd.append('remark', uploadForm.remark)
|
||||
await invoiceApi.upload(fd)
|
||||
ElMessage.success('上传成功')
|
||||
uploadVisible.value = false
|
||||
await reloadDetail()
|
||||
await loadList()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '上传失败')
|
||||
} finally {
|
||||
loadingMap.upload = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定删除该发票(金额 ${formatMoneyYuan(row.amount)} 元)?将冲减员工发票总额。`,
|
||||
'删除确认',
|
||||
{ type: 'warning', confirmButtonText: '确定删除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
loadingMap[`del_${row.id}`] = true
|
||||
try {
|
||||
await invoiceApi.delete(row.id)
|
||||
ElMessage.success('已删除')
|
||||
await reloadDetail()
|
||||
await loadList()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '删除失败')
|
||||
} finally {
|
||||
loadingMap[`del_${row.id}`] = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wallet-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.wallet-summary-item {
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--el-border-color-lighter, #d9e8e2);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.wallet-summary-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary, #64748b);
|
||||
}
|
||||
|
||||
.wallet-summary-value {
|
||||
margin-top: 4px;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
|
||||
&.is-primary {
|
||||
color: var(--el-color-primary, #10b981);
|
||||
}
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 16px 0 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.list-toolbar-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,279 @@
|
||||
<!-- 我的发票夹 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
<div class="panel-top">
|
||||
<h2 class="title-bar-heading">我的发票夹</h2>
|
||||
</div>
|
||||
|
||||
<div class="wallet-summary">
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">发票总额(元)</div>
|
||||
<div class="wallet-summary-value">{{ formatMoneyYuan(summary.totalAmount) }}</div>
|
||||
</div>
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">已报销占用(元)</div>
|
||||
<div class="wallet-summary-value">{{ formatMoneyYuan(summary.usedAmount) }}</div>
|
||||
</div>
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">可用余额(元)</div>
|
||||
<div class="wallet-summary-value is-primary">{{ formatMoneyYuan(summary.balance) }}</div>
|
||||
</div>
|
||||
<div class="wallet-summary-item">
|
||||
<div class="wallet-summary-label">发票张数</div>
|
||||
<div class="wallet-summary-value">{{ summary.invoiceCount ?? 0 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="list-toolbar-row">
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.upload" @click="openUpload">
|
||||
<el-icon><Upload /></el-icon>上传发票
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" :loading="loading" @click="reloadAll">
|
||||
<el-icon><Refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-tabs v-model="activeTab" class="wallet-tabs">
|
||||
<el-tab-pane label="发票列表" name="invoices">
|
||||
<div class="list-body list-wrap">
|
||||
<el-table v-loading="loading" class="list-table" :data="invoiceRows" stripe>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fileName" label="附件" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fileName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="uploadByName" label="上传人" min-width="100">
|
||||
<template #default="{ row }">{{ row.uploadByName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="上传时间" min-width="170" />
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="额度流水" name="ledgers">
|
||||
<div class="list-body list-wrap">
|
||||
<el-table v-loading="ledgerLoading" class="list-table" :data="ledgerRows" stripe>
|
||||
<el-table-column prop="createTime" label="时间" min-width="170" />
|
||||
<el-table-column prop="entryType" label="类型" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="ledgerTagType(row.entryType)">
|
||||
{{ ledgerTypeLabel(row.entryType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</section>
|
||||
|
||||
<el-dialog
|
||||
v-model="uploadVisible"
|
||||
title="上传发票"
|
||||
width="560px"
|
||||
class="dialog-form-layout"
|
||||
align-center
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form label-position="top" class="bx-dialog-form">
|
||||
<el-form-item label="发票金额(元)" required>
|
||||
<el-input-number
|
||||
v-model="uploadForm.amount"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
:step="100"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发票文件" required>
|
||||
<input ref="fileInputRef" type="file" @change="onFileChange" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="uploadForm.remark" type="textarea" :rows="3" placeholder="可选" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="uploadVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button class="btn-main" type="primary" :loading="loadingMap.upload" @click="submitUpload">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { Upload, Refresh, Close, Check } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { invoiceApi, invoiceWalletApi } from '@/api/bx'
|
||||
import { formatMoneyYuan } from '@/utils/bx/format'
|
||||
import { pickBxData, pickBxList, pickBxPageResult } from '@/utils/http/bx'
|
||||
|
||||
const loading = ref(false)
|
||||
const ledgerLoading = ref(false)
|
||||
const activeTab = ref('invoices')
|
||||
const loadingMap = reactive({ upload: false })
|
||||
const summary = reactive({
|
||||
totalAmount: 0,
|
||||
usedAmount: 0,
|
||||
balance: 0,
|
||||
invoiceCount: 0
|
||||
})
|
||||
const invoiceRows = ref<any[]>([])
|
||||
const ledgerRows = ref<any[]>([])
|
||||
const uploadVisible = ref(false)
|
||||
const uploadForm = reactive({ amount: undefined as number | undefined, remark: '' })
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
|
||||
function ledgerTypeLabel(t: string) {
|
||||
const map: Record<string, string> = {
|
||||
credit_upload: '上传入账',
|
||||
debit_delete: '删除冲减',
|
||||
debit_reimburse: '报销占用',
|
||||
credit_release: '驳回/撤回退回'
|
||||
}
|
||||
return map[t] || t
|
||||
}
|
||||
|
||||
function ledgerTagType(t: string): 'success' | 'warning' | 'danger' | 'info' {
|
||||
if (t === 'credit_upload' || t === 'credit_release') return 'success'
|
||||
if (t === 'debit_reimburse') return 'warning'
|
||||
if (t === 'debit_delete') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
async function loadSummary() {
|
||||
const res: any = await invoiceWalletApi.mineSummary()
|
||||
const data: any = pickBxData(res) || {}
|
||||
summary.totalAmount = Number(data.totalAmount ?? 0)
|
||||
summary.usedAmount = Number(data.usedAmount ?? 0)
|
||||
summary.balance = Number(data.balance ?? 0)
|
||||
summary.invoiceCount = Number(data.invoiceCount ?? 0)
|
||||
}
|
||||
|
||||
async function loadInvoices() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await invoiceApi.list({ page: 1, pageSize: 100 })
|
||||
invoiceRows.value = pickBxPageResult(res).list
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLedgers() {
|
||||
ledgerLoading.value = true
|
||||
try {
|
||||
const res: any = await invoiceApi.ledgers()
|
||||
ledgerRows.value = pickBxList(res)
|
||||
} finally {
|
||||
ledgerLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadAll() {
|
||||
await Promise.all([loadSummary(), loadInvoices(), loadLedgers()])
|
||||
}
|
||||
|
||||
function openUpload() {
|
||||
uploadForm.amount = undefined
|
||||
uploadForm.remark = ''
|
||||
selectedFile.value = null
|
||||
if (fileInputRef.value) fileInputRef.value.value = ''
|
||||
uploadVisible.value = true
|
||||
}
|
||||
|
||||
function onFileChange(e: Event) {
|
||||
const input = e.target as HTMLInputElement
|
||||
selectedFile.value = input.files?.[0] || null
|
||||
}
|
||||
|
||||
async function submitUpload() {
|
||||
if (!uploadForm.amount || Number(uploadForm.amount) <= 0) {
|
||||
ElMessage.warning('请填写发票金额')
|
||||
return
|
||||
}
|
||||
if (!selectedFile.value) {
|
||||
ElMessage.warning('请选择发票文件')
|
||||
return
|
||||
}
|
||||
loadingMap.upload = true
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', selectedFile.value)
|
||||
fd.append('amount', String(uploadForm.amount))
|
||||
if (uploadForm.remark) fd.append('remark', uploadForm.remark)
|
||||
await invoiceApi.upload(fd)
|
||||
ElMessage.success('上传成功')
|
||||
uploadVisible.value = false
|
||||
await reloadAll()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '上传失败')
|
||||
} finally {
|
||||
loadingMap.upload = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
reloadAll()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.wallet-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
.wallet-summary-item {
|
||||
padding: 14px 16px;
|
||||
background: var(--el-bg-color);
|
||||
border: 1px solid var(--el-border-color-lighter, #d9e8e2);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.wallet-summary-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary, #64748b);
|
||||
}
|
||||
|
||||
.wallet-summary-value {
|
||||
margin-top: 6px;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary, #1e293b);
|
||||
|
||||
&.is-primary {
|
||||
color: var(--el-color-primary, #10b981);
|
||||
}
|
||||
}
|
||||
|
||||
.wallet-tabs {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.wallet-summary {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -328,13 +328,33 @@
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<h4>附件上传</h4>
|
||||
<BxAttachmentUpload
|
||||
ref="attachmentUploadRef"
|
||||
v-model="uploadedFiles"
|
||||
biz-type="reimburse_apply"
|
||||
:biz-id="editingId || 0"
|
||||
/>
|
||||
<h4>关联发票(可选)</h4>
|
||||
<p class="invoice-balance-tip">
|
||||
当前发票余额:<b>{{ formatMoneyYuan(walletBalance) }}</b>
|
||||
;本次合计:<b>{{ formatMoneyYuan(detailTotalAmount) }}</b>
|
||||
<span v-if="Number(walletBalance) < Number(detailTotalAmount)" class="invoice-balance-warn">
|
||||
(余额不足,提交时将被拦截)
|
||||
</span>
|
||||
</p>
|
||||
<div class="invoice-select-toolbar">
|
||||
<el-button class="btn-ghost" @click="invoiceSelectVisible = true">
|
||||
<el-icon><FolderOpened /></el-icon>从发票夹选择
|
||||
</el-button>
|
||||
<span class="invoice-select-hint">发票请先在「我的发票夹」上传;此处仅做可选关联。</span>
|
||||
</div>
|
||||
<div v-if="selectedInvoices.length" class="invoice-selected-list">
|
||||
<el-tag
|
||||
v-for="inv in selectedInvoices"
|
||||
:key="inv.id"
|
||||
class="invoice-selected-tag"
|
||||
closable
|
||||
@close="removeSelectedInvoice(inv.id)"
|
||||
>
|
||||
{{ formatMoneyYuan(inv.amount) }} 元
|
||||
<template v-if="inv.fileName"> · {{ inv.fileName }}</template>
|
||||
</el-tag>
|
||||
</div>
|
||||
<div v-else class="invoice-selected-empty">未关联发票(可选)</div>
|
||||
</div>
|
||||
|
||||
<el-form label-position="top" class="bx-dialog-form">
|
||||
@@ -353,6 +373,12 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<BxInvoiceSelectDialog
|
||||
v-model="invoiceSelectVisible"
|
||||
:selected-ids="selectedInvoices.map((i) => String(i.id))"
|
||||
@confirm="onInvoicesPicked"
|
||||
/>
|
||||
|
||||
<!-- 详情 -->
|
||||
<el-dialog
|
||||
v-model="dialogs.view"
|
||||
@@ -431,8 +457,23 @@
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewLinkedInvoices.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">关联发票</h4>
|
||||
<el-table class="list-table" :data="viewLinkedInvoices" stripe>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fileName" label="附件" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fileName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">附件</h4>
|
||||
<h4 class="dlg-view-section-title">历史附件</h4>
|
||||
<BxAttachmentReadonly :files="viewAttachments" />
|
||||
</div>
|
||||
|
||||
@@ -499,9 +540,10 @@ import {
|
||||
Delete,
|
||||
Check,
|
||||
Search,
|
||||
RefreshLeft
|
||||
RefreshLeft,
|
||||
FolderOpened
|
||||
} from '@element-plus/icons-vue'
|
||||
import { reimburseApi, attachmentApi } from '@/api/bx'
|
||||
import { reimburseApi, invoiceWalletApi } from '@/api/bx'
|
||||
import { buildApplyDateRangeQuery, type ApplyDateRange } from '@/utils/bx/apply-date-filter'
|
||||
import { canDeleteByCreator, allRowsDeletableByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
||||
import { useExpenseItemTree, type ExpenseItem } from '@/hooks/bx/useExpenseItemTree'
|
||||
@@ -520,11 +562,13 @@ import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||||
import BxApprovalFlowTabs from '@/components/bx/base/BxApprovalFlowTabs.vue'
|
||||
import BxViewKvGrid from '@/components/bx/base/BxViewKvGrid.vue'
|
||||
import BxViewKvTable from '@/components/bx/base/BxViewKvTable.vue'
|
||||
import BxAttachmentUpload from '@/components/bx/base/BxAttachmentUpload.vue'
|
||||
import BxAttachmentReadonly from '@/components/bx/base/BxAttachmentReadonly.vue'
|
||||
import BxInvoiceSelectDialog from '@/components/bx/base/BxInvoiceSelectDialog.vue'
|
||||
import type { ViewField } from '@/components/business/system-view-dialog/types'
|
||||
import { bxViewKv, bxViewKvLong, bxViewKvMoney } from '@/utils/bx/view-kv'
|
||||
import { buildPageSummaryMethod, sumField } from '@/utils/bx/table-summary'
|
||||
import { type BxAttachmentItem, loadBxAttachments } from '@/utils/bx/attachment'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
|
||||
type DialogKey = 'add' | 'view' | 'viewFlow'
|
||||
|
||||
@@ -639,11 +683,13 @@ const flowLoading = ref(false)
|
||||
const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
const uploadedFiles = ref<BxAttachmentItem[]>([])
|
||||
const attachmentUploadRef = ref<InstanceType<typeof BxAttachmentUpload> | null>(null)
|
||||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewPayAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewOffsetAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewLinkedInvoices = ref<any[]>([])
|
||||
const selectedInvoices = ref<any[]>([])
|
||||
const invoiceSelectVisible = ref(false)
|
||||
const walletBalance = ref(0)
|
||||
const editingId = ref<number | null>(null)
|
||||
const titleAutoLinked = ref(true)
|
||||
|
||||
@@ -679,16 +725,34 @@ async function onReimburseDateChange() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshWalletBalance() {
|
||||
try {
|
||||
const res: any = await invoiceWalletApi.mineSummary()
|
||||
const data: any = pickBxData(res) || {}
|
||||
walletBalance.value = Number(data.balance ?? 0)
|
||||
} catch {
|
||||
walletBalance.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
function onInvoicesPicked(rows: any[]) {
|
||||
selectedInvoices.value = rows
|
||||
}
|
||||
|
||||
function removeSelectedInvoice(id: string | number) {
|
||||
selectedInvoices.value = selectedInvoices.value.filter((i) => String(i.id) !== String(id))
|
||||
}
|
||||
|
||||
async function openAddDialog() {
|
||||
addForm.reimburseDate = todayYmd()
|
||||
addForm.title = ''
|
||||
addForm.remark = ''
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
uploadedFiles.value = []
|
||||
selectedInvoices.value = []
|
||||
editingId.value = null
|
||||
titleAutoLinked.value = true
|
||||
dialogs.add = true
|
||||
await refreshGeneratedTitle()
|
||||
await Promise.all([refreshGeneratedTitle(), refreshWalletBalance()])
|
||||
}
|
||||
|
||||
function isDraftEditable(row?: any) {
|
||||
@@ -770,13 +834,9 @@ async function openEditDialog(row: any) {
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
}
|
||||
editingId.value = row.id
|
||||
uploadedFiles.value = []
|
||||
selectedInvoices.value = Array.isArray(data.invoices) ? data.invoices : []
|
||||
dialogs.add = true
|
||||
try {
|
||||
uploadedFiles.value = await loadBxAttachments('reimburse_apply', row.id)
|
||||
} catch {
|
||||
/* ignore attachment fetch error */
|
||||
}
|
||||
await refreshWalletBalance()
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message || '加载失败')
|
||||
}
|
||||
@@ -847,6 +907,18 @@ async function handleToolbarSubmit() {
|
||||
ElMessage.warning('请先勾选要提交的报销单')
|
||||
return
|
||||
}
|
||||
if (!selectedRows.value.every(isDraftEditable)) {
|
||||
ElMessage.warning('仅草稿或已驳回的报销单可提交')
|
||||
return
|
||||
}
|
||||
await refreshWalletBalance()
|
||||
const totalNeed = selectedRows.value.reduce((s, r) => s + Number(r.amount || 0), 0)
|
||||
if (Number(walletBalance.value) < totalNeed) {
|
||||
ElMessage.warning(
|
||||
`发票额度不足(余额 ${formatMoneyYuan(walletBalance.value)},本次 ${formatMoneyYuan(totalNeed)})`
|
||||
)
|
||||
return
|
||||
}
|
||||
loadingMap.submit = true
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
@@ -872,45 +944,25 @@ async function submitAdd() {
|
||||
ElMessage.warning('请为每条报销明细填写报销事由')
|
||||
return
|
||||
}
|
||||
if (attachmentUploadRef.value?.hasUploading()) {
|
||||
ElMessage.warning('附件上传中,请稍候')
|
||||
return
|
||||
const invoiceIds = selectedInvoices.value.map((i) => String(i.id))
|
||||
const payload = {
|
||||
reimburseDate: addForm.reimburseDate,
|
||||
title: addForm.title || undefined,
|
||||
remark: addForm.remark,
|
||||
invoiceIds,
|
||||
details: validDetails.map((d) => ({
|
||||
expenseItemId: String(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim()
|
||||
}))
|
||||
}
|
||||
loadingMap.addSubmit = true
|
||||
try {
|
||||
if (editingId.value) {
|
||||
await reimburseApi.update(editingId.value, {
|
||||
reimburseDate: addForm.reimburseDate,
|
||||
title: addForm.title,
|
||||
details: validDetails.map((d) => ({
|
||||
expenseItemId: String(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim()
|
||||
})),
|
||||
remark: addForm.remark
|
||||
})
|
||||
const newFiles = uploadedFiles.value.filter((f) => !f._existing)
|
||||
if (newFiles.length) {
|
||||
const fileIds = newFiles.map((f) => f.id)
|
||||
await attachmentApi.bindBiz(fileIds, 'reimburse_apply', editingId.value)
|
||||
}
|
||||
await reimburseApi.update(editingId.value, payload)
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
const res: any = await reimburseApi.create({
|
||||
reimburseDate: addForm.reimburseDate,
|
||||
title: addForm.title || undefined,
|
||||
remark: addForm.remark,
|
||||
details: validDetails.map((d) => ({
|
||||
expenseItemId: String(d.expenseItemId),
|
||||
amount: Number(d.amount),
|
||||
remark: String(d.remark).trim()
|
||||
}))
|
||||
})
|
||||
const newId = res.data?.id
|
||||
if (newId && uploadedFiles.value.length) {
|
||||
const fileIds = uploadedFiles.value.map((f) => f.id)
|
||||
await attachmentApi.bindBiz(fileIds, 'reimburse_apply', newId)
|
||||
}
|
||||
await reimburseApi.create(payload)
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
dialogs.add = false
|
||||
@@ -918,7 +970,7 @@ async function submitAdd() {
|
||||
addForm.title = ''
|
||||
addForm.remark = ''
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '' }]
|
||||
uploadedFiles.value = []
|
||||
selectedInvoices.value = []
|
||||
editingId.value = null
|
||||
await refreshList()
|
||||
} catch (e: any) {
|
||||
@@ -937,6 +989,7 @@ async function openView(row: any) {
|
||||
viewAttachments.value = []
|
||||
viewPayAttachments.value = []
|
||||
viewOffsetAttachments.value = []
|
||||
viewLinkedInvoices.value = Array.isArray(viewData.value?.invoices) ? viewData.value.invoices : []
|
||||
dialogs.view = true
|
||||
if (row.id) {
|
||||
try {
|
||||
@@ -1004,6 +1057,13 @@ async function openFlowDialog(row?: any) {
|
||||
}
|
||||
|
||||
async function handleSubmit(row: any) {
|
||||
await refreshWalletBalance()
|
||||
if (Number(walletBalance.value) < Number(row.amount || 0)) {
|
||||
ElMessage.warning(
|
||||
`发票额度不足(余额 ${formatMoneyYuan(walletBalance.value)},本次 ${formatMoneyYuan(row.amount)})`
|
||||
)
|
||||
return
|
||||
}
|
||||
loadingMap[`submit_${row.id}`] = true
|
||||
try {
|
||||
await reimburseApi.submit(row.id)
|
||||
@@ -1063,3 +1123,43 @@ function viewDetailSummary({ columns, data }: { columns: any[]; data: any[] }) {
|
||||
return sums
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.invoice-balance-tip {
|
||||
margin: 0 0 10px;
|
||||
font-size: 13px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.invoice-balance-warn {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.invoice-select-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.invoice-select-hint {
|
||||
font-size: 12px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.invoice-selected-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.invoice-selected-tag {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.invoice-selected-empty {
|
||||
font-size: 13px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
</style>
|
||||
@@ -524,8 +524,23 @@
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewLinkedInvoices.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">关联发票</h4>
|
||||
<el-table class="list-table" :data="viewLinkedInvoices" stripe>
|
||||
<el-table-column prop="amount" label="金额(元)" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoneyYuan(row.amount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="fileName" label="附件" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fileName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||||
<h4 class="dlg-view-section-title">附件</h4>
|
||||
<h4 class="dlg-view-section-title">历史附件</h4>
|
||||
<BxAttachmentReadonly :files="viewAttachments" />
|
||||
</div>
|
||||
|
||||
@@ -699,6 +714,7 @@ const viewFlowNodes = ref<any[]>([])
|
||||
const viewApprovalHistory = ref<any[]>([])
|
||||
const viewFlowLoading = ref(false)
|
||||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||||
const viewLinkedInvoices = ref<any[]>([])
|
||||
|
||||
const approveAction = ref<'approve' | 'reject'>('approve')
|
||||
const approveRows = ref<any[]>([])
|
||||
@@ -882,6 +898,7 @@ async function openView(row: any) {
|
||||
viewFlowNodes.value = []
|
||||
viewApprovalHistory.value = []
|
||||
viewAttachments.value = []
|
||||
viewLinkedInvoices.value = Array.isArray(viewData.value?.invoices) ? viewData.value.invoices : []
|
||||
dialogs.viewDetail = true
|
||||
viewFlowLoading.value = true
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user