import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '微信公众号id',
    align: "center",
    dataIndex: 'wechatid'
  },
  {
    title: '用户名',
    align: "center",
    dataIndex: 'username'
  },
  {
    title: '校验类型（扫描/校验）',
    align: "center",
    dataIndex: 'testType_dictText'
  },
  {
    title: '扫描时间',
    align: "center",
    dataIndex: 'scanTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '错词数量',
    align: "center",
    dataIndex: 'errorWordCount'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "微信公众号id",
    field: 'wechatid',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "用户名",
    field: 'username',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "校验类型（扫描/校验）",
    field: 'testType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "scan_test_type"
    },
    colProps: {span: 6},
  },
  {
    label: "扫描时间",
    field: "scanTime",
    component: 'RangePicker',
    colProps: {span: 6},
  },
  {
    label: "错词数量",
    field: 'errorWordCount',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '微信公众号id',
    field: 'wechatid',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入微信公众号id!'},
             ];
    },
  },
  {
    label: '用户名',
    field: 'username',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入用户名!'},
             ];
    },
  },
  {
    label: '校验类型（扫描/校验）',
    field: 'testType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "scan_test_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入校验类型（扫描/校验）!'},
             ];
    },
  },
  {
    label: '扫描时间',
    field: 'scanTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入扫描时间!'},
             ];
    },
  },
  {
    label: '错词数量',
    field: 'errorWordCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入错词数量!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
