123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import Vue from 'vue'
- import 'normalize.css/normalize.css' // A modern alternative to CSS resets
- import ElementUI from 'element-ui'
- import 'element-ui/lib/theme-chalk/index.css'
- import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n zh-CN/en
- import '@/styles/index.scss' // global css
- import '@/styles/common.scss' // global css
- import App from './App'
- import store from './store'
- import router from './router'
- import '@/icons' // icon
- import '@/permission' // permission control
- import 'echarts-liquidfill'
- // 引入富文本编译器
- import VueQuillEditor from 'vue-quill-editor'
- import 'quill/dist/quill.core.css'
- import 'quill/dist/quill.snow.css'
- import 'quill/dist/quill.bubble.css'
- // 图片放大
- import Viewer from 'v-viewer'
- import 'viewerjs/dist/viewer.css'
- import * as echarts from 'echarts'
- import echartsGL from 'echarts-gl' // 引入echarts
- import axios from 'axios'
- import Qs from 'qs'
- import constant from './static/utils/constant.js'
- import common from './static/utils/common.js'
- import channel from './static/utils/channel.js'
- // 全局注册加密工具,使用方法为:this.$md5
- import md5 from 'js-md5'
- //全局注册
- import SearchBar from 'search-bar-vue2'
- // 引入第三方字体
- import '@/assets/css/font.css'
- // 弹窗拖动
- import elDragDialog from './dialog'
- Vue.use(ElementUI, { locale })
- Vue.use(VueQuillEditor)
- Vue.use(Viewer, { defaultOptions: {
- zIndex: 9999
- }})
- Vue.prototype.$echarts = echarts
- Vue.prototype.$echartsGL = echartsGL // 引入组件(将echarts注册为全局)
- // 添加
- // const Vue = require('vue')
- // const ElementUI = require('element-ui')
- // const axios = require('axios')
- // const Qs = require('qs')
- Vue.config.productionTip = false
- Vue.prototype.$axios = axios
- Vue.prototype.$qs = Qs
- Vue.prototype.$constant = constant
- Vue.prototype.$common = common
- Vue.prototype.$channel = channel
- Vue.prototype.$md5 = md5
- Vue.use(SearchBar)
- /* 导入Excel组件*/
- // import XLSX from 'xlsx'
- const XLSX = require('xlsx')
- router.beforeEach((to, from, next) => {
- if (to.meta.title) {
- window.document.title = to.meta.title
- next()
- } else {
- //console.log(to)
- let name = '保障房管理系统'
- window.document.title = name
- next()
- }
- console.log(new Date())
- })
- router.afterEach((to, from, next) => {
- console.log('你來自哪裏',from.fullPath)
- if(from.fullPath=='/lifeline'||from.fullPath=='/lifeLine'||from.fullPath=='/lifeline/supervise'){
- // try{
- //
- // }catch (e) {
- //
- // }
- console.log('我来自/lifeline','请允许通行')
- // setTimeout(() => {
- // window.location.reload();
- //
- // }, 100)
- }
- })
- // 使用组件
- new Vue({
- el: '#app',
- router,
- store,
- render: h => h(App)
- })
- /* 日期时间格式化*/
- Date.prototype.Format = function(fmt) { // author: meizz
- var o = {
- 'M+': this.getMonth() + 1, // 月份
- 'd+': this.getDate(), // 日
- 'h+': this.getHours(), // 小时
- 'm+': this.getMinutes(), // 分
- 's+': this.getSeconds(), // 秒
- 'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
- 'S': this.getMilliseconds() // 毫秒
- }
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
- for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
- return fmt
- }
- /* 数字小数位格式化*/
- Number.prototype.FMoney = function(n) {
- n = n > 0 && n <= 20 ? n : 2
- var s = parseFloat((this + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
- var l = s.split('.')[0].split('').reverse()
- var r = s.split('.')[1]
- var t = ''
- for (var i = 0; i < l.length; i++) {
- t += l[i] + ((i + 1) % 3 === 0 && (i + 1) !== l.length ? ',' : '')
- }
- return t.split('').reverse().join('') + '.' + r
- }
- /* 计算字符串byte长度*/
- String.prototype.getByteLen = function() {
- var len = 0
- for (var i = 0; i < this.length; i++) {
- if ((this.charCodeAt(i) & 0xff00) !== 0) { len++ }
- len++
- }
- return len
- }
- /**
- * 导出数据报表xlsx文件
- * 已注入所有Vue实例,
- * template模板里调用 $$outputXlsxFile
- * 组件方法里调用 this.$outputXlsxFile
- * 例:this.$outputXlsxFile([['字段1', '字段2'], [1, 2]], [{wch: 10}, {wch: 50}], '测试导出') 得到 测试导出.xlsx 文件
- * 第一个参数是导出的数组对象,第二个参数是设置字段宽度,第三个参数是文件名
- */
- const outputXlsxFile = (data, wscols, xlsxName) => {
- /* convert state to workbook */
- const ws = XLSX.utils.aoa_to_sheet(data)
- ws['!cols'] = wscols
- const wb = XLSX.utils.book_new()
- XLSX.utils.book_append_sheet(wb, ws, xlsxName)
- /* generate file and send to client */
- XLSX.writeFile(wb, xlsxName + '.xlsx')
- }
- Vue.directive('el-drag-dialog', elDragDialog)// 添加标签事件绑定 可以放大移动弹窗
- // 弹窗默认点击遮罩改为不关闭 为了防止和拖拽冲突 ,这句需要放在use ElementUI之前(也可以不加这句,自己测试区别)
- // ElementUI.Dialog.props.closeOnClickModal.default = false
- Vue.prototype.$outputXlsxFile = outputXlsxFile
|