import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {h} from "vue";
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '用户地址',
    align: "center",
    dataIndex: 'userId',
    width:250,
    customRender: (text) => {
      if(text.text.length == 0){
        return "暂无"
      }
      let url = 'https://m.weibo.cn/u/'+text.text;
      if(url.length > 30){
        url = url.substring(0,30) + "...."
      }
      return h('a', {
          title: 'https://m.weibo.cn/u/'+text.text,
          href: 'https://m.weibo.cn/u/'+text.text,
          target: '_blank'
        },
        url
      );
    },
  },
  {
    title: '微博昵称',
    align: "center",
    dataIndex: 'screenName'
  },
  {
    title: '校验类型（扫描/校验）',
    align: "center",
    dataIndex: 'testType_dictText'
  },
  {
    title: '扫描时间',
    align: "center",
    dataIndex: 'scanTime'
  },
  {
    title: '电话号数量',
    align: "center",
    dataIndex: 'personalPhoneCount'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "微博用户id",
    field: 'userId',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "微博昵称",
    field: 'screenName',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "校验类型（扫描/校验）",
    field: 'testType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "scan_test_type"
    },
    colProps: {span: 6},
  },
  {
    label: "扫描时间",
    field: "scanTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "电话号数量",
    field: 'personalPhoneCount',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '微博用户id',
    field: 'userId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入微博用户id!'},
             ];
    },
  },
  {
    label: '微博昵称',
    field: 'screenName',
    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',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入扫描时间!'},
             ];
    },
  },
  {
    label: '电话号数量',
    field: 'personalPhoneCount',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入电话号数量!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
