From bd50c3fc9518968daf86c9933972ee2f124c97e9 Mon Sep 17 00:00:00 2001 From: zy Date: Fri, 16 May 2025 13:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=87=92=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/crm/business/BusinessForm.vue | 8 +- src/views/crm/contact/ContactForm.vue | 116 ++++++++++++++++-- .../crm/contact/components/ContactList.vue | 2 +- .../contact/components/ContactListModal.vue | 2 +- src/views/crm/customer/CustomerForm.vue | 8 +- src/views/crm/customer/detail/index.vue | 2 +- src/views/crm/quotation/QuotationForm.vue | 32 ++--- .../project/components/ProjectTaskForm.vue | 2 +- .../project/project/components/TaskAdd.vue | 2 +- 9 files changed, 134 insertions(+), 40 deletions(-) diff --git a/src/views/crm/business/BusinessForm.vue b/src/views/crm/business/BusinessForm.vue index 723cd2a07..2b9b0c175 100644 --- a/src/views/crm/business/BusinessForm.vue +++ b/src/views/crm/business/BusinessForm.vue @@ -372,10 +372,10 @@ const setList = (newProducts) => { // 改版账期 const changePayment = (val) => { -const currentDate = new Date(); // 获取当前日期 -const currentMonth = currentDate.getMonth() + 1; // 获取当前月份(注意月份是从0开始的,所以需要加1) -const daysInMonth = new Date(currentDate.getFullYear(), currentMonth, 0).getDate(); // 获取指定月份的天数 - formData.value.creditCalcCycle = (val > 2 ? parseInt(daysInMonth + Number(val)) : 0) +// const currentDate = new Date(); // 获取当前日期 +// const currentMonth = currentDate.getMonth() + 1; // 获取当前月份(注意月份是从0开始的,所以需要加1) +// const daysInMonth = new Date(currentDate.getFullYear(), currentMonth, 0).getDate(); // 获取指定月份的天数 + formData.value.creditCalcCycle = (val > 2 ? parseInt(30 + Number(val)) : 0) formData.value.creditLimit = parseInt(formData.value.totalPrice / 365 * formData.value.creditCalcCycle) } const { push } = useRouter() diff --git a/src/views/crm/contact/ContactForm.vue b/src/views/crm/contact/ContactForm.vue index 1fe7ebd7f..fd91361bd 100644 --- a/src/views/crm/contact/ContactForm.vue +++ b/src/views/crm/contact/ContactForm.vue @@ -37,16 +37,23 @@ + clearable + popper-class="event-select-poper" + v-el-select-loadmore="loadmore" + :placeholder="placeholder" + style="width: 100%" + :filter-method="filterOptions" + @change="handleEventsChange" + @visible-change="handleVisibleChange"> + :value="item.id" /> + @@ -59,7 +66,7 @@ - + @@ -204,12 +211,26 @@ const formData = ref({ const formRules = reactive({ name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }], customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }], - ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }] + ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }], + email: [{ required: false, message: '电子邮箱不能为空', trigger: 'blur' } , + { + pattern: + /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})$/, + message: "请输入正确的电子邮箱", + } + ], + mobile: [{ required: false, message: '手机号不能为空', trigger: 'blur' } , + {pattern: /^(1[3-9][0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/, message: '请输入正确手机号'} + ], }) const formRef = ref() // 表单 Ref const userOptions = ref([]) // 用户列表 const customerList = ref([]) // 客户列表 const contactList = ref([]) // 联系人列表 +let pageNo = ref(1) +let pageSize = ref(10) +let total = 0 +const options = ref([]); /** 打开弹窗 */ const open = async (type: string, id?: number, customerId?: number, businessId?: number) => { @@ -226,6 +247,7 @@ const open = async (type: string, id?: number, customerId?: number, businessId?: formLoading.value = false } } else { + // console.log('%csrc/views/crm/contact/ContactForm.vue:229 customerId', 'color: #007acc;', customerId); if (customerId) { formData.value.customerId = customerId formData.value.customerDefault = true // 默认客户的选择,不允许变 @@ -239,6 +261,7 @@ const open = async (type: string, id?: number, customerId?: number, businessId?: contactList.value = await ContactApi.getSimpleContactList() // 获得客户列表 customerList.value = await CustomerApi.getSelfCustomerSimpleList() + options.value = customerList.value.slice(0, 10) // 获得地区列表 areaList.value = await AreaApi.getAreaTree() // 获得用户列表 @@ -301,4 +324,81 @@ const resetForm = () => { } formRef.value?.resetFields() } + +const loading = ref(false); +const placeholder = ref('请选择'); +const allFilterEvents = reactive([]); +const vElSelectLoadmore = { + beforeMount(el, binding) { + const selectDom = document.querySelector('.event-select-poper .el-select-dropdown__wrap'); + const loadMores = function() { + const isBase = this.scrollHeight - this.scrollTop <= this.clientHeight + 20; + if (isBase) { + binding.value && binding.value(); + } + }; + el.selectDomInfo = selectDom; + el.selectLoadMore = loadMores; + selectDom?.addEventListener('scroll', loadMores.bind(selectDom)); + }, + beforeUnmount(el) { + if (el.selectLoadMore) { + el.selectDomInfo.removeEventListener('scroll', el.selectLoadMore); + delete el.selectDomInfo; + delete el.selectLoadMore; + } + } +}; + +watch(() => allFilterEvents, () => { + let startIndex = pageNo.value * pageSize.value - pageSize.value; + let endIndex = pageNo.value * pageSize.value; + options.value = allFilterEvents.slice(startIndex, endIndex); +}, { + immediate: true, + deep: true +}); + +const loadmore = () => { + if (customerList.value.length <= options.value.length) return; + pageNo.value++; + nextTick(() => { + loading.value = true; + let startIndex = pageNo.value * pageSize.value - pageSize.value; + let endIndex = pageNo.value * pageSize.value; + options.value = [ + ...options.value, + ...customerList.value.slice(startIndex, endIndex) + ]; + loading.value = false; + }); +}; + +const filterOptions = (query = '') => { + pageNo.value = 1; + nextTick(() => { + if (query === '') { + allFilterEvents.splice(0, allFilterEvents.length, ...customerList.value); + } else { + allFilterEvents.splice(0, allFilterEvents.length, ...customerList.value.filter(item => item.name.includes(query))); + } + }); +}; + +const handleVisibleChange = (visible) => { + if (!visible) { + pageNo.value = 1; + nextTick(() => { + allFilterEvents.splice(0, allFilterEvents.length, ...customerList.value); + }); + } +}; + +const handleEventsChange = (val) => { + console.log('Selected value:', val); +}; + + +// onMounted(async() => { +// }) diff --git a/src/views/crm/contact/components/ContactList.vue b/src/views/crm/contact/components/ContactList.vue index 1c12ca81e..080bbf333 100644 --- a/src/views/crm/contact/components/ContactList.vue +++ b/src/views/crm/contact/components/ContactList.vue @@ -130,7 +130,7 @@ const handleQuery = () => { /** 添加操作 */ const formRef = ref() const openForm = () => { - formRef.value.open('create', undefined, props.customerId, props.businessId) + formRef.value.open('create', undefined, props.bizId, props.businessId) } /** 打开联系人详情 */ diff --git a/src/views/crm/contact/components/ContactListModal.vue b/src/views/crm/contact/components/ContactListModal.vue index 8b655c139..92a4452e1 100644 --- a/src/views/crm/contact/components/ContactListModal.vue +++ b/src/views/crm/contact/components/ContactListModal.vue @@ -137,7 +137,7 @@ const resetQuery = () => { /** 添加操作 */ const formRef = ref() const openForm = () => { - formRef.value.open('create') + formRef.value.open('create', '', Number(props.customerId)) } /** 关联联系人提交 */ diff --git a/src/views/crm/customer/CustomerForm.vue b/src/views/crm/customer/CustomerForm.vue index ba85aaabb..ae1ee25a5 100644 --- a/src/views/crm/customer/CustomerForm.vue +++ b/src/views/crm/customer/CustomerForm.vue @@ -266,13 +266,7 @@ - - - - - - - +