loading.js
2.3 KB
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
export function showloading(txt) {
$("#luckysheet-cell-loading").find("span").text(txt).end().show();
};
export function hideloading() {
$("#luckysheet-cell-loading").hide();
};
// 消息弹框 ***********************************************************
const showAlert = (message, style, time) =>{
style = (style === undefined) ? 'alert-success-custom' : style;
time = (time === undefined) ? 5000 : time;
var iconName = 'fa-check';
if(style === 'alert-warning-custom'){
iconName = 'fa-warning';
} else if(style === 'alert-danger-custom'){
iconName = 'fa-times';
}
var id = (new Date()).getTime();
var icon = `<i style="font-size:14px;margin-right: 3px;" class="fa ${iconName} ${style}" aria-hidden="true"></i>`
$(`<div id="${id}"></div>`)
.appendTo('body')
.addClass('alert-custom ' + style)
.html(icon + message)
.show()
.delay(time)
.fadeOut();
// 隐藏后删除
setTimeout(function (){
$('#'+id).remove();
},5500)
};
export function showSuccess(message, style, time) {
showAlert(message,'alert-success-custom');
};
export function showDanger(message, style, time) {
showAlert(message,'alert-danger-custom');
};
export function showWarning(message, style, time) {
showAlert(message,'alert-warning-custom');
};
var func = null;
var arr = [];
/**
* 延迟加载函数
* @param message
* @param style
* @param time
*/
export function delayMessage(data) {
let message = data.handelMsg;
if(!message){
return;
}
var id = 'toast' + (new Date()).getTime();
var html = `<div id="${id}" class="toast align-items-center border-0 m-2" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
${message}
</div>
<button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>`;
if($('#delayMessageLive').length == 0){
$(`<div id="delayMessageLive" class="position-absolute top-0 end-0 p-3" style="z-index: 100000"></div>`).appendTo('body');
}
$(html).appendTo('#delayMessageLive');
var toastLiveExample = document.getElementById(id)
var toast = new bootstrap.Toast(toastLiveExample)
toast.show()
};