main.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import 'normalize.css/normalize.css' // a modern alternative to CSS resets
  4. import Element from 'element-ui'
  5. import './styles/element-variables.scss'
  6. import '@/styles/index.scss' // global css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import Pagination from "@/components/Pagination";
  11. import i18n from './lang' // internationalization
  12. import './icons' // icon
  13. import './permission' // permission control
  14. import './utils/error-log' // error log
  15. import axios from './axios'
  16. import moment from 'moment'
  17. import * as filters from './filters' // global filters
  18. /**
  19. * If you don't want to use mock-server
  20. * you want to use MockJs for mock api
  21. * you can execute: mockXHR()
  22. *
  23. * Currently MockJs will be used in the production environment,
  24. * please remove it before going online ! ! !
  25. */
  26. if (process.env.NODE_ENV === 'production') {
  27. const { mockXHR } = require('../mock')
  28. mockXHR()
  29. }
  30. Vue.use(Element, {
  31. size: Cookies.get('size') || 'medium', // set element-ui default size
  32. i18n: (key, value) => i18n.t(key, value)
  33. })
  34. Vue.component('Pagination', Pagination)
  35. // register global utility filters
  36. Object.keys(filters).forEach(key => {
  37. Vue.filter(key, filters[key])
  38. })
  39. Vue.filter('formatDate', function(value) {
  40. if (value) {
  41. return moment(String(value)).format('YYYY-MM-DD')
  42. }
  43. })
  44. Vue.filter('formatDateTime', function(value) {
  45. if (value) {
  46. return moment(String(value)).format('YYYY-MM-DD hh:mm:ss')
  47. }
  48. })
  49. Vue.filter('displayWorkflowStatus', function(value) {
  50. if (value == 0) {
  51. return '未审核'
  52. }
  53. if (value == 1) {
  54. return '审核中'
  55. }
  56. if (value == 2) {
  57. return '已审核'
  58. }
  59. })
  60. Vue.filter('workflowStatusFilter', function(value) {
  61. if (value == 0) {
  62. return 'info'
  63. }
  64. else if (value == 2) {
  65. return 'success'
  66. }
  67. else{
  68. return 'warning'
  69. }
  70. })
  71. Vue.prototype.$axios = axios
  72. Vue.config.productionTip = false
  73. new Vue({
  74. el: '#app',
  75. router,
  76. store,
  77. i18n,
  78. render: h => h(App)
  79. })