1300 lines
48 KiB
Vue
1300 lines
48 KiB
Vue
<!-- 支付管理(发放/冲抵) -->
|
||
<!-- eslint-disable vue/no-v-model-argument -->
|
||
<template>
|
||
<div class="page-container">
|
||
<section class="panel">
|
||
<el-tabs
|
||
v-model="activeTab"
|
||
class="panel-tabs"
|
||
@tab-change="handleTabChange"
|
||
>
|
||
<!-- 待处理 -->
|
||
<el-tab-pane label="待处理" name="pending">
|
||
<div class="filter-block">
|
||
<el-form :model="filterForm" class="filter-form" @submit.prevent>
|
||
<div class="filter-grid">
|
||
<el-form-item label="单号">
|
||
<el-input v-model="filterForm.code" placeholder="请输入单号" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="申请人">
|
||
<el-select v-model="filterForm.applicantId" placeholder="请选择申请人" clearable filterable>
|
||
<el-option
|
||
v-for="opt in applicantOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="申请时间">
|
||
<el-date-picker
|
||
v-model="filterForm.applyDateRange"
|
||
type="daterange"
|
||
range-separator="-"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
value-format="YYYY-MM-DD"
|
||
clearable
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="filter-actions-row">
|
||
<span class="filter-hint">审批通过后由财务执行发放或冲抵备用金。</span>
|
||
<div class="filter-actions-end">
|
||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||
<el-icon><RefreshLeft /></el-icon>重置
|
||
</el-button>
|
||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||
<el-icon><Search /></el-icon>搜索
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<div class="list-toolbar">
|
||
<div class="list-toolbar-row">
|
||
<ListQuickSearchInput
|
||
v-model="quickSearchKeyword"
|
||
placeholder="单号/报销标题"
|
||
@search="handleQuickSearch"
|
||
@clear="handleQuickSearchClear"
|
||
/>
|
||
<el-button class="btn-main" type="primary" @click="handleToolbarIssue">
|
||
<el-icon><Money /></el-icon>发放
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="handleToolbarOffset">
|
||
<el-icon><Switch /></el-icon>冲抵备用金
|
||
</el-button>
|
||
<ListToolbarEndActions
|
||
:loading="loading"
|
||
:column-defs="listColumnDefs"
|
||
v-model:visible-columns="visibleColumns"
|
||
v-model:check-all="checkAll"
|
||
:is-indeterminate="isIndeterminate"
|
||
@refresh="handleSearch"
|
||
@reset-columns="resetToDefault"
|
||
/>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="list-body list-wrap">
|
||
<div class="table-scroll table-page-summary">
|
||
<ListTable table-key="bx-payment"
|
||
class="list-table"
|
||
:data="rows"
|
||
v-loading="loading"
|
||
stripe
|
||
show-summary
|
||
:summary-method="summaryMethod"
|
||
@selection-change="onSelectionChange"
|
||
@row-dblclick="openView"
|
||
>
|
||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||
<el-table-column
|
||
v-if="isColumnVisible('applyTime')"
|
||
prop="applyTime"
|
||
label="申请时间"
|
||
min-width="160"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
prop="applyCode"
|
||
label="单号"
|
||
class-name="col-apply-code"
|
||
min-width="140"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="openView(row)">{{ row.applyCode }}</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('applicantName')"
|
||
prop="applicantName"
|
||
label="申请人"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('title')"
|
||
prop="title"
|
||
label="报销标题"
|
||
min-width="180"
|
||
align="left"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('amount')"
|
||
prop="amount"
|
||
label="报销金额(元)"
|
||
:formatter="moneyTableFormatter"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('offsetAmount')"
|
||
prop="offsetAmount"
|
||
label="冲抵金额(元)"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ formatSumMoney(Number(row.offsetAmount || 0)) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('payAmount')"
|
||
prop="actualAmount"
|
||
label="发放金额(元)"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{
|
||
row.actualAmount != null && row.actualAmount !== ''
|
||
? formatSumMoney(Number(row.actualAmount))
|
||
: '—'
|
||
}}
|
||
</template>
|
||
</el-table-column>
|
||
</ListTable>
|
||
</div>
|
||
|
||
<div class="pagination list-pager-bar">
|
||
<div class="list-pager-selected">
|
||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||
</div>
|
||
|
||
<span class="list-range">{{ rangeText }}</span>
|
||
<el-pagination
|
||
v-model:current-page="currentPage"
|
||
v-model:page-size="pageSize"
|
||
:total="total"
|
||
layout="total, sizes, prev, pager, next"
|
||
:page-sizes="[10, 20, 30]"
|
||
@size-change="onSizeChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</el-tab-pane>
|
||
|
||
<!-- 已处理 -->
|
||
<el-tab-pane label="已处理" name="processed">
|
||
<div class="filter-block">
|
||
<el-form :model="processedFilterForm" class="filter-form" @submit.prevent>
|
||
<div class="filter-grid">
|
||
<el-form-item label="单号">
|
||
<el-input v-model="processedFilterForm.code" placeholder="请输入单号" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="申请人">
|
||
<el-select
|
||
v-model="processedFilterForm.applicantId"
|
||
placeholder="请选择申请人"
|
||
clearable
|
||
filterable
|
||
>
|
||
<el-option
|
||
v-for="opt in applicantOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="申请时间">
|
||
<el-date-picker
|
||
v-model="processedFilterForm.applyDateRange"
|
||
type="daterange"
|
||
range-separator="-"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
value-format="YYYY-MM-DD"
|
||
clearable
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="处理状态">
|
||
<el-select v-model="processedFilterForm.status" placeholder="请选择" clearable>
|
||
<el-option v-for="s in processedStatusOptions" :key="s" :label="s" :value="s" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="filter-actions-row">
|
||
<span class="filter-hint">查询已完成发放或冲抵的报销单。</span>
|
||
<div class="filter-actions-end">
|
||
<el-button class="btn-ghost" :loading="processedLoading" @click="handleProcessedReset">
|
||
<el-icon><RefreshLeft /></el-icon>重置
|
||
</el-button>
|
||
<el-button class="btn-main" type="primary" :loading="processedLoading" @click="handleProcessedSearch">
|
||
<el-icon><Search /></el-icon>搜索
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<div class="list-toolbar">
|
||
<div class="list-toolbar-row">
|
||
<ListQuickSearchInput
|
||
v-model="processedQuickSearchKeyword"
|
||
placeholder="单号/报销标题"
|
||
@search="handleProcessedQuickSearch"
|
||
@clear="handleProcessedQuickSearchClear"
|
||
/>
|
||
<ListToolbarEndActions
|
||
:loading="processedLoading"
|
||
:column-defs="listColumnDefs"
|
||
v-model:visible-columns="visibleColumns"
|
||
v-model:check-all="checkAll"
|
||
:is-indeterminate="isIndeterminate"
|
||
@refresh="handleProcessedSearch"
|
||
@reset-columns="resetToDefault"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="list-body list-wrap">
|
||
<div class="table-scroll table-page-summary">
|
||
<ListTable table-key="bx-payment-2"
|
||
class="list-table"
|
||
:data="processedRows"
|
||
v-loading="processedLoading"
|
||
stripe
|
||
show-summary
|
||
:summary-method="processedSummaryMethod"
|
||
@row-dblclick="openProcessedView"
|
||
>
|
||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||
<el-table-column
|
||
v-if="isColumnVisible('applyTime')"
|
||
prop="applyTime"
|
||
label="申请时间"
|
||
min-width="160"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
prop="applyCode"
|
||
label="单号"
|
||
class-name="col-apply-code"
|
||
min-width="140"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="openProcessedView(row)">{{ row.applyCode }}</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('applicantName')"
|
||
prop="applicantName"
|
||
label="申请人"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('title')"
|
||
prop="title"
|
||
label="标题"
|
||
min-width="180"
|
||
align="left"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('amount')"
|
||
prop="amount"
|
||
label="报销金额(元)"
|
||
:formatter="moneyTableFormatter"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
v-if="isColumnVisible('offsetAmount')"
|
||
prop="offsetAmount"
|
||
label="冲抵金额(元)"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ formatSumMoney(Number(row.offsetAmount || 0)) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('payAmount')"
|
||
prop="actualAmount"
|
||
label="发放金额(元)"
|
||
class-name="col-money"
|
||
min-width="120"
|
||
align="right"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{
|
||
row.actualAmount != null && row.actualAmount !== ''
|
||
? formatSumMoney(Number(row.actualAmount))
|
||
: '—'
|
||
}}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('processStatus')"
|
||
label="处理状态"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-tag :type="processedStatusTagType(row.status, row.payStatus)" size="small">
|
||
{{ processedStatusLabel(row.status, row.payStatus) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('payTime')"
|
||
prop="payTime"
|
||
label="处理时间"
|
||
min-width="160"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ row.payTime || '-' }}
|
||
</template>
|
||
</el-table-column>
|
||
</ListTable>
|
||
</div>
|
||
|
||
<div class="pagination list-pager-bar">
|
||
<span class="list-range">{{ processedRangeText }}</span>
|
||
<el-pagination
|
||
v-model:current-page="processedCurrentPage"
|
||
v-model:page-size="processedPageSize"
|
||
:total="processedTotal"
|
||
layout="total, sizes, prev, pager, next"
|
||
:page-sizes="[10, 20, 30]"
|
||
@size-change="processedOnSizeChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
</section>
|
||
|
||
<!-- 单据详情 -->
|
||
<el-dialog
|
||
v-model="dialogs.viewDetail"
|
||
title="单据详情"
|
||
width="1040px"
|
||
class="dialog-form-layout dialog-view-xl"
|
||
align-center
|
||
destroy-on-close
|
||
>
|
||
<div class="dlg-view">
|
||
<div class="dlg-view-hero">
|
||
<div class="dlg-view-hero-top">
|
||
<h2 class="dlg-view-title">{{ viewData.applyCode || '-' }}</h2>
|
||
<div class="dlg-view-tags">
|
||
<el-tag :type="statusTagType(viewData.status)" size="small">
|
||
{{ statusLabel(viewData.status) }}
|
||
</el-tag>
|
||
</div>
|
||
</div>
|
||
<p class="dlg-view-meta">
|
||
金额(元):<b class="money-em">{{ formatMoneyYuan(viewData.amount || 0) }}</b>
|
||
</p>
|
||
<div v-if="activeTab === 'pending'" class="dlg-view-hero-actions">
|
||
<el-button class="btn-main" type="primary" @click="openIssueDialog(viewData)">
|
||
<el-icon><Money /></el-icon>发放
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="openOffsetDialog(viewData)">
|
||
<el-icon><Switch /></el-icon>冲抵备用金
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
<div class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">基础信息</h4>
|
||
<BxViewKvTable :fields="viewBasicKvFields" mode="triple" />
|
||
</div>
|
||
<div class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">发放信息</h4>
|
||
<BxViewKvTable :fields="viewPayKvFields" mode="triple" />
|
||
</div>
|
||
<div v-if="viewAttachments.length" class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">相关附件</h4>
|
||
<BxAttachmentReadonly :files="viewAttachments" />
|
||
</div>
|
||
</div>
|
||
</el-dialog>
|
||
|
||
<!-- 标记已发放 -->
|
||
<el-dialog
|
||
v-model="dialogs.issue"
|
||
title="标记已发放"
|
||
width="640px"
|
||
class="dialog-form-layout"
|
||
align-center
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<el-form label-position="top" class="bx-dialog-form">
|
||
<div class="form-grid-2">
|
||
<el-form-item label="发放金额(元)" class="field-amount">
|
||
<el-input :model-value="String(currentRow.amount || '')" disabled placeholder="发放金额" />
|
||
</el-form-item>
|
||
<el-form-item label="实际发放金额(元)" class="field-amount">
|
||
<el-input v-model="actualAmount" placeholder="请输入实际发放金额" />
|
||
</el-form-item>
|
||
<el-form-item label="备注" style="grid-column: 1 / -1">
|
||
<el-input v-model="issueRemark" type="textarea" :rows="4" placeholder="请输入备注" />
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
|
||
<div class="form-section form-section-last">
|
||
<h4>发放附件</h4>
|
||
<BxAttachmentUpload
|
||
ref="issueAttachmentRef"
|
||
v-model="uploadedFiles"
|
||
biz-type="reimburse_pay"
|
||
:biz-id="currentRow.id"
|
||
hint="支持上传发放截图等凭证。"
|
||
/>
|
||
</div>
|
||
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="dialogs.issue = false">
|
||
<el-icon><Close /></el-icon>取消
|
||
</el-button>
|
||
<el-button class="btn-main" type="primary" :loading="loadingMap.issueSubmit" @click="submitIssue">
|
||
<el-icon><Check /></el-icon>确认发放
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 冲抵备用金 -->
|
||
<el-dialog
|
||
v-model="dialogs.offset"
|
||
title="冲抵备用金"
|
||
width="960px"
|
||
class="dialog-form-layout"
|
||
align-center
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<el-form label-position="top" class="bx-dialog-form">
|
||
<h4 class="dialog-section-title">报销单信息</h4>
|
||
<div class="form-grid-2">
|
||
<el-form-item label="报销单号">
|
||
<el-input :model-value="currentRow.applyCode || ''" disabled />
|
||
</el-form-item>
|
||
<el-form-item label="报销金额(元)" class="field-amount">
|
||
<el-input :model-value="String(currentRow.amount || '')" disabled />
|
||
</el-form-item>
|
||
<el-form-item label="冲抵金额(元)" class="field-amount">
|
||
<el-input v-model="offsetAmount" placeholder="请输入冲抵金额" />
|
||
</el-form-item>
|
||
<el-form-item label="发放金额(元)" class="field-amount">
|
||
<el-input v-model="offsetPayAmount" placeholder="冲抵后剩余直接发放" />
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<h4 class="dialog-section-title">已发放备用金列表</h4>
|
||
<div class="inline-row">
|
||
<el-input v-model="offsetAdvanceFilter.keyword" placeholder="搜索单号/申请人" class="inline-grow" clearable />
|
||
<el-button class="btn-main" type="primary" :loading="offsetAdvanceLoading" @click="handleOffsetAdvanceSearch">
|
||
<el-icon><Search /></el-icon>搜索
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="handleOffsetAdvanceReset">
|
||
<el-icon><RefreshLeft /></el-icon>重置
|
||
</el-button>
|
||
</div>
|
||
<ListTable table-key="bx-payment-3"
|
||
class="list-table"
|
||
:data="offsetAdvances"
|
||
v-loading="offsetAdvanceLoading"
|
||
max-height="300"
|
||
stripe
|
||
@selection-change="handleOffsetSelectionChange"
|
||
>
|
||
<el-table-column type="selection" min-width="48" align="center" header-align="center" />
|
||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||
<el-table-column prop="applyCode" label="申请单号" min-width="130" align="center" header-align="center" />
|
||
<el-table-column prop="applicantName" label="申请人" min-width="80" align="center" header-align="center" />
|
||
<el-table-column prop="reason" label="申请原因" min-width="120" align="left" header-align="center" show-overflow-tooltip />
|
||
<el-table-column label="已发放金额(元)" min-width="100" class-name="col-money" align="right" header-align="center">
|
||
<template #default="{ row }">
|
||
{{ formatMoney(row.actualAmount || row.amount || 0) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="已冲抵金额(元)" min-width="100" class-name="col-money" align="right" header-align="center">
|
||
<template #default="{ row }">
|
||
{{ formatMoney(row.offsetAmount || 0) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="剩余可冲抵(元)" min-width="100" class-name="col-money" align="right" header-align="center">
|
||
<template #default="{ row }">
|
||
{{ formatMoney(Number(row.actualAmount || row.amount || 0) - Number(row.offsetAmount || 0)) }}
|
||
</template>
|
||
</el-table-column>
|
||
</ListTable>
|
||
<div class="offset-pager">
|
||
<el-pagination
|
||
v-model:current-page="offsetAdvancePage"
|
||
v-model:page-size="offsetAdvancePageSize"
|
||
:total="offsetAdvanceTotal"
|
||
layout="total, sizes, prev, pager, next"
|
||
:page-sizes="[5, 10, 20]"
|
||
@current-change="fetchOffsetAdvances"
|
||
@size-change="handleOffsetAdvanceSizeChange"
|
||
/>
|
||
</div>
|
||
|
||
<el-form-item label="备注">
|
||
<el-input v-model="offsetRemark" type="textarea" :rows="3" placeholder="请输入备注" />
|
||
</el-form-item>
|
||
|
||
<h4 class="dialog-section-title">冲抵附件(必填)</h4>
|
||
<BxAttachmentUpload
|
||
ref="offsetAttachmentRef"
|
||
v-model="uploadedFiles"
|
||
biz-type="reimburse_offset"
|
||
:biz-id="currentRow.id"
|
||
hint="请至少上传 1 个冲抵附件。"
|
||
/>
|
||
</el-form>
|
||
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="dialogs.offset = false">
|
||
<el-icon><Close /></el-icon>取消
|
||
</el-button>
|
||
<el-button class="btn-main" type="primary" :loading="loadingMap.offsetSubmit" @click="submitOffset">
|
||
<el-icon><Check /></el-icon>确认冲抵
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 处理详情 -->
|
||
<el-dialog
|
||
v-model="dialogs.processedDetail"
|
||
title="处理详情"
|
||
width="1040px"
|
||
class="dialog-form-layout dialog-view-xl"
|
||
align-center
|
||
destroy-on-close
|
||
>
|
||
<div class="dlg-view">
|
||
<div class="dlg-view-hero">
|
||
<div class="dlg-view-hero-top">
|
||
<h2 class="dlg-view-title">{{ processedViewData.applyCode || '-' }}</h2>
|
||
<div class="dlg-view-tags">
|
||
<el-tag :type="processedStatusTagType(processedViewData.status, processedViewData.payStatus)" size="small">
|
||
{{ processedStatusLabel(processedViewData.status, processedViewData.payStatus) }}
|
||
</el-tag>
|
||
</div>
|
||
</div>
|
||
<p class="dlg-view-meta">
|
||
金额(元):<b class="money-em">{{ formatMoneyYuan(processedViewData.amount || 0) }}</b>
|
||
</p>
|
||
</div>
|
||
|
||
<div class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">基础信息</h4>
|
||
<BxViewKvTable :fields="processedBasicKvFields" mode="triple" />
|
||
<div v-if="processedAttachments['申请附件']?.length" class="dlg-view-section-attach">
|
||
<h4 class="dlg-view-section-title">申请附件</h4>
|
||
<BxAttachmentReadonly :files="processedAttachments['申请附件']" />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">发放信息</h4>
|
||
<BxViewKvTable :fields="processedPayKvFields" mode="triple" />
|
||
<div v-if="processedAttachments['发放附件']?.length" class="dlg-view-section-attach">
|
||
<h4 class="dlg-view-section-title">发放附件</h4>
|
||
<BxAttachmentReadonly :files="processedAttachments['发放附件']" />
|
||
</div>
|
||
</div>
|
||
|
||
<div v-if="Number(processedViewData.offsetAmount || 0) > 0" class="dlg-view-section">
|
||
<h4 class="dlg-view-section-title">冲抵信息</h4>
|
||
<BxViewKvGrid :fields="processedOffsetKvFields" />
|
||
<div v-if="processedAttachments['冲抵附件']?.length" class="dlg-view-section-attach">
|
||
<h4 class="dlg-view-section-title">冲抵附件</h4>
|
||
<BxAttachmentReadonly :files="processedAttachments['冲抵附件']" />
|
||
</div>
|
||
|
||
<h4 class="dlg-view-section-title section-gap-tight">冲抵明细</h4>
|
||
<BaseDetailTableSection embedded title="冲抵明细" :data="processedOffsetRecords" empty-text="暂无冲抵明细">
|
||
<ListTable table-key="bx-payment-4" class="list-table" :data="processedOffsetRecords" stripe size="small">
|
||
<el-table-column type="index" label="序号" min-width="68" align="center" header-align="center" />
|
||
<el-table-column prop="advanceApplyCode" label="备用金单号" min-width="130" align="center" header-align="center" />
|
||
<el-table-column prop="advanceApplicantName" label="备用金申请人" min-width="110" align="center" header-align="center" />
|
||
<el-table-column prop="advanceReason" label="申请原因" min-width="160" align="left" header-align="center" show-overflow-tooltip />
|
||
<el-table-column label="冲抵金额(元)" min-width="120" class-name="col-money" align="right" header-align="center">
|
||
<template #default="{ row: offsetRow }">
|
||
{{ formatMoneyYuan(offsetRow.offsetAmount || 0) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="createTime" label="冲抵时间" min-width="160" align="center" header-align="center" />
|
||
<el-table-column prop="operator" label="操作人" min-width="100" align="center" header-align="center" />
|
||
</ListTable>
|
||
</BaseDetailTableSection>
|
||
</div>
|
||
|
||
<BxApprovalFlowTabs
|
||
:nodes="processedApprovals"
|
||
:history="processedApprovalHistory"
|
||
:loading="processedApprovalLoading"
|
||
/>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||
import { reactive, ref, computed, onMounted } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import {
|
||
View,
|
||
Money,
|
||
Switch,
|
||
Close,
|
||
Check,
|
||
Search,
|
||
RefreshLeft
|
||
} from '@element-plus/icons-vue'
|
||
import { paymentApi, reimburseApi } from '@/api/bx'
|
||
import { type BxAttachmentItem, loadBxAttachments } from '@/utils/bx/attachment'
|
||
import { statusLabel, statusTagType, formatSumMoney, formatMoney, formatMoneyYuan, moneyTableFormatter } from '@/utils/bx/format'
|
||
import { useServerPaged } from '@/hooks/bx/useServerPaged'
|
||
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
|
||
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 BaseDetailTableSection from '@/components/bx/base/BaseDetailTableSection.vue'
|
||
import BxAttachmentUpload from '@/components/bx/base/BxAttachmentUpload.vue'
|
||
import BxAttachmentReadonly from '@/components/bx/base/BxAttachmentReadonly.vue'
|
||
import type { ViewField } from '@/components/business/system-view-dialog/types'
|
||
import { bxViewKv, bxViewKvMoney } from '@/utils/bx/view-kv'
|
||
import { buildApplyDateRangeQuery, type ApplyDateRange } from '@/utils/bx/apply-date-filter'
|
||
import { buildPageSummaryMethod, sumField } from '@/utils/bx/table-summary'
|
||
|
||
type DialogKey = 'viewDetail' | 'issue' | 'offset' | 'processedDetail'
|
||
|
||
const listColumnDefs = [
|
||
{ prop: 'applyTime', label: '申请时间' },
|
||
{ prop: 'applicantName', label: '申请人' },
|
||
{ prop: 'title', label: '报销标题' },
|
||
{ prop: 'amount', label: '报销金额(元)' },
|
||
{ prop: 'offsetAmount', label: '冲抵金额(元)', defaultVisible: false },
|
||
{ prop: 'payAmount', label: '发放金额(元)' },
|
||
{ prop: 'processStatus', label: '处理状态', defaultVisible: false },
|
||
{ prop: 'payTime', label: '处理时间', defaultVisible: false }
|
||
]
|
||
|
||
const {
|
||
visibleColumns,
|
||
checkAll,
|
||
isIndeterminate,
|
||
isColumnVisible,
|
||
resetToDefault
|
||
} = usePersistedListColumns('bx-payment-list-columns', listColumnDefs)
|
||
|
||
const { applicantOptions, loadApplicantOptions } = useApplicantOptions()
|
||
const loadingMap = reactive<Record<string, boolean>>({})
|
||
const dialogs = reactive<Record<DialogKey, boolean>>({
|
||
viewDetail: false,
|
||
issue: false,
|
||
offset: false,
|
||
processedDetail: false
|
||
})
|
||
|
||
const { rows, total, currentPage, pageSize, rangeText, loading, refresh, search, onSizeChange } = useServerPaged(
|
||
async (params) => {
|
||
const res: any = await paymentApi.pending(params)
|
||
const raw = res.data
|
||
if (!raw) return { rows: [], total: 0 }
|
||
const flatRows = (raw.rows || []).map((item: any) => ({
|
||
...item.data,
|
||
title: item.data.title || ''
|
||
}))
|
||
return { rows: flatRows, total: raw.total || flatRows.length }
|
||
}
|
||
)
|
||
|
||
const quickSearchKeyword = ref('')
|
||
const processedQuickSearchKeyword = ref('')
|
||
|
||
const filterForm = reactive({
|
||
code: '',
|
||
applicantId: undefined as number | undefined,
|
||
applyDateRange: null as ApplyDateRange,
|
||
status: '' as string
|
||
})
|
||
|
||
const currentRow = ref<Record<string, any>>({})
|
||
const selectedRows = ref<any[]>([])
|
||
const viewData = ref<Record<string, any>>({})
|
||
|
||
const viewBasicKvFields = computed<ViewField[]>(() => {
|
||
const d = viewData.value
|
||
return [
|
||
bxViewKv('单号', d.applyCode, { long: false }),
|
||
bxViewKv('申请人', d.applicantName, { long: false }),
|
||
bxViewKv('报销标题', d.title, { long: false }),
|
||
bxViewKv('审批完成时间', d.applyTime, { long: false }),
|
||
bxViewKvMoney('金额(元)', formatMoneyYuan(d.amount || 0), { long: false }),
|
||
bxViewKv('状态', statusLabel(d.status), { long: false, tagType: statusTagType(d.status) })
|
||
]
|
||
})
|
||
|
||
const viewPayKvFields = computed<ViewField[]>(() => {
|
||
const d = viewData.value
|
||
const payAmount = Number(d.amount || 0) - Number(d.offsetAmount || 0)
|
||
return [
|
||
bxViewKvMoney('冲抵金额(元)', formatMoneyYuan(d.offsetAmount || 0), { long: false }),
|
||
bxViewKvMoney('发放金额(元)', formatMoneyYuan(Math.max(0, payAmount)), { long: false }),
|
||
bxViewKvMoney(
|
||
'实际发放金额(元)',
|
||
d.actualAmount != null && d.actualAmount !== '' ? formatMoneyYuan(d.actualAmount) : '—',
|
||
{ long: false }
|
||
),
|
||
bxViewKv('发放时间', d.payTime, { long: false }),
|
||
bxViewKv('发放操作人', d.payUserName, { long: false }),
|
||
bxViewKv('发放备注', d.payRemark, { long: false })
|
||
]
|
||
})
|
||
const issueRemark = ref('')
|
||
const actualAmount = ref('')
|
||
const offsetRemark = ref('')
|
||
const uploadedFiles = ref<BxAttachmentItem[]>([])
|
||
const issueAttachmentRef = ref<InstanceType<typeof BxAttachmentUpload> | null>(null)
|
||
const offsetAttachmentRef = ref<InstanceType<typeof BxAttachmentUpload> | null>(null)
|
||
const viewAttachments = ref<BxAttachmentItem[]>([])
|
||
|
||
const offsetAdvanceFilter = reactive({ keyword: '' })
|
||
const offsetAdvances = ref<any[]>([])
|
||
const offsetAdvanceTotal = ref(0)
|
||
const offsetAdvancePage = ref(1)
|
||
const offsetAdvancePageSize = ref(5)
|
||
const offsetAdvanceLoading = ref(false)
|
||
const offsetSelectedAdvances = ref<any[]>([])
|
||
const offsetAmount = ref('')
|
||
const offsetPayAmount = computed({
|
||
get: () => {
|
||
const amt = Number(currentRow.value.amount || 0)
|
||
const offset = Number(offsetAmount.value) || 0
|
||
return String(Math.max(0, amt - offset))
|
||
},
|
||
set: (val: string) => {
|
||
const amt = Number(currentRow.value.amount || 0)
|
||
const pay = Number(val) || 0
|
||
offsetAmount.value = String(Math.max(0, amt - pay))
|
||
}
|
||
})
|
||
|
||
const activeTab = ref('pending')
|
||
const tabLoaded = reactive({ pending: true, processed: false })
|
||
|
||
const processedFilterForm = reactive({
|
||
code: '',
|
||
applicantId: undefined as number | undefined,
|
||
applyDateRange: null as ApplyDateRange,
|
||
status: '' as string
|
||
})
|
||
const processedStatusOptions = ['全部', '已处理']
|
||
|
||
const {
|
||
rows: processedRows,
|
||
total: processedTotal,
|
||
currentPage: processedCurrentPage,
|
||
pageSize: processedPageSize,
|
||
rangeText: processedRangeText,
|
||
loading: processedLoading,
|
||
search: processedSearch,
|
||
onSizeChange: processedOnSizeChange
|
||
} = useServerPaged(async (params) => {
|
||
const res: any = await paymentApi.processed({
|
||
...params,
|
||
keyword: processedFilterForm.code.trim() || undefined,
|
||
applicantId: processedFilterForm.applicantId,
|
||
...buildApplyDateRangeQuery(processedFilterForm.applyDateRange)
|
||
})
|
||
const raw = res.data
|
||
if (!raw) return { rows: [], total: 0 }
|
||
let flatRows = (raw.rows || []).map((item: any) => ({
|
||
...item.data,
|
||
title: item.data.title || ''
|
||
}))
|
||
if (processedFilterForm.status && processedFilterForm.status !== '全部') {
|
||
flatRows = flatRows.filter(
|
||
(row: any) => processedStatusLabel(row.status, row.payStatus) === processedFilterForm.status
|
||
)
|
||
}
|
||
return { rows: flatRows, total: raw.total || flatRows.length }
|
||
})
|
||
|
||
const processedViewData = ref<Record<string, any>>({})
|
||
|
||
const processedBasicKvFields = computed<ViewField[]>(() => {
|
||
const d = processedViewData.value
|
||
return [
|
||
bxViewKv('单号', d.applyCode, { long: false }),
|
||
bxViewKv('申请人', d.applicantName, { long: false }),
|
||
bxViewKv('报销标题', d.title || d.reason, { long: false }),
|
||
bxViewKvMoney('金额(元)', formatMoneyYuan(d.amount || 0), { long: false }),
|
||
bxViewKv('处理状态', processedStatusLabel(d.status, d.payStatus), {
|
||
long: false,
|
||
tagType: processedStatusTagType(d.status, d.payStatus)
|
||
}),
|
||
bxViewKv('处理时间', d.payTime, { long: false })
|
||
]
|
||
})
|
||
|
||
const processedPayKvFields = computed<ViewField[]>(() => {
|
||
const d = processedViewData.value
|
||
const payAmount = Number(d.amount || 0) - Number(d.offsetAmount || 0)
|
||
return [
|
||
bxViewKvMoney('冲抵金额(元)', formatMoneyYuan(d.offsetAmount || 0), { long: false }),
|
||
bxViewKvMoney('发放金额(元)', formatMoneyYuan(Math.max(0, payAmount)), { long: false }),
|
||
bxViewKvMoney(
|
||
'实际发放金额(元)',
|
||
formatMoneyYuan(d.actualAmount ?? Math.max(0, payAmount)),
|
||
{ long: false }
|
||
),
|
||
bxViewKv('发放时间', d.payTime, { long: false }),
|
||
bxViewKv('发放操作人', d.payUserName, { long: false }),
|
||
bxViewKv('发放备注', d.payRemark, { long: false })
|
||
]
|
||
})
|
||
|
||
const processedOffsetKvFields = computed<ViewField[]>(() => {
|
||
const d = processedViewData.value
|
||
const fields: ViewField[] = [
|
||
bxViewKvMoney('冲抵金额(元)', formatMoneyYuan(d.offsetAmount || 0))
|
||
]
|
||
if (d.payTime) fields.push(bxViewKv('处理时间', d.payTime))
|
||
if (d.payUserName) fields.push(bxViewKv('处理操作人', d.payUserName))
|
||
return fields
|
||
})
|
||
const processedApprovals = ref<any[]>([])
|
||
const processedApprovalHistory = ref<any[]>([])
|
||
const processedApprovalLoading = ref(false)
|
||
const processedAttachments = ref<Record<string, BxAttachmentItem[]>>({})
|
||
const processedOffsetRecords = ref<any[]>([])
|
||
|
||
onMounted(() => {
|
||
loadApplicantOptions()
|
||
refresh()
|
||
})
|
||
|
||
function onSelectionChange(rows: any[]) {
|
||
selectedRows.value = rows
|
||
}
|
||
|
||
function handleToolbarIssue() {
|
||
if (selectedRows.value.length === 0) {
|
||
ElMessage.warning('请先勾选一条待处理记录')
|
||
return
|
||
}
|
||
openIssueDialog(selectedRows.value[0])
|
||
}
|
||
|
||
function handleToolbarOffset() {
|
||
if (selectedRows.value.length === 0) {
|
||
ElMessage.warning('请先勾选一条待处理记录')
|
||
return
|
||
}
|
||
openOffsetDialog(selectedRows.value[0])
|
||
}
|
||
|
||
function buildPendingQuery() {
|
||
const q: Record<string, string | number> = {}
|
||
const kw = (quickSearchKeyword.value.trim() || filterForm.code.trim())
|
||
if (kw) q.keyword = kw
|
||
if (filterForm.applicantId != null) q.applicantId = filterForm.applicantId
|
||
buildApplyDateRangeQuery(filterForm.applyDateRange, q)
|
||
return q
|
||
}
|
||
|
||
function handleSearch() {
|
||
quickSearchKeyword.value = ''
|
||
search(buildPendingQuery())
|
||
}
|
||
|
||
function handleReset() {
|
||
quickSearchKeyword.value = ''
|
||
Object.assign(filterForm, { code: '', applicantId: undefined, applyDateRange: null, status: '' })
|
||
search()
|
||
}
|
||
|
||
function handleQuickSearch() {
|
||
search(buildPendingQuery())
|
||
}
|
||
|
||
function handleQuickSearchClear() {
|
||
quickSearchKeyword.value = ''
|
||
search(buildPendingQuery())
|
||
}
|
||
|
||
function handleTabChange(tab: string | number) {
|
||
if (tab === 'processed' && !tabLoaded.processed) {
|
||
processedSearch()
|
||
tabLoaded.processed = true
|
||
}
|
||
}
|
||
|
||
function buildProcessedQuery() {
|
||
const q: Record<string, string | number> = {}
|
||
const kw = (processedQuickSearchKeyword.value.trim() || processedFilterForm.code.trim())
|
||
if (kw) q.keyword = kw
|
||
if (processedFilterForm.applicantId != null) q.applicantId = processedFilterForm.applicantId
|
||
buildApplyDateRangeQuery(processedFilterForm.applyDateRange, q)
|
||
return q
|
||
}
|
||
|
||
function handleProcessedSearch() {
|
||
processedQuickSearchKeyword.value = ''
|
||
processedSearch(buildProcessedQuery())
|
||
}
|
||
|
||
function handleProcessedReset() {
|
||
processedQuickSearchKeyword.value = ''
|
||
Object.assign(processedFilterForm, { code: '', applicantId: undefined, applyDateRange: null, status: '' })
|
||
processedSearch()
|
||
}
|
||
|
||
function handleProcessedQuickSearch() {
|
||
processedSearch(buildProcessedQuery())
|
||
}
|
||
|
||
function handleProcessedQuickSearchClear() {
|
||
processedQuickSearchKeyword.value = ''
|
||
processedSearch(buildProcessedQuery())
|
||
}
|
||
|
||
useDbInstantSearch(
|
||
() => ({
|
||
code: filterForm.code,
|
||
applicantId: filterForm.applicantId,
|
||
applyDateRange: filterForm.applyDateRange,
|
||
status: filterForm.status
|
||
}),
|
||
handleSearch
|
||
)
|
||
|
||
useDbInstantSearch(
|
||
() => ({
|
||
code: processedFilterForm.code,
|
||
applicantId: processedFilterForm.applicantId,
|
||
applyDateRange: processedFilterForm.applyDateRange,
|
||
status: processedFilterForm.status
|
||
}),
|
||
handleProcessedSearch
|
||
)
|
||
|
||
async function openView(row: any) {
|
||
viewData.value = row
|
||
viewAttachments.value = []
|
||
try {
|
||
if (row.id) {
|
||
const [payFiles, offsetFiles] = await Promise.all([
|
||
loadBxAttachments('reimburse_pay', row.id).catch(() => []),
|
||
loadBxAttachments('reimburse_offset', row.id).catch(() => [])
|
||
])
|
||
viewAttachments.value = [...payFiles, ...offsetFiles]
|
||
}
|
||
} catch {
|
||
/* skip */
|
||
}
|
||
dialogs.viewDetail = true
|
||
}
|
||
|
||
function openIssueDialog(row: any) {
|
||
currentRow.value = row
|
||
issueRemark.value = ''
|
||
actualAmount.value = String(row.amount ?? '')
|
||
uploadedFiles.value = []
|
||
dialogs.issue = true
|
||
}
|
||
|
||
async function submitIssue() {
|
||
if (issueAttachmentRef.value?.hasUploading()) {
|
||
ElMessage.warning('附件上传中,请稍候')
|
||
return
|
||
}
|
||
loadingMap.issueSubmit = true
|
||
try {
|
||
await paymentApi.pay(currentRow.value.id, {
|
||
payRemark: issueRemark.value,
|
||
actualAmount: Number(actualAmount.value) || undefined
|
||
})
|
||
ElMessage.success('发放成功')
|
||
dialogs.issue = false
|
||
await refresh()
|
||
} catch (e: any) {
|
||
ElMessage.error(e.message || '发放失败')
|
||
} finally {
|
||
loadingMap.issueSubmit = false
|
||
}
|
||
}
|
||
|
||
async function fetchOffsetAdvances() {
|
||
offsetAdvanceLoading.value = true
|
||
try {
|
||
const res: any = await paymentApi.advanceIssues({
|
||
page: offsetAdvancePage.value,
|
||
pageSize: offsetAdvancePageSize.value,
|
||
issueStatus: 'issued',
|
||
keyword: offsetAdvanceFilter.keyword
|
||
})
|
||
const data = res.data
|
||
if (Array.isArray(data)) {
|
||
offsetAdvances.value = data
|
||
offsetAdvanceTotal.value = data.length
|
||
} else {
|
||
offsetAdvances.value = data?.rows ?? []
|
||
offsetAdvanceTotal.value = data?.total ?? 0
|
||
}
|
||
} finally {
|
||
offsetAdvanceLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleOffsetAdvanceSearch() {
|
||
offsetAdvancePage.value = 1
|
||
fetchOffsetAdvances()
|
||
}
|
||
|
||
function handleOffsetAdvanceReset() {
|
||
offsetAdvanceFilter.keyword = ''
|
||
offsetAdvancePage.value = 1
|
||
fetchOffsetAdvances()
|
||
}
|
||
|
||
function handleOffsetAdvanceSizeChange() {
|
||
offsetAdvancePage.value = 1
|
||
fetchOffsetAdvances()
|
||
}
|
||
|
||
function getAdvanceAvailable(adv: any): number {
|
||
return Math.max(0, Number(adv.actualAmount || adv.amount || 0) - Number(adv.offsetAmount || 0))
|
||
}
|
||
|
||
function calcAutoOffsetAmount(selected: any[], reimburseAmount: number): number {
|
||
const totalAvailable = selected.reduce((sum, adv) => sum + getAdvanceAvailable(adv), 0)
|
||
return Math.min(totalAvailable, reimburseAmount)
|
||
}
|
||
|
||
function handleOffsetSelectionChange(rows: any[]) {
|
||
offsetSelectedAdvances.value = rows
|
||
const reimburseAmount = Number(currentRow.value.amount || 0)
|
||
offsetAmount.value = String(calcAutoOffsetAmount(rows, reimburseAmount))
|
||
}
|
||
|
||
function openOffsetDialog(row: any) {
|
||
currentRow.value = row
|
||
offsetAdvanceFilter.keyword = ''
|
||
offsetAdvancePage.value = 1
|
||
offsetSelectedAdvances.value = []
|
||
offsetAmount.value = '0'
|
||
offsetRemark.value = ''
|
||
uploadedFiles.value = []
|
||
dialogs.offset = true
|
||
fetchOffsetAdvances()
|
||
}
|
||
|
||
function buildOffsetItems(totalOffset: number) {
|
||
const items: Array<{ advanceId: number; offsetAmount: number; applyCode: string }> = []
|
||
let remaining = totalOffset
|
||
for (const adv of offsetSelectedAdvances.value) {
|
||
if (remaining <= 0) break
|
||
const available = getAdvanceAvailable(adv)
|
||
const toOffset = Math.min(remaining, available)
|
||
items.push({
|
||
advanceId: adv.id,
|
||
offsetAmount: toOffset,
|
||
applyCode: adv.applyCode || String(adv.id)
|
||
})
|
||
remaining -= toOffset
|
||
}
|
||
return items
|
||
}
|
||
|
||
async function submitOffset() {
|
||
if (offsetSelectedAdvances.value.length === 0) {
|
||
ElMessage.warning('请选择要冲抵的备用金申请单')
|
||
return
|
||
}
|
||
const totalOffset = Number(offsetAmount.value) || 0
|
||
if (totalOffset <= 0) {
|
||
ElMessage.warning('请填写冲抵金额')
|
||
return
|
||
}
|
||
if (uploadedFiles.value.length === 0) {
|
||
ElMessage.warning('请至少上传 1 个冲抵附件')
|
||
return
|
||
}
|
||
if (offsetAttachmentRef.value?.hasUploading()) {
|
||
ElMessage.warning('附件上传中,请稍候')
|
||
return
|
||
}
|
||
|
||
const items = buildOffsetItems(totalOffset)
|
||
const payAmount = Number(offsetPayAmount.value) || 0
|
||
const advanceLines = items.map((it) => `${it.applyCode}(冲抵 ${formatMoneyYuan(it.offsetAmount)})`).join('\n')
|
||
const confirmMsg = [
|
||
'请确认冲抵信息:',
|
||
'',
|
||
`冲抵金额(元):${formatMoneyYuan(totalOffset)}`,
|
||
'冲抵备用金:',
|
||
advanceLines,
|
||
`发放金额(元):${formatMoneyYuan(payAmount)}`,
|
||
'',
|
||
'确定提交冲抵吗?'
|
||
].join('\n')
|
||
|
||
try {
|
||
await ElMessageBox.confirm(confirmMsg, '确认冲抵', {
|
||
confirmButtonText: '确定冲抵',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
})
|
||
} catch {
|
||
return
|
||
}
|
||
|
||
loadingMap.offsetSubmit = true
|
||
try {
|
||
await paymentApi.batchOffset(currentRow.value.id, {
|
||
items: items.map(({ advanceId, offsetAmount: amt }) => ({ advanceId, offsetAmount: amt })),
|
||
payAmount,
|
||
remark: offsetRemark.value
|
||
})
|
||
ElMessage.success('冲抵成功')
|
||
dialogs.offset = false
|
||
await refresh()
|
||
} catch (e: any) {
|
||
ElMessage.error(e.message || '冲抵失败')
|
||
} finally {
|
||
loadingMap.offsetSubmit = false
|
||
}
|
||
}
|
||
|
||
const paymentSummary = buildPageSummaryMethod({
|
||
sumByProp: {
|
||
amount: (data) => sumField(data, 'amount'),
|
||
offsetAmount: (data) => sumField(data, 'offsetAmount'),
|
||
actualAmount: (data) => sumField(data, 'actualAmount')
|
||
}
|
||
})
|
||
const summaryMethod = paymentSummary
|
||
const processedSummaryMethod = paymentSummary
|
||
|
||
async function openProcessedView(row: any) {
|
||
processedViewData.value = row
|
||
processedApprovals.value = []
|
||
processedApprovalHistory.value = []
|
||
processedAttachments.value = {}
|
||
processedOffsetRecords.value = []
|
||
processedApprovalLoading.value = true
|
||
dialogs.processedDetail = true
|
||
|
||
const fetchApprovalAndAttachments = async () => {
|
||
const bizId = row.id
|
||
if (!bizId) {
|
||
processedApprovalLoading.value = false
|
||
return
|
||
}
|
||
|
||
const tasks: Promise<any>[] = []
|
||
|
||
tasks.push(
|
||
Promise.all([
|
||
reimburseApi.getApprovals(bizId),
|
||
reimburseApi.getApprovalHistory(bizId)
|
||
])
|
||
.then(([flowRes, historyRes]: any[]) => {
|
||
processedApprovals.value = (flowRes.data || []).sort(
|
||
(a: any, b: any) => a.nodeOrder - b.nodeOrder
|
||
)
|
||
processedApprovalHistory.value = historyRes.data || []
|
||
})
|
||
.catch(() => {})
|
||
)
|
||
tasks.push(
|
||
paymentApi.reimburseOffsetRecords(bizId).then((res: any) => {
|
||
processedOffsetRecords.value = res.data || []
|
||
}).catch(() => {
|
||
processedOffsetRecords.value = []
|
||
})
|
||
)
|
||
|
||
const attachTypes = [
|
||
{ key: '申请附件', bizType: 'reimburse_apply' },
|
||
{ key: '发放附件', bizType: 'reimburse_pay' },
|
||
{ key: '冲抵附件', bizType: 'reimburse_offset' }
|
||
]
|
||
|
||
for (const at of attachTypes) {
|
||
tasks.push(
|
||
loadBxAttachments(at.bizType, bizId)
|
||
.then((files) => {
|
||
processedAttachments.value[at.key] = files
|
||
})
|
||
.catch(() => {
|
||
processedAttachments.value[at.key] = []
|
||
})
|
||
)
|
||
}
|
||
|
||
await Promise.all(tasks)
|
||
processedApprovalLoading.value = false
|
||
}
|
||
|
||
fetchApprovalAndAttachments()
|
||
}
|
||
|
||
function processedStatusLabel(status: string, payStatus?: string): string {
|
||
if (status === 'processed' || status === 'paid' || status === 'offset' || payStatus === 'paid' || payStatus === 'issued')
|
||
return '已处理'
|
||
return status || '-'
|
||
}
|
||
|
||
function processedStatusTagType(
|
||
status: string,
|
||
payStatus?: string
|
||
): 'success' | 'warning' | 'danger' | 'info' | 'primary' {
|
||
if (processedStatusLabel(status, payStatus) === '已处理') return 'success'
|
||
return 'info'
|
||
}
|
||
</script>
|