You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wkcrm_web/src/App.vue

141 lines
3.8 KiB

4 years ago
<template>
<div id="app">
<router-view class="router-view" />
<vue-picture-viewer
v-if="showPreviewImg"
:img-data="previewImgs"
:select-index="previewIndex"
@close-viewer="showPreviewImg=false"/>
<xr-import
v-if="showFixImport"
:process-status="crmImportStatus"
@click.native="fixImportClick"/>
<c-r-m-import
:show.sync="showCRMImport"
:crm-type="crmType"
:props="crmProps"
:cache-show.sync="cacheShow"
:cache-done="cacheDone"
@status="crmImportChange"
@close="crmImportClose"/>
4 years ago
<xr-upgrade-dialog v-if="upgradeDialogShow" :visible.sync="upgradeDialogShow" />
4 years ago
</div>
</template>
<script>
/** 常用图片预览创建组件 */
import VuePictureViewer from '@/components/VuePictureViewer/index'
import XrImport from '@/components/XrImport'
import XrImportMixins from '@/components/XrImport/XrImportMixins'
4 years ago
import XrUpgradeDialog from '@/components/XrUpgradeDialog'
4 years ago
import CRMImport from '@/components/CRMImport'
import { mapGetters } from 'vuex'
import cache from '@/utils/cache'
export default {
name: 'App',
components: {
VuePictureViewer,
XrImport,
4 years ago
CRMImport,
XrUpgradeDialog
4 years ago
},
mixins: [XrImportMixins],
data() {
return {
showPreviewImg: false,
previewIndex: 0,
4 years ago
previewImgs: [],
upgradeDialogShow: false
4 years ago
}
},
computed: {
4 years ago
...mapGetters(['activeIndex', 'addRouters', 'userInfo'])
4 years ago
},
watch: {
$route(to, from) {
this.showPreviewImg = false // 切换页面隐藏图片预览
4 years ago
},
addRouters() {
if (this.userInfo && this.userInfo.is_read_notice != 1) {
setTimeout(() => {
this.upgradeDialogShow = true
}, 5000)
}
4 years ago
}
},
mounted() {
this.addBus()
this.addDocumentVisibilityChange()
this.setMinHeight()
},
methods: {
addDocumentVisibilityChange() {
// 网页当前状态判断
// hidden,
var state, visibilityChange
if (typeof document.hidden !== 'undefined') {
// hidden = 'hidden'
visibilityChange = 'visibilitychange'
state = 'visibilityState'
} else if (typeof document.mozHidden !== 'undefined') {
// hidden = 'mozHidden'
visibilityChange = 'mozvisibilitychange'
state = 'mozVisibilityState'
} else if (typeof document.msHidden !== 'undefined') {
// hidden = 'msHidden'
visibilityChange = 'msvisibilitychange'
state = 'msVisibilityState'
} else if (typeof document.webkitHidden !== 'undefined') {
// hidden = 'webkitHidden'
visibilityChange = 'webkitvisibilitychange'
state = 'webkitVisibilityState'
}
// 添加监听器在title里显示状态变化
document.addEventListener(visibilityChange, () => {
if (document[state] == 'visible') {
cache.updateAxiosHeaders()
}
this.$bus.emit('document-visibility', document[state])
}, false)
},
addBus() {
var self = this
this.$bus.on('preview-image-bus', function(data) {
self.previewIndex = data.index
self.previewImgs = data.data
self.showPreviewImg = true
})
},
setMinHeight() {
this.$nextTick(() => {
const dpr = window.devicePixelRatio || 1
const clientWidth = document.body.clientWidth
const dom = document.getElementById('app')
if (dpr !== 1 && clientWidth > 1600) {
dom.style.minHeight = '800px'
} else if (dpr === 1 && clientWidth > 1600) {
dom.style.minWidth = '1650px'
} else {
// dom.style.minWidth = '1200px'
dom.style.minHeight = '605px'
}
})
}
}
}
</script>
<style>
#app {
width: 100%;
position: relative;
height: 100%;
min-width: 1200px;
min-height: 605px;
}
</style>