import { BasicColumn, FormSchema } from '/@/components/Table';
// import { radioSwitch } from '/@/utils/filters';
import { listDictModel } from '/@/api/common';
import { sysUserQueryPage } from '/@/api/sys/sysUserApi';
export const columns: BasicColumn[] = [
  {
    title: '部门名称',
    dataIndex: 'name',
  },
  {
    title: '负责人',
    dataIndex: 'leaderUserName',
  },
  {
    title: '办公电话',
    dataIndex: 'phone',
  },
  {
    title: '邮箱',
    dataIndex: 'email',
  },
  {
    title: '排序',
    dataIndex: 'sort',
  },
  {
    title: '状态',
    dataIndex: 'disable',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '部门名称',
    component: 'Input',
    componentProps: {
      placeholder: '请输入部门名称',
    },
  },
];

export const dataFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '部门名称',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入部门名称',
    },
  },
  {
    field: 'parentId',
    label: '上级部门',
    component: 'TreeSelect',
    componentProps: {
      placeholder: '请选择上级部门',
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'leaderUserId',
    label: '负责人',
    component: 'ApiSelect',
    componentProps: {
      api: sysUserQueryPage,
      params: {
        pageNum: 1,
        pageSize: 999,
        disable: '0',
      },
      mode: 'single',
      labelField: 'nickname',
      valueField: 'id',
      resultField: 'data',
      placeholder: '请输入负责人',
    },
  },
  {
    field: 'phone',
    label: '办公电话',
    component: 'Input',
    componentProps: {
      placeholder: '请输入办公电话',
    },
  },
  {
    field: 'email',
    label: '邮箱',
    component: 'Input',
    componentProps: {
      placeholder: '请输入邮箱',
    },
  },
  {
    field: 'sort',
    label: '排序',
    component: 'InputNumber',
    required: true,
    defaultValue: 99,
    componentProps: {
      placeholder: '请输入排序',
      min: 0,
    },
  },
  {
    field: 'disable',
    label: '状态',
    component: 'ApiRadioGroup',
    required: true,
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'sys_disable_type',
      },
    },
    defaultValue: '0',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入备注',
    },
  },
];
