From 5369328b37daf6c96c0546a32eb46f0dafff55b5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 25 Feb 2024 18:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20CRM=EF=BC=9A=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E7=9A=84=E6=96=B0=E5=A2=9E/=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/crm/receivable/plan/index.ts | 6 +- src/views/crm/receivable/ReceivableForm.vue | 181 ++++++++++-------- src/views/crm/receivable/index.vue | 1 - .../plan/components/ReceivablePlanList.vue | 13 +- src/views/crm/receivable/plan/index.vue | 31 +-- 5 files changed, 123 insertions(+), 109 deletions(-) diff --git a/src/api/crm/receivable/plan/index.ts b/src/api/crm/receivable/plan/index.ts index f11ca17c..ce379beb 100644 --- a/src/api/crm/receivable/plan/index.ts +++ b/src/api/crm/receivable/plan/index.ts @@ -4,7 +4,6 @@ export interface ReceivablePlanVO { id: number period: number receivableId: number - finishStatus: number price: number returnTime: Date remindDays: number @@ -43,10 +42,9 @@ export const getReceivablePlan = async (id: number) => { } // 查询回款计划下拉数据 -// TODO @芋艿:再看看这里 -export const getReceivablePlanListByContractId = async (customerId: number, contractId: number) => { +export const getReceivablePlanSimpleList = async (customerId: number, contractId: number) => { return await request.get({ - url: `/crm/receivable-plan/list-all-simple-by-customer?customerId=${customerId}&contractId=${contractId}` + url: `/crm/receivable-plan/simple-list?customerId=${customerId}&contractId=${contractId}` }) } diff --git a/src/views/crm/receivable/ReceivableForm.vue b/src/views/crm/receivable/ReceivableForm.vue index 537173f9..67715b58 100644 --- a/src/views/crm/receivable/ReceivableForm.vue +++ b/src/views/crm/receivable/ReceivableForm.vue @@ -10,12 +10,37 @@ - + + + + + + + + + + - + + + - - - - - - - - + + + @@ -103,14 +127,11 @@ /> + + - + @@ -129,20 +150,19 @@ import * as CustomerApi from '@/api/crm/customer' import * as ContractApi from '@/api/crm/contract' import { useUserStore } from '@/store/modules/user' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' +import form from '@/components/Form/src/Form.vue' const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 -const userList = ref([]) // 用户列表 +const userOptions = ref([]) // 用户列表 const dialogVisible = ref(false) // 弹窗的是否展示 const dialogTitle = ref('') // 弹窗的标题 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 const formType = ref('') // 表单的类型:create - 新增;update - 修改 const formData = ref({} as ReceivableApi.ReceivableVO) const formRules = reactive({ - no: [{ required: true, message: '回款编号不能为空', trigger: 'blur' }], customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }], contractId: [{ required: true, message: '合同不能为空', trigger: 'blur' }], - auditStatus: [{ required: true, message: '审批状态不能为空', trigger: 'blur' }], returnTime: [{ required: true, message: '回款日期不能为空', trigger: 'blur' }], price: [{ required: true, message: '回款金额不能为空', trigger: 'blur' }] }) @@ -150,8 +170,13 @@ const formRef = ref() // 表单 Ref const customerList = ref([]) // 客户列表 const contractList = ref([]) // 合同列表 const receivablePlanList = ref([]) // 回款计划列表 + /** 打开弹窗 */ -const open = async (type: string, id?: number, planData?: ReceivablePlanApi.ReceivablePlanVO) => { +const open = async ( + type: string, + id?: number, + receivablePlan?: ReceivablePlanApi.ReceivablePlanVO +) => { dialogVisible.value = true dialogTitle.value = t('action.' + type) formType.value = type @@ -166,7 +191,7 @@ const open = async (type: string, id?: number, planData?: ReceivablePlanApi.Rece } } // 获得用户列表 - userList.value = await UserApi.getSimpleUserList() + userOptions.value = await UserApi.getSimpleUserList() // 获得客户列表 customerList.value = await CustomerApi.getCustomerSimpleList() // 默认新建时选中自己 @@ -174,10 +199,12 @@ const open = async (type: string, id?: number, planData?: ReceivablePlanApi.Rece formData.value.ownerUserId = useUserStore().getUser.id } // 从回款计划创建回款 - if (planData) { - formData.value.customerId = planData.customerId - formData.value.contractId = planData.contractId - formData.value.planId = planData.id + if (receivablePlan) { + formData.value.customerId = receivablePlan.customerId + formData.value.contractId = receivablePlan.contractId + formData.value.planId = receivablePlan.id + formData.value.price = receivablePlan.price + formData.value.returnType = receivablePlan.returnType } } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 @@ -214,53 +241,47 @@ const resetForm = () => { formRef.value?.resetFields() } -const getContractList = async (customerId: number) => { - contractList.value = await ContractApi.getContractSimpleList(customerId) +/** 处理切换客户 */ +const handleCustomerChange = async (customerId: number) => { + // 重置合同编号 + formData.value.contractId = undefined + // 获得合同列表 + if (customerId) { + contractList.value = [] + contractList.value = await ContractApi.getContractSimpleList(customerId) + } } -const getReceivablePlanList = async (contractId: number) => { - receivablePlanList.value = await ReceivablePlanApi.getReceivablePlanListByContractId( - formData.value.customerId, - contractId - ) + +/** 处理切换合同 */ +const handleContractChange = async (contractId: number) => { + // 重置回款计划编号 + formData.value.planId = undefined + if (contractId) { + // 获得回款计划列表 + receivablePlanList.value = [] + receivablePlanList.value = await ReceivablePlanApi.getReceivablePlanSimpleList( + formData.value.customerId, + contractId + ) + // 设置金额 + const contract = contractList.value.find((item) => item.id === contractId) + if (contract) { + // TODO @芋艿:后续可以改成未还款金额 + formData.value.price = contract.totalPrice + } + } } -watch( - () => formData.value.customerId, - (newVal) => { - if (!newVal) { - return - } - getContractList(newVal) - }, - { - immediate: true + +/** 处理切换回款计划 */ +const handleReceivablePlanChange = (planId: number) => { + if (!planId) { + return } -) -watch( - () => formData.value.contractId, - (newVal) => { - if (!newVal) { - return - } - getReceivablePlanList(newVal) - }, - { - immediate: true + const receivablePlan = receivablePlanList.value.find((item) => item.id === planId) + if (!receivablePlan) { + return } -) -watch( - () => formData.value.planId, - (newVal) => { - if (!newVal) { - return - } - const receivablePlan = receivablePlanList.value.find((item) => item.id === newVal) - if (!receivablePlan) { - return - } - // 只有没有金额的时候才设置 - if (!formData.value.price || formData.value.price === 0) { - formData.value.price = receivablePlan.price - } - } -) + formData.value.price = receivablePlan.price + formData.value.returnType = receivablePlan.returnType +} diff --git a/src/views/crm/receivable/index.vue b/src/views/crm/receivable/index.vue index a02847ba..0ec29bdb 100644 --- a/src/views/crm/receivable/index.vue +++ b/src/views/crm/receivable/index.vue @@ -195,7 +195,6 @@ -