import { BasicColumn, FormSchema } from '/@/components/Table';
import { rules } from '@/utils/helper/validator';

//列表数据
export const columns: BasicColumn[] = [
  {
    title: '站点名称',
    align: 'center',
    dataIndex: 'siteName',
    defaultHidden: true,
  },
  {
    title: '姓名',
    align: 'left',
    dataIndex: 'contact',
  },
  {
    title: '邮箱',
    align: 'center',
    dataIndex: 'fromEmail',
    width: 300,
  },
  {
    title: 'WhatsApp',
    align: 'center',
    dataIndex: 'whatsApp',
    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },

  {
    title: '手机号',
    align: 'center',
    dataIndex: 'phone',
    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },

  {
    title: '来源IP',
    align: 'center',
    dataIndex: 'fromIp',
    defaultHidden: true,

    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },

  {
    title: '状态',
    align: 'center',
    dataIndex: 'readStatus',
  },
  {
    title: '询盘详情',
    align: 'left',
    dataIndex: 'details',
  },
  // {
  //   title: '跟进人',
  //   align: "center",
  //   dataIndex: 'principalUid',
  // },
  {
    title: '来源页面',
    align: 'left',
    dataIndex: 'fromPage',
  },
  {
    title: '分类',
    align: 'center',
    dataIndex: 'userEffective',
  },
  {
    title: '询盘审核进度',
    align: 'center',
    dataIndex: 'verifyProgress',
  },
  {
    title: '来源国家',
    align: 'left',
    dataIndex: 'countryName',
    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },
  {
    title: '来源插件',
    align: 'center',
    dataIndex: 'pluginName',
    defaultHidden: true,
  },
  {
    title: '询盘时间',
    align: 'center',
    dataIndex: 'recordCtime',
    customRender: function ({ text }) {
      return !text ? '' : text.length > 16 ? text.substr(0, 16) : text;
    },
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'ctime',
    customRender: function ({ text }) {
      return !text ? '' : text.length > 16 ? text.substr(0, 16) : text;
    },
  },
  {
    title: '跟进人',
    align: 'center',
    dataIndex: 'principalUid',
    width: 200,
  },
];

