vuefunc.js 5.09 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
import BigNumber from "bignumber.js"
import {convertLockMsg,syncMsgbox} from "./index";

export function findCodeLabel(codes,val)
{
    if(!codes)
        return val;
    let item = codes.find(item=>item.value==val)
    if(!item)
        return val;
    return item.label
} 

export function dateFormat (date, format) {
    if(!date)
      return date
    if(typeof date == 'string')
      date = new Date(date)  

    let _format = format || 'yyyy-MM-dd';
  
    const d = date;
    const o = {
      'M+' : d.getMonth() + 1, // month
      'd+' : d.getDate(), // day
      'h+' : d.getHours(), // hour
      'm+' : d.getMinutes(), // minute
      's+' : d.getSeconds(), // second
      'q+' : Math.floor((d.getMonth() + 3) / 3), // quarter
      'S' : d.getMilliseconds() // millisecond
    };
    if (/(y+)/.test(_format)) {
        _format = _format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
      }
    
      for (const k in o) {
        if (o.hasOwnProperty(k) && new RegExp('(' + k + ')').test(_format)) {
          _format = _format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
        }
      }
    
      return _format;
}
// 数字展示成金额
export function moneyFormat(value, lanType) {
	let num = value
	let decimals = 2
	if (lanType !== undefined && ['KRW', 'JPY'].includes(lanType)) {
		decimals = 0
	}
	if (value === null || isNaN(value)) {
		num = '0'
	}
	return new BigNumber(num).toFormat(decimals)
}

export function routerPush(route, isClickMenu) {
	let tagsArry = this.$store.state.rulebpmn.tagsArry
	// console.log('tagsArry', tagsArry)
	// console.log('route', route)
	let routerPath = typeof route === 'string' ? route : route.path
	if (isClickMenu) {
		this.$router.push(route)
		return
	}
	if (!routerPath) {
		this.$router.push(route)
		return
	}
	if (routerPath.startsWith('/business') || routerPath.startsWith('/review')) {
		let isInRouteList = false
		isInRouteList = tagsArry.some((item) => {
			return item.routePath === routerPath
		})
		if (isInRouteList) {
			this.$notify({
				title: '提示',
				message: '该类型页面已经打开,请先关闭再操作!',
				type: 'warning',
			});
		} else {
			this.$router.push(route)
		}
	} else {
		this.$router.push(route)
	}
}
export function moduleRouter(defaultFlag){
  if (defaultFlag) {
    return this.$route.meta.module || 'Business';
  } else {
    return this.$route.meta.module || 'business';
  }
}

export function trnNameRouter(){
    return this.$route.meta.trnName || '';
}

//押汇中心经办+分行经办
export function isPubJinB(){
	let role=JSON.parse(window.sessionStorage.curRole)
	let roleId=role.id+"";
	let parentRoleId=role.parentRoleId+"";
105 106
	console.log("aaaaaa",window.sessionStorage.curRole,"bbbbbbb",role,"ccccccccccc",roleId,"ddddddddd",parentRoleId);
	if (roleId==="10265" || roleId==="1502" || roleId==="10231" || parentRoleId==="10265" ){
fukai committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
		return true;
	}
	return false;
}

export function isPubBranchJinB(){
	let curRole=JSON.parse(window.sessionStorage.curRole);
	if(curRole.parentRoleId+""==="10265"|| curRole.id+""==="10265"){
		return true;
	}
	return false;
}
export function isPubHeadJinB() {
	if(JSON.parse(window.sessionStorage.curRole).id+""==="10255"){
		return true;
	}
	return false;
}

export function  isPubHeadCenter() {//单证中心
	let roleId=JSON.parse(window.sessionStorage.curRole).id;
	if ("-10253-".indexOf(roleId)>0 ){
		return true;
	}
	return false;
}

export function isPubFuhe(){
	let roleId=JSON.parse(window.sessionStorage.curRole).id;
	if ("-10256-10232-10253-".indexOf(roleId)>0 ){
		return true;
	}
	return false;
}

export function isPubHeadFuhe(){
	let roleId=JSON.parse(window.sessionStorage.curRole).id;
	if ("-10256-10253-".indexOf(roleId)>0 ){
		return true;
	}
	return false;
}

export function isPubBranchFuhe(){
	if(JSON.parse(window.sessionStorage.curRole).id+""==="10232"){
		return true;
	}
	return false;
}

export function isPubAdmin() {
	let roleName = JSON.parse(window.sessionStorage.curRole).name;
	if (roleName.indexOf("管理员")>0 ){
		return true;
	}
	return false;
}

export function isPubJinBRerouting() {
	let role=JSON.parse(window.sessionStorage.curRole);
	let parentRoleId=role.parentRoleId+"";
	let headId=JSON.parse(window.sessionStorage.currentOrg).departmentNumber;
	if (parentRoleId==="10265" && headId!=="1000" ){
		return true;
	}
	return false;
}

export default {
	install(Vue){
		Vue.prototype.findCodeLabel = findCodeLabel
		// Vue.prototype.dateFormat = dateFormat
		Vue.prototype.moneyFormat = moneyFormat
		Vue.prototype.routerPush = routerPush
		Vue.prototype.moduleRouter = moduleRouter
		Vue.prototype.trnNameRouter = trnNameRouter
		Vue.prototype.convertLockMsg = convertLockMsg
		Vue.prototype.$smsgbox=syncMsgbox
		Vue.prototype.isPubJinB=isPubJinB;
		Vue.prototype.isPubFuhe=isPubFuhe;
		Vue.prototype.isPubBranchJinB=isPubBranchJinB;
		Vue.prototype.isPubHeadJinB=isPubHeadJinB;
		Vue.prototype.isPubHeadFuhe=isPubHeadFuhe;
		Vue.prototype.isPubHeadCenter=isPubHeadCenter;
		Vue.prototype.isPubBranchFuhe=isPubBranchFuhe;
		Vue.prototype.isPubAdmin=isPubAdmin;
		Vue.prototype.isPubJinBRerouting=isPubJinBRerouting;
	}
}