CRM:完善回款 plan 新增/修改

(cherry picked from commit 56d92e5bfb)
This commit is contained in:
YunaiV 2024-02-25 16:09:22 +08:00 committed by shizhong
parent 3ca2dcbea0
commit 71125e5b7c
4 changed files with 72 additions and 54 deletions

View File

@ -66,9 +66,9 @@ export const getContract = async (id: number) => {
} }
// 查询 CRM 合同下拉列表 // 查询 CRM 合同下拉列表
export const getCrmContractSimpleListByCustomerId = async (customerId: number) => { export const getContractSimpleList = async (customerId: number) => {
return await request.get({ return await request.get({
url: `/crm/contract/list-all-simple-by-customer?customerId=${customerId}` url: `/crm/contract/simple-list?customerId=${customerId}`
}) })
} }

View File

@ -5,10 +5,10 @@ export interface ReceivablePlanVO {
period: number period: number
receivableId: number receivableId: number
finishStatus: number finishStatus: number
processInstanceId: number
price: number price: number
returnTime: Date returnTime: Date
remindDays: number remindDays: number
returnType: number
remindTime: Date remindTime: Date
customerId: number customerId: number
customerName?: string customerName?: string
@ -43,6 +43,7 @@ export const getReceivablePlan = async (id: number) => {
} }
// 查询回款计划下拉数据 // 查询回款计划下拉数据
// TODO @芋艿:再看看这里
export const getReceivablePlanListByContractId = async (customerId: number, contractId: number) => { export const getReceivablePlanListByContractId = async (customerId: number, contractId: number) => {
return await request.get({ return await request.get({
url: `/crm/receivable-plan/list-all-simple-by-customer?customerId=${customerId}&contractId=${contractId}` url: `/crm/receivable-plan/list-all-simple-by-customer?customerId=${customerId}&contractId=${contractId}`

View File

@ -75,7 +75,7 @@
<el-form-item label="回款方式" prop="returnType"> <el-form-item label="回款方式" prop="returnType">
<el-select v-model="formData.returnType" placeholder="请选择回款方式"> <el-select v-model="formData.returnType" placeholder="请选择回款方式">
<el-option <el-option
v-for="dict in getStrDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
@ -128,7 +128,7 @@ import * as UserApi from '@/api/system/user'
import * as CustomerApi from '@/api/crm/customer' import * as CustomerApi from '@/api/crm/customer'
import * as ContractApi from '@/api/crm/contract' import * as ContractApi from '@/api/crm/contract'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -215,7 +215,7 @@ const resetForm = () => {
} }
const getContractList = async (customerId: number) => { const getContractList = async (customerId: number) => {
contractList.value = await ContractApi.getCrmContractSimpleListByCustomerId(customerId) contractList.value = await ContractApi.getContractSimpleList(customerId)
} }
const getReceivablePlanList = async (contractId: number) => { const getReceivablePlanList = async (contractId: number) => {
receivablePlanList.value = await ReceivablePlanApi.getReceivablePlanListByContractId( receivablePlanList.value = await ReceivablePlanApi.getReceivablePlanListByContractId(

View File

@ -7,10 +7,40 @@
:rules="formRules" :rules="formRules"
label-width="110px" label-width="110px"
> >
<el-row>
<el-col :span="12">
<el-form-item label="还款期数" prop="period">
<el-input disabled v-model="formData.period" placeholder="保存时自动生成" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="负责人" prop="ownerUserId">
<el-select
v-model="formData.ownerUserId"
:disabled="formType !== 'create'"
class="w-1/1"
>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="客户名称" prop="customerId"> <el-form-item label="客户名称" prop="customerId">
<el-select v-model="formData.customerId" class="w-1/1" placeholder="请选择客户"> <el-select
v-model="formData.customerId"
:disabled="formType !== 'create'"
class="w-1/1"
filterable
@change="handleCustomerChange"
placeholder="请选择客户"
>
<el-option <el-option
v-for="item in customerList" v-for="item in customerList"
:key="item.id" :key="item.id"
@ -24,8 +54,9 @@
<el-form-item label="合同名称" prop="contractId"> <el-form-item label="合同名称" prop="contractId">
<el-select <el-select
v-model="formData.contractId" v-model="formData.contractId"
:disabled="!formData.customerId" :disabled="formType !== 'create' || !formData.customerId"
class="!w-100%" class="w-1/1"
filterable
placeholder="请选择合同" placeholder="请选择合同"
> >
<el-option <el-option
@ -37,18 +68,8 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> </el-row>
<el-form-item label="负责人" prop="ownerUserId"> <el-row>
<el-select v-model="formData.ownerUserId" clearable placeholder="请输入负责人">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="计划回款金额" prop="price"> <el-form-item label="计划回款金额" prop="price">
<el-input-number <el-input-number
@ -56,6 +77,8 @@
class="!w-100%" class="!w-100%"
controls-position="right" controls-position="right"
placeholder="请输入计划回款金额" placeholder="请输入计划回款金额"
:min="0.01"
:precision="2"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -69,6 +92,8 @@
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row>
<el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="提前几天提醒" prop="remindDays"> <el-form-item label="提前几天提醒" prop="remindDays">
<el-input-number <el-input-number
@ -80,23 +105,20 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="提醒日期" prop="remindTime"> <el-form-item label="回款方式" prop="returnType">
<el-date-picker <el-select v-model="formData.returnType" class="w-1/1" placeholder="请选择回款方式">
v-model="formData.remindTime" <el-option
placeholder="选择提醒日期" v-for="dict in getIntDictOptions(DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE)"
type="date" :key="dict.value"
value-format="x" :label="dict.label"
/> :value="dict.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input <el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
v-model="formData.remark"
:rows="3"
placeholder="请输入备注"
type="textarea"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -113,10 +135,11 @@ import * as UserApi from '@/api/system/user'
import * as CustomerApi from '@/api/crm/customer' import * as CustomerApi from '@/api/crm/customer'
import * as ContractApi from '@/api/crm/contract' import * as ContractApi from '@/api/crm/contract'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const userList = ref<UserApi.UserVO[]>([]) // const userOptions = ref<UserApi.UserVO[]>([]) //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
@ -125,7 +148,6 @@ const formData = ref<ReceivablePlanApi.ReceivablePlanVO>({} as ReceivablePlanApi
const formRules = reactive({ const formRules = reactive({
price: [{ required: true, message: '计划回款金额不能为空', trigger: 'blur' }], price: [{ required: true, message: '计划回款金额不能为空', trigger: 'blur' }],
returnTime: [{ required: true, message: '计划回款日期不能为空', trigger: 'blur' }], returnTime: [{ required: true, message: '计划回款日期不能为空', trigger: 'blur' }],
remindTime: [{ required: true, message: '提醒日期不能为空', trigger: 'blur' }],
customerId: [{ required: true, message: '客户编号不能为空', trigger: 'blur' }], customerId: [{ required: true, message: '客户编号不能为空', trigger: 'blur' }],
contractId: [{ required: true, message: '合同编号不能为空', trigger: 'blur' }], contractId: [{ required: true, message: '合同编号不能为空', trigger: 'blur' }],
ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }] ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }]
@ -133,6 +155,7 @@ const formRules = reactive({
const formRef = ref() // Ref const formRef = ref() // Ref
const customerList = ref<CustomerApi.CustomerVO[]>([]) // const customerList = ref<CustomerApi.CustomerVO[]>([]) //
const contractList = ref<ContractApi.ContractVO[]>([]) // const contractList = ref<ContractApi.ContractVO[]>([]) //
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -148,9 +171,8 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
// //
userList.value = await UserApi.getSimpleUserList() userOptions.value = await UserApi.getSimpleUserList()
// //
customerList.value = await CustomerApi.getCustomerSimpleList() customerList.value = await CustomerApi.getCustomerSimpleList()
// //
@ -160,22 +182,6 @@ const open = async (type: string, id?: number) => {
} }
defineExpose({ open }) // open defineExpose({ open }) // open
const getContractList = async (customerId: number) => {
contractList.value = await ContractApi.getCrmContractSimpleListByCustomerId(customerId)
}
watch(
() => formData.value.customerId,
(newVal) => {
if (!newVal) {
return
}
getContractList(newVal)
},
{
immediate: true
}
)
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {
@ -207,4 +213,15 @@ const resetForm = () => {
formData.value = {} as ReceivablePlanApi.ReceivablePlanVO formData.value = {} as ReceivablePlanApi.ReceivablePlanVO
formRef.value?.resetFields() formRef.value?.resetFields()
} }
/** 处理切换客户 */
const handleCustomerChange = async (customerId: number) => {
//
formData.value.contractId = undefined
//
if (customerId) {
contractList.value = []
contractList.value = await ContractApi.getContractSimpleList(customerId)
}
}
</script> </script>