545 lines
18 KiB
JavaScript
545 lines
18 KiB
JavaScript
import '@babel/polyfill'
|
|
require('es6-promise').polyfill();
|
|
require('es6-promise/auto');
|
|
import Vue from 'vue'
|
|
import App from './App'
|
|
import ElementUI from 'element-ui'
|
|
import 'element-ui/lib/theme-chalk/index.css'
|
|
// jQuery
|
|
import $ from 'jquery'
|
|
// vuex
|
|
import store from './store'
|
|
import Axios from 'axios'
|
|
// 复制
|
|
import VueClipboard from 'vue-clipboard2'
|
|
// 全局样式文件
|
|
import '@/assets/styles/common.less'
|
|
// 样式重置
|
|
import '@/assets/styles/reset.css'
|
|
// iconfont字体库
|
|
import '@/assets/styles/iconfont.css'
|
|
import '@/assets/styles/shangqi-iconfont/iconfont.css'
|
|
import '@/assets/styles/shangqi-iconfont-replace/iconfont.css' // 可直接替换此文件夹
|
|
import '@/assets/styles/shangqi-iconfont-2021/iconfont.css'
|
|
// axios
|
|
import axios from 'axios'
|
|
import $axios from '@/common/axios'
|
|
// 自定义全局组件
|
|
import components from '@/components'
|
|
// 自定义插件
|
|
import common from '@/common'
|
|
// 自定义按钮显示指令
|
|
import btnPermission from '@/common/btnPermission' // eslint-disable-line
|
|
import VueI18n from 'vue-i18n' // 国际化
|
|
// import * as echarts from 'echarts'
|
|
import { simpleUploadPath } from '@/sysConfig'
|
|
// 时间转换
|
|
import moment from 'moment'
|
|
moment.suppressDeprecationWarnings = true;
|
|
// 右键菜单
|
|
import Contextmenu from 'vue-contextmenujs'
|
|
|
|
// vant
|
|
import vant from 'vant';
|
|
import 'vant/lib/index.css';
|
|
//vant
|
|
|
|
import animate from 'animate.css'
|
|
import tool from './utils/tool'
|
|
Vue.use(tool)
|
|
// 引入路由器
|
|
import router from './router'
|
|
// 路由解析器
|
|
import Re from 'path-to-regexp'
|
|
|
|
import { get_verify_by_instance,loginIdm,getMenu,loginMobile } from 'api/process'
|
|
import hwh5 from 'api/hwh5-cloudonline.js';
|
|
|
|
import { ssoLoginUrlDev,ssoLoginUrl,webLoginType,devWebUrl } from '@/sysConfig'
|
|
|
|
import { mapMutations, mapActions } from 'vuex'
|
|
import VConsole from 'vuex'
|
|
|
|
|
|
import isMobile from "./store/isMobile";
|
|
import { Loading } from 'element-ui';
|
|
|
|
// 路由拦截
|
|
router.beforeEach(function (to, from, next) {
|
|
// const currentURL = window.location.href
|
|
// if (currentURL.indexOf('#/') > 0) {
|
|
// const index = currentURL.indexOf('#/')
|
|
// const startUrl = currentURL.slice(0, index)
|
|
// const endUrl = currentURL.slice(index + 2)
|
|
// window.location.href = startUrl + endUrl
|
|
// }
|
|
let loading = Loading.service({
|
|
text: '加载中...',
|
|
background: '#fff'
|
|
});
|
|
function closeLoading(){
|
|
setTimeout(() => {
|
|
loading.close()
|
|
loading = null
|
|
}, 1000)
|
|
}
|
|
let fromName = from.name
|
|
if(fromName === undefined || fromName === null){
|
|
window.sessionStorage.clear()
|
|
}
|
|
console.log(to)
|
|
console.log(from)
|
|
let toName = to.name
|
|
if (toName === 'CheckPage' || toName === 'loginStandDetails' || toName === 'error'
|
|
|| toName === 'LoginVerifyPhone') {
|
|
next()
|
|
closeLoading()
|
|
return
|
|
}
|
|
|
|
if(webLoginType === 'idm' && toName === 'Login'){
|
|
window.location.href = ssoLoginUrlDev
|
|
}
|
|
|
|
let token = store.state.token
|
|
let path = to.path;
|
|
let userName = ""
|
|
if((fromName === undefined || fromName === null) && (path.indexOf("/standardSearch/All&userName=") !== -1 || (path.indexOf("/standardSearch/All") !== -1 && to.query.userName !== undefined))){
|
|
if((path.indexOf("/standardSearch/All") !== -1 && to.query.userName !== undefined)){
|
|
userName = to.query.userName
|
|
}else {
|
|
userName = path.split("&")[1].split("=")[1]
|
|
}
|
|
window.sessionStorage.clear()
|
|
}else {
|
|
if(fromName === 'Home2'){
|
|
localStorage.removeItem("external")
|
|
}
|
|
}
|
|
let requireAuth = to.meta.requireAuth;
|
|
let taskId = to.query.taskIds;
|
|
let prcId = to.query.prcId;
|
|
let prcNum = to.query.prcNum;
|
|
let prcName = to.query.prcName;
|
|
let prcType = to.query.prcType;
|
|
let routerType = to.query.routerType;
|
|
let unShowReceipt = to.query.unShowReceipt;
|
|
let param = "taskIds=" + taskId + "&prcId=" + prcId
|
|
+ "&prcNum=" + prcNum + "&prcName=" + prcName + "&prcType=" + prcType;
|
|
if (unShowReceipt) {
|
|
param += "&unShowReceipt=" + unShowReceipt
|
|
}
|
|
let param4 = {
|
|
path: path,
|
|
token: token,
|
|
taskId: taskId,
|
|
prcId: prcId,
|
|
prcNum: prcNum,
|
|
prcName: prcName,
|
|
prcType: prcType,
|
|
toName: toName
|
|
}
|
|
let url = window.location.search
|
|
let code = "";
|
|
if(url){
|
|
url = url.substr(1);
|
|
url = url.split('&');
|
|
let info = [];
|
|
let obj = {};
|
|
for (let i = 0,len = url.length; i < len; i++) {
|
|
info = url[i].split('=')
|
|
obj[info[0]] = decodeURI(info[1]);
|
|
url[i] = obj;
|
|
}
|
|
code = url[0].code
|
|
}
|
|
|
|
function extractedLocalStorage(url,param,param4) {
|
|
localStorage.removeItem("external")
|
|
localStorage.removeItem("routerUrl")
|
|
localStorage.setItem('routerUrl', url)
|
|
localStorage.removeItem("routerParam")
|
|
localStorage.setItem('routerParam', param)
|
|
}
|
|
// 返回值为登录状态
|
|
// 单点登录
|
|
/** 判断是不是在手机端操作 */
|
|
if (isMobile()) {
|
|
if(toName === 'phoneHome' && (token === undefined || token === null || token === '')){
|
|
localStorage.removeItem('token')
|
|
token = localStorage.getItem("token")
|
|
window.sessionStorage.clear()
|
|
localStorage.setItem("routerName","phoneHome")
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else if(toName === 'phoneHome' && token != null && (fromName === undefined || fromName === null)){
|
|
localStorage.removeItem('token')
|
|
token = localStorage.getItem("token")
|
|
window.sessionStorage.clear()
|
|
next()
|
|
closeLoading()
|
|
}else if(toName === 'phoneHome' && token != null){
|
|
next()
|
|
closeLoading()
|
|
} else if(toName === 'processCenter'){
|
|
// hwh5.close();
|
|
//关闭当前窗口
|
|
let userAgent = navigator.userAgent;
|
|
if (userAgent.indexOf("Firefox") !== -1 || userAgent.indexOf("Chrome") !==-1) {
|
|
window.location.href="about:blank";
|
|
}else if(userAgent.indexOf('Android') > -1 || userAgent.indexOf('Linux') > -1){
|
|
window.opener=null;window.open('about:blank','_self','').close();
|
|
}else {
|
|
window.opener = null;
|
|
window.open("about:blank", "_self");
|
|
window.close();
|
|
}
|
|
//如果是微信打开,关闭当前微信窗口
|
|
weixinClosePage()
|
|
}else {
|
|
|
|
if ((token === null || token === '' ) && toName !== 'Login') {
|
|
if(toName !== 'phoneIndex'){
|
|
if(toName === 'phoneHome'){
|
|
// 手机端 首页 首次进入系统 清除 缓存, 防止 跳转 oa 的页面, 问题追溯 #55852
|
|
localStorage.removeItem('token')
|
|
token = localStorage.getItem("token")
|
|
window.sessionStorage.clear()
|
|
localStorage.setItem("routerName","phoneHome")
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else if(toName === 'databaseSearch' || toName === 'standDynamics' ||
|
|
toName === 'domesticStand' || toName === 'domesticDetails' || toName === 'zlzxDetails'){
|
|
localStorage.setItem("routerName",toName)
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else {
|
|
if(fromName === 'phoneHome'){
|
|
next()
|
|
closeLoading()
|
|
}else {
|
|
localStorage.removeItem("param");
|
|
localStorage.setItem('param',JSON.stringify(param4))
|
|
next('/phoneIndex')
|
|
closeLoading()
|
|
}
|
|
}
|
|
}else {
|
|
// 区分手机端首页 单独逻辑处理 token 为空 跳回验证页面重新验证
|
|
if(fromName === 'databaseSearch' || fromName === 'standDynamics' ||
|
|
fromName === 'domesticStand' || fromName === 'domesticDetails' || toName === 'zlzxDetails'){
|
|
localStorage.setItem("routerName",toName)
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}
|
|
} else {
|
|
if(toName === 'databaseSearch' || toName === 'standDynamics' || toName === 'zlzxDetails' ||
|
|
toName === 'domesticStand' || toName === 'domesticDetails'){
|
|
next()
|
|
closeLoading()
|
|
}else if (toName.slice(0,5) !== 'phone') {
|
|
if(toName === 'LoginVerify'){
|
|
if(toName === 'phoneHome'){
|
|
// 手机端 首页 首次进入系统 清除 缓存, 防止 跳转 oa 的页面, 问题追溯 #55852
|
|
localStorage.removeItem('token')
|
|
token = localStorage.getItem("token")
|
|
window.sessionStorage.clear()
|
|
localStorage.setItem("routerName","phoneHome")
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else{
|
|
next('/blankPage')
|
|
closeLoading()
|
|
}
|
|
}else {
|
|
if(toName === 'blankPage' || toName === 'processedPage') {
|
|
next()
|
|
closeLoading()
|
|
}else {
|
|
|
|
console.log('-bussLibrary4-')
|
|
extractedVerify()
|
|
}
|
|
}
|
|
}else {
|
|
if(toName !== 'blankPage'){
|
|
if(to.matched.length === 0){
|
|
if(toName === 'phoneHome'){
|
|
// 手机端 首页 首次进入系统 清除 缓存, 防止 跳转 oa 的页面, 问题追溯 #55852
|
|
localStorage.removeItem('token')
|
|
token = localStorage.getItem("token")
|
|
window.sessionStorage.clear()
|
|
localStorage.setItem("routerName","phoneHome")
|
|
next('/loginVerifyPhone')
|
|
closeLoading()
|
|
}else{
|
|
next('/blankPage')
|
|
closeLoading()
|
|
}
|
|
}else {
|
|
console.log('-phoneBussLibrary4-')
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if ((token === null || token === '' ) && toName === 'OtherStandardDetails') {
|
|
if (document.cookie) {
|
|
next()
|
|
closeLoading()
|
|
return
|
|
}
|
|
}
|
|
if ((token === null || token === '' ) && toName !== 'Login') {
|
|
if(webLoginType != null && webLoginType === 'idm' ){
|
|
if(code){
|
|
next()
|
|
closeLoading()
|
|
}else {
|
|
if (taskId !== undefined && taskId !== null && prcId !== undefined && prcId !== null) {
|
|
extractedVerify(token)
|
|
}else {
|
|
if((fromName === undefined || fromName === null) && (path.indexOf("/standardSearch/All&userName") !== -1 || (path.indexOf("/standardSearch/All") !== -1 && userName !== undefined))){
|
|
extractedLocalStorage("standardSearch/All",userName)
|
|
localStorage.setItem('external', "external")
|
|
next('/LoginVerifyNoEncryption')
|
|
closeLoading()
|
|
}else {
|
|
if (toName === 'LoginVerifyNoEncryption') {
|
|
next()
|
|
closeLoading()
|
|
}else {
|
|
if(path === '/standardSearch/All'){
|
|
extractedLocalStorage('standardSearch/All','');
|
|
}else {
|
|
extractedLocalStorage('home2','');
|
|
}
|
|
// ssoLoginUrlDev 默认sso 地址
|
|
window.location.href = ssoLoginUrlDev
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if(webLoginType != null && webLoginType === 'dev'){
|
|
if (isMobile()) {
|
|
extractedVerify(token)
|
|
} else {
|
|
next('/Login')
|
|
closeLoading()
|
|
}
|
|
|
|
}
|
|
}else {
|
|
extractedVerify(token)
|
|
}
|
|
}
|
|
function weixinClosePage() {
|
|
if (typeof WeixinJSBridge == "undefined") {
|
|
if (document.addEventListener) {
|
|
document.addEventListener('WeixinJSBridgeReady', weixin_ClosePage, false);
|
|
} else if (document.attachEvent) {
|
|
document.attachEvent('WeixinJSBridgeReady', weixin_ClosePage);
|
|
document.attachEvent('onWeixinJSBridgeReady', weixin_ClosePage);
|
|
}
|
|
} else {
|
|
weixin_ClosePage();
|
|
}
|
|
}
|
|
function weixin_ClosePage() {
|
|
WeixinJSBridge.call('closeWindow');
|
|
}
|
|
function extractedVerify() {
|
|
if (taskId !== undefined && taskId !== null && prcId !== undefined && prcId !== null) {
|
|
get_verify_by_instance({
|
|
taskId: taskId, // 任务id
|
|
pId: prcId // 流程实例
|
|
}).then(res => {
|
|
let hisCount = res.hisCount === undefined ? 0 : res.hisCount;
|
|
let commitStatus = res.commitStatus === undefined ? 0 : res.commitStatus;
|
|
let isNotFinished = res.isNotFinished === undefined ? 0 : res.isNotFinished;
|
|
if ((hisCount && hisCount > 0)) { // 业务系统 当前节点已完成
|
|
if(isMobile()){
|
|
next('/processedPage')
|
|
closeLoading()
|
|
}else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
} else { // 业务系统 当前节点未完成
|
|
// commitStatus 大于0 表示当前节点存在未完成干活流程
|
|
// isNotFinished OA 系统显示接受任务 已置为已办
|
|
if (routerType && routerType === 'oa' &&isNotFinished && isNotFinished > 0 && commitStatus && commitStatus > 0) {
|
|
if(isMobile()) {
|
|
extractedIphone()
|
|
}else if (prcType === '3') {
|
|
//标准征求意见 接受节点 未完成 oa已办 跳转详情页面
|
|
if (path === '/bzzqyjStep3') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '5') {
|
|
if (path === '/xmpgStep4') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '2') {
|
|
if (path === '/bzdyStep3') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '9') {
|
|
if (path === '/bzjdStep3') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '6') {
|
|
if (path === '/xmpg2Step6') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '10') {
|
|
if (path === '/xmqdqrStep2') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}else if (prcType === '8') {
|
|
if (path === '/wfhxzgStep4') {
|
|
extracted2("processAcceptDetail","prcNum=" + prcNum + "&tabsName=AlreadyProcess");
|
|
}
|
|
}
|
|
} else {
|
|
if(isMobile()) {
|
|
extractedIphone()
|
|
}else{
|
|
extracted3()
|
|
}
|
|
|
|
}
|
|
}
|
|
function extracted(routerPath) {
|
|
if (token === null || token === '') {
|
|
extractedLocalStorage(routerPath,param);
|
|
// ssoLoginUrlDev 默认sso 地址
|
|
window.location.href = ssoLoginUrlDev
|
|
} else {
|
|
next({path: routerPath + '?' +param})
|
|
closeLoading()
|
|
}
|
|
}
|
|
|
|
function extracted3() {
|
|
if (token === null || token === '') {
|
|
extractedLocalStorage(toName,param);
|
|
// ssoLoginUrlDev 默认sso 地址
|
|
window.location.href = ssoLoginUrlDev
|
|
} else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}
|
|
|
|
function extractedIphone() {
|
|
let paramPhone = 'taskIds=' + taskId + '&prcId=' + prcId + '&prcNum=' + prcNum +
|
|
'&taskAssignee=' + toName + '&prcName=' + prcName + '&prcType=' + prcType
|
|
let phoneRouter = 'phone' + toName.charAt(0).toUpperCase() + toName.slice(1)
|
|
console.log(phoneRouter);
|
|
next({path: phoneRouter + '?' + paramPhone})
|
|
closeLoading()
|
|
}
|
|
function extracted2(routerPath,param2) {
|
|
if (token === null || token === '') {
|
|
extractedLocalStorage(routerPath,param2);
|
|
// ssoLoginUrlDev 默认sso 地址
|
|
window.location.href = ssoLoginUrlDev
|
|
} else {
|
|
next({path: routerPath + '?' + param2})
|
|
closeLoading()
|
|
}
|
|
}
|
|
function extracted4(routerPath,param4) {
|
|
if (token === null || token === '') {
|
|
extractedLocalStorage(routerPath,param4);
|
|
// ssoLoginUrlDev 默认sso 地址
|
|
window.location.href = ssoLoginUrlDev
|
|
} else {
|
|
next({path: routerPath + '?' + param4})
|
|
closeLoading()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
if(path === '/loginVerify'){
|
|
if(webLoginType != null && webLoginType === 'dev'){
|
|
next('/Login')
|
|
closeLoading()
|
|
}else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}else {
|
|
if((fromName === undefined || fromName === null) && (path.indexOf("/standardSearch/All&userName") !== -1 || (path.indexOf("/standardSearch/All") !== -1 && userName !== undefined))) {
|
|
extractedLocalStorage("standardSearch/All",userName)
|
|
localStorage.setItem('external', "external")
|
|
next('/LoginVerifyNoEncryption')
|
|
closeLoading()
|
|
}else {
|
|
next()
|
|
closeLoading()
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
// 设置用户信息
|
|
function setUserInfo (userInfo) {
|
|
const timeStamp = new Date().getTime().toString()
|
|
const _USERINFO = JSON.parse(userInfo)
|
|
_USERINFO.userId = _USERINFO.userId || _USERINFO.usId
|
|
_USERINFO.userName = _USERINFO.userName || _USERINFO.uName
|
|
try {
|
|
localStorage.setItem('userInfo', JSON.stringify(_USERINFO))
|
|
localStorage.setItem('userInfoModifyTime', timeStamp)
|
|
} catch (e) {}
|
|
}
|
|
|
|
|
|
Vue.config.productionTip = false
|
|
// jquery
|
|
Vue.prototype.$ = $
|
|
Vue.use(ElementUI)
|
|
Vue.use(common)
|
|
Vue.use(components)
|
|
Vue.use(VueI18n)
|
|
Vue.use(VueClipboard)
|
|
Vue.use(Contextmenu)
|
|
Vue.use(animate)
|
|
Vue.use(vant)
|
|
|
|
// Vue.prototype.$echarts = echarts
|
|
// 原生axios
|
|
Vue.prototype.axios = axios
|
|
// 封装后的axios
|
|
Vue.prototype.$http = $axios
|
|
Vue.prototype.simpleUploadPath = simpleUploadPath
|
|
Vue.prototype.$moment = moment
|
|
// 国际化
|
|
const i18n = new VueI18n({
|
|
locale: store.getters.getLanguage || 'cn', // 定义默认语言为中文
|
|
messages: {
|
|
cn: require('@/assets/languages/cn'),
|
|
en: require('@/assets/languages/en')
|
|
}
|
|
})
|
|
/* eslint-disable no-new */
|
|
window.vm = new Vue({
|
|
VConsole,
|
|
router,
|
|
store,
|
|
i18n,
|
|
render: h => h(App)
|
|
}).$mount('#app')
|