CRM:合同的 code review

(cherry picked from commit 956f19d9d0)
This commit is contained in:
YunaiV
2024-02-01 13:38:14 +08:00
committed by shizhong
parent 82fbaa16a3
commit ff84ef64a5
15 changed files with 75 additions and 28 deletions

View File

@ -144,6 +144,7 @@
<el-col :span="24">
<CardTitle class="mb-10px" title="审批信息" />
</el-col>
<!-- TODO 芋艿需要后面在 review 目前看不到信息 -->
<el-col :span="12">
<el-button
class="m-20px"
@ -188,7 +189,9 @@ const formRules = reactive({
no: [{ required: true, message: '合同编号不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const BPMLModelRef = ref<InstanceType<typeof BPMLModel>>()
const BPMLModelRef = ref<InstanceType<typeof BPMLModel>>() // TODO @puhui999这个变量不太对另外可以不做 bpm model 窗口,而是可以点击跳转到工作流详情里;
// TODO @puhui999加个注释哈
watch(
() => formData.value.productItems,
(val) => {
@ -196,7 +199,7 @@ watch(
formData.value.productPrice = 0
return
}
// 使用reduce函数进行累加
// 使用 reduce 函数进行累加
formData.value.productPrice = val.reduce(
(accumulator, currentValue) =>
isNaN(accumulator + currentValue.totalPrice) ? 0 : accumulator + currentValue.totalPrice,
@ -205,13 +208,13 @@ watch(
},
{ deep: true }
)
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
await getAllApi()
// 修改时,设置数据
if (id) {
formLoading.value = true
@ -221,10 +224,9 @@ const open = async (type: string, id?: number) => {
formLoading.value = false
}
}
await getAllApi()
}
const getAllApi = async () => {
await Promise.all([getCustomerList(), getUserList(), getContactListList(), getBusinessList()])
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
@ -252,32 +254,42 @@ const submitForm = async () => {
formLoading.value = false
}
}
const customerList = ref<CustomerApi.CustomerVO[]>([])
/** 重置表单 */
const resetForm = () => {
formData.value = {} as ContractApi.ContractVO
formRef.value?.resetFields()
}
/** 获取其它相关数据 */
const getAllApi = async () => {
await Promise.all([getCustomerList(), getUserList(), getContactListList(), getBusinessList()])
}
/** 获取客户 */
const customerList = ref<CustomerApi.CustomerVO[]>([])
const getCustomerList = async () => {
customerList.value = await CustomerApi.getSimpleCustomerList()
}
const contactList = ref<ContactApi.ContactVO[]>([])
/** 动态获取客户联系人 */
const contactList = ref<ContactApi.ContactVO[]>([])
const getContactOptions = computed(() =>
contactList.value.filter((item) => item.customerId === formData.value.customerId)
)
const getContactListList = async () => {
contactList.value = await ContactApi.getSimpleContactList()
}
const userList = ref<UserApi.UserVO[]>([])
/** 获取用户列表 */
const userList = ref<UserApi.UserVO[]>([])
const getUserList = async () => {
userList.value = await UserApi.getSimpleUserList()
}
const businessList = ref<BusinessApi.BusinessVO[]>([])
/** 获取商机 */
const businessList = ref<BusinessApi.BusinessVO[]>([])
const getBusinessList = async () => {
businessList.value = await BusinessApi.getSimpleBusinessList()
}
/** 重置表单 */
const resetForm = () => {
formData.value = {} as ContractApi.ContractVO
formRef.value?.resetFields()
}
</script>

View File

@ -1,3 +1,4 @@
<!-- 合同 Form 表单下的 Product 列表 -->
<template>
<el-row justify="end">
<el-button plain type="primary" @click="openForm">添加产品</el-button>
@ -71,23 +72,32 @@ withDefaults(defineProps<{ modelValue: any[] }>(), { modelValue: () => [] })
const emits = defineEmits<{
(e: 'update:modelValue', v: any[]): void
}>()
const list = ref<ProductApi.ProductExpandVO[]>([])
const list = ref<ProductApi.ProductExpandVO[]>([]) // TODO @puhui999
const multipleSelection = ref<ProductApi.ProductExpandVO[]>([]) // 多选
/** 处理删除 */
const handleDelete = (id: number) => {
const index = list.value.findIndex((item) => item.id === id)
if (index !== -1) {
list.value.splice(index, 1)
}
}
/** 打开 Product 弹窗 */
const tableSelectFormRef = ref<InstanceType<typeof TableSelectForm>>()
const multipleSelection = ref<ProductApi.ProductExpandVO[]>([])
const openForm = () => {
tableSelectFormRef.value?.open(ProductApi.getProductPage)
}
/** 计算 totalPrice */
const getTotalPrice = computed(() => (row: ProductApi.ProductExpandVO) => {
const totalPrice = (row.price * row.count * row.discountPercent) / 100
row.totalPrice = isNaN(totalPrice) ? 0 : totalPrice
return isNaN(totalPrice) ? 0 : totalPrice
})
// TODO @puhui999注释下
watch(
list,
(val) => {
@ -98,6 +108,8 @@ watch(
},
{ deep: true }
)
// TODO @puhui999注释下
watch(
multipleSelection,
(val) => {

View File

@ -1,3 +1,4 @@
<!-- TODO @puhui999这个组件的注释加下方便大家打开就知道哈 -->
<template>
<div>
<div class="flex items-start justify-between">

View File

@ -1,3 +1,4 @@
<!-- TODO @puhui999这个组件的注释加下方便大家打开就知道哈 -->
<template>
<ContentWrap>
<el-collapse v-model="activeNames">

View File

@ -1,3 +1,4 @@
<!-- TODO @puhui999这个组件的注释加下方便大家打开就知道哈 -->
<template>
<ContractDetailsHeader v-loading="loading" :contract="contract">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contract.id)">
@ -57,11 +58,14 @@ const message = useMessage()
const contractId = ref(0) // 编号
const loading = ref(true) // 加载中
const contract = ref<ContractApi.ContractVO>({} as ContractApi.ContractVO) // 详情
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
/** 编辑 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 获取详情 */
const getContractData = async () => {
loading.value = true
@ -86,18 +90,21 @@ const getOperateLog = async (contractId: number) => {
logList.value = data.list
}
/** 转移 */
// TODO @puhui999transferFormRef 简洁一点哈
const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 合同转移表单 ref
const transfer = () => {
crmTransferFormRef.value?.open('合同转移', contract.value.id, ContractApi.transfer)
}
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
/** 初始化 */
/** 关闭 */
const { delView } = useTagsViewStore() // 视图操作
const { currentRoute } = useRouter() // 路由
const close = () => {
delView(unref(currentRoute))
}
/** 初始化 */
onMounted(async () => {
const id = route.params.id
if (!id) {

View File

@ -1,3 +1,4 @@
<!-- TODO @puhui999这个好像和 detail 重复了 -->
<template>
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="110px">
<el-row>