线索管理客户添加上一个下一个的功能

This commit is contained in:
jiangjunhong 2025-04-25 17:53:28 +08:00
parent 9beb069550
commit 5039edd882
3 changed files with 49 additions and 18 deletions

View File

@ -38,7 +38,7 @@ declare module 'vue' {
CopyTaskNode: typeof import('./../components/SimpleProcessDesignerV2/src/nodes/CopyTaskNode.vue')['default']
CopyTaskNodeConfig: typeof import('./../components/SimpleProcessDesignerV2/src/nodes-config/CopyTaskNodeConfig.vue')['default']
CountTo: typeof import('./../components/CountTo/src/CountTo.vue')['default']
Crm: typeof import('./../store/modules/crm.ts')['default']
Crm: typeof import('./../utils/crm.ts')['default']
Crontab: typeof import('./../components/Crontab/src/Crontab.vue')['default']
Cropper: typeof import('./../components/Cropper/src/Cropper.vue')['default']
CropperAvatar: typeof import('./../components/Cropper/src/CropperAvatar.vue')['default']

34
src/utils/crm.ts Normal file
View File

@ -0,0 +1,34 @@
interface HandlePrevNextOptions {
list: any[]
currentId: number
onUpdateIds: (params: { currentId: number; prevId: number; nextId: number }) => void
}
/**
* /
* @param type 'prev' - | 'next' -
* @param options
* - list: 数据列表
* - currentId: 当前查看的ID
* - onUpdateIds: ID更新后的回调函数
*/
export const handlePrevNext = (type: 'prev' | 'next', options: HandlePrevNextOptions): void => {
const { list, currentId, onUpdateIds } = options
// 找到当前记录在列表中的索引
const currentIndex = list.findIndex(item => item.id === currentId)
// 根据类型确定要切换到的索引
const targetIndex = type === 'prev' ? currentIndex - 1 : currentIndex + 1
// 检查目标索引是否有效
if (targetIndex >= 0 && targetIndex < list.length) {
const targetId = list[targetIndex].id
// 更新ID
onUpdateIds({
currentId: targetId,
prevId: targetIndex > 0 ? list[targetIndex - 1].id : 0,
nextId: targetIndex < list.length - 1 ? list[targetIndex + 1].id : 0
})
}
}

View File

@ -212,8 +212,8 @@
:customer-id="customerId"
:prev-id="prevId"
:next-id="nextId"
@prev="handlePrevNext('prev')"
@next="handlePrevNext('next')"
@prev="handlePrevNextClick('prev')"
@next="handlePrevNextClick('next')"
/>
</el-drawer>
@ -226,6 +226,7 @@
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { buildTree } from '@/utils/tree'
import { handlePrevNext } from '@/utils/crm'
import {CustomerSourceApi} from '@/api/crm/config/customersource'
import {ChannelApi,ChannelVO} from '@/api/crm/config/channel'
import {CustomerInforApi, CustomerInforVO} from '@/api/crm/customer/customer'
@ -351,21 +352,17 @@ onMounted(async () => {
})
/** 处理上一条/下一条切换 */
const handlePrevNext = async (type: 'prev' | 'next') => {
//
const currentIndex = list.value.findIndex(item => item.id === customerId.value)
const handlePrevNextClick = (type: 'prev' | 'next') => {
if (customerId.value === undefined) return
//
const targetIndex = type === 'prev' ? currentIndex - 1 : currentIndex + 1
//
if (targetIndex >= 0 && targetIndex < list.value.length) {
const targetId = list.value[targetIndex].id
// ID
customerId.value = targetId
// /ID
prevId.value = targetIndex > 0 ? list.value[targetIndex - 1].id : 0
nextId.value = targetIndex < list.value.length - 1 ? list.value[targetIndex + 1].id : 0
}
handlePrevNext(type, {
list: list.value,
currentId: customerId.value,
onUpdateIds: ({ currentId, prevId: newPrevId, nextId: newNextId }) => {
customerId.value = currentId
prevId.value = newPrevId
nextId.value = newNextId
}
})
}
</script>