|
|
|
|
@ -17,11 +17,10 @@
|
|
|
|
|
<template #header>
|
|
|
|
|
<div class="flex items-center justify-between">
|
|
|
|
|
<div style="text-align: left; font-weight: bold; font-size: 24px">{{ pageTitle }}</div>
|
|
|
|
|
<el-button v-if="canAllocate" type="primary" @click="handleAddDetail">
|
|
|
|
|
<el-button v-if="canEditDetail" type="primary" @click="handleAddDetail">
|
|
|
|
|
<el-icon class="mr-1"><Plus /></el-icon>
|
|
|
|
|
新增分款
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-tag v-else-if="routeParams.type === 'allocate'" type="info">{{ allocateHintText }}</el-tag>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
@ -71,7 +70,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
|
|
|
<el-table-column v-if="canAllocate" label="操作" align="center" width="100" fixed="right">
|
|
|
|
|
<el-table-column v-if="canEditDetail" label="操作" align="center" width="100" fixed="right">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-button link type="primary" size="small" @click="handleEditDetail(row)">编辑</el-button>
|
|
|
|
|
<el-button link type="danger" size="small" @click="handleDeleteDetail(row)">删除</el-button>
|
|
|
|
|
@ -80,7 +79,7 @@
|
|
|
|
|
</el-table>
|
|
|
|
|
<el-empty
|
|
|
|
|
v-if="!detailLoading && !detailList.length"
|
|
|
|
|
:description="canAllocate ? '暂无分款明细,请点击新增分款添加' : '暂无分款明细'"
|
|
|
|
|
:description="canEditDetail ? '暂无分款明细,请点击新增分款添加' : '暂无分款明细'"
|
|
|
|
|
class="mt-3"
|
|
|
|
|
/>
|
|
|
|
|
</el-card>
|
|
|
|
|
@ -197,12 +196,6 @@ const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
|
|
|
|
|
const taskVariables = ref<Record<string, any>>({});
|
|
|
|
|
|
|
|
|
|
const FLOW_STATUS = { DRAFT: 'draft', WAITING: 'waiting', FINISH: 'finish', BACK: 'back', CANCEL: 'cancel' };
|
|
|
|
|
const INSTALLMENT_STATUS = { NOT_ALLOCATED: '0', DISPATCHED: '1', COMPLETE: '2' };
|
|
|
|
|
|
|
|
|
|
const isFlowEditable = (flowStatus?: string) =>
|
|
|
|
|
!flowStatus || flowStatus === FLOW_STATUS.DRAFT || flowStatus === FLOW_STATUS.BACK || flowStatus === FLOW_STATUS.CANCEL;
|
|
|
|
|
|
|
|
|
|
const initFormData: FinAccountInstallmentForm = {
|
|
|
|
|
accountInstallmentId: undefined,
|
|
|
|
|
installmentCode: undefined,
|
|
|
|
|
@ -216,7 +209,6 @@ const initFormData: FinAccountInstallmentForm = {
|
|
|
|
|
accountManagerIds: undefined,
|
|
|
|
|
managerUserIds: [],
|
|
|
|
|
managerNickNames: undefined,
|
|
|
|
|
canAllocate: undefined
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const form = ref<FinAccountInstallmentForm>({ ...initFormData });
|
|
|
|
|
@ -228,20 +220,8 @@ const pageTitle = computed(() => {
|
|
|
|
|
return '客户分款';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** 客户经理分款:查看模式只读,审批/分款模式在 canAllocate 时可维护明细 */
|
|
|
|
|
const canAllocate = computed(() => form.value.canAllocate === true && routeParams.value.type !== 'view');
|
|
|
|
|
|
|
|
|
|
const allocateHintText = computed(() => {
|
|
|
|
|
if (form.value.canAllocate) return '';
|
|
|
|
|
if (isFlowEditable(form.value.flowStatus) && form.value.installmentStatus === INSTALLMENT_STATUS.NOT_ALLOCATED) {
|
|
|
|
|
return '请先由财务派发给客户经理';
|
|
|
|
|
}
|
|
|
|
|
if (form.value.flowStatus === FLOW_STATUS.FINISH || form.value.installmentStatus === INSTALLMENT_STATUS.COMPLETE) {
|
|
|
|
|
return '分款已完成';
|
|
|
|
|
}
|
|
|
|
|
if (form.value.flowStatus !== FLOW_STATUS.WAITING) return '流程未处于待处理状态';
|
|
|
|
|
return '您无权操作该回款分款';
|
|
|
|
|
});
|
|
|
|
|
/** 仅分款审核页(type=approval,待办审批进入)可维护分款明细 */
|
|
|
|
|
const canEditDetail = computed(() => routeParams.value.type === 'approval');
|
|
|
|
|
|
|
|
|
|
const allocatedAmount = computed(() =>
|
|
|
|
|
Number((detailList.value || []).reduce((sum, item) => sum + Number(item.detailAmount || 0), 0))
|
|
|
|
|
@ -249,6 +229,27 @@ const allocatedAmount = computed(() =>
|
|
|
|
|
|
|
|
|
|
const remainingAmount = computed(() => Number(form.value.paymentAmount || 0) - allocatedAmount.value);
|
|
|
|
|
|
|
|
|
|
/** 分款金额与回款金额平衡容差(元) */
|
|
|
|
|
const ALLOCATION_AMOUNT_EPS = 0.005;
|
|
|
|
|
|
|
|
|
|
/** 提交/审批前校验:分款总额须等于回款金额 */
|
|
|
|
|
const validateAllocationBeforeSubmit = (): boolean => {
|
|
|
|
|
const remain = remainingAmount.value;
|
|
|
|
|
if (remain < -ALLOCATION_AMOUNT_EPS) {
|
|
|
|
|
proxy?.$modal.msgWarning(`分款金额超出回款金额,已超出 ¥${formatMoney(Math.abs(remain))},无法提交`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (remain > ALLOCATION_AMOUNT_EPS) {
|
|
|
|
|
proxy?.$modal.msgWarning(`分款金额不足回款金额,还差 ¥${formatMoney(remain)} 未分配,无法提交`);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!detailList.value.length) {
|
|
|
|
|
proxy?.$modal.msgWarning('请至少添加一条分款明细后再提交');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const formRemainingAmount = computed(() => {
|
|
|
|
|
const currentDetailAmount = Number(detailForm.detailAmount) || 0;
|
|
|
|
|
const existingTotal = Number(
|
|
|
|
|
@ -441,8 +442,7 @@ const handleAddDetail = () => {
|
|
|
|
|
proxy?.$modal.msgWarning('回款数据未加载');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!canAllocate.value) {
|
|
|
|
|
proxy?.$modal.msgWarning(allocateHintText.value || '当前不可分款');
|
|
|
|
|
if (!canEditDetail.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
showProjectDialog.value = true;
|
|
|
|
|
@ -593,6 +593,9 @@ const handleApprovalRecord = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const approvalVerifyOpen = async () => {
|
|
|
|
|
if (!validateAllocationBeforeSubmit()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
syncTaskVariables();
|
|
|
|
|
await submitVerifyRef.value?.openDialog(routeParams.value.taskId);
|
|
|
|
|
};
|
|
|
|
|
|