main.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/ruoyi.scss' // ruoyi css
  7. import App from './App'
  8. import store from './store'
  9. import router from './router'
  10. import directive from './directive' // directive
  11. import plugins from './plugins' // plugins
  12. import { download } from '@/utils/request'
  13. import './assets/icons' // icon
  14. import './permission' // permission control
  15. import { getDicts } from "@/api/system/dict/data";
  16. import { getConfigKey } from "@/api/system/config";
  17. import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree, inputMoney, uninputMoney } from "@/utils/ruoyi";
  18. // 分页组件
  19. import Pagination from "@/components/Pagination";
  20. // 自定义表格工具组件
  21. import RightToolbar from "@/components/RightToolbar"
  22. // 富文本组件
  23. import Editor from "@/components/Editor"
  24. // 文件上传组件
  25. import FileUpload from "@/components/FileUpload"
  26. // 图片上传组件
  27. import ImageUpload from "@/components/ImageUpload"
  28. // 图片预览组件
  29. import ImagePreview from "@/components/ImagePreview"
  30. // 字典标签组件
  31. import DictTag from '@/components/DictTag'
  32. // 头部标签组件
  33. import VueMeta from 'vue-meta'
  34. // 字典数据组件
  35. import DictData from '@/components/DictData'
  36. // 投放时间段组件
  37. import ScheduleTime from "@/components/ScheduleTime"
  38. import qs from 'qs'
  39. // 全局方法挂载
  40. Vue.prototype.inputMoney = inputMoney
  41. Vue.prototype.uninputMoney = uninputMoney
  42. Vue.prototype.getDicts = getDicts
  43. Vue.prototype.getConfigKey = getConfigKey
  44. Vue.prototype.parseTime = parseTime
  45. Vue.prototype.resetForm = resetForm
  46. Vue.prototype.addDateRange = addDateRange
  47. Vue.prototype.selectDictLabel = selectDictLabel
  48. Vue.prototype.selectDictLabels = selectDictLabels
  49. Vue.prototype.download = download
  50. Vue.prototype.handleTree = handleTree
  51. Vue.prototype.qs = qs
  52. // 全局组件挂载
  53. Vue.component('DictTag', DictTag)
  54. Vue.component('Pagination', Pagination)
  55. Vue.component('RightToolbar', RightToolbar)
  56. Vue.component('Editor', Editor)
  57. Vue.component('FileUpload', FileUpload)
  58. Vue.component('ImageUpload', ImageUpload)
  59. Vue.component('ImagePreview', ImagePreview)
  60. Vue.component('ScheduleTime', ScheduleTime)
  61. Vue.use(directive)
  62. Vue.use(plugins)
  63. Vue.use(VueMeta)
  64. DictData.install()
  65. Vue.prototype.allMoney = function (num, n) {
  66. n = n || 2;
  67. let symbol = ",";
  68. if (num === null) return num;
  69. if (typeof num !== "number")
  70. throw new TypeError("num参数应该是一个number类型");
  71. if (n < 0) throw new Error("参数n不应该小于0");
  72. let hasDot = parseInt(num) != num; //这里检测num是否为小数,true表示小数
  73. let m = n != undefined && n != null ? n : 1;
  74. num =
  75. m == 0
  76. ? num.toFixed(m) + "."
  77. : hasDot
  78. ? n
  79. ? num.toFixed(n)
  80. : num
  81. : num.toFixed(m);
  82. symbol = symbol || ",";
  83. num = num
  84. .toString()
  85. .replace(/(\d)(?=(\d{3})+\.)/g, function (match, p1, p2) {
  86. return p1 + symbol;
  87. });
  88. if (n == 0 || (!hasDot && !n)) {
  89. //如果n为0或者传入的num是整数并且没有指定整数的保留位数,则去掉前面操作中的小数位
  90. num = num.substring(0, num.indexOf("."));
  91. }
  92. return num;
  93. }
  94. /**
  95. * If you don't want to use mock-server
  96. * you want to use MockJs for mock api
  97. * you can execute: mockXHR()
  98. *
  99. * Currently MockJs will be used in the production environment,
  100. * please remove it before going online! ! !
  101. */
  102. Vue.use(Element, {
  103. size: Cookies.get('size') || 'medium' // set element-ui default size
  104. })
  105. Vue.config.productionTip = false
  106. new Vue({
  107. el: '#app',
  108. router,
  109. store,
  110. render: h => h(App)
  111. })