import { BasicColumn, FormSchema } from '/@/components/Table';
import { sysDictQueryTree } from '/@/api/sys/sysDictApi';
export const columns: BasicColumn[] = [
  {
    title: '业务名',
    dataIndex: 'busName',
  },
  {
    title: '功能名',
    dataIndex: 'functionName',
  },
  {
    title: '类名',
    dataIndex: 'className',
  },
  {
    title: '包名',
    dataIndex: 'packageName',
  },
  {
    title: '作者',
    dataIndex: 'authorName',
  },
  {
    title: '移除表前缀',
    dataIndex: 'tablePrefix',
    format: text => {
      return text == 'Y' ? '是' : '否';
    },
  },
  {
    title: '生成方式',
    dataIndex: 'generateType',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
    fixed: 'right',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'tableName',
    label: '表名称',
    component: 'Input',
    componentProps: {
      placeholder: '请输入表名称',
    },
  },
  {
    field: 'tableComment',
    label: '表描述',
    component: 'Input',
    componentProps: {
      placeholder: '请输入表描述',
    },
  },
];

// Java类型
export const JavaTypeSelect = [
  { label: 'Long', value: 'Long' },
  { label: 'String', value: 'String' },
  { label: 'Integer', value: 'Integer' },
  { label: 'Double', value: 'Double' },
  { label: 'BigDecimal', value: 'BigDecimal' },
  { label: 'Date', value: 'Date' },
  { label: 'Boolean', value: 'Boolean' },
];
// 查询方式
export const queryTypeSelect = [
  {
    label: '模糊包含',
    value: 'like',
  },
  {
    label: '模糊不包含',
    value: 'notLike',
  },
  {
    label: '等于',
    value: 'eq',
  },
  {
    label: '不等于',
    value: 'ne',
  },
  {
    label: '大于',
    value: 'gt',
  },
  {
    label: '大于等于',
    value: 'ge',
  },
  {
    label: '小于',
    value: 'lt',
  },
  {
    label: '小于等于',
    value: 'le',
  },
  { label: 'BETWEEN', value: 'BETWEEN' },
];
// 显示类型
export const htmlTypeSelect = [
  { label: '文本框', value: 'input' },
  { label: '文本域', value: 'inputTextArea' },
  { label: '数字框', value: 'inputNumber' },
  { label: '下拉框', value: 'select' },
  { label: '字典下拉框', value: 'apiSelect' },
  { label: '开关框', value: 'switch' },
  { label: '单选框', value: 'radioGroup' },
  { label: '字典单选框', value: 'apiRadioGroup' },
  { label: '复选框', value: 'checkboxGroup' },
  { label: '日期控件', value: 'datePicker' },
  { label: '文件上传', value: 'upload' },
  { label: '富文本控件', value: 'textEditor' },
  {
    label: '滑动数字条',
    value: 'Slider',
  },
];

