import {
  VxeUI,
  VxeButton,
  VxeButtonGroup,
  VxeDrawer,
  VxeForm,
  VxeFormGroup,
  VxeFormItem,
  VxeIcon,
  VxeLoading,
  VxeModal,
  VxePager,
  VxePrint,
  VxeTooltip,
  VxeUpload,
  VxeTabPane,
  VxeTabs,
  VxeCheckbox,
  VxeNumberInput,
  VxeRadioGroup,
} from 'vxe-pc-ui';

import { VxeTable, VxeColumn, VxeColgroup, VxeGrid, VxeToolbar } from 'vxe-table';
import VxeUIPluginExportXLSX from '@vxe-ui/plugin-export-xlsx'
// 导入主题变量，也可以重写主题变量
import 'vxe-table/styles/cssvar.scss';
import 'vxe-pc-ui/styles/cssvar.scss';
import 'vxe-pc-ui/lib/style.css';
import 'vxe-table/lib/style.css';

// 导入默认的语言
import zhCN from 'vxe-pc-ui/lib/language/zh-CN';

VxeUI.setI18n('zh-CN', zhCN);
VxeUI.setLanguage('zh-CN');
VxeUI.use(VxeUIPluginExportXLSX);

// 可选组件
function lazyVxeUI(app) {
  app.use(VxeButton);
  app.use(VxeButtonGroup);
  app.use(VxeDrawer);
  app.use(VxeForm);
  app.use(VxeFormGroup);
  app.use(VxeFormItem);
  app.use(VxeIcon);
  app.use(VxeLoading);
  app.use(VxeModal);
  app.use(VxePager);
  app.use(VxePrint);
  app.use(VxeTooltip);
  app.use(VxeUpload);
  app.use(VxeCheckbox);
  app.use(VxeTabPane);
  app.use(VxeTabs);
  app.use(VxeNumberInput);
  app.use(VxeRadioGroup);
}

function lazyVxeTable(app) {
  app.use(VxeTable);
  app.use(VxeColumn);
  app.use(VxeColgroup);
  app.use(VxeGrid);
  app.use(VxeToolbar);
}

export function setupVxeTabele(app) {
  VxeUI.setConfig({
    table: {
      minHeight: 400,
      maxHeight: 900,
      border: true,
      round: true,
      size: 'small',
      resizableConfig: {
        dragMode: 'auto',
        showDragTip: true,
      },
      customConfig: {
        allowFixed: true,
        allowSort: true,
        allowVisible: true,
        mode: 'modal',
      },
      columnConfig: {
        maxFixedSize: 0, // 设置最大冻结列，0为无限制
        resizable: true, // 列宽调整
      },
      checkboxConfig: {
        reserve: false,
      },
      rowConfig: {
        isCurrent: true,
        isHover: true,
        keyField: '_ROW_KEY',
      },
    },
    grid: {
      size: 'small',
      border: true,
      minHeight: 400,
      maxHeight: 900,
      round: true
    },
  });
  lazyVxeUI(app);
  lazyVxeTable(app);
}