export const wasteColumns: BasicColumn[] = [
  {
    title: '站点名称',
    align: 'center',
    dataIndex: 'siteName',
    defaultHidden: true,
  },
  {
    title: '姓名',
    align: 'center',
    dataIndex: 'contact',
  },
  {
    title: '邮箱',
    align: 'center',
    dataIndex: 'fromEmail',
  },

  {
    title: '手机号',
    align: 'center',
    dataIndex: 'phone',
    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },

  {
    title: '来源IP',
    align: 'center',
    dataIndex: 'fromIp',

    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },

  {
    title: '状态',
    align: 'center',
    dataIndex: 'readStatus',
  },
  {
    title: '询盘详情',
    align: 'center',

    dataIndex: 'details',
  },
  // {
  //   title: '跟进人',
  //   align: "center",
  //   dataIndex: 'principalUid',
  // },
  {
    title: '来源页面',
    align: 'center',

    dataIndex: 'fromPage',
  },
  {
    title: '询盘类型',
    align: 'center',
    dataIndex: 'wasteEnquiryType',
  },
  {
    title: '来源国家',
    align: 'center',
    dataIndex: 'countryName',
    customRender: function ({ text }) {
      if (text == null || text == '' || text == undefined) {
        return '--';
      } else {
        return text;
      }
    },
  },
  {
    title: '询盘时间',
    align: 'center',

    dataIndex: 'recordCtime',
    customRender: function ({ text }) {
      return !text ? '' : text.length > 16 ? text.substr(0, 16) : text;
    },
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'ctime',
    customRender: function ({ text }) {
      return !text ? '' : text.length > 16 ? text.substr(0, 16) : text;
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
    required: true,
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    required: true,
    dynamicRules: ({}) => {
      return [{ ...rules.rule('email', false)[0], trigger: 'blur' }];
    },
  },
  {
    label: '手机号码',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({}) => {
      return [{ pattern: /^1[3456789]\d{9}$/, message: '手机号码格式有误', trigger: 'blur' }];
    },
  },
  {
    label: '询盘内容',
    field: 'message',
    required: true,
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入询盘内容',
      rows: 8,
    },
  },
  {
    label: '询盘来源',
    field: 'fromSource',
    component: 'Select',
    componentProps: {
      mode: 'single',
      options: [
        {
          label: '邮件',
          value: 'email',
        },
        {
          label: '广告',
          value: 'ad',
        },
        {
          label: '社媒',
          value: 'socialMedia',
        },
        {
          label: '聊天',
          value: 'chat',
        },
        {
          label: '电话',
          value: 'phone',
        },
      ],
    },
  },
  {
    label: '来源国家',
    field: 'countryCode',
    component: 'JSearchSelect',
    componentProps: {
      dict: 'adweb_country,country_name,country_iso_code',
      async: true,
    },
  },
  {
    label: '图片上传',
    field: 'enquiryFile',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
      bizPath: 'enquiry',
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  fromIp: { title: '询盘来源IP', order: 0, view: 'text', type: 'string' },
  fromEmail: { title: '询盘发送者邮箱账号', order: 1, view: 'text', type: 'string' },
  modular: { title: '询盘模块:admp_web:admp网站询盘 ;email:邮件询盘  ;diy_element:自定义组件询盘', order: 2, view: 'text', type: 'string' },
  fromUser: { title: '发送人姓名', order: 3, view: 'text', type: 'string' },
  status: { title: '0删除,1有效,默认值1   2:待解析  3:数据解析中 4.解析失败', order: 4, view: 'number', type: 'number' },
  dealCount: { title: '数据解析次数', order: 5, view: 'number', type: 'number' },
  sysEffective: { title: '系统有效性  0:无效       1;有效 后台字段', order: 6, view: 'number', type: 'number' },
  userEffective: { title: '用户有效性  0:无效       1:有效   2 : 待定 取自字典表', order: 7, view: 'number', type: 'number' },
  sensitiveMessage: { title: '敏感信息', order: 8, view: 'textarea', type: 'string' },
  phase: { title: '询盘阶段,由跟踪来决定(1:待沟通 ;2:沟通中;3:成单;4;放弃)', order: 9, view: 'text', type: 'string' },
  trackStatus: { title: '跟进跟进状态,由跟踪来决定(1:待跟进 ;2:跟进中;3:完成;4;停止)', order: 10, view: 'text', type: 'string' },
  uid: { title: '询盘所属用户主账号ID', order: 11, view: 'text', type: 'string' },
  tracker: { title: '询盘跟进人 id', order: 12, view: 'number', type: 'number' },
  recordCtime: { title: '询盘创建时间', order: 13, view: 'datetime', type: 'string' },
  ctime: { title: 'ADMP平台创建时间', order: 14, view: 'datetime', type: 'string' },
  country: { title: '国家/地区(根据ip获取)', order: 15, view: 'text', type: 'string' },
  countryIsoCode: { title: '通过ip解析获得国家码', order: 16, view: 'text', type: 'string' },
  areaIsoCode: { title: '通过ip解析获得区域码', order: 17, view: 'text', type: 'string' },
  pluginName: { title: '询盘插件名称,名称小写,如:wpforms', order: 18, view: 'text', type: 'string' },
  siteCode: { title: '站点code,关联站点表', order: 19, view: 'text', type: 'string' },
  siteToken: { title: '站点token', order: 20, view: 'text', type: 'string' },
  siteHost: { title: '询盘来自站点的域名', order: 21, view: 'text', type: 'string' },
  recordId: { title: '询盘原站点记录ID', order: 22, view: 'text', type: 'string' },
  utime: { title: '状态更新时间', order: 23, view: 'datetime', type: 'string' },
  replyTime: { title: '回复时间', order: 24, view: 'datetime', type: 'string' },
  forward: { title: '转发状态:0未转发,1已转发,默认值0', order: 25, view: 'number', type: 'number' },
  forwardTime: { title: '转发时间', order: 26, view: 'datetime', type: 'string' },
  visitId: { title: '访客id', order: 27, view: 'text', type: 'string' },
  siteId: { title: '来源于站点的id', order: 28, view: 'number', type: 'number' },
  companyId: { title: '公司id', order: 29, view: 'number', type: 'number' },
  contactIds: { title: '联系人id,字符串组合', order: 30, view: 'text', type: 'string' },
  jobId: { title: '定时器任务修改查询唯一标识(10位随机数)', order: 31, view: 'text', type: 'string' },
  replayStatus: { title: '回复状态', order: 32, view: 'text', type: 'string' },
  noOut: { title: '外部编号', order: 33, view: 'text', type: 'string' },
  modifyRecordCtime: { title: '处理后的询盘当地时间字段', order: 34, view: 'datetime', type: 'string' },
  transContent: { title: 'transContent', order: 35, view: 'textarea', type: 'string' },
  countryCode: { title: '国家code', order: 36, view: 'text', type: 'string' },
  countryName: { title: '国家名', order: 37, view: 'text', type: 'string' },
  whatsApp: { title: 'WhatsApp', order: 38, view: 'text', type: 'string' },
  wasteEnquiry: { title: '0:不是;1:是', order: 39, view: 'number', type: 'number' },
  pushStatus: { title: '推送状态,0:待发送,1:成功,2不予发送', order: 40, view: 'number', type: 'number' },
  pushErrorNum: { title: '推送错误次数', order: 41, view: 'number', type: 'number' },
  name: { title: '姓名', order: 42, view: 'text', type: 'string' },
  email: { title: '邮箱地址', order: 43, view: 'text', type: 'string' },
  message: { title: '询盘信息', order: 44, view: 'textarea', type: 'string' },
  company: { title: '用户名称', order: 45, view: 'text', type: 'string' },
  fromPage: { title: '来源页面', order: 46, view: 'text', type: 'string' },
  customerIp: { title: 'form表单传入Ip', order: 47, view: 'text', type: 'string' },
  phone: { title: '手机号', order: 48, view: 'text', type: 'string' },
  whatsapp: { title: 'WhatsApp', order: 49, view: 'text', type: 'string' },
  readStatus: { title: '阅读状态,0是未阅读,1是已阅读', order: 50, view: 'number', type: 'number' },
  principalUid: { title: '负责人的id', order: 51, view: 'text', type: 'string' },
  principalType: { title: '0代表系统根据规则分配,1代表主账户指定', order: 52, view: 'number', type: 'number' },
  address: { title: 'form表单中的地址', order: 53, view: 'textarea', type: 'string' },
  specialField: { title: '客户自定义字段', order: 54, view: 'textarea', type: 'string' },
  requestTime: { title: '向Wp发送请求时间', order: 55, view: 'datetime', type: 'string' },
  acquireMessageTime: { title: 'Adweb实时获取WebHookS消息时间,定时器无该值', order: 56, view: 'datetime', type: 'string' },
  effectiveReason: { title: '疑似垃圾询盘理由', order: 57, view: 'text', type: 'string' },
  wasteEnquiryType: { title: '垃圾询盘类型,关键词:keyword,邮箱:email,ip: ip,其他:other', order: 58, view: 'text', type: 'string' },
  cartItems: { title: '询盘关联产品', order: 59, view: 'textarea', type: 'string' },
};