<template>
    <w-card>
        <template #title>
            <view class="flex justify-between w-full py-[10rpx]">
                <view class="flex">
                    <text>{{ item.studentName }}</text>
                    <view class="flex ml-[48rpx] gap-[4rpx] items-center">
                        <text class="text-primary">{{ item.phone }}</text>
                        <u-copy content="uview-plus is great !">
                            <TIcon name="icon-copy" color="#0E66FB" />
                        </u-copy>
                    </view>
                </view>
                <text v-if="item.situation == converStatusEnum.UN_RECEIVED" class="text-[#ED6D41]">
                    待领取
                </text>
            </view>
        </template>
        <template #content>
            <view class="flex gap-[20rpx] mb-[16rpx]">
                <text class="text-muted w-[128rpx]">基本情况</text>
                <text class="flex-1">
                    {{ ellipsisDesc(item) }}
                </text>
            </view>
            <view class="flex gap-[20rpx] mb-[16rpx]">
                <text class="text-muted w-[128rpx]">跟进时间</text>
                <text class="flex-1">{{ item.createTime }}</text>
            </view>
            <view class="flex gap-[20rpx] mb-[16rpx]" v-if="item.recruitTeacherId !== null">
                <text class="text-muted w-[128rpx]">招生老师</text>
                <text class="flex-1">{{ item.recruitTeacherName }}</text>
            </view>
            <view class="flex gap-[20rpx]" v-if="item.state !== null">
                <text class="text-muted w-[128rpx]">状态</text>
                <text class="flex-1">账号不存在</text>
            </view>
        </template>
        <template #action>
            <view
                class="px-[32rpx] border-t border-solid border-[#F3F3F3] flex justify-end py-[12rpx]"
                v-if="item.situation == converStatusEnum.EXCEPTION"
            >
                <u-button color="#0E66FB" shape="circle" @click="handleEditFollow">
                    修改跟进
                </u-button>
            </view>
        </template>
    </w-card>
</template>

<script setup lang="ts">
import { PropType } from 'vue'
import { computed } from 'vue'
import { converStatusEnum, stateEnum } from '@/enums'

export interface IClue {
    studentName: string
    phone: string
    id: number
    basicInformation: string
    remark: string
    isConversion: number
    listSource: number //线索来源
    state: stateEnum //状态
    situation: number // 转化情况
    createTime: string // 跟进时间
    telemarketingTeacherName: string // 电销老师
    recruitTeacherName: string // 招生老师
    recruitTeacherId: number
    telemarketingTeacherId: number
}
const props = defineProps({
    item: {
        type: Object as PropType<IClue>,
        default: () => ({})
    }
})
const ellipsisDesc = computed(
    () => (item: IClue) =>
        item.basicInformation?.length >= 14
            ? item.basicInformation?.slice(0, 14) + '...'
            : item.basicInformation
)
const handleEditFollow = () => {
    const { item } = props
    uni.navigateTo({
        url: '/bundle/pages/follow_edit/index?id=' + item.id
    })
}
</script>
<style scoped></style>
