import { VxeUI } from '@vxe-ui/core'

const { setConfig, setIcon } = VxeUI

VxeUI.ganttVersion = process.env.VUE_APP_VXE_VERSION as string

const ymdFormat = 'yyyy-MM-dd'
const ymdhmsFormat = 'yyyy-MM-dd HH:mm:ss'

setConfig({
  gantt: {
    // size: null,
    // zoomConfig: {
    //   escRestore: true
    // },
    formConfig: {
      enabled: true
    },
    pagerConfig: {
      enabled: true
      // perfect: false
    },
    toolbarConfig: {
      enabled: true
      // perfect: false
    },
    proxyConfig: {
      enabled: true,
      autoLoad: true,
      showLoading: true,
      showResponseMsg: true,
      showActionMsg: true,
      response: {
        list: null,
        result: 'result',
        total: 'page.total',
        message: 'message'
      }
      // beforeItem: null,
      // beforeColumn: null,
      // beforeQuery: null,
      // afterQuery: null,
      // beforeDelete: null,
      // afterDelete: null,
      // beforeSave: null,
      // afterSave: null
    },
    taskBarTooltipConfig: {
      enterable: true
    },
    taskLinkConfig: {
      enabled: true,
      isHover: true,
      showArrow: true
    },
    taskViewScaleConfig: {
      year: {
        valueFormat: ymdFormat
      },
      quarter: {
        valueFormat: ymdFormat
      },
      month: {
        valueFormat: ymdFormat
      },
      week: {
        startDay: 1,
        valueFormat: ymdFormat
      },
      day: {
        valueFormat: ymdFormat
      },
      date: {
        valueFormat: ymdFormat
      },
      hour: {
        valueFormat: ymdhmsFormat
      },
      minute: {
        valueFormat: ymdhmsFormat
      },
      second: {
        valueFormat: ymdhmsFormat
      }
    },
    taskViewConfig: {
      showNowLine: true,
      gridding: {
        leftSpacing: 1,
        rightSpacing: 1
      }
    },
    taskSplitConfig: {
      enabled: true,
      resize: true,
      showCollapseTableButton: true,
      showCollapseTaskButton: true
    },
    taskBarSubviewConfig: {
      // showOverview: false
    }
  }
})

const iconPrefix = 'vxe-icon-'

setIcon({
  // gantt
  GANTT_VIEW_LEFT_OPEN: iconPrefix + 'arrow-left',
  GANTT_VIEW_LEFT_CLOSE: iconPrefix + 'arrow-right',
  GANTT_VIEW_RIGHT_OPEN: iconPrefix + 'arrow-right',
  GANTT_VIEW_RIGHT_CLOSE: iconPrefix + 'arrow-left',
  GANTT_VIEW_TASK_MILESTONE: iconPrefix + 'square-fill rotate45'
})

export {
  VxeUI
}
export default VxeUI
