import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {h} from "vue";
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '主站点名称',
    align: "center",
    dataIndex: 'mainSiteName'
  },
  {
    title: '主站点地址',
    align: "center",
    dataIndex: 'mainSiteUrl',
    width:250,
    customRender: (text) => {
      let url = text.text;
      if(url.length > 30){
        url = url.substring(0,30) + "...."
      }
      return h('a', {
          title: text.text,
          href: text.text,
          target: '_blank'
        },
        url
      );
    },
  },
  {
    title: '线程数',
    align: "center",
    dataIndex: 'threadNumber'
  },
  {
    title: 'GO语言文件执行路径',
    align: "center",
    dataIndex: 'goFile'
  },
  {
    title: 'GO语言文件执行系统类型',
    align: "center",
    dataIndex: 'systemTypeGo_dictText'
  },
  {
    title: '正则表达式',
    align: "center",
    dataIndex: 'regularExpression'
  },
  {
    title: '超时时间（秒）',
    align: "center",
    dataIndex: 'timeOut'
  },
  {
    title: '页面抓取类型',
    align: "center",
    dataIndex: 'grabPage_dictText'
  },
  {
    title: '回调系统地址',
    align: "center",
    dataIndex: 'stateUrl'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "主站点名称",
    field: 'mainSiteName',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "主站点URL",
    field: 'mainSiteUrl',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "线程数",
    field: 'threadNumber',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "GO语言文件执行路径",
    field: 'goFile',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "GO语言文件执行系统类型",
    field: 'systemTypeGo',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "system_type"
    },
    colProps: {span: 6},
  },
  {
    label: "正则表达式",
    field: 'regularExpression',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "超时时间（秒）",
    field: 'timeOut',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "页面抓取类型",
    field: 'grabPage',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "grab_page_type"
    },
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '主站点名称',
    field: 'mainSiteName',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入主站点名称!'},
             ];
    },
  },
  {
    label: '主站点URL',
    field: 'mainSiteUrl',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入主站点URL!'},
             ];
    },
  },
  {
    label: '线程数',
    field: 'threadNumber',
    component: 'InputNumber',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入线程数!'},
             ];
    },
  },
  {
    label: 'GO语言文件执行路径',
    field: 'goFile',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入GO语言文件执行路径!'},
             ];
    },
  },
  {
    label: 'GO语言文件执行系统类型',
    field: 'systemTypeGo',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "system_type"
    },
    dynamicRules: () => {
      return [
              { required: true, message: '请输入GO语言文件执行系统类型!'},
             ];
    },
  },
  {
    label: '正则表达式',
    field: 'regularExpression',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入正则表达式!'},
             ];
    },
  },
  {
    label: '超时时间（秒）',
    field: 'timeOut',
    component: 'InputNumber',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入超时时间（秒）!'},
             ];
    },
  },
  {
    label: '页面抓取类型',
    field: 'grabPage',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "grab_page_type"
    },
    dynamicRules: () => {
      return [
              { required: true, message: '请输入页面抓取类型!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
