优化一下产品库加载

This commit is contained in:
aixianling
2022-05-10 16:54:21 +08:00
parent b4446a24a6
commit c0d890a0a8
3 changed files with 86 additions and 47 deletions

View File

@@ -58,22 +58,42 @@ const $decimalCalc = (...arr) => {
//返回计算值
return intArr.reduce((t, a) => t + a) / precision
}
/**
* @param { function } func
* @param { number } wait 延迟执行毫秒数
* @param { boolean } immediate true 表立即执行false 表非立即执行
*/
export const waiting = {
init(ops, count) {
if (document.body) {
let div = document.createElement('div')
div.id = "ai-waiting"
div.className = "el-loading-mask is-fullscreen"
div.style.zIndex = '202204271710'
div.style.textAlign = 'center'
div.style.lineHeight = '100vh'
div.style.color = '#26f'
div.style.background = 'rgba(0,0,0,.8)'
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
$decimalCalc,
$waiting: waiting
}