import {BasicColumn} from '/src/components/Table';
import {FormSchema} from '/src/components/Table';
import { rules} from '/src/utils/helper/validator';
import { render } from '/src/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/src/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '关联用户ID',
    align:"center",
    dataIndex: 'userId_dictText'
   },
   {
    title: '账号',
    align:"center",
    dataIndex: 'accountId'
   },
   {
    title: '账号名',
    align:"center",
    dataIndex: 'accountName'
   },
   {
    title: '账号渠道',
    align:"center",
    dataIndex: 'accountChannel_dictText'
   },
   {
    title: '账号分类',
    align:"center",
    dataIndex: 'accountCategory_dictText'
   },
   {
    title: '账号状态',
    align:"center",
    dataIndex: 'accountStatus_dictText'
   },
   {
    title: '检查状态',
    align:"center",
    dataIndex: 'reviewStatus_dictText'
   },
   {
    title: '币种',
    align:"center",
    dataIndex: 'currencyCode_dictText'
   },
   {
    title: '公司',
    align:"center",
    dataIndex: 'company'
   },
   {
    title: '网址',
    align:"center",
    dataIndex: 'website'
   },
   {
    title: '领域',
    align:"center",
    dataIndex: 'industry'
   },
   {
    title: '邮箱',
    align:"center",
    dataIndex: 'email'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createdAt',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '更新时间',
    align:"center",
    dataIndex: 'updatedAt',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '关联用户ID',
    field: 'userId',
    component: 'JSearchSelect',
    show: true,
    componentProps:{
       dict:"user_login,username,id"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入关联用户ID!'},
          ];
     },
  },
  {
    label: '账号',
    field: 'accountId',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号!'},
          ];
     },
  },
  {
    label: '账号名',
    field: 'accountName',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号名!'},
          ];
     },
  },
  {
    label: '账号渠道',
    field: 'accountChannel',
    component: 'JDictSelectTag',
    show: true,
    componentProps:{
        dictCode:"account_channel"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号渠道!'},
          ];
     },
  },
  {
    label: '账号分类',
    field: 'accountCategory',
    component: 'JDictSelectTag',
    show: true,
    componentProps:{
        dictCode:"account_category"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号分类!'},
          ];
     },
  },
  {
    label: '账号状态',
    field: 'accountStatus',
    component: 'JDictSelectTag',
    show: true,
    componentProps:{
        dictCode:"account_status"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号状态!'},
          ];
     },
  },
  {
    label: '检查状态',
    field: 'reviewStatus',
    component: 'JDictSelectTag',
    show: true,
    componentProps:{
        dictCode:"review_status"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入检查状态!'},
          ];
     },
  },
  {
    label: '币种',
    field: 'currencyCode',
    component: 'JDictSelectTag',
    show: true,
    componentProps:{
        dictCode:"currency_code"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入币种!'},
          ];
     },
  },
  {
    label: '公司',
    field: 'company',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入公司!'},
          ];
     },
  },
  {
    label: '网址',
    field: 'website',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入网址!'},
          ];
     },
  },
  {
    label: '领域',
    field: 'industry',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入领域!'},
          ];
     },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入邮箱!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
    show: true,
    dynamicRules: ({model,schema}) => {
      return [
        { required: false, message: '请输入备注!'},
      ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  userId: {title: '关联用户ID',order: 0,view: 'number', type: 'number',dictTable: "user_login", dictCode: 'id', dictText: 'username',},
  accountId: {title: '账号',order: 1,view: 'text', type: 'string',},
  accountName: {title: '账号名',order: 2,view: 'text', type: 'string',},
  accountChannel: {title: '账号渠道',order: 3,view: 'list', type: 'string',dictCode: 'account_channel',},
  accountCategory: {title: '账号分类',order: 4,view: 'list', type: 'string',dictCode: 'account_category',},
  accountStatus: {title: '账号状态',order: 5,view: 'list', type: 'string',dictCode: 'account_status',},
  reviewStatus: {title: '检查状态',order: 6,view: 'list', type: 'string',dictCode: 'review_status',},
  currencyCode: {title: '币种',order: 7,view: 'list', type: 'string',dictCode: 'currency_code',},
  company: {title: '公司',order: 8,view: 'text', type: 'string',},
  website: {title: '网址',order: 9,view: 'text', type: 'string',},
  industry: {title: '领域',order: 10,view: 'text', type: 'string',},
  email: {title: '邮箱',order: 11,view: 'text', type: 'string',},
  createdAt: {title: '创建时间',order: 12,view: 'date', type: 'string',},
  updatedAt: {title: '更新时间',order: 13,view: 'date', type: 'string',},
};

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