import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {getOkkiAccounts, getSiteBindInfo} from "@/views/okki/site/OkkiSite.api";
import {h} from "vue";
import {Tag} from "ant-design-vue";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '站点id',
    align:"center",
    dataIndex: 'siteId'
   },
   {
    title: '公司名称',
    align:"center",
    width:'300px',
    dataIndex: 'companyName'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status_dictText'
   },
    {
      title: '创建日期',
      align:"center",
      dataIndex: 'createTime'
    },
   {
    title: '初始化的域名',
    align:"center",
    width:'300px',
    dataIndex: 'domain'
   },
   {
    title: '联系方式',
    align:"center",
    dataIndex: 'tel'
   },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'contact'
   },
   {
    title: '邮箱',
    align:"center",
    dataIndex: 'email'
   },
   {
    title: '公司名英⽂简称',
    align:"center",
    dataIndex: 'enname'
   },
   {
    title: '套餐名',
    align:"center",
    dataIndex: 'tcName'
   },
   {
    title: '套餐周期，单位⽉',
    align:"center",
    dataIndex: 'tcPeriod'
   },
   {
    title: '站点选择的⼩语种语⾔',
    align:"center",
    dataIndex: 'tcLanguage'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   // {
   //  title: '所属部门',
   //  align:"center",
   //  dataIndex: 'sysOrgCode_dictText'
   // },
   // {
   //  title: '所属人员',
   //  align:"center",
   //  dataIndex: 'sysUserCode_dictText'
   // },
  {
    title: '服务主管',
    align:"center",
    // dataIndex: 'serviceManageUser_dictText'
    dataIndex: 'serviceManageUserStr',
    // dataIndex: 'serviceManageUser',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: '资料专员',
    align:"center",
    // dataIndex: 'dataUser_dictText'
    dataIndex: 'dataUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: '建站顾问',
    align:"center",
    // dataIndex: 'kefuUser_dictText'
    dataIndex: 'kefuUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: 'SEO专员',
    align:"center",
    // dataIndex: 'seoUser_dictText'
    dataIndex: 'seoUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: 'SEM主管',
    align:"center",
    // dataIndex: 'semManageUser_dictText'
    dataIndex: 'semManageUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: 'SEM专员',
    align:"center",
    // dataIndex: 'semUser_dictText'
    dataIndex: 'semUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: '设计师',
    align:"center",
    // dataIndex: 'uiUser_dictText'
    dataIndex: 'uiUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: '建站专员',
    align:"center",
    // dataIndex: 'websiteUser_dictText'
    dataIndex: 'websiteUserStr',
    slots: { customRender: 'xiaoErUserTag' },
  },
  {
    title: '社媒专员',
    align:"center",
    // dataIndex: 'socialUser_dictText',
    dataIndex: 'socialUserStr',
  slots: { customRender: 'xiaoErUserTag' },
    // fixed: 'right',
  },
  {
    title: '技术',
    align:"center",
    // dataIndex: 'socialUser_dictText',
    dataIndex: 'rdUserStr',
  slots: { customRender: 'xiaoErUserTag' },
    // fixed: 'right',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
    {
    label: "公司名称",
    field: 'companyName',
    component: 'JInput',
    //colProps: {span: 6},
    },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属部门',
    field: 'sysOrgCode',
    component: 'JSelectDept',
    componentProps:{
      rowKey:'orgCode',
    },
  },
  {
    label: '所属人员',
    field: 'sysUserCode',
    component: 'JSelectUser',
    componentProps:{
      labelKey:'realname',
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

const commonTagRender = (color: string) => (curVal) => h(Tag, { color }, () => curVal);

// 小二分配
// @ts-ignore
export const xiaoErFormSchema: FormSchema[] = [
  {
    label: '服务主管',
    field: 'serviceManageUser',
    // component: 'Select',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      numberToString: false,
      labelField: 'name',
      valueField: 'userId',
      params: { userRole: 1 },
      resultField: 'records',
    },
  },
  {
    label: '资料专员',
    field: 'dataUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 5 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: '建站顾问',
    field: 'kefuUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      //multiple: 多选；不填写为单选
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 2 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: 'SEO专员',
    field: 'seoUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 7 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: 'SEM主管',
    field: 'semManageUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 9 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: 'SEM专员',
    field: 'semUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 10 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: '设计师',
    field: 'uiUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 4 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: '建站专员',
    field: 'websiteUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 11 },
      //返回结果字段
      resultField: 'records',
    },
  },
  {
    label: '社媒专员',
    field: 'socialUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: {userRole: 8},
      //返回结果字段
      resultField: 'records',
    }
  },
  {
    label: '技术',
    field: 'rdUser',
    required: true,
    colProps: {span: 12},
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getOkkiAccounts,
      //数值转成String
      numberToString: false,
      //标题字段
      labelField: 'name',
      //值字段
      valueField: 'userId',
      //请求参数
      params: { userRole: 12 },
      //返回结果字段
      resultField: 'records',
    },
  },

  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },

  {
    label: '',
    field: 'siteId',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  siteId: {title: '站点id',order: 0,view: 'number', type: 'number',},
  companyName: {title: '公司名称',order: 1,view: 'text', type: 'string',},
  status: {title: '状态',order: 2,view: 'number', type: 'number',},
  createTime: {title: '创建日期',order: 0,view: 'datetime', type: 'string',},
  domain: {title: '初始化的域名',order: 3,view: 'text', type: 'string',},
  tel: {title: '联系方式',order: 4,view: 'text', type: 'string',},
  contact: {title: '联系人',order: 5,view: 'text', type: 'string',},
  email: {title: '邮箱',order: 6,view: 'text', type: 'string',},
  enname: {title: '公司名英⽂简称',order: 7,view: 'text', type: 'string',},
  tcName: {title: '套餐名',order: 8,view: 'text', type: 'string',},
  tcPeriod: {title: '套餐周期，单位⽉',order: 9,view: 'number', type: 'number',},
  tcLanguage: {title: '站点选择的⼩语种语⾔',order: 10,view: 'text', type: 'string',},
  remark: {title: '备注',order: 11,view: 'textarea', type: 'string',},
  sysOrgCode: {title: '所属部门',order: 12,view: 'sel_depart', type: 'string',},
  sysUserCode: {title: '所属人员',order: 13,view: 'sel_user', type: 'string',},
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param _formData
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

export function getXiaoErFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return xiaoErFormSchema;
}
