import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {h} from "vue";
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '主站点id',
    align: "center",
    dataIndex: 'mainSiteId'
  },
  {
    title: '主站点名称',
    align: "center",
    dataIndex: 'mainSiteName'
  },
  {
    title: '主站点URL',
    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: 'word'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "主站点id",
    field: 'mainSiteId',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "主站点名称",
    field: 'mainSiteName',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "主站点URL",
    field: 'mainSiteUrl',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "白名单单词",
    field: 'word',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '主站点id',
    field: 'mainSiteId',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入主站点id!'},
             ];
    },
  },
  {
    label: '主站点名称',
    field: 'mainSiteName',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入主站点名称!'},
             ];
    },
  },
  {
    label: '主站点URL',
    field: 'mainSiteUrl',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入主站点URL!'},
             ];
    },
  },
  {
    label: '白名单单词',
    field: 'word',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入白名单单词!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
