From c1fc0f9764ba1dcc8e71e1dc20c151055e35bbe1 Mon Sep 17 00:00:00 2001 From: jiangjunhong <870160034@qq.com> Date: Sun, 27 Apr 2025 01:36:42 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/crm/customer/customer/index.ts | 2 +- src/api/crm/follw/index.ts | 3 +- src/types/auto-components.d.ts | 2 + src/views/crm/components/Customer/Detail.vue | 9 +++- .../crm/components/Customer/FollowRecord.vue | 34 +++++++++++---- .../crm/components/Customer/QuickFollow.vue | 36 ++++++++++------ src/views/crm/customer/my/tables/all.vue | 33 ++++++++++++++- src/views/crm/customer/my/tables/import.vue | 33 ++++++++++++++- src/views/crm/customer/my/tables/seven.vue | 33 ++++++++++++++- src/views/crm/customer/my/tables/today.vue | 33 ++++++++++++++- src/views/crm/customer/my/tables/unfollow.vue | 33 ++++++++++++++- src/views/crm/opensea/customer/allopensea.vue | 41 +++++++++++++++++-- src/views/crm/opensea/customer/myopensea.vue | 35 +++++++++++++++- 13 files changed, 293 insertions(+), 34 deletions(-) diff --git a/src/api/crm/customer/customer/index.ts b/src/api/crm/customer/customer/index.ts index f8c5bb97..a61a9310 100644 --- a/src/api/crm/customer/customer/index.ts +++ b/src/api/crm/customer/customer/index.ts @@ -66,7 +66,7 @@ export const CustomerInforApi = { // 修改客户信息 - updateCustomer: async (data: CustomerInforVO) => { + updateCustomer: async (data: any) => { return await request.put({ url: `/crm/customer/update`, data }) }, // 分配客户 diff --git a/src/api/crm/follw/index.ts b/src/api/crm/follw/index.ts index 06274fd9..c0b54245 100644 --- a/src/api/crm/follw/index.ts +++ b/src/api/crm/follw/index.ts @@ -6,6 +6,7 @@ export interface FollwRecordVO { customerId: number // 客户ID content: string // 跟进内容 userId: number // 客户经理 + createTime: number // 创建时间 } // 跟进记录 API @@ -16,7 +17,7 @@ export const FollwRecordApi = { }, // 新增跟进记录 - createFollwRecord: async (data: FollwRecordVO) => { + createFollwRecord: async (data: any) => { return await request.post({ url: `/crm/follw-record/create`, data }) }, diff --git a/src/types/auto-components.d.ts b/src/types/auto-components.d.ts index c330b42b..a0c9ae19 100644 --- a/src/types/auto-components.d.ts +++ b/src/types/auto-components.d.ts @@ -80,6 +80,8 @@ declare module 'vue' { ElCheckTag: typeof import('element-plus/es')['ElCheckTag'] ElCol: typeof import('element-plus/es')['ElCol'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] + ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] + ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElDrawer: typeof import('element-plus/es')['ElDrawer'] diff --git a/src/views/crm/components/Customer/Detail.vue b/src/views/crm/components/Customer/Detail.vue index a8105d04..25f038a9 100644 --- a/src/views/crm/components/Customer/Detail.vue +++ b/src/views/crm/components/Customer/Detail.vue @@ -62,7 +62,7 @@
- + @@ -75,7 +75,11 @@
- +
@@ -112,6 +116,7 @@ const emit = defineEmits(['prev', 'next']) const formRef = ref() // 分配表单的 Ref const transferFormRef = ref() // 转公海表单的 Ref +const followRecordRef = ref() // 客户表单数据 const customerForm = ref({ diff --git a/src/views/crm/components/Customer/FollowRecord.vue b/src/views/crm/components/Customer/FollowRecord.vue index 2ae6e95a..0a334b3d 100644 --- a/src/views/crm/components/Customer/FollowRecord.vue +++ b/src/views/crm/components/Customer/FollowRecord.vue @@ -35,6 +35,16 @@ const props = defineProps<{ customerId?: number }>() +// 暴露刷新方法给父组件 +defineExpose({ + refresh: () => { + resetData() + if (props.customerId) { + loadData() + } + } +}) + const followRecordList = ref([]) const pageNo = ref(1) const pageSize = ref(10) @@ -74,6 +84,15 @@ const loadData = async () => { } } +// 重置数据 +const resetData = () => { + followRecordList.value = [] + pageNo.value = 1 + total.value = 0 + finished.value = false + loading.value = false +} + // 加载更多 const loadMore = async () => { if (finished.value) return @@ -82,13 +101,14 @@ const loadMore = async () => { } // 监听 customerId 变化,重置并加载数据 -watch(() => props.customerId, async (id) => { - if (id) { - pageNo.value = 1 - finished.value = false - // 确保用户列表已加载 - await crmStore.getUserList() - await loadData() +watch(() => props.customerId, async (newId, oldId) => { + if (newId !== oldId) { + resetData() + if (newId) { + // 确保用户列表已加载 + await crmStore.getUserList() + await loadData() + } } }, { immediate: true }) diff --git a/src/views/crm/components/Customer/QuickFollow.vue b/src/views/crm/components/Customer/QuickFollow.vue index de7f73f4..709801dd 100644 --- a/src/views/crm/components/Customer/QuickFollow.vue +++ b/src/views/crm/components/Customer/QuickFollow.vue @@ -103,11 +103,11 @@
() -const emit = defineEmits(['prev', 'next']) +const emit = defineEmits(['prev', 'next', 'save-success']) const message = useMessage() @@ -247,7 +247,7 @@ const form = ref<{ importLevelId: number | undefined isImport: number | undefined customerLabelIds: number[] - nextFollowTime: string | undefined + nextFollowTime: number | null }>({ id: 0, haveCar: undefined, @@ -259,7 +259,7 @@ const form = ref<{ importLevelId: undefined, isImport: undefined, customerLabelIds: [], - nextFollowTime: undefined + nextFollowTime: null }) // 表单验证规则 @@ -314,8 +314,8 @@ const handleCustomerLablesChange = (labelId: number, checked: boolean) => { // 设置下次跟进时间 const setNextFollowTime = (minutes: number) => { - form.value.nextFollowTime = minutes ? dayjs().add(minutes, 'minute').format('YYYY-MM-DD HH:mm:ss') : undefined -} + form.value.nextFollowTime = minutes ? dayjs().add(minutes, 'minute').valueOf() : undefined +} // 保存 const handleSave = async () => { @@ -333,16 +333,23 @@ const handleSave = async () => { //2:添加跟进记录 if (content.value) { - const followRecord: FollwRecordVO = { - id: 0, + await FollwRecordApi.createFollwRecord({ customerId: props.customerId!, content: content.value, userId: userStore.getUser.id - } - await FollwRecordApi.createFollwRecord(followRecord) + }) + + console.log("content:"+content.value); + //3:修改客户的最新跟进信息 + await CustomerInforApi.updateCustomer({ + id: props.customerId!, + lastFollowTime: dayjs().valueOf(), + lastFollowContent: content.value + }); + emit('save-success') } - - //3:添加客户标签 + + //4:添加客户标签 if (props.customerId && customerLabels.value.length > 0) { await request.post({ url: '/crm/customer-labels/create', @@ -354,6 +361,9 @@ const handleSave = async () => { } message.success('保存成功') + // 重置跟进备注 + content.value = '' + } catch (error: any) { // 只有在实际保存操作失败时才显示错误 if (error?.message) { diff --git a/src/views/crm/customer/my/tables/all.vue b/src/views/crm/customer/my/tables/all.vue index db6ce35e..bc278a73 100644 --- a/src/views/crm/customer/my/tables/all.vue +++ b/src/views/crm/customer/my/tables/all.vue @@ -302,7 +302,13 @@ - + @@ -314,6 +320,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { dateFormatter } from '@/utils/formatTime' import { buildTree } from '@/utils/tree' +import { handlePrevNext } from '@/utils/crm' import { CustomerInforApi, CustomerInforVO } from '@/api/crm/customer/customer' import CustomerDetail from '@/views/crm/components/Customer/Detail.vue' import TransferForm from '@/views/crm/components/Transfer/TransferForm.vue' @@ -363,6 +370,8 @@ let customerSourceOptions = ref(); let customerTypeOptions = ref(); const drawerVisible = ref(false) // 抽屉是否显示 const customerId = ref() // 当前查看的客户ID +const prevId = ref(0) // 上一条记录ID +const nextId = ref(0) // 下一条记录ID const cascaderProps= { emitPath: false, } @@ -395,9 +404,31 @@ const resetQuery = () => { /** 打开跟进抽屉 */ const openInforForm = (id?: number) => { customerId.value = id + // 找到当前记录在列表中的索引 + const currentIndex = list.value.findIndex(item => item.id === id) + + // 获取上一条和下一条记录的ID + prevId.value = currentIndex > 0 ? list.value[currentIndex - 1].id : 0 + nextId.value = currentIndex < list.value.length - 1 ? list.value[currentIndex + 1].id : 0 + drawerVisible.value = true } +/** 处理上一条/下一条切换 */ +const handlePrevNextClick = (type: 'prev' | 'next') => { + if (customerId.value === undefined) return + + handlePrevNext(type, { + list: list.value, + currentId: customerId.value, + onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => { + customerId.value = currentId + prevId.value = newPrevId + nextId.value = newNextId + } + }) +} + /** 打开转公海弹窗 */ const openTransferForm = () => { if (multipleSelection.value.length === 0) { diff --git a/src/views/crm/customer/my/tables/import.vue b/src/views/crm/customer/my/tables/import.vue index 582b6c55..c2844687 100644 --- a/src/views/crm/customer/my/tables/import.vue +++ b/src/views/crm/customer/my/tables/import.vue @@ -281,7 +281,13 @@ - + @@ -293,6 +299,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { dateFormatter } from '@/utils/formatTime' import { buildTree } from '@/utils/tree' +import { handlePrevNext } from '@/utils/crm' import { CustomerInforApi, CustomerInforVO } from '@/api/crm/customer/customer' import CustomerDetail from '@/views/crm/components/Customer/Detail.vue' import TransferForm from '@/views/crm/components/Transfer/TransferForm.vue' @@ -342,6 +349,8 @@ let customerSourceOptions = ref() let customerTypeOptions = ref() const drawerVisible = ref(false) // 抽屉是否显示 const customerId = ref() // 当前查看的客户ID +const prevId = ref(0) // 上一条记录ID +const nextId = ref(0) // 下一条记录ID const cascaderProps= { emitPath: false, } @@ -375,9 +384,31 @@ const resetQuery = () => { /** 打开跟进抽屉 */ const openInforForm = (id?: number) => { customerId.value = id + // 找到当前记录在列表中的索引 + const currentIndex = list.value.findIndex(item => item.id === id) + + // 获取上一条和下一条记录的ID + prevId.value = currentIndex > 0 ? list.value[currentIndex - 1].id : 0 + nextId.value = currentIndex < list.value.length - 1 ? list.value[currentIndex + 1].id : 0 + drawerVisible.value = true } +/** 处理上一条/下一条切换 */ +const handlePrevNextClick = (type: 'prev' | 'next') => { + if (customerId.value === undefined) return + + handlePrevNext(type, { + list: list.value, + currentId: customerId.value, + onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => { + customerId.value = currentId + prevId.value = newPrevId + nextId.value = newNextId + } + }) +} + /** 打开转公海弹窗 */ const openTransferForm = () => { if (multipleSelection.value.length === 0) { diff --git a/src/views/crm/customer/my/tables/seven.vue b/src/views/crm/customer/my/tables/seven.vue index 508da240..b6386eae 100644 --- a/src/views/crm/customer/my/tables/seven.vue +++ b/src/views/crm/customer/my/tables/seven.vue @@ -280,7 +280,13 @@ - + @@ -298,6 +304,7 @@ import TransferForm from '@/views/crm/components/Transfer/TransferForm.vue' import { useCrmStore } from '@/store/modules/crm' import { storeToRefs } from 'pinia' import dayjs from 'dayjs' +import { handlePrevNext } from '@/utils/crm' /** 客户信息 列表 */ defineOptions({ name: 'AllCustomer' }) @@ -342,6 +349,8 @@ let customerSourceOptions = ref() let customerTypeOptions = ref() const drawerVisible = ref(false) // 抽屉是否显示 const customerId = ref() // 当前查看的客户ID +const prevId = ref(0) // 上一条记录ID +const nextId = ref(0) // 下一条记录ID const cascaderProps= { emitPath: false, } @@ -380,9 +389,31 @@ const resetQuery = () => { /** 打开跟进抽屉 */ const openInforForm = (id?: number) => { customerId.value = id + // 找到当前记录在列表中的索引 + const currentIndex = list.value.findIndex(item => item.id === id) + + // 获取上一条和下一条记录的ID + prevId.value = currentIndex > 0 ? list.value[currentIndex - 1].id : 0 + nextId.value = currentIndex < list.value.length - 1 ? list.value[currentIndex + 1].id : 0 + drawerVisible.value = true } +/** 处理上一条/下一条切换 */ +const handlePrevNextClick = (type: 'prev' | 'next') => { + if (customerId.value === undefined) return + + handlePrevNext(type, { + list: list.value, + currentId: customerId.value, + onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => { + customerId.value = currentId + prevId.value = newPrevId + nextId.value = newNextId + } + }) +} + /** 打开转公海弹窗 */ const openTransferForm = () => { if (multipleSelection.value.length === 0) { diff --git a/src/views/crm/customer/my/tables/today.vue b/src/views/crm/customer/my/tables/today.vue index 37f7016d..0c86e805 100644 --- a/src/views/crm/customer/my/tables/today.vue +++ b/src/views/crm/customer/my/tables/today.vue @@ -280,7 +280,13 @@ - + @@ -298,6 +304,7 @@ import TransferForm from '@/views/crm/components/Transfer/TransferForm.vue' import { useCrmStore } from '@/store/modules/crm' import { storeToRefs } from 'pinia' import dayjs from 'dayjs' +import { handlePrevNext } from '@/utils/crm' /** 客户信息 列表 */ defineOptions({ name: 'AllCustomer' }) @@ -342,6 +349,8 @@ let customerSourceOptions = ref() let customerTypeOptions = ref() const drawerVisible = ref(false) // 抽屉是否显示 const customerId = ref() // 当前查看的客户ID +const prevId = ref(0) // 上一条记录ID +const nextId = ref(0) // 下一条记录ID const cascaderProps= { emitPath: false, } @@ -380,9 +389,31 @@ const resetQuery = () => { /** 打开跟进抽屉 */ const openInforForm = (id?: number) => { customerId.value = id + // 找到当前记录在列表中的索引 + const currentIndex = list.value.findIndex(item => item.id === id) + + // 获取上一条和下一条记录的ID + prevId.value = currentIndex > 0 ? list.value[currentIndex - 1].id : 0 + nextId.value = currentIndex < list.value.length - 1 ? list.value[currentIndex + 1].id : 0 + drawerVisible.value = true } +/** 处理上一条/下一条切换 */ +const handlePrevNextClick = (type: 'prev' | 'next') => { + if (customerId.value === undefined) return + + handlePrevNext(type, { + list: list.value, + currentId: customerId.value, + onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => { + customerId.value = currentId + prevId.value = newPrevId + nextId.value = newNextId + } + }) +} + /** 打开转公海弹窗 */ const openTransferForm = () => { if (multipleSelection.value.length === 0) { diff --git a/src/views/crm/customer/my/tables/unfollow.vue b/src/views/crm/customer/my/tables/unfollow.vue index 18891911..2a364b4c 100644 --- a/src/views/crm/customer/my/tables/unfollow.vue +++ b/src/views/crm/customer/my/tables/unfollow.vue @@ -277,7 +277,13 @@ - + @@ -289,6 +295,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { dateFormatter } from '@/utils/formatTime' import { buildTree } from '@/utils/tree' +import { handlePrevNext } from '@/utils/crm' import { CustomerInforApi, CustomerInforVO } from '@/api/crm/customer/customer' import CustomerDetail from '@/views/crm/components/Customer/Detail.vue' import TransferForm from '@/views/crm/components/Transfer/TransferForm.vue' @@ -338,6 +345,8 @@ let customerSourceOptions = ref() let customerTypeOptions = ref() const drawerVisible = ref(false) // 抽屉是否显示 const customerId = ref() // 当前查看的客户ID +const prevId = ref(0) // 上一条记录ID +const nextId = ref(0) // 下一条记录ID const cascaderProps= { emitPath: false, } @@ -372,9 +381,31 @@ const resetQuery = () => { /** 打开跟进抽屉 */ const openInforForm = (id?: number) => { customerId.value = id + // 找到当前记录在列表中的索引 + const currentIndex = list.value.findIndex(item => item.id === id) + + // 获取上一条和下一条记录的ID + prevId.value = currentIndex > 0 ? list.value[currentIndex - 1].id : 0 + nextId.value = currentIndex < list.value.length - 1 ? list.value[currentIndex + 1].id : 0 + drawerVisible.value = true } +/** 处理上一条/下一条切换 */ +const handlePrevNextClick = (type: 'prev' | 'next') => { + if (customerId.value === undefined) return + + handlePrevNext(type, { + list: list.value, + currentId: customerId.value, + onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => { + customerId.value = currentId + prevId.value = newPrevId + nextId.value = newNextId + } + }) +} + /** 打开转公海弹窗 */ const openTransferForm = () => { if (multipleSelection.value.length === 0) { diff --git a/src/views/crm/opensea/customer/allopensea.vue b/src/views/crm/opensea/customer/allopensea.vue index 8bb34d22..8b9b2bba 100644 --- a/src/views/crm/opensea/customer/allopensea.vue +++ b/src/views/crm/opensea/customer/allopensea.vue @@ -263,9 +263,15 @@ @pagination="getList" /> - - - + + + @@ -274,6 +280,7 @@ \ No newline at end of file diff --git a/src/views/crm/opensea/customer/myopensea.vue b/src/views/crm/opensea/customer/myopensea.vue index 4c3590a4..83710510 100644 --- a/src/views/crm/opensea/customer/myopensea.vue +++ b/src/views/crm/opensea/customer/myopensea.vue @@ -265,7 +265,13 @@ - + @@ -274,6 +280,7 @@ \ No newline at end of file