import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const tableColumns: VxeGridProps['columns'] = [
  {
    field: 'oilId',
    title: '道路名称',
  },
  {
    field: 'level',
    title: '道路类型',
    slots: {
      default: ({ row }) => {
        return renderDict(row.level, DictEnum.ROAD_TYPE);
      },
    },
  },
  {
    field: 'name',
    title: '道路双向车道数',
  },
  {
    field: 'createTime',
    title: '车道方向',
    slots: {
      default: ({ row }) => {
        return renderDict(row.level, DictEnum.ROAD_DIRECTION);
      },
    },
  },
  {
    field: 'createTime',
    title: '隔离',
    slots: {
      default: ({ row }) => {
        return renderDict(row.level, DictEnum.ISOLATION_TYPE);
      },
    },
  },
  {
    field: 'createTime',
    title: '可视度',
    slots: {
      default: ({ row }) => {
        return renderDict(row.level, DictEnum.VISIBILITY);
      },
    },
  },
  {
    field: 'createTime',
    title: '其他说明',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
  },
];

export const drawerFormSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'configKey',
    label: '道路名称',
    componentProps: {
      maxlength: 100,
    },
  },
  {
    component: 'Select',
    fieldName: 'configId',
    label: '道路类型',
    componentProps: {
      options: getDictOptions(DictEnum.ROAD_TYPE),
    },
    rules: 'required',
  },

  {
    component: 'InputNumber',
    fieldName: 'configKey',
    label: '道路双向车道数',
    componentProps: {
      maxlength: 100,
    },
  },
  {
    component: 'Select',
    fieldName: 'configId',
    label: '车道方向',
    componentProps: {
      options: getDictOptions(DictEnum.ROAD_DIRECTION),
    },
    rules: 'required',
  },
  {
    component: 'RadioGroup',
    fieldName: 'configId',
    label: '隔离',
    componentProps: {
      options: getDictOptions(DictEnum.ISOLATION_TYPE),
    },
    rules: 'required',
  },
  {
    component: 'Select',
    fieldName: 'configId',
    label: '可视度',
    componentProps: {
      options: getDictOptions(DictEnum.VISIBILITY),
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'configKey',
    label: '其他说明',
    componentProps: {
      type: 'textarea',
      rows: 4,
      maxlength: 200,
    },
  },
];
