main.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import Vue from 'vue'
  2. import Cookies from 'js-cookie'
  3. import Element from 'element-ui'
  4. import './assets/styles/element-variables.scss'
  5. import '@/assets/styles/index.scss' // global css
  6. import '@/assets/styles/ygp.scss' // ygp css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' //directive
  11. import './assets/icons' // icon
  12. import './permission' // permission control
  13. import { getDicts } from "@/api/system/dict/data";
  14. import { getConfigKey } from "@/api/system/config";
  15. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree, numberFormat } from "@/utils/util";
  16. import Pagination from "@/components/Pagination";
  17. // 自定义表格工具组件
  18. import RightToolbar from "@/components/RightToolbar"
  19. // 富文本组件
  20. import Editor from "@/components/Editor"
  21. // 文件上传组件
  22. import FileUpload from "@/components/FileUpload"
  23. // 图片上传组件
  24. import ImageUpload from "@/components/ImageUpload"
  25. // 图片展示组件
  26. import ImageShow from "@/components/ImageShow"
  27. // 字典标签组件
  28. import DictTag from '@/components/DictTag'
  29. // 头部标签组件
  30. import VueMeta from 'vue-meta'
  31. // 全局方法挂载
  32. Vue.prototype.getDicts = getDicts
  33. Vue.prototype.getConfigKey = getConfigKey
  34. Vue.prototype.parseTime = parseTime
  35. Vue.prototype.resetForm = resetForm
  36. Vue.prototype.addDateRange = addDateRange
  37. Vue.prototype.selectDictLabel = selectDictLabel
  38. Vue.prototype.selectDictLabels = selectDictLabels
  39. Vue.prototype.download = download
  40. Vue.prototype.handleTree = handleTree
  41. Vue.prototype.$numberFormat = numberFormat
  42. import echarts from 'echarts'
  43. Vue.prototype.$echarts = echarts
  44. // 处理时间的过滤器
  45. Vue.use(require('vue-moment'))
  46. import moment from 'moment'
  47. moment.locale('zh_cn')
  48. Vue.prototype.msgSuccess = function (msg) {
  49. this.$message({ showClose: true, message: msg, type: "success" });
  50. }
  51. Vue.prototype.msgError = function (msg) {
  52. this.$message({ showClose: true, message: msg, type: "error" });
  53. }
  54. Vue.prototype.msgInfo = function (msg) {
  55. this.$message.info(msg);
  56. }
  57. // 全局组件挂载
  58. Vue.component('DictTag', DictTag)
  59. Vue.component('Pagination', Pagination)
  60. Vue.component('RightToolbar', RightToolbar)
  61. Vue.component('Editor', Editor)
  62. Vue.component('FileUpload', FileUpload)
  63. Vue.component('ImageUpload', ImageUpload)
  64. Vue.component('ImageShow', ImageShow)
  65. /** 常用flex组件 */
  66. import {
  67. Flexbox,
  68. FlexboxItem
  69. } from '@/components/Flexbox'
  70. Vue.component('flexbox', Flexbox)
  71. Vue.component('flexbox-item', FlexboxItem)
  72. Vue.use(directive)
  73. Vue.use(VueMeta)
  74. /**
  75. * If you don't want to use mock-server
  76. * you want to use MockJs for mock api
  77. * you can execute: mockXHR()
  78. *
  79. * Currently MockJs will be used in the production environment,
  80. * please remove it before going online! ! !
  81. */
  82. Vue.use(Element, {
  83. size: Cookies.get('size') || 'medium' // set element-ui default size
  84. })
  85. Vue.config.productionTip = false
  86. // 时间戳转化为年月日
  87. Vue.filter('dateFormat', function(originVal) {
  88. const dt = new Date(originVal)
  89. const y = dt.getFullYear()
  90. const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  91. const d = (dt.getDate() + '').padStart(2, '0')
  92. return `${y}-${m}-${d}`
  93. })
  94. new Vue({
  95. el: '#app',
  96. router,
  97. store,
  98. render: h => h(App)
  99. })