mirror of
https://github.com/DzzXH/DzzOffice.git
synced 2026-03-01 15:22:42 +08:00
216 lines
6.7 KiB
JavaScript
216 lines
6.7 KiB
JavaScript
$(document).ready( function() {
|
||
$("button:submit,input:submit, .nav-link, .btn,a").click(function(){
|
||
$(this).attr('disable', 'true');
|
||
var l = $(this).lyearloading({
|
||
opacity: 0.2,
|
||
spinnerSize: 'nm',
|
||
});
|
||
l.addClass('disabled');
|
||
setTimeout(function() {
|
||
$(this).prop('disable', 'false');
|
||
l.destroy(); // 可以使用hide,页面中如果有多个loading,最好用destroy,避免后面的loading设置不生效
|
||
l.removeClass('disabled');
|
||
}, 1e3);
|
||
});
|
||
// 停止
|
||
$("body").on('click','[data-stopPropagation]',function (e) {
|
||
e.stopPropagation();
|
||
});
|
||
// 遮罩层
|
||
$(document).on('click', '.lyear-mask-modal', function() {
|
||
$( this ).remove();
|
||
$('.lyear-layout-sidebar').toggleClass('lyear-aside-open');
|
||
$('body').toggleClass('lyear-layout-sidebar-close');
|
||
});
|
||
|
||
// 工具提示
|
||
if ($('[data-bs-toggle="tooltip"]')[0]) {
|
||
$('[data-bs-toggle="tooltip"]').tooltip({
|
||
"container" : 'body',
|
||
});
|
||
}
|
||
|
||
// pop提示
|
||
if ($('[data-bs-toggle="popover"]')[0]) {
|
||
$('[data-bs-toggle="popover"]').popover({
|
||
container: 'body'
|
||
});
|
||
}
|
||
// Card最大化
|
||
$(document).on('click', '.card-btn-fullscreen', function(){
|
||
$(this).closest('.card').toggleClass('card-fullscreen');
|
||
});
|
||
|
||
// Card收缩/展开
|
||
$(document).on('click', '.card-btn-slide', function(){
|
||
$(this).toggleClass('rotate-180').closest('.card').find('.card-body').slideToggle();
|
||
});
|
||
|
||
// Card刷新
|
||
$(document).on('click', '.card-btn-reload', function(e) {
|
||
e.preventDefault();
|
||
var url = $(this).attr('href');
|
||
var $card = $(this).closest('.card');
|
||
|
||
if (url == "#" | url == "#!") {
|
||
return;
|
||
}
|
||
|
||
var l = $card.lyearloading({
|
||
opacity: 0.1,
|
||
spinnerSize: 'nm'
|
||
});
|
||
$card.find('.card-body').load(url, function(){
|
||
l.destroy();
|
||
});
|
||
});
|
||
|
||
// Card关闭
|
||
$(document).on('click', '.card-btn-close', function() {
|
||
$(this).closest('.card').fadeOut(600, function() {
|
||
if ($(this).parent().children().length == 1) {
|
||
$(this).parent().remove();
|
||
} else {
|
||
$(this).remove();
|
||
}
|
||
});
|
||
});
|
||
/**
|
||
* 滚动条
|
||
*/
|
||
if($('.lyear-scroll')[0]) {
|
||
$('.lyear-scroll').each(function(){
|
||
new PerfectScrollbar(this, {
|
||
swipeEasing: false,
|
||
suppressScrollX: true
|
||
});
|
||
});
|
||
}
|
||
|
||
// 颜色选取
|
||
jQuery('.js-colorpicker').each(function() {
|
||
var $colorpicker = jQuery(this);
|
||
$colorpicker.colorpicker({
|
||
'format': $colorpicker.data('colorpicker-mode') ? $colorpicker.data('colorpicker-mode') : 'auto',
|
||
'horizontal' : $colorpicker.data('colorpicker-horizontal') ? $colorpicker.data('colorpicker-horizontal') : false
|
||
});
|
||
});
|
||
|
||
// 日期选择器
|
||
jQuery("[data-provide = 'datepicker']").each(function() {
|
||
var options = {
|
||
language: 'zh-CN', // 默认简体中文
|
||
multidateSeparator: ', ' // 默认多个日期用,分隔
|
||
}
|
||
|
||
options = $.extend( options, getDataOptions( $(this) ));
|
||
|
||
if ( $(this).prop("tagName") != 'INPUT' ) {
|
||
options.inputs = [$(this).find('input:first'), $(this).find('input:last')];
|
||
}
|
||
|
||
$(this).datepicker(options);
|
||
});
|
||
|
||
// 时间日期选择器
|
||
jQuery("[data-provide = 'datetimepicker']").each(function() {
|
||
var options = {
|
||
locale: moment.locale(),
|
||
}
|
||
|
||
options = $.extend( options, getDataOptions( $(this) ));
|
||
|
||
if ( $(this).prop("tagName") != 'INPUT' ) {
|
||
options.inputs = [$(this).find('input:first'), $(this).find('input:last')];
|
||
}
|
||
console.log(options);
|
||
$(this).datetimepicker(options);
|
||
});
|
||
|
||
// 标签
|
||
$('.js-tags-input').each(function() {
|
||
var $this = $(this);
|
||
$this.tagsInput({
|
||
height: $this.data('height') ? $this.data('height') : '100%',
|
||
width: '100%',
|
||
defaultText: $this.attr("placeholder"),
|
||
removeWithBackspace: true,
|
||
delimiter: [',']
|
||
});
|
||
});
|
||
|
||
// 复选框全选
|
||
$(document).on('change', '#check-all', function () {
|
||
if ($boxname = $(this).data('name')) {
|
||
$(this).closest('table').find("input[name='" + $boxname + "']").prop('checked', $(this).prop("checked"));
|
||
} else {
|
||
$(this).closest('table').find(".form-check input[type='checkbox']").prop('checked', $(this).prop("checked"));
|
||
}
|
||
});
|
||
/*
|
||
* 提取通用的通知消息方法
|
||
* 这里只采用简单的用法,如果想要使用回调或者更多的用法,请查看lyear_js_notify.html页面
|
||
* @param $msg 提示信息
|
||
* @param $type 提示类型:'info', 'success', 'warning', 'danger'
|
||
* @param $delay 毫秒数,例如:1000
|
||
* @param $icon 图标,例如:'fa fa-user' 或 'mdi mdi-alert'
|
||
* @param $from 'top' 或 'bottom' 消息出现的位置
|
||
* @param $align 'left', 'right', 'center' 消息出现的位置
|
||
* @param $url 跳转链接,$delay毫秒后跳转 例如: https://www.xxxx.com
|
||
*/
|
||
showNotify = function ($msg, $type, $delay, $icon, $from, $align, $url) {
|
||
$type = $type || 'info';
|
||
$delay = $delay || 1000;
|
||
$from = $from || 'top';
|
||
$align = $align || 'right';
|
||
$enter = $type == 'danger' ? 'animate__animated animate__shakeX' : 'animate__animated animate__fadeInUp';
|
||
$url = $url || '';
|
||
|
||
jQuery.notify({
|
||
icon: $icon,
|
||
message: $msg
|
||
},
|
||
{
|
||
element: 'body',
|
||
type: $type,
|
||
allow_dismiss: true,
|
||
newest_on_top: true,
|
||
showProgressbar: false,
|
||
placement: {
|
||
from: $from,
|
||
align: $align
|
||
},
|
||
offset: 20,
|
||
spacing: 10,
|
||
z_index: 10800,
|
||
delay: $delay,
|
||
animate: {
|
||
enter: $enter,
|
||
exit: 'animate__animated animate__fadeOutDown'
|
||
}
|
||
});
|
||
if ($url != '') {
|
||
setTimeout(function() {
|
||
window.location.href = $url;
|
||
}, $delay);
|
||
}
|
||
}
|
||
});
|
||
getDataOptions = function(el, castList) {
|
||
var options = {};
|
||
|
||
$.each( $(el).data(), function(key, value){
|
||
|
||
key = dataToOption(key);
|
||
|
||
if ( key == 'provide' ) {
|
||
return;
|
||
}
|
||
options[key] = value;
|
||
});
|
||
|
||
return options;
|
||
}
|
||
dataToOption = function(name) {
|
||
return name.replace(/-([a-z])/g, function(x){return x[1].toUpperCase();});
|
||
} |