持续集成分支
This commit is contained in:
100
src/utils/index.js
Normal file
100
src/utils/index.js
Normal file
@@ -0,0 +1,100 @@
|
||||
import {MessageBox} from 'element-ui'
|
||||
import tools from 'dui/lib/js/utils'
|
||||
import store from "./store";
|
||||
|
||||
let {state: {user}} = store
|
||||
const addChildParty = (parent, pending) => {
|
||||
let doBeforeCount = pending.length
|
||||
parent["children"] = parent["children"] || []
|
||||
pending.map((e, index, arr) => {
|
||||
if (e.partyOrgParentId == parent.partyOrgId) {
|
||||
parent.children.push(e)
|
||||
arr.splice(index, 1)
|
||||
addChildParty(parent, arr)
|
||||
}
|
||||
})
|
||||
if (parent.children.length == 0) {
|
||||
delete parent.children
|
||||
}
|
||||
if (pending.length > 0 && doBeforeCount > pending.length) {
|
||||
parent.children.map(c => addChildParty(c, pending))
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 封装提示框
|
||||
*/
|
||||
|
||||
|
||||
const $confirm = (content, options) => {
|
||||
return MessageBox.confirm(content, {
|
||||
type: "warning",
|
||||
confirmButtonText: "确认",
|
||||
center: true,
|
||||
title: "提示",
|
||||
dangerouslyUseHTMLString: true,
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装权限判断方法
|
||||
*/
|
||||
|
||||
|
||||
const $permissions = flag => {
|
||||
const buttons = user?.info?.buttons
|
||||
if (buttons) return buttons.some(b => b.id == flag || b.permission == flag)
|
||||
else return false
|
||||
}
|
||||
|
||||
const $decimalCalc = (...arr) => {
|
||||
//确认提升精度
|
||||
let decimalLengthes = arr.map(e => {
|
||||
let index = ("" + e).indexOf(".")
|
||||
return ("" + e).length - index
|
||||
})
|
||||
let maxDecimal = Math.max(...decimalLengthes), precision = Math.pow(10, maxDecimal)
|
||||
//计算
|
||||
let intArr = arr.map(e => (Number(e) || 0) * precision)
|
||||
//返回计算值
|
||||
return intArr.reduce((t, a) => t + a) / precision
|
||||
}
|
||||
export const waiting = {
|
||||
init(ops, count) {
|
||||
if (document.body) {
|
||||
let div = document.createElement('div')
|
||||
div.id = "ai-waiting"
|
||||
div.innerHTML = "信息正在加载中..."
|
||||
div.className = "el-loading-mask is-fullscreen"
|
||||
div.style.zIndex = '202204271710'
|
||||
div.style.textAlign = 'center'
|
||||
div.style.lineHeight = '100vh'
|
||||
div.style.background = 'rgba(255,255,255,.8)'
|
||||
div.style.backdropFilter = 'blur(6px)'
|
||||
document.body.appendChild(div)
|
||||
} else if (count < 10) {
|
||||
setTimeout(() => this.init(ops, ++count), 500)
|
||||
}
|
||||
},
|
||||
getDom() {
|
||||
return document.querySelector('#ai-waiting')
|
||||
},
|
||||
setContent(html) {
|
||||
let div = this.getDom()
|
||||
div.innerHTML = html
|
||||
},
|
||||
close() {
|
||||
let div = this.getDom()
|
||||
div.parentElement.removeChild(div)
|
||||
}
|
||||
}
|
||||
export default {
|
||||
...tools,
|
||||
addChildParty,
|
||||
$confirm,
|
||||
$permissions,
|
||||
$decimalCalc,
|
||||
$waiting: waiting
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user