import { BasicColumn, FormSchema, render } from '@jdlinker/ui';
import { getAutoScrollContainer } from '@jdlinker/func';

export const columns: BasicColumn[] = [
  {
    title: '租户名称',
    dataIndex: 'name',
    width: 100
  },
  {
    title: '租户编号',
    dataIndex: 'id',
    width: 100
  },
  {
    title: '角色编码前缀',
    dataIndex: 'preCode',
    width: 100
  },
  {
    title: '开始时间',
    dataIndex: 'beginDate',
    sorter: true,
    width: 100
  },
  {
    title: '结束时间',
    dataIndex: 'endDate',
    sorter: true,
    width: 100
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ text }) => {
      return render.renderDict(text, 'status');
    }
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    component: 'Input'
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '正常', value: 1 },
        { label: '冻结', value: 0 }
      ]
    }
  }
];

// @ts-ignore
export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    component: 'Input',
    required: true
  },
  {
    field: 'id',
    label: '编号',
    component: 'InputNumber',
    required: true
  },
  {
    field: 'preCode',
    label: '角色编码前缀',
    component: 'Input',
    required: true
  },
  {
    field: 'beginDate',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      getPopupContainer: getAutoScrollContainer
    }
  },
  {
    field: 'endDate',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      getPopupContainer: getAutoScrollContainer
    }
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '正常', value: 1 },
        { label: '冻结', value: 0 }
      ]
    }
  }
];
