qa-prevention-gwj-vue/src/main.js

123 lines
3.1 KiB
JavaScript
Raw Normal View History

2023-11-06 18:11:01 +08:00
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Cookies from 'js-cookie'
import 'normalize.css'
import App from './App'
import store from './store'
import router from './router'
import './asyncRouter'
import './icons' // icon
import BaiduMap from 'vue-baidu-map'
import Element from 'element-ui'
import dataV from '@jiaminghi/data-view'
import './styles/element-variables.scss'
import '@/assets/assbi/iconfont/iconfont.css'
Element.Dialog.props.closeOnClickModal.default = false // 禁用遮罩关闭
// import the component
import Treeselect from '@riophae/vue-treeselect'
// import the styles
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import VueParticles from 'vue-particles'
Vue.use(VueParticles)
Vue.component('Treeselect', Treeselect)
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
Vue.use(Viewer, {
defaultOptions: {
zIndex: 9999// 解决图片放大的层级问题
}})
Vue.use(Viewer)
Vue.use(dataV)
Viewer.setDefaults({
Options: {
'inline': true,
'button': true,
'navbar': true,
'title': true,
'toolbar': true,
'tooltip': true,
'movable': true,
'zoomable': true,
'rotatable': true,
'scalable': true,
'transition': true,
'fullscreen': true,
'keyboard': true,
'url': 'data-source'
}
})
Vue.use(BaiduMap, {
ak: 'OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr'
})
import Print from 'vue-print-nb'// 打印
Vue.use(Print) // 注册
import '@/styles/index.scss' // global css
Vue.config.productionTip = false
Vue.use(Element, {
size: Cookies.get('size') || 'small' // set element-ui default size
})
Vue.prototype.validStr = function(str) {
if (str != null && str != '' && typeof (str) != 'undefined' && str != 'undefined' && str != 0) { return true }
return false
}
/**
* json格式转树状结构
* @param {json} json数据
* @param {String} id的字符串
* @param {String} 父id的字符串
* @param {String} children的字符串
* @return {Array} 数组
*/
Vue.prototype.listTransTree = function(json, idStr, pidStr, chindrenStr) {
// eslint-disable-next-line one-var
var r = [], hash = {}, id = idStr, pid = pidStr, children = chindrenStr, i = 0, j = 0, len = json.length
for (; i < len; i++) {
hash[json[i][id]] = json[i]
}
for (; j < len; j++) {
// eslint-disable-next-line one-var
var aVal = json[j], hashVP = hash[aVal[pid]]
if (hashVP) {
!hashVP[children] && (hashVP[children] = [])
hashVP[children].push(aVal)
} else {
r.push(aVal)
}
}
return r
}
// 树数据结构去除空子级
Vue.prototype.removeEmptyChildren = function(data) {
for (let i = 0; i < data.length; i++) {
if (data[i].nodes && data[i].nodes.length > 0) {
this.removeEmptyChildren(data[i].nodes)
} else {
delete data[i].nodes
}
}
return data
}
// vue手写签名
import vueEsign from 'vue-esign'
Vue.use(vueEsign)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
})