CRM:完善合同的新增、修改需求

(cherry picked from commit 3bfdb2df33)
This commit is contained in:
YunaiV 2024-02-23 00:20:14 +08:00 committed by shizhong
parent a807a3a674
commit fdbcc559d8

View File

@ -38,7 +38,12 @@
<el-row>
<el-col :span="8">
<el-form-item label="客户名称" prop="customerId">
<el-select v-model="formData.customerId" placeholder="请选择客户" class="w-1/1">
<el-select
v-model="formData.customerId"
placeholder="请选择客户"
class="w-1/1"
@change="handleCustomerChange"
>
<el-option
v-for="item in customerList"
:key="item.id"
@ -50,7 +55,12 @@
</el-col>
<el-col :span="8">
<el-form-item label="商机名称" prop="businessId">
<el-select :disabled="!formData.customerId" v-model="formData.businessId" class="w-1/1">
<el-select
@change="handleBusinessChange"
:disabled="!formData.customerId"
v-model="formData.businessId"
class="w-1/1"
>
<el-option
v-for="item in getBusinessOptions"
:key="item.id"
@ -192,6 +202,7 @@ import * as BusinessApi from '@/api/crm/business'
import { erpPriceInputFormatter, erpPriceMultiply } from '@/utils'
import { useUserStore } from '@/store/modules/user'
import ContractProductForm from '@/views/crm/contract/components/ContractProductForm.vue'
import { bu } from '../../../../dist-prod/assets/index-9eac537b'
const { t } = useI18n() //
const message = useMessage() //
@ -333,15 +344,28 @@ const resetForm = () => {
formRef.value?.resetFields()
}
// TODO reset
// TODO
/** 处理切换客户 */
const handleCustomerChange = () => {
formData.value.businessId = undefined
formData.value.signContactId = undefined
formData.value.products = []
}
/** 处理商机变化 */
const handleBusinessChange = async (businessId: number) => {
const business = await BusinessApi.getBusiness(businessId)
business.products.forEach((item) => {
item.contractPrice = item.businessPrice
})
formData.value.products = business.products
}
/** 动态获取客户联系人 */
const getContactOptions = computed(() =>
contactList.value.filter((item) => item.customerId === formData.value.customerId)
contactList.value.filter((item) => item.customerId == formData.value.customerId)
)
/** 动态获取商机 */
const getBusinessOptions = computed(() =>
businessList.value.filter((item) => item.customerId === formData.value.customerId)
businessList.value.filter((item) => item.customerId == formData.value.customerId)
)
</script>