// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import store from './store/storeAll'
import 'element-ui/lib/theme-chalk/index.css'
import '@assets/css/reset.css'
import '@assets/css/table.css'
import '@assets/css/new.css'
import '@assets/icon/iconfont.css'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import eleLocale from 'element-ui/lib/locale'
import api from './api/api.js'
import pubFunction from './common/pub_function/function.js'
import VueDND from 'awe-dnd' // 拖拽组件
import axios from 'axios'
import echarts from 'echarts'
import API from '@utils/sha256/myHttpClient'
import fetch from './api/fetch'
import bill_type from '@basicClass/etc_type'
import appConfig from '@basicClass/app_config'
import utilsExcel from '@utils/excel/utils_excel'
import * as filters from './filters' // global filters
import '@components/baseComponents/index'
import hswebapp2frame from 'hswebapp2frame'
axios.defaults.headers.common['Authorization'] = sessionStorage.getItem(
  'header'
) || ''
sessionStorage.AppCode = 'BMS'
axios.defaults.headers.common['AppCode'] = sessionStorage.AppCode
// 兼容ie 11
import 'babel-polyfill'
import beforeEach from './router/before_each'
hswebapp2frame.initFrame(axios, router, beforeEach)
Vue.config.productionTip = false
Vue.use(VueDND)
// 定义全局api变量
Vue.prototype.$echarts = echarts
Vue.prototype.$api = api
Vue.prototype.$API = API
Vue.prototype.$pub_fun = pubFunction
Vue.prototype.$fetch = fetch
Vue.prototype.$bill_type = bill_type
Vue.prototype.$appConfig = appConfig
Vue.prototype.$Loading = ElementUI.Loading
Vue.prototype.$utilsExcel = utilsExcel
Vue.prototype.$tt = hswebapp2frame.getLangByKey
Vue.use(ElementUI)
eleLocale.use(zhLocale)
const HEADER_KEY = 'Authentication-Token'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App },
  beforeCreate() {
    const val = sessionStorage.getItem('token')
    if (val) {
      axios.defaults.headers.common[HEADER_KEY] = val
    }
  }
})
