main.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import { setToken } from '@/utils/auth'
  2. import { getUrlParam, findElem, deleteEmptyObj } from '@/utils/util'
  3. if (getUrlParam().token) {
  4. setToken(getUrlParam().token)
  5. }
  6. import Vue from 'vue'
  7. import 'normalize.css/normalize.css' // A modern alternative to CSS resets
  8. // import './plugins/jquery.hiwprint.js'
  9. import ElementUI from '@zjlib/element-ui2'
  10. import '@zjlib/element-ui2/lib/theme-chalk/index.css'
  11. import VueQuillEditor from 'vue-quill-editor'
  12. // require styles
  13. import 'quill/dist/quill.core.css'
  14. import 'quill/dist/quill.snow.css'
  15. import 'quill/dist/quill.bubble.css'
  16. Vue.use(VueQuillEditor /* { default global options } */)
  17. import dataV from '@jiaminghi/data-view';
  18. Vue.use(dataV)
  19. import VQuillEditor from '@/components/v-quill-editor'
  20. Vue.component('v-quill-editor', VQuillEditor)
  21. import { Loading } from '@zjlib/element-ui2'
  22. let loading
  23. function startLoading() {
  24. loading = Loading.service({
  25. lock: true,
  26. text: '拼命加载中...',
  27. spinner: 'el-icon-loading',
  28. customClass: '.app-container'
  29. })
  30. }
  31. function endLoading() {
  32. loading.close()
  33. }
  34. import * as echarts from 'echarts'
  35. Vue.prototype.$echarts = echarts
  36. import '@/styles/index.scss' // global css
  37. import App from './App'
  38. import store from './store'
  39. import router from './router'
  40. import '@/icons' // icon
  41. import '@/permission' // permission control
  42. import * as filters from './filters' // global filters
  43. import directives from './directives'
  44. window._AMapSecurityConfig = {
  45. serviceHost: 'https://jiasm.zfire.top/' + '_AMapService'
  46. }
  47. import '@zjlib/element-plugins/dest/element-plugins.css'
  48. import ElementPlugins, { AMap } from '@zjlib/element-plugins'
  49. Vue.use(ElementPlugins, {
  50. // 表单页面表单属性配置
  51. formAttributes: {
  52. 'label-position': 'right'
  53. }
  54. // // 操作记录配置
  55. // operationRecord: function (options) {
  56. // // console.log(options.meta.moduleId)
  57. // // return new Promise((r, j) => {
  58. // // r([[], []])
  59. // // })
  60. // }
  61. })
  62. Vue.use(AMap)
  63. AMap.initAMapApiLoader({
  64. // 高德的key
  65. key: '5894bf90997454b0df3c3d60cab12f64',
  66. version: '2.0',
  67. plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch', 'AMap.DistrictSearch']
  68. })
  69. // // 本地引用;
  70. // import ElementPlugins, { AMap } from '@packages'
  71. // Vue.use(ElementPlugins, {
  72. // formAttributes: {
  73. // 'label-position': 'right'
  74. // }
  75. // })
  76. // Vue.use(AMap)
  77. // AMap.initAMapApiLoader({
  78. // // 高德的key
  79. // key: '5894bf90997454b0df3c3d60cab12f64',
  80. // plugins: ['AMap.Geocoder', 'AMap.AutoComplete', 'AMap.PlaceSearch']
  81. // })
  82. import '@/utils/time.js'
  83. import { getIPAdd } from '@/utils/lbs.js'
  84. getIPAdd()
  85. .then(res => {
  86. Vue.prototype.$IpAdd = res.data
  87. })
  88. .catch(err => {})
  89. // 成功/错误提示
  90. import { successMsg, errorMsg, warningNotify, checkBtnRole, getSummaries, numToFixed } from '@/utils/common.js'
  91. Vue.prototype.$successMsg = successMsg
  92. Vue.prototype.$errorMsg = errorMsg
  93. Vue.prototype.$warningNotify = warningNotify
  94. Vue.prototype.$checkBtnRole = checkBtnRole
  95. Vue.prototype.$getSummaries = getSummaries
  96. Vue.prototype.$numToFixed = numToFixed
  97. Vue.prototype.$startLoading = startLoading
  98. Vue.prototype.$endLoading = endLoading
  99. Vue.prototype.$restrict = function (...codes) {
  100. var roles = this.$route.meta.roles || []
  101. for (var code of codes) {
  102. if (roles.includes(code)) {
  103. return true
  104. }
  105. }
  106. return false
  107. }
  108. // 自定义组件
  109. import ExportButton from '@/components/Common/export-button.vue'
  110. Vue.component('ExportButton', ExportButton)
  111. import ImportButton from '@/components/Common/import-button.vue'
  112. Vue.component('ImportButton', ImportButton)
  113. import CopyButton from '@/components/Common/copy-button.vue'
  114. Vue.component('CopyButton', CopyButton)
  115. import Collapse from '@/components/Common/collapse'
  116. Vue.component('Collapse', Collapse)
  117. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_OSS;
  118. Vue.prototype.$xdocUrl = 'https://pgxtadm.greeapps.com/preview/onlinePreview?url='
  119. Vue.prototype.$findElem = findElem;
  120. Vue.prototype.$deleteEmptyObj = deleteEmptyObj;
  121. /**
  122. * If you don't want to use mock-server
  123. * you want to use MockJs for mock api
  124. * you can execute: mockXHR()
  125. *
  126. * Currently MockJs will be used in the production environment,
  127. * please remove it before going online ! ! !
  128. */
  129. if (process.env.NODE_ENV === 'production') {
  130. const { mockXHR } = require('../mock')
  131. mockXHR()
  132. }
  133. // set ElementUI lang to EN
  134. // Vue.use(ElementUI, { locale })
  135. // 如果想要中文版 element-ui,按如下方式声明
  136. Vue.use(ElementUI)
  137. import { Message } from 'element-ui';
  138. //定义一个新的Message方法,多传入一个offset参数
  139. const $message = options => {
  140. return Message({
  141. ...options,
  142. offset: 80
  143. });
  144. };
  145. //重写方法,将offset写入options
  146. ['success', 'warning', 'info', 'error'].forEach(type => {
  147. $message[type] = options => {
  148. if (typeof options === 'string') {
  149. options = {
  150. message: options,
  151. offset: 80
  152. };
  153. }
  154. options.type = type;
  155. return Message(options);
  156. };
  157. });
  158. //将$message挂载到this上
  159. Vue.prototype.$message = $message;
  160. //不加这行代码运行this.$message.closeAll时会报错
  161. Vue.prototype.$message.closeAll = Message.closeAll;
  162. // register global utility filters
  163. Object.keys(filters).forEach(key => {
  164. Vue.filter(key, filters[key])
  165. })
  166. Object.keys(directives).forEach(key => {
  167. Vue.directive(key, directives[key])
  168. })
  169. Vue.config.productionTip = false
  170. new Vue({
  171. el: '#app',
  172. router,
  173. store,
  174. render: h => h(App)
  175. })