diff --git a/src/views/oa/erp/finAccountInstallment/index.vue b/src/views/oa/erp/finAccountInstallment/index.vue index d00b818..7d084df 100644 --- a/src/views/oa/erp/finAccountInstallment/index.vue +++ b/src/views/oa/erp/finAccountInstallment/index.vue @@ -119,23 +119,39 @@ - + - - - + + + selectedInstallmentRows.value.length > 0 && selectedInstallmentRows.value.every(isNotAllocated) ); -const installmentDialog = reactive({ visible: false, loading: false }); +const installmentDialog = reactive({ visible: false, loading: false, title: '新增回款' }); const installmentFormRef = ref(); -const installmentForm = reactive({ +const installmentFormKey = ref(0); +const getDefaultInstallmentForm = (): FinAccountInstallmentForm => ({ + accountInstallmentId: undefined, customerName: undefined, paymentAmount: undefined, paymentDate: undefined, remark: undefined, currency: 'CNY' }); +const installmentForm = reactive(getDefaultInstallmentForm()); /** 客户下拉(选项值存客户名称) */ const customerInfoList = ref([]); const getCustomerInfoListSelect = async () => { @@ -523,29 +556,87 @@ const handleInstallmentSelectionChange = (rows: FinAccountInstallmentVO[]) => { selectedInstallmentRows.value = rows; }; -const handleAddInstallment = () => { - installmentForm.customerName = undefined; - installmentForm.paymentAmount = undefined; - installmentForm.paymentDate = undefined; - installmentForm.remark = undefined; - installmentForm.currency = 'CNY'; +const resetInstallmentForm = () => { + Object.assign(installmentForm, getDefaultInstallmentForm()); +}; + +const handleAddInstallment = async () => { + resetInstallmentForm(); + installmentFormKey.value++; + installmentDialog.title = '新增回款'; installmentDialog.visible = true; + await nextTick(); + installmentFormRef.value?.clearValidate(); +}; + +/** 修改未分款回款 */ +const handleUpdate = async (row: FinAccountInstallmentVO) => { + if (!isNotAllocated(row)) { + proxy?.$modal.msgWarning('仅未分款状态的回款可修改'); + return; + } + resetInstallmentForm(); + Object.assign(installmentForm, { + accountInstallmentId: row.accountInstallmentId, + customerName: row.customerName, + paymentAmount: row.paymentAmount, + paymentDate: row.paymentDate, + remark: row.remark, + currency: row.currency || 'CNY' + }); + installmentDialog.title = '修改回款'; + installmentDialog.visible = true; + await nextTick(); + installmentFormRef.value?.clearValidate(); }; const submitInstallmentForm = async () => { const valid = await installmentFormRef.value?.validate(); if (!valid) return; installmentDialog.loading = true; + const isEdit = !!installmentForm.accountInstallmentId; try { - await addFinAccountInstallment(installmentForm); - proxy?.$modal.msgSuccess('新增成功'); + if (isEdit) { + await updateFinAccountInstallment(installmentForm); + proxy?.$modal.msgSuccess('修改成功'); + } else { + await addFinAccountInstallment(installmentForm); + proxy?.$modal.msgSuccess('新增成功'); + } installmentDialog.visible = false; + const selectedId = selectedInstallment.value?.accountInstallmentId; await getList(); + if (isEdit && selectedId === installmentForm.accountInstallmentId) { + const updated = finAccountInstallmentList.value.find((item) => item.accountInstallmentId === selectedId); + if (updated) { + selectedInstallment.value = updated; + await getDetailList(); + } + } } finally { installmentDialog.loading = false; } }; +/** 删除单条未分款回款 */ +const handleDelete = async (row: FinAccountInstallmentVO) => { + if (!isNotAllocated(row)) { + proxy?.$modal.msgWarning('仅未分款状态的回款可删除'); + return; + } + await proxy?.$modal.confirm(`是否确认删除回款编号为「${row.installmentCode}」的数据?`); + await delFinAccountInstallment(row.accountInstallmentId); + proxy?.$modal.msgSuccess('删除成功'); + if (selectedInstallment.value?.accountInstallmentId === row.accountInstallmentId) { + selectedInstallment.value = null; + finAccountInstallmentDetailList.value = []; + } + selectedInstallmentRows.value = selectedInstallmentRows.value.filter( + (item) => item.accountInstallmentId !== row.accountInstallmentId + ); + await getList(); +}; + /** 打开派发弹窗(批量勾选或操作列单条) */ const openDispatchDialog = async (rows?: FinAccountInstallmentVO[]) => { const targetRows = rows ?? selectedInstallmentRows.value; diff --git a/src/views/oa/finAccountInstallment/index.vue b/src/views/oa/finAccountInstallment/index.vue deleted file mode 100644 index 71ecce7..0000000 --- a/src/views/oa/finAccountInstallment/index.vue +++ /dev/null @@ -1,357 +0,0 @@ - - -