线索管理客户添加上一个下一个的功能
This commit is contained in:
parent
9beb069550
commit
5039edd882
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue