Files
shanxia2.0/web-admin/src/views/cell-storage/payment-confirm/RefundConfirmTab.vue
T
2026-05-28 00:15:29 +08:00

635 lines
20 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- 缴退费财务确认 · 退费 Tab -->
<!-- eslint-disable vue/no-v-model-argument -->
<template>
<div class="refund-confirm-tab">
<el-tabs
v-model="activeTab"
class="work-order-type-tabs"
@tab-change="handleStatusTabChange"
>
<el-tab-pane label="待确认" name="pending" />
<el-tab-pane label="已确认" name="confirmed" />
</el-tabs>
<div class="filter-block">
<el-form :model="searchForm" class="filter-form" label-position="top" @submit.prevent>
<div class="filter-grid">
<el-form-item label="关键词">
<el-input
v-model="searchForm.keyword"
placeholder="协议号/客户姓名/身份证号/新生儿姓名/新生儿身份证号"
clearable
@keyup.enter="handleSearch"
/>
</el-form-item>
<el-form-item label="应缴费时间">
<el-date-picker
v-model="installmentDueDateRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
style="width: 100%"
/>
</el-form-item>
</div>
<div class="filter-actions-row">
<span class="filter-hint"
>支持协议号、客户姓名、身份证号、新生儿姓名、新生儿身份证号模糊检索;默认展示应缴费时间前
15 天至后 15 天内的明细。</span
>
<div class="filter-actions-end">
<el-button class="btn-ghost" @click="handleReset">
<el-icon><RefreshLeft /></el-icon>重置
</el-button>
<el-button class="btn-main" type="primary" @click="handleSearch">
<el-icon><Search /></el-icon>搜索
</el-button>
</div>
</div>
</el-form>
</div>
<div class="list-body list-wrap refund-confirm-table-wrap">
<el-table
class="list-table"
:data="tableData"
v-loading="loading"
stripe
row-key="id"
@row-dblclick="handleRowDblClick"
>
<el-table-column
type="index"
label="序号"
min-width="68"
align="center"
header-align="center"
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
/>
<el-table-column
prop="protocolNo"
label="协议号"
min-width="130"
align="center"
header-align="center"
/>
<el-table-column
prop="motherName"
label="客户姓名"
min-width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.motherName || '-' }}</template>
</el-table-column>
<el-table-column
prop="motherIdCard"
label="身份证号"
min-width="170"
align="center"
header-align="center"
>
<template #default="{ row }">{{ maskIdCard(row.motherIdCard) }}</template>
</el-table-column>
<el-table-column
prop="newbornName"
label="新生儿姓名"
min-width="110"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.newbornName || '-' }}</template>
</el-table-column>
<el-table-column
prop="newbornIdCard"
label="新生儿身份证号"
min-width="170"
align="center"
header-align="center"
>
<template #default="{ row }">{{ maskIdCard(row.newbornIdCard) }}</template>
</el-table-column>
<el-table-column
prop="protocolStatus"
label="协议状态"
min-width="100"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-tag
:type="protocolStatusTagType(String(row.protocolStatus || ''))"
size="small"
>{{ protocolStatusLabel(String(row.protocolStatus || '')) }}</el-tag
>
</template>
</el-table-column>
<el-table-column
prop="payMode"
label="缴费方式"
min-width="100"
align="center"
header-align="center"
>
<template #default="{ row }">{{ payModeLabel(String(row.payMode || '')) }}</template>
</el-table-column>
<el-table-column
prop="installmentNo"
label="期数"
min-width="80"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.installmentNo ?? '-' }}</template>
</el-table-column>
<el-table-column
prop="installmentDueDate"
label="应缴费时间"
min-width="120"
align="center"
header-align="center"
>
<template #default="{ row }">{{
formatPaymentDueDate(row.installmentDueDate)
}}</template>
</el-table-column>
<el-table-column
prop="dueAmount"
label="应缴金额(元)"
min-width="120"
align="center"
header-align="center"
>
<template #default="{ row }">{{ formatPaymentAmount(row.dueAmount) }}</template>
</el-table-column>
<el-table-column
prop="transferAmount"
label="实缴金额(元)"
min-width="120"
align="center"
header-align="center"
>
<template #default="{ row }">{{ formatPaymentAmount(row.transferAmount) }}</template>
</el-table-column>
<el-table-column
prop="transferType"
label="转账方式"
min-width="110"
align="center"
header-align="center"
>
<template #default="{ row }">{{
transferTypeLabel(String(row.transferType || ''))
}}</template>
</el-table-column>
<el-table-column
prop="transferTime"
label="转账时间"
min-width="170"
align="center"
header-align="center"
>
<template #default="{ row }">{{ row.transferTime || '-' }}</template>
</el-table-column>
<el-table-column
prop="refundAmount"
label="退费金额(元)"
min-width="120"
align="center"
header-align="center"
>
<template #default="{ row }">{{ formatPaymentAmount(row.refundAmount) }}</template>
</el-table-column>
<el-table-column
prop="refundRemark"
label="退费备注"
min-width="120"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">{{ row.refundRemark || '-' }}</template>
</el-table-column>
<el-table-column
prop="payStatus"
label="状态"
min-width="110"
align="center"
header-align="center"
>
<template #default>
<el-tag :type="activeTab === 'pending' ? 'warning' : 'success'" size="small">
{{ activeTab === 'pending' ? '退费确认中' : '已退费' }}
</el-tag>
</template>
</el-table-column>
<el-table-column
v-if="activeTab === 'confirmed'"
prop="updateTime"
label="确认时间"
min-width="170"
align="center"
header-align="center"
/>
<el-table-column
v-if="activeTab === 'confirmed'"
prop="refundFinanceRemark"
label="财务备注"
min-width="120"
align="center"
header-align="center"
show-overflow-tooltip
>
<template #default="{ row }">{{ row.refundFinanceRemark || '-' }}</template>
</el-table-column>
<el-table-column
v-if="activeTab === 'pending'"
prop="createTime"
label="创建时间"
min-width="170"
align="center"
header-align="center"
/>
<el-table-column
label="操作"
min-width="140"
fixed="right"
align="center"
header-align="center"
>
<template #default="{ row }">
<el-button
v-if="activeTab === 'pending'"
class="btn-op-item primary"
@click="openConfirm(row)"
>
确认退费
</el-button>
<el-button v-else class="btn-op-item" @click="openViewConfirm(row)"
>查看确认信息</el-button
>
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
<el-pagination
:current-page="pagination.page"
:page-size="pagination.pageSize"
:total="pagination.total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())"
@current-change="(val) => ((pagination.page = val), loadData())"
/>
</div>
</div>
<el-dialog
v-model="dialogVisible"
title="确认退费"
width="900px"
class="dialog-form-layout refund-confirm-dialog"
align-center
destroy-on-close
:close-on-click-modal="false"
>
<ProtocolPaymentDetailReadonly
:detail="confirmRow"
title="缴费明细(请核对)"
show-refund-apply
refund-apply-title="退费申请(请核对)"
@preview="handleAttachmentPreview"
@download="handleAttachmentDownload"
/>
<div class="form-section-divider" />
<h4 class="detail-section-title">财务确认</h4>
<el-form label-position="top" class="biz-dialog-form">
<ProtocolFinanceConfirmFields
v-model:finance-remark="financeRemark"
v-model:attachments="attachments"
upload-folder="protocol-finance-refund"
/>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="dialogVisible = false">
<el-icon><Close /></el-icon>
取消
</el-button>
<el-button
class="btn-main"
type="primary"
:loading="submitLoading"
@click="submitConfirm"
>
<el-icon><Check /></el-icon>
确认
</el-button>
</template>
</el-dialog>
<el-dialog
v-model="viewDialogVisible"
title="确认退费信息"
width="900px"
class="dialog-form-layout refund-confirm-dialog"
align-center
destroy-on-close
>
<ProtocolPaymentDetailReadonly
:detail="viewRow"
title="缴费明细"
show-refund-apply
refund-apply-title="退费申请"
@preview="handleAttachmentPreview"
@download="handleAttachmentDownload"
/>
<div class="form-section-divider" />
<h4 class="detail-section-title">财务确认信息</h4>
<el-form label-position="top" class="biz-dialog-form view-confirm-form">
<div class="form-grid-2">
<el-form-item label="确认时间" class="form-col-span-2">
<span class="view-field-text">{{ viewRow?.updateTime || '-' }}</span>
</el-form-item>
<el-form-item label="财务备注" class="form-col-span-2">
<span class="view-field-text view-field-text--multiline">{{
viewRow?.refundFinanceRemark || '—'
}}</span>
</el-form-item>
<el-form-item label="财务确认附件" class="form-col-span-2">
<ProtocolAttachmentReadonly
:files="viewFinanceAttachmentFiles"
@preview="handleAttachmentPreview"
@download="handleAttachmentDownload"
/>
</el-form-item>
</div>
</el-form>
<template #footer>
<el-button class="btn-ghost" @click="viewDialogVisible = false">
<el-icon><Close /></el-icon>
关闭
</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Close, Check, RefreshLeft, Search } from '@element-plus/icons-vue'
import {
fetchRefundConfirmList,
fetchRefundConfirmedList,
fetchRefundConfirmSubmit
} from '@/api/collection-protocol'
import ProtocolFinanceConfirmFields from '@/components/business/protocol-finance-confirm-fields/index.vue'
import ProtocolPaymentDetailReadonly from '@/components/business/protocol-payment-detail-readonly/index.vue'
import ProtocolAttachmentReadonly from '../protocol/ProtocolAttachmentReadonly.vue'
import {
financeAttachmentsToUrlString,
type FinanceAttachmentItem
} from '@/components/business/protocol-finance-confirm-fields/finance-attachments'
import { maskIdCard } from '@/utils/mask-sensitive'
import { downloadAttachmentFile } from '@/utils/download-attachment'
import {
formatPaymentDueDate,
payModeLabel,
protocolStatusLabel,
protocolStatusTagType,
transferTypeLabel
} from '@/utils/protocol-payment-labels'
import { formatMoneyDisplay } from '@/utils/money-format'
defineOptions({ name: 'CellStorageRefundConfirmTab' })
function formatPaymentAmount(v: unknown): string {
if (v == null || v === '') return '-'
return '¥' + formatMoneyDisplay(v)
}
function formatLocalDate(d: Date): string {
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
return `${y}-${m}-${day}`
}
function getDefaultInstallmentDueDateRange(): [string, string] {
const today = new Date()
const start = new Date(today)
const end = new Date(today)
start.setDate(start.getDate() - 15)
end.setDate(end.getDate() + 15)
return [formatLocalDate(start), formatLocalDate(end)]
}
const searchForm = reactive({ keyword: '' })
const installmentDueDateRange = ref<[string, string] | null>(getDefaultInstallmentDueDateRange())
const activeTab = ref('pending')
const tableData = ref<Record<string, unknown>[]>([])
const loading = ref(false)
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
const dialogVisible = ref(false)
const viewDialogVisible = ref(false)
const submitLoading = ref(false)
const financeRemark = ref('')
const attachments = ref<FinanceAttachmentItem[]>([])
const currentDetailId = ref<string | null>(null)
const confirmRow = ref<Record<string, unknown> | null>(null)
const viewRow = ref<Record<string, unknown> | null>(null)
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
const viewFinanceAttachmentFiles = computed(() => {
const row = viewRow.value
if (!row) return []
if (Array.isArray(row.refundFinanceConfirmAttachmentFiles)) {
return row.refundFinanceConfirmAttachmentFiles as Array<Record<string, unknown>>
}
const urls = String(row.refundFinanceConfirmAttachments || '')
if (!urls.trim()) return []
return urls
.split(',')
.map((u, i) => {
const url = u.trim()
if (!url) return null
const name = url.includes('/') ? url.split('/').pop() || `附件${i + 1}` : url
return { id: `url_${i}`, fileUrl: url, fileName: name }
})
.filter(Boolean) as Array<Record<string, unknown>>
})
function fullFileUrl(url: string) {
if (!url) return ''
if (/^https?:\/\//i.test(url)) return url
return minioBaseUrl ? `${minioBaseUrl}/${url.replace(/^\//, '')}` : url
}
function handleAttachmentPreview(file: Record<string, unknown>) {
const url = String(file.fileUrl || '')
if (!url) return
window.open(fullFileUrl(url), '_blank')
}
function handleAttachmentDownload(file: Record<string, unknown>) {
downloadAttachmentFile(file, { fullFileUrl })
}
function buildListParams() {
return {
page: pagination.page,
pageSize: pagination.pageSize,
keyword: searchForm.keyword || undefined,
installmentDueDateStart: installmentDueDateRange.value?.[0] || undefined,
installmentDueDateEnd: installmentDueDateRange.value?.[1] || undefined
}
}
async function loadData() {
loading.value = true
try {
const params = buildListParams()
const res =
activeTab.value === 'pending'
? await fetchRefundConfirmList(params)
: await fetchRefundConfirmedList(params)
tableData.value = res.list || []
pagination.total = res.total ?? 0
} finally {
loading.value = false
}
}
function handleStatusTabChange() {
pagination.page = 1
loadData()
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.keyword = ''
installmentDueDateRange.value = getDefaultInstallmentDueDateRange()
pagination.page = 1
loadData()
}
function openConfirm(row: Record<string, unknown>) {
currentDetailId.value = String(row.id)
confirmRow.value = row
financeRemark.value = ''
attachments.value = []
dialogVisible.value = true
}
function openViewConfirm(row: Record<string, unknown>) {
viewRow.value = row
viewDialogVisible.value = true
}
/** 双击行:非待确认 tab 时等同于点击「查看确认信息」 */
function handleRowDblClick(row: Record<string, unknown>) {
if (activeTab.value !== 'pending') openViewConfirm(row)
}
async function submitConfirm() {
if (!currentDetailId.value) return
if (attachments.value.some((f) => f._uploading)) {
ElMessage.warning('附件上传中,请稍候')
return
}
submitLoading.value = true
try {
await fetchRefundConfirmSubmit(currentDetailId.value, {
refundFinanceConfirmAttachments:
financeAttachmentsToUrlString(attachments.value) || undefined,
refundFinanceRemark: financeRemark.value.trim() || undefined
})
dialogVisible.value = false
loadData()
} finally {
submitLoading.value = false
}
}
watchDebounced(
[searchForm, installmentDueDateRange],
() => {
pagination.page = 1
loadData()
},
{ debounce: 300, deep: true }
)
onMounted(() => {
loadData()
})
</script>
<style scoped lang="scss">
.work-order-type-tabs {
padding: 0 16px;
margin-bottom: 4px;
}
.filter-form :deep(.el-form-item) {
margin-bottom: 0;
min-width: 0;
}
.filter-form :deep(.el-form-item__label) {
font-size: 13px;
font-weight: 500;
color: var(--mint-text-muted, #64748b);
padding: 0 0 4px;
line-height: 1.2;
}
.refund-confirm-table-wrap {
overflow-x: auto;
}
.refund-confirm-dialog {
:deep(.el-dialog__body) {
padding-top: 16px;
}
}
.form-section-divider {
height: 1px;
margin: 20px 0;
background: var(--mint-border, #e2e8f0);
}
.detail-section-title {
margin: 0 0 16px;
font-size: 14px;
font-weight: 600;
color: var(--mint-text, #334155);
line-height: 1.4;
}
.view-confirm-form :deep(.el-form-item) {
margin-bottom: 0;
}
.view-field-text {
display: block;
font-size: 14px;
color: var(--mint-text, #334155);
line-height: 1.5;
word-break: break-word;
&--multiline {
white-space: pre-wrap;
}
}
</style>