export const columnsEdit: BasicColumn[] = [
  {
    title: '字段',
    dataIndex: 'fieldName',
    width: 150,
  },
  {
    title: '注释',
    dataIndex: 'fieldRemark',
    edit: true,
    editable: true,
    width: 180,
    editComponentProps: {
      editIconHidden: true,
    },
  },
  {
    title: '类型',
    dataIndex: 'fieldType',
    width: 100,
  },
  {
    title: '实体类型',
    dataIndex: 'fieldJavaType',
    width: 150,
    edit: true,
    editable: true,
    editComponent: 'Select',
    editComponentProps: {
      options: JavaTypeSelect,
      editIconHidden: true,
    },
  },
  {
    title: '列表',
    dataIndex: 'whetherTable',
    width: 82,
    edit: true,
    editable: true,
    editComponent: 'Switch',
    editComponentProps: {
      editIconHidden: true,
    },
    editValueMap: value => {
      return Number(value) ? '是' : '否';
    },
  },
  {
    title: '增改',
    dataIndex: 'whetherAddUpdate',
    width: 82,
    edit: true,
    editable: true,
    editComponent: 'Switch',
    editComponentProps: {
      editIconHidden: true,
    },
    editValueMap: value => {
      return Number(value) ? '是' : '否';
    },
  },
  {
    title: '必填',
    dataIndex: 'whetherRequired',
    width: 82,
    edit: true,
    editable: true,
    editComponent: 'Switch',
    editComponentProps: {
      editIconHidden: true,
    },
    editValueMap: value => {
      return Number(value) ? '是' : '否';
    },
  },
  // {
  //   title: '列表',
  //   dataIndex: 'isList',
  //   width: 82,
  //   edit: true,
  //   editComponent: 'Switch',
  //   editValueMap: value => {
  //     return Number(value) ? '是' : '否';
  //   },
  // },
  {
    title: '查询',
    dataIndex: 'queryWhether',
    width: 82,
    edit: true,
    editable: true,
    editComponent: 'Switch',
    editComponentProps: {
      editIconHidden: true,
    },
    editValueMap: value => {
      return Number(value) ? '是' : '否';
    },
  },
  {
    title: '导出',
    dataIndex: 'columnType',
    width: 82,
    edit: true,
    editable: true,
    editComponent: 'Switch',
    editComponentProps: {
      editIconHidden: true,
    },
    editValueMap: value => {
      return Number(value) ? '是' : '否';
    },
  },
  {
    title: '查询方式',
    dataIndex: 'queryType',
    width: 180,
    edit: true,
    editable: true,
    editComponent: 'Select',
    editComponentProps: {
      options: queryTypeSelect,
      editIconHidden: true,
    },
  },
  {
    title: '显示类型',
    dataIndex: 'effectType',
    width: 180,
    edit: true,
    editable: true,
    editComponent: 'Select',
    editComponentProps: {
      options: htmlTypeSelect,
      editIconHidden: true,
    },
  },
  {
    title: '字典类型',
    dataIndex: 'dictTypeCode',
    edit: true,
    editable: true,
    editComponent: 'ApiTreeSelect',
    editComponentProps: {
      // api: sysDictQueryList,
      // editIconHidden: true,
      // showSearch: true,
      // resultField: 'data',
      // extraLabelField: 'dictName',
      // labelField: 'dictCode',
      // valueField: 'dictCode',
      api: sysDictQueryTree,
      params: { root: true },
      resultField: 'data',
      fieldNames: {
        label: 'dictName',
        key: 'dictCode',
        value: 'dictCode',
      },
      getPopupContainer: () => document.body,
    },
  },
];

export const tplCategory = [
  { label: '单表（增删改查）', value: 'crud' },
  { label: '树表（增删改查）', value: 'tree' },
];

export const genTypeSelect = [
  { label: 'zip压缩包', value: '0' },
  { label: '自定义路径', value: '1' },
];

export const genFormSchema: FormSchema[] = [
  {
    field: 'tableName',
    label: '生成模板',
    component: 'Select',
    componentProps: {
      options: tplCategory,
    },
  },
  {
    field: 'packageName',
    label: '生成包路径',
    component: 'Input',
    componentProps: {
      placeholder: '生成在哪个java包下，例如 com.ruoyi.system',
    },
  },
  {
    field: 'moduleName',
    label: '生成模块名',
    component: 'Input',
    componentProps: {
      placeholder: '可理解为子系统名，例如 system',
    },
  },
  {
    field: 'businessName',
    label: '生成业务名',
    component: 'Input',
    componentProps: {
      placeholder: '可理解为功能英文名，例如 user',
    },
  },
  {
    field: 'functionName',
    label: '生成功能名',
    component: 'Input',
    componentProps: {
      placeholder: '用作类描述，例如 用户',
    },
  },
  // {
  //   field: 'businessName',
  //   label: '上级菜单',
  //   component: 'ApiTreeSelect',
  //   componentProps: {
  //     api: treeOptionsListApi,
  //     resultField: 'list',
  //   },
  // },
  {
    field: 'genType',
    label: '生成代码方式',
    component: 'Select',
    componentProps: {
      options: genTypeSelect,
    },
  },
];
