import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import moment from 'moment'

import './icons' // icon
import './permission' // permission control

import * as filters from './filters' // global filters

import permission from '@/directive/permission/index.js' // 权限判断指令

import Print from '@/utils/print' // 打印
Vue.use(Print)

import ZkTable from 'vue-table-with-tree-grid'
Vue.use(ZkTable)

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.directive('permission', permission)
//判空
Vue.prototype.isEmptyObjVue = function (obj) {
  if (obj == null || obj == undefined || ("" + obj) == "") {
    return true;
  }
  return false;
};
//时间格式统一处理

Vue.prototype.formateDate = function (date) {
  if (Vue.prototype.isEmptyObjVue(date)) {
    return '';
  }
  return moment(date).format('YYYY-MM-DD HH:mm:ss');
}

Vue.prototype.formateDay = function (date) {
  if (Vue.prototype.isEmptyObjVue(date)) {
    return '';
  }
  return moment(date).format('YYYY-MM-DD');
}
Vue.prototype.formatMinute=function(duration){
  if(!duration) return "00分00秒";
 

    let day=parseInt(duration/(60*60*24))
    let h=parseInt((duration%(60*60*24))/(60*60))
    let m=parseInt((duration-h*60*60-day*(60*60*24))/60)
    let s=duration%60;

    h=h.toString().length<2?"0"+h.toString():h.toString();
    m=m.toString().length<2?"0"+m.toString():m.toString();
    s=s.toString().length<2?"0"+s.toString():s.toString();

    return m.toString()+'分'+s.toString()+'秒';

}
// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
