额度审批

This commit is contained in:
luojiaquan
2026-09-17 09:00:26 +08:00
parent 6487146117
commit 324da1baa1
14 changed files with 974 additions and 439 deletions
@@ -14,14 +14,14 @@
<el-button
icon="Document"
@click="goBillView"
v-hasPermi="['customer:bill:list']"
v-hasPermi="['ar:bill:list']"
>查看账单</el-button>
<el-button
type="primary"
icon="Money"
@click="openAdjustDialog()"
v-hasPermi="['customer:credit:adjust']"
>额度调整</el-button>
>额度调整申请</el-button>
</div>
</div>
</el-card>
@@ -339,6 +339,97 @@
@pagination="getCreditFlowList"
/>
</el-tab-pane>
<!-- ====== 额度审批(信用/额外额度调整申请) ====== -->
<el-tab-pane label="额度审批" name="creditApply">
<el-alert type="warning" :closable="false" class="credit-apply-tip">
信用额度 / 额外额度调整需先提交申请,审批通过后额度才会调整并写入额度流水。
</el-alert>
<el-form :model="applyQuery" :inline="true" class="search-form">
<el-form-item label="额度类型" prop="creditType">
<el-select v-model="applyQuery.creditType" placeholder="全部" clearable style="width: 130px;">
<el-option v-for="opt in creditTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="applyQuery.status" placeholder="全部" clearable style="width: 130px;">
<el-option v-for="opt in applyStatusOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="getApplyList">搜索</el-button>
<el-button icon="Refresh" @click="resetApplyQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="applyList" border v-loading="applyLoading">
<el-table-column label="申请单号" align="center" prop="applyNo" width="180" />
<el-table-column label="额度类型" align="center" prop="creditType" width="100">
<template #default="scope">
<el-tag :type="scope.row.creditType === 'TEMP' ? 'warning' : ''">
{{ formatOption(creditTypeOptions, scope.row.creditType) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="调整方式" align="center" prop="adjustMode" width="90">
<template #default="scope">{{ formatOption(adjustModeOptions, scope.row.adjustMode) }}</template>
</el-table-column>
<el-table-column label="调整金额" align="center" prop="changeAmount" width="110">
<template #default="scope">{{ formatMoney(scope.row.changeAmount) }}</template>
</el-table-column>
<el-table-column label="生效日期" align="center" prop="effectiveDate" width="100">
<template #default="scope">{{ scope.row.effectiveDate || '-' }}</template>
</el-table-column>
<el-table-column label="失效日期" align="center" prop="expireDate" width="100">
<template #default="scope">{{ scope.row.expireDate || '长期' }}</template>
</el-table-column>
<el-table-column label="调整原因" align="center" prop="reason" min-width="150" show-overflow-tooltip />
<el-table-column label="状态" align="center" prop="status" width="90">
<template #default="scope">
<el-tag :type="applyStatusTag(scope.row.status)" size="small">
{{ formatOption(applyStatusOptions, scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="申请人" align="center" prop="applyBy" width="100" />
<el-table-column label="申请时间" align="center" prop="applyTime" width="150">
<template #default="scope">{{ formatDateTime(scope.row.applyTime) }}</template>
</el-table-column>
<el-table-column label="审批人" align="center" prop="approveBy" width="100">
<template #default="scope">{{ scope.row.approveBy || '-' }}</template>
</el-table-column>
<el-table-column label="审批时间" align="center" prop="approveTime" width="150">
<template #default="scope">{{ scope.row.approveTime ? formatDateTime(scope.row.approveTime) : '-' }}</template>
</el-table-column>
<el-table-column label="审批意见" align="center" prop="approveRemark" min-width="140" show-overflow-tooltip>
<template #default="scope">{{ scope.row.approveRemark || '-' }}</template>
</el-table-column>
<el-table-column label="操作" align="center" width="150" fixed="right">
<template #default="scope">
<template v-if="scope.row.status === 'PENDING'">
<el-button link type="success" size="small"
@click="handleApproveApply(scope.row)"
v-hasPermi="['customer:credit:approve']">通过</el-button>
<el-button link type="danger" size="small"
@click="handleRejectApply(scope.row)"
v-hasPermi="['customer:credit:approve']">驳回</el-button>
<el-button link type="warning" size="small"
@click="handleCancelApply(scope.row)"
v-hasPermi="['customer:credit:adjust']">撤销</el-button>
</template>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="applyTotal > 0"
:total="applyTotal"
v-model:page="applyQuery.pageNum"
v-model:limit="applyQuery.pageSize"
@pagination="getApplyList"
/>
</el-tab-pane>
<!-- ====== 账单核销(用账户余额核销应收账单) ====== -->
<el-tab-pane label="账单核销" name="billWriteoff">
<el-alert type="info" :closable="false" class="writeoff-summary">
@@ -348,7 +439,7 @@
<span>账户余额:<b class="money-in">CNY {{ formatMoney(currentAccount.balance) }}</b></span>
<el-button type="primary" link size="small" icon="Refresh" @click="loadBillWriteoffData">刷新</el-button>
<el-button type="primary" plain size="small" @click="goBillView"
v-hasPermi="['customer:bill:list']">查看全部账单</el-button>
v-hasPermi="['ar:bill:list']">查看全部账单</el-button>
</div>
</el-alert>
@@ -621,9 +712,9 @@
</template>
</el-dialog>
<!-- ====== 额度调整弹窗 ====== -->
<!-- ====== 额度调整申请弹窗 ====== -->
<el-dialog
:title="creditDialog.form.creditType === 'TEMP' ? '临时额度调整' : '信用额度调整'"
:title="(creditDialog.form.creditType === 'TEMP' ? '额外额度调整申请' : '信用额度调整申请') + '(提交后需审批)'"
v-model="creditDialog.visible"
width="600px"
append-to-body
@@ -724,7 +815,7 @@
</div>
<template #footer>
<el-button type="primary" :loading="creditSubmitLoading" @click="submitAdjustCredit">确 定</el-button>
<el-button type="primary" :loading="creditSubmitLoading" @click="submitAdjustCredit">提交申请</el-button>
<el-button @click="creditDialog.visible = false">取 消</el-button>
</template>
</el-dialog>
@@ -804,7 +895,7 @@
import axios from 'axios'
import { saveAs } from 'file-saver'
import { getCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
import { listAccount, listReceipt, getReceipt, addReceipt, confirmReceipt, cancelReceipt, listFlow, listCreditFlow, adjustCredit } from "@/api/customersuppliermanagement/customermoney/customermoney.js"
import { listAccount, listReceipt, getReceipt, addReceipt, confirmReceipt, cancelReceipt, listFlow, listCreditFlow, applyCreditAdjust, listCreditApply, approveCreditApply, rejectCreditApply, cancelCreditApply } from "@/api/customersuppliermanagement/customermoney/customermoney.js"
import { listUnsettledBill, listBalanceWriteoff, balanceWriteoff, cancelBalanceWriteoff } from "@/api/customersuppliermanagement/customermoney/customerbill.js"
import { convertToBase } from "@/api/data/exchangeRate"
import { getToken } from "@/utils/auth"
@@ -1056,12 +1147,12 @@ function submitAdjustCredit() {
payload.expireDate = f.expireDate || null
}
creditSubmitLoading.value = true
adjustCredit(payload).then(() => {
proxy.$modal.msgSuccess('额度调整成功')
applyCreditAdjust(payload).then(() => {
proxy.$modal.msgSuccess('申请已提交,等待审批')
creditDialog.visible = false
loadCustomer()
loadAccounts()
getCreditFlowList()
if (creditApplyLoaded) {
getApplyList()
}
}).finally(() => {
creditSubmitLoading.value = false
})
@@ -1346,6 +1437,88 @@ function resetCreditFlowQuery() {
getCreditFlowList()
}
/* ================= 额度调整申请/审批 ================= */
const applyStatusOptions = [
{ value: 'PENDING', label: '待审批' },
{ value: 'APPROVED', label: '已通过' },
{ value: 'REJECTED', label: '已驳回' },
{ value: 'CANCELLED', label: '已撤销' }
]
const applyStatusTagMap = { PENDING: 'warning', APPROVED: 'success', REJECTED: 'danger', CANCELLED: 'info' }
function applyStatusTag(v) {
return applyStatusTagMap[v] || 'info'
}
const applyList = ref([])
const applyTotal = ref(0)
const applyLoading = ref(false)
const applyQuery = reactive({
pageNum: 1,
pageSize: 10,
customerId: route.query.customerId,
creditType: '',
status: ''
})
let creditApplyLoaded = false
function getApplyList() {
const customerId = route.query.customerId
if (!customerId) return
applyLoading.value = true
applyQuery.customerId = customerId
listCreditApply({ ...applyQuery }).then(res => {
applyList.value = res.rows || []
applyTotal.value = res.total || 0
}).finally(() => {
applyLoading.value = false
})
}
function resetApplyQuery() {
applyQuery.creditType = ''
applyQuery.status = ''
applyQuery.pageNum = 1
getApplyList()
}
/** 审批通过后刷新账户卡片与额度流水 */
function afterApplyHandled() {
getApplyList()
loadAccounts()
getCreditFlowList()
}
function handleApproveApply(row) {
proxy.$modal.confirm(`确认通过额度调整申请「${row.applyNo}」?通过后将立即调整客户额度并写入额度流水。`)
.then(() => approveCreditApply(row.applyId, '审批通过'))
.then(() => {
proxy.$modal.msgSuccess('已审批通过')
afterApplyHandled()
}).catch(() => {})
}
function handleRejectApply(row) {
proxy.$prompt('请输入驳回原因', '驳回额度调整申请', {
confirmButtonText: '确认驳回',
cancelButtonText: '取消',
inputType: 'textarea',
inputPattern: /\S+/,
inputErrorMessage: '驳回原因不能为空'
}).then(({ value }) => rejectCreditApply(row.applyId, value)).then(() => {
proxy.$modal.msgSuccess('已驳回')
getApplyList()
}).catch(() => {})
}
function handleCancelApply(row) {
proxy.$modal.confirm(`确认撤销待审批申请「${row.applyNo}」?`)
.then(() => cancelCreditApply(row.applyId))
.then(() => {
proxy.$modal.msgSuccess('已撤销')
getApplyList()
}).catch(() => {})
}
/* ================= 账单核销 ================= */
const billStatusMap = {
DRAFT: { label: '草稿', type: 'info' },
@@ -1366,7 +1539,7 @@ function formatDate(val) {
}
function goBillView() {
router.push({
path: '/customersuppliermanagement/customerbill',
path: '/ar/bill',
query: { customerId: route.query.customerId || '' }
})
}
@@ -1510,6 +1683,10 @@ function submitCancelWriteoff() {
}
watch(activeTab, (tab) => {
if (tab === 'creditApply' && !creditApplyLoaded) {
creditApplyLoaded = true
getApplyList()
}
if (tab === 'billWriteoff' && !billWriteoffLoaded) {
billWriteoffLoaded = true
loadBillWriteoffData()
@@ -1632,6 +1809,13 @@ function initPage() {
flowTotal.value = 0
creditFlowList.value = []
creditFlowTotal.value = 0
applyList.value = []
applyTotal.value = 0
applyQuery.customerId = customerId
applyQuery.creditType = ''
applyQuery.status = ''
applyQuery.pageNum = 1
creditApplyLoaded = false
unsettledList.value = []
writeoffList.value = []
writeoffTotal.value = 0
@@ -1716,6 +1900,9 @@ watch(() => route.query.customerId, (newId, oldId) => {
.credit-tip {
margin-bottom: 12px;
}
.credit-apply-tip {
margin-bottom: 12px;
}
.credit-preview {
margin-top: 4px;
padding: 10px 14px;