diff --git a/src/views/crm/contract/detail/index.vue b/src/views/crm/contract/detail/index.vue index 96613dac..bd30489a 100644 --- a/src/views/crm/contract/detail/index.vue +++ b/src/views/crm/contract/detail/index.vue @@ -23,7 +23,7 @@ { /** 从回款计划创建回款 */ const receivableListRef = ref>() // 回款列表 Ref -const crateReceivable = (planData: any) => { - receivableListRef.value?.crateReceivable(planData) +const createReceivable = (planData: any) => { + receivableListRef.value?.createReceivable(planData) } /** 转移 */ diff --git a/src/views/crm/customer/detail/index.vue b/src/views/crm/customer/detail/index.vue index aed4c6f2..031fcfbf 100644 --- a/src/views/crm/customer/detail/index.vue +++ b/src/views/crm/customer/detail/index.vue @@ -64,7 +64,7 @@ - + @@ -199,8 +199,8 @@ const getOperateLog = async () => { /** 从回款计划创建回款 */ const receivableListRef = ref>() // 回款列表 Ref -const crateReceivable = (planData: any) => { - receivableListRef.value?.crateReceivable(planData) +const createReceivable = (planData: any) => { + receivableListRef.value?.createReceivable(planData) } const close = () => { diff --git a/src/views/crm/receivable/ReceivableForm.vue b/src/views/crm/receivable/ReceivableForm.vue index 67715b58..bf1c141b 100644 --- a/src/views/crm/receivable/ReceivableForm.vue +++ b/src/views/crm/receivable/ReceivableForm.vue @@ -201,10 +201,14 @@ const open = async ( // 从回款计划创建回款 if (receivablePlan) { formData.value.customerId = receivablePlan.customerId + await handleCustomerChange(receivablePlan.customerId) formData.value.contractId = receivablePlan.contractId - formData.value.planId = receivablePlan.id - formData.value.price = receivablePlan.price - formData.value.returnType = receivablePlan.returnType + await handleContractChange(receivablePlan.contractId) + if (receivablePlan.id) { + formData.value.planId = receivablePlan.id + formData.value.price = receivablePlan.price + formData.value.returnType = receivablePlan.returnType + } } } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 diff --git a/src/views/crm/receivable/components/ReceivableList.vue b/src/views/crm/receivable/components/ReceivableList.vue index 587db1c5..67287ea7 100644 --- a/src/views/crm/receivable/components/ReceivableList.vue +++ b/src/views/crm/receivable/components/ReceivableList.vue @@ -1,7 +1,7 @@ - + @@ -67,6 +72,7 @@ import * as ReceivableApi from '@/api/crm/receivable' import ReceivableForm from './../ReceivableForm.vue' import { dateFormatter2 } from '@/utils/formatTime' import { DICT_TYPE } from '@/utils/dict' +import { erpPriceTableColumnFormatter } from '@/utils' defineOptions({ name: 'CrmReceivableList' }) const props = defineProps<{ @@ -117,7 +123,10 @@ const handleQuery = () => { /** 添加/修改操作 */ const formRef = ref() const openForm = (type: string, id?: number) => { - formRef.value.open(type, id) + formRef.value.open(type, id, { + customerId: props.customerId, + contractId: props.contractId + }) } /** 删除按钮操作 */ @@ -134,11 +143,12 @@ const handleDelete = async (id: number) => { } /** 从回款计划创建回款 */ -const crateReceivable = (planData: any) => { +const createReceivable = (planData: any) => { const data = planData as unknown as ReceivablePlanApi.ReceivablePlanVO formRef.value.open('create', undefined, data) } -defineExpose({ crateReceivable }) +defineExpose({ createReceivable }) + /** 监听打开的 customerId + contractId,从而加载最新的列表 */ watch( () => [props.customerId, props.contractId], diff --git a/src/views/crm/receivable/detail/index.vue b/src/views/crm/receivable/detail/index.vue index 51a3ad20..162825f2 100644 --- a/src/views/crm/receivable/detail/index.vue +++ b/src/views/crm/receivable/detail/index.vue @@ -87,12 +87,13 @@ const close = () => { /** 初始化 */ const { params } = useRoute() onMounted(async () => { - if (!params.id) { + const id = props.id || route.params.id + if (!id) { message.warning('参数错误,回款不能为空!') close() return } - receivableId.value = params.id as unknown as number + receivableId.value = id await getReceivable(receivableId.value) }) diff --git a/src/views/crm/receivable/plan/ReceivablePlanForm.vue b/src/views/crm/receivable/plan/ReceivablePlanForm.vue index 8401e5a2..5cb29429 100644 --- a/src/views/crm/receivable/plan/ReceivablePlanForm.vue +++ b/src/views/crm/receivable/plan/ReceivablePlanForm.vue @@ -136,6 +136,7 @@ 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 { aw } from '../../../../../dist-prod/assets/index-9eac537b' const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 @@ -157,7 +158,7 @@ const customerList = ref([]) // 客户列表 const contractList = ref([]) // 合同列表 /** 打开弹窗 */ -const open = async (type: string, id?: number) => { +const open = async (type: string, id?: number, customerId?: number, contractId?: number) => { dialogVisible.value = true dialogTitle.value = t('action.' + type) formType.value = type @@ -179,6 +180,14 @@ const open = async (type: string, id?: number) => { if (formType.value === 'create') { formData.value.ownerUserId = useUserStore().getUser.id } + // 设置 customerId 和 contractId 默认值 + if (customerId) { + formData.value.customerId = customerId + await handleCustomerChange(customerId) + } + if (contractId) { + formData.value.contractId = contractId + } } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 diff --git a/src/views/crm/receivable/plan/components/ReceivablePlanList.vue b/src/views/crm/receivable/plan/components/ReceivablePlanList.vue index 6edcf788..3b80526b 100644 --- a/src/views/crm/receivable/plan/components/ReceivablePlanList.vue +++ b/src/views/crm/receivable/plan/components/ReceivablePlanList.vue @@ -1,7 +1,7 @@