import { ref, reactive } from 'vue'
import clueService, { ClueParams } from '@/api/clue'

const ClueModule = () => {
  // 定义tab
  const useTab = () => {
    const tab = ref(1)
    const setTab = (name: number) => {
      tab.value = name
    }
    return [tab, setTab]
  }

  const msg = reactive({
    PageIndex: 1,
    PageSize: 10,
    pageCount: 0,
    CorpName: '', //企业名称
    CustomerName: '', //备注名
    WeChatName: '', //昵称
    CustomerMobile: '', //手机号码
    CreateSTime: '', //创建开始时间
    CreateETime: '', //创建结束时间
    FriendSTime: '', //好友开始时间
    FriendETime: '', //好友结束时间
    Q_NotFollowUpDay: 0, //几天未跟进
    Q_Friends: '', //好友关系 多选逗号分隔、
    Q_AddWay: '', //获取来源 多选英文逗号分隔
    EmpId: 0, //员工id
    CustomerType: 0, //类型1微信用户 2企业微信用户
    SelectList: [], //自定义查询
    OrderBy: 1, //排序
    AddCondition: 0 //查询条件
  })
  const data = reactive({
    columns: [
      {
        name: 'CustomerName',
        label: '客户',
        field: 'CustomerName',
        align: 'left'
      },
      { name: 'StageName', align: 'center', field: 'StageName', label: '客户阶段' },
      { name: 'LableList', label: '客户标签', field: 'LableList', align: 'left' },
      { name: 'carbs', label: '内容标签', field: 'carbs', align: 'left' },
      { name: 'CreateTime', label: '创建时间', field: 'CreateTime', align: 'left' },
      { name: 'sodium', label: '负责人', field: 'sodium', align: 'left' },
      { name: 'LastFollowUpTime', label: '上次跟进', field: 'LastFollowUpTime', align: 'left' },
      { name: 'Source', label: '渠道活码来源', field: 'Source', align: 'left' },
      // { name: 'num', label: '7日内客户回复消息数', align: 'left'},
      // { name: 'num', label: '7日内员工发送消息数', align: 'left'},
      { name: 'FriendTime', label: '添加好友时间', field: 'FriendTime', align: 'left' },
      { name: 'CheckInNum', label: '签到拜访', field: 'CheckInNum', align: 'left' }
    ],
    selected: [],
    dataList: [],
    WayList: [],
    EmployeeList: [],
    rowsPerPage: 0
  })
   const TypeList = reactive([
     {
       Name: '企业',
       Id: 0
     },
     {
       Name: '昵称',
       Id: 1
     },
     {
       Name: '备注名',
       Id: 2
     },
     {
       Name: '电话',
       Id: 3
     }
   ])
  //获取线索列表
  const getCluerList = (param: ClueParams) => {
    clueService.getCustomerClueList(param).then(res => {
      console.log(res, '数据')
      data.dataList = res.data.Data.PageData
      msg.pageCount = res.data.Data.PageCount
    })
  }

  return { useTab, msg, data, getCluerList, TypeList }
}
export default ClueModule
