!108 refactor: 移除 Lib 脚本目录

* refactor: 移除 Lib 目录
pull/108/MERGE
Argo 5 years ago
parent bc0b3b6812
commit 7d81c1e63c

@ -5,7 +5,7 @@
<OutputType>Library</OutputType>
<RazorLangVersion>3.0</RazorLangVersion>
<IsPackable>true</IsPackable>
<Version>3.1.4-beta02</Version>
<Version>3.1.4</Version>
</PropertyGroup>
<ItemGroup>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 434 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,833 +0,0 @@
(function ($) {
// 增加Array扩展
if (!$.isFunction(Array.prototype.filter)) {
Array.prototype.filter = function (callback, thisObject) {
if ($.isFunction(callback)) {
var res = new Array();
for (var i = 0; i < this.length; i++) {
callback.call(thisObject, this[i], i, this) && res.push(this[i]);
}
return res;
}
};
}
// 增加String扩展
if (!$.isFunction(String.prototype.trim)) {
String.prototype.trim = function () {
if (this === null) return "";
var trimLeft = /^\s+/, trimRight = /\s+$/;
return this.replace(trimLeft, "").replace(trimRight, "");
};
}
// 扩展Date
if (!$.isFunction(Date.prototype.format)) {
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours() % 12 === 0 ? 12 : this.getHours() % 12,
"H+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
var week = {
0: "日",
1: "一",
2: "二",
3: "三",
4: "四",
5: "五",
6: "六"
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
if (/(E+)/.test(format))
format = format.replace(RegExp.$1, (RegExp.$1.length > 1 ? RegExp.$1.length > 2 ? "星期" : "周" : "") + week[this.getDay()]);
for (var k in o)
if (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;
};
}
// enhance window.console.log
if (!window.console) {
window.console = {
log: function () {
}
};
}
window.console = window.console || {};
console.log || (console.log = opera.postError);
// client
jQuery.browser = {
versions: function () {
var u = navigator.userAgent;
return { //移动终端浏览器版本信息
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPod: u.indexOf('iPod') > -1, //是否为iPod或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') === -1 //是否web应该程序没有头部与底部
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
};
$.extend({
format: function (source, params) {
if (params === undefined || params === null) {
return null;
}
if (arguments.length > 2 && params.constructor !== Array) {
params = $.makeArray(arguments).slice(1);
}
if (params.constructor !== Array) {
params = [params];
}
$.each(params, function (i, n) {
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function () {
return n;
});
});
return source;
},
copyText: function (ele) {
if (typeof ele !== "string") return false;
var input = document.createElement('input');
input.setAttribute('type', 'text');
input.setAttribute('value', ele);
document.body.appendChild(input);
input.select();
var ret = document.execCommand('copy');
document.body.removeChild(input);
return ret;
},
fullScreenStatus: function fullScreenStatus(value) {
if (value !== undefined) window.fullscreen = value;
return document.fullscreen ||
document.mozFullScreen ||
document.webkitIsFullScreen || window.fullscreen ||
false;
},
remoteValidate: function (url, method) {
if (method === undefined) method = 'get';
var check = false;
jQuery[method]({
url: $.formatUrl(url),
async: false,
cache: false,
success: function (result) {
check = result
}
});
return check;
},
bc: function (options) {
options = $.extend({
id: "",
url: "",
data: {},
title: "",
modal: false,
loading: false,
loadingTimeout: 10000,
callback: false,
cors: false,
contentType: 'application/json',
dataType: 'json',
method: 'get',
autoFooter: false
}, options);
if (!options.url || options.url === "") {
toastr.error('未设置请求地址Url', '参数错误');
return;
}
var loadFlag = "loading";
var loadingHandler = null;
if (options.loading && options.modal) {
var $modal = $(options.modal);
$modal.on('shown.bs.modal', function () {
var $this = $(this);
if (loadingHandler !== null) {
window.clearTimeout(loadingHandler);
loadingHandler = null;
}
if ($this.hasClass(loadFlag)) return;
$this.modal('hide');
});
loadingHandler = window.setTimeout(function () { $(options.modal).addClass(loadFlag).modal('show'); }, 300);
var loadTimeoutHandler = setTimeout(function () {
$(options.modal).find('.close').removeClass('d-none');
clearTimeout(loadTimeoutHandler);
}, options.loadingTimeout);
}
var data = options.method === 'get' ? options.data : JSON.stringify(options.data);
var url = options.id !== '' ? options.url + '/' + options.id : options.url;
if (options.query) {
var qs = [];
for (var key in options.query) {
qs.push($.format("{0}={1}", key, options.query[key]));
}
url = url + "?" + qs.join('&');
}
function success(result) {
if (options.modal && (result || options.loading)) {
if (loadingHandler !== null) {
// cancel show modal event
window.clearTimeout(loadingHandler);
loadingHandler = null;
}
else $(options.modal).removeClass(loadFlag).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
if ($.isFunction(options.callback)) {
options.callback.call(options, result);
}
if (options.autoFooter === true) {
$.footer();
}
}
var ajaxSettings = {
url: $.formatUrl(url),
data: data,
method: options.method,
contentType: options.contentType,
dataType: options.dataType,
crossDomain: false,
success: function (result) {
success(result);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if (errorThrown === "Unauthorized") {
window.location.href = $.formatUrl('Account/Logout');
return;
}
if (window.toastr) {
if (errorThrown === '') errorThrown = url;
toastr.error(XMLHttpRequest.status === 500 ? '后台应用程序错误' : errorThrown, '程序错误');
}
success(false);
}
};
if (options.cors) $.extend(ajaxSettings, {
xhrFields: { withCredentials: true },
crossDomain: true
});
if ($.isArray($.logData) && !$.isEmptyObject(options.data)) $.logData.push({ url: url, data: options.method === 'delete' ? options.logData : options.data });
if (options.method === 'delete' && $.logData && $.isFunction($.logData.log)) $.logData.log();
$.ajax(ajaxSettings);
},
lgbSwal: function (options) {
if ($.isFunction(swal)) {
swal($.extend({ showConfirmButton: false, showCancelButton: false, timer: 1000, title: '未设置', type: "success" }, options));
}
else {
window.log('缺少 swal 脚本引用');
}
},
getUID: function (prefix) {
if (!prefix) prefix = 'lgb';
do prefix += ~~(Math.random() * 1000000);
while (document.getElementById(prefix));
return prefix;
},
footer: function (options) {
var op = $.extend({ header: "header", content: "body > section:first", ele: 'footer' }, options);
var $ele = $(op.ele);
// 增加 1px 修复 IE11 下由于小数点导致页脚消失bug
return $(op.header).outerHeight() + $(op.content).outerHeight() + $ele.outerHeight() > $(window).height() + 1 ? $ele.removeClass('position-fixed') : $ele.addClass('position-fixed');
},
formatUrl: function (url) {
if (!url) return url;
if (url.substr(0, 4) === "http") return url;
var base = $('#pathBase').attr('href');
return base + url;
},
safeHtml: function (text) {
return (text && typeof text === "string") ? $('<div>').text(text).html() : text;
},
syntaxHighlight: function (json) {
if (typeof (json) === 'string') {
json = JSON.parse(json);
}
json = JSON.stringify(json, undefined, 2);
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
}
);
}
});
window.lgbSwal = $.lgbSwal;
$.fn.extend({
autoCenter: function (options) {
if (this.length === 0) return;
options = $.extend({ top: 0 }, options);
var that = this;
var defaultVal = parseFloat(that.css('marginTop').replace('px', ''));
var getHeight = function () {
return Math.max(defaultVal, ($(window).height() - options.top - that.outerHeight()) / 2 + $(document).scrollTop());
};
$(window).resize(function () {
that.css({ marginTop: getHeight() });
});
that.css({ marginTop: getHeight(), transition: "all .5s linear" });
return this;
},
lgbTable: function (options) {
var bsa = new DataTable($.extend(options.dataBinder, { url: options.url, bootstrapTable: this }));
var settings = $.extend(true, {
url: options.url,
checkbox: true,
editButtons: {
id: "#tableButtons",
events: {},
formatter: false
},
editTitle: "操作",
editField: "Id",
queryButton: false
}, options.smartTable);
var $editButtons = $(settings.editButtons.id);
if ($editButtons.find('button').length > 0) settings.columns.push({
title: settings.editTitle,
field: settings.editField,
events: $.extend({}, bsa.idEvents(), settings.editButtons.events),
formatter: function (value, row, index) {
if ($.isFunction(settings.editButtons.formatter)) {
return settings.editButtons.formatter.call($editButtons, value, row, index);
}
return $editButtons.html();
}
});
if (settings.checkbox) settings.columns.unshift({ checkbox: true });
return this.smartTable(settings);
},
smartTable: function (options) {
var settings = $.extend({
toolbar: '#toolbar', //工具按钮用哪个容器
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sortOrder: "asc", //排序方式
sidePagination: "server", //分页方式client客户端分页server服务端分页*
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 20, //每页的记录行数(*
pageList: [20, 40, 80, 120], //可供选择的每页的行数(*
showExport: true,
exportTypes: ['csv', 'txt', 'excel'],
advancedSearchModal: '#dialogAdvancedSearch',
minHeight: 400,
height: undefined,
calcHeight: undefined,
search: true,
tableContainer: '.main-content',
searchOnEnterKey: false,
searchTimeOut: 0,
showSearchClearButton: true,
showAdvancedSearchButton: true,
showButtonText: true,
showSearchButton: true, //是否显示搜索按钮
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: $(window).width() < 768, //是否显示详细视图
queryButton: '#btn_query',
onLoadSuccess: function (data) {
// 设置 数据库 滚动条
if (settings.height !== undefined) {
$('.bootstrap-table .fixed-table-body').overlayScrollbars({
className: 'os-theme-dark',
scrollbars: {
autoHide: 'leave',
autoHideDelay: 100
}
});
}
$.footer();
if (data.IsSuccess === false) {
toastr.error(data.HttpResult.Message, data.HttpResult.Name);
}
},
onToggle: function () {
$.footer();
}
}, options);
settings.url = $.formatUrl(settings.url);
$.each(settings.columns, function (index, value) {
if (value.checkbox) return;
if (!$.isFunction(value.formatter)) {
value.formatter = function (value, row, index, field) {
return $.safeHtml(value);
}
}
else {
var formatter = value.formatter;
value.formatter = function (value, row, index, field) {
return formatter.call(this, $.safeHtml(value), row, index, field);
}
}
});
if (settings.search) {
// 自动收集 SearchText
var queryParams = settings.queryParams || function (params) { };
settings.queryParams = function (params) {
return $.extend({}, queryParams(params), { search: $('.bootstrap-table .fixed-table-toolbar .search-input').val() });
}
// 支持键盘回车搜索
$(document).on('keyup', '.bootstrap-table .fixed-table-toolbar .search-input', this, function (event) {
if (event.keyCode === 13) {
// ENTER
var $buttons = $(this).next();
var $search = $buttons.find('[name="search"]');
if ($search.length === 1) {
$search.trigger('click');
}
else {
// 无搜索按钮是使用 refresh 方法
event.data.bootstrapTable('refresh');
}
}
else if (event.keyCode === 27) {
// ESC
event.data.bootstrapTable('resetSearch');
}
});
}
// 判断是否固定表头 小屏幕禁止固定表头功能
var fixHeader = this.attr('data-header') === 'fixed' && $(window).width() >= 768;
var $tabContainer = $(settings.tableContainer);
if (fixHeader && settings.height === undefined) {
var calcPrevHeight = function (element) {
var height = 0;
while (element.length === 1) {
if (element.is(":visible")) height += element.outerHeight(true);
element = element.prev();
}
return height;
}
var calcParentHeight = function (element) {
var height = 0;
while (element.length === 1) {
// 跳过 tableContainer
if (['SELECTION', 'BODY', settings.tableContainer].filter(function (v) {
return v === element.attr('nodeName') || element.hasClass(v) || element.attr('id');
}).length > 0) {
break;
}
height += calcPrevHeight(element.prev());
element = element.parent();
}
return height;
}
if (settings.calcHeight === undefined) {
settings.calcHeight = function (element) {
var marginHeight = 0;
if ($tabContainer.length === 1) {
marginHeight = ($tabContainer.outerHeight() - $tabContainer.height()) * 2;
// 计算 table 控件前元素高度
var $prev = element.prev();
marginHeight += calcPrevHeight($prev);
marginHeight += calcParentHeight(element.parent());
}
return Math.max(settings.minHeight, $(window).height() - $('header').outerHeight(true) - $('footer').outerHeight(true) - marginHeight - 20 - 10);
};
}
// 设置最小高度为
settings.height = settings.calcHeight(this);
// 设置 onresize 事件
$(window).on('resize', this, function (event) {
event.data.bootstrapTable('resetView', { height: settings.calcHeight(event.data.parents('.bootstrap-table')) });
});
}
// 加载数据
this.bootstrapTable(settings);
// 如果固定表头 禁止容器滚动条出现
if (fixHeader && $tabContainer.length > 0) {
$tabContainer.addClass('overflow-hidden');
}
// 格式化工具栏
$('.bootstrap-table .fixed-table-toolbar .columns .export .dropdown-menu').addClass("dropdown-menu-right");
var $gear = $(settings.toolbar).removeClass('d-none').find('.gear');
if ($gear.find('.dropdown-menu > a').length === 0) $gear.addClass('d-none');
$gear.on('click', 'a', function (e) {
e.preventDefault();
$('#' + $(this).attr('id').replace('tb_', 'btn_')).trigger("click");
});
if (settings.queryButton) {
$(settings.queryButton).on('click', this, function (e) {
// fix bug: 翻页后再更改查询条件导致页码未更改数据为空
// 更改页码为 1 即可
// https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues/I1A739
var options = e.data.data('bootstrap.table').options;
options.pageNumber = 1;
e.data.bootstrapTable('refresh');
});
}
// 增加 Tooltip
if (settings.search) {
$('.bootstrap-table .fixed-table-toolbar .search-input').tooltip({
sanitize: false,
title: '<div class="search-input-tooltip">输入任意字符串全局搜索 </br> <kbd>Enter</kbd> 搜索 <kbd>ESC</kbd> 清除搜索</div>',
html: true
});
// 生成高级查询按钮
if (settings.showAdvancedSearchButton) {
// template
var $advancedSearchButtonHtml = $('<button class="btn btn-secondary" type="button" name="advancedSearch" title="高级搜索"><i class="fa fa-search-plus"></i><span>高级搜索</span></button>');
$advancedSearchButtonHtml.insertAfter($('.bootstrap-table .fixed-table-toolbar .search [name="clearSearch"]')).on('click', function () {
// 弹出高级查询对话框
$(settings.advancedSearchModal).modal('show');
});
// 高级搜索有值时颜色为红色
$(settings.advancedSearchModal).on('hide.bs.modal', function () {
var $modal = $(this)
var hasValue = false;
$modal.find('[data-default-val]').each(function (index, element) {
var $ele = $(element);
var val = $ele.attr('data-default-val');
if ($ele.prop('nodeName') === 'INPUT') {
if ($ele.hasClass('form-select-input')) {
hasValue = $ele.prev().val() !== val;
}
else {
hasValue = $ele.val() !== val;
}
}
if (hasValue) return false;
});
if (hasValue) $advancedSearchButtonHtml.removeClass('btn-secondary').addClass('btn-primary');
else $advancedSearchButtonHtml.removeClass('btn-primary').addClass('btn-secondary');
});
}
}
// fix bug 移除 Toolbar 按钮 Title 中的 Html
$('.bootstrap-table .fixed-table-toolbar button[title]').each(function (index, element) {
element.title = element.title.replace('<span>', '').replace('</span>', '');
});
return this;
},
lgbPopover: function (options) {
this.each(function (index, ele) {
var $ele = $(ele);
var data = $ele.data($.fn.popover.Constructor.DATA_KEY);
if (data) {
$.extend(data.config, options);
}
else {
$ele.popover(options);
}
});
return this;
},
lgbTooltip: function (options) {
this.each(function (index, ele) {
var $ele = $(ele);
var data = $ele.data($.fn.tooltip.Constructor.DATA_KEY);
if (data) {
$.extend(data.config, options);
}
else {
$ele.tooltip(options);
}
});
return this;
},
lgbDatePicker: function (options) {
if (!$.isFunction(this.datetimepicker)) return this;
var option = $.extend({
language: 'zh-CN',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0,
format: 'yyyy-mm-dd',
pickerPosition: 'bottom-left',
fontAwesome: true
}, options);
this.datetimepicker(option);
return this;
},
getTextByValue: function (value) {
// 通过value获取select控件的text属性
var text = "";
if (typeof value !== "string") value = value.toString();
if (this.attr('data-toggle') === 'lgbSelect') {
if (value === this.val()) text = this.attr('data-text');
else {
var data = [];
this.lgbSelect('get', function (source) { data = source; });
var find = data.filter(function (item, index) { return item.value === value; });
if (find.length === 1) text = find[0].text;
}
}
else {
text = this.children().filter(function () { return $(this).val() === value; }).text();
if (text === "") text = value;
}
return text;
},
lgbInfo: function (option) {
this.each(function () {
var $element = $(this);
$element.append($('<a href="#" tabindex="-1" role="button" data-toggle="popover"><i class="fa fa-question-circle"></i></a>'));
});
var container = this.attr('data-container') || 'body';
this.find('[data-toggle="popover"]').on('click', function (event) { event.preventDefault(); }).popover($.extend({
title: function () {
return $(this).parent().text();
},
content: function () {
return $(this).parent().attr('data-content');
},
trigger: 'focus',
html: false,
sanitize: true,
container: container,
placement: function () {
return $(this.element).parent().attr('data-placement') || 'auto';
}
}, option));
return this;
},
notifi: function (options) {
var op = $.extend({ url: '', method: 'rev', invoke: false, callback: false }, options);
var connection = new signalR.HubConnectionBuilder().withUrl($.formatUrl(op.url)).build();
var that = this;
connection.on(op.method, function () {
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
});
connection.start().catch(function (err) {
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
return console.error(err.toString());
}).then(function () {
// 连接成功
// invoke 为 调用服务端方法
// invoke: function (connection) { return connection.invoke('RetrieveDashboard'); }
if (!op.invoke) return;
var executor = op.invoke(connection);
if (typeof executor === "object" && $.isFunction(executor.then)) executor.then(function (result) { console.log(result); }).catch(function (err) { console.error(err.toString()); });
});
this.hub = connection;
return this;
}
});
//extend dropdown method
if ($.fn.dropdown) {
$.extend($.fn.dropdown.Constructor.prototype, {
val: function () {
var $element = $(this._element);
var $op = $(this._menu).find('[data-val="' + $element.val() + '"]:first');
$element.text($op.text());
},
select: function () {
var $element = $(this._element);
$(this._menu).on('click', 'a', function (event) {
event.preventDefault();
var $op = $(this);
$element.text($op.text()).val($op.attr('data-val'));
});
}
});
}
$(function () {
// fix bug bootstrap-table 1.14.2 showToggle
if ($.fn.bootstrapTable) {
$.extend($.fn.bootstrapTable.defaults.icons, {
refresh: 'fa-refresh'
});
// fix bug bootstrap-table showButtonText support mobile
// argo at 2020-01-18
$.extend($.fn.bootstrapTable.defaults, {
formatClearSearch: function formatClearSearch() {
return '<span>清空过滤</span>';
},
formatSearch: function formatSearch() {
return '搜索';
},
formatNoMatches: function formatNoMatches() {
return '<span>没有找到匹配的记录</span>';
},
formatPaginationSwitch: function formatPaginationSwitch() {
return '<span>隐藏/显示分页</span>';
},
formatPaginationSwitchDown: function formatPaginationSwitchDown() {
return '<span>显示分页</span>';
},
formatPaginationSwitchUp: function formatPaginationSwitchUp() {
return '<span>隐藏分页</span>';
},
formatRefresh: function formatRefresh() {
return '<span>刷新</span>';
},
formatToggle: function formatToggle() {
return '<span>切换</span>';
},
formatToggleOn: function formatToggleOn() {
return '<span>显示卡片视图</span>';
},
formatToggleOff: function formatToggleOff() {
return '<span>隐藏卡片视图</span>';
},
formatColumns: function formatColumns() {
return '<span>列</span>';
},
formatColumnsToggleAll: function formatColumnsToggleAll() {
return '<span>切换所有</span>';
},
formatFullscreen: function formatFullscreen() {
return '<span>全屏</span>';
},
formatAllRows: function formatAllRows() {
return '<span>所有</span>';
},
formatAutoRefresh: function formatAutoRefresh() {
return '<span>自动刷新</span>';
},
formatExport: function formatExport() {
return '<span>导出数据</span>';
},
formatJumpTo: function formatJumpTo() {
return '<span>跳转</span>';
},
formatAdvancedSearch: function formatAdvancedSearch() {
return '<span>高级搜索</span>';
},
formatAdvancedCloseButton: function formatAdvancedCloseButton() {
return '<span>关闭</span>';
}
});
}
// extend bootstrap-toggle
if ($.fn.bootstrapToggle) {
var toggle = $.fn.bootstrapToggle.Constructor;
var oldFunc = toggle.prototype.render;
toggle.prototype.render = function () {
var defaultVal = this.$element.attr('data-default-val') || '';
if (defaultVal === "True") this.$element.prop('checked', true);
oldFunc.call(this);
this.$toggle.on('touchend', function (e) {
$(this).trigger('click.bs.toggle');
e.preventDefault();
});
};
}
if (window.NProgress) {
$(document).ajaxStart(function () {
return NProgress.start();
});
$(document).ajaxComplete(function (e) {
return NProgress.done();
});
}
if (window.toastr) toastr.options = {
"closeButton": true,
"debug": false,
"progressBar": true,
"positionClass": "toast-bottom-right",
"onclick": null,
"showDuration": "600",
"hideDuration": "2000",
"timeOut": "4000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
$('body > section .collapse').on('shown.bs.collapse', function () {
$.footer().removeClass('d-none');
}).on('body > section hidden.bs.collapse', function () {
$.footer().removeClass('d-none');
}).on('body > section hide.bs.collapse', function () {
$('footer').addClass('d-none');
}).on('body > section show.bs.collapse', function () {
$('footer').addClass('d-none');
});
$(window).on('resize', function () {
$.footer();
});
$("#gotoTop").on('click', function (e) {
e.preventDefault();
$('html, body, body > section:first').animate({
scrollTop: 0
}, 200);
});
$('[data-toggle="dropdown"].dropdown-select').dropdown('select');
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
$('[data-toggle="lgbinfo"]').lgbInfo();
$('.date').lgbDatePicker().on('show hide', function (e) {
e.stopPropagation();
});
});
})(jQuery);

@ -1,293 +0,0 @@
(function ($) {
var findIdField = function (tableName) {
var idField = tableName.bootstrapTable("getOptions").idField;
if (idField === undefined) idField = "Id";
return idField;
};
var swalDeleteOptions = {
title: "删除数据",
html: '您确定要删除选中的所有数据吗',
type: "warning",
showCancelButton: true,
confirmButtonColor: '#dc3545',
cancelButtonColor: '#6c757d',
confirmButtonText: "我要删除",
cancelButtonText: "取消"
};
DataEntity = function (options) {
this.options = options;
};
DataEntity.prototype = {
load: function (value) {
for (name in this.options) {
var ctl = $(this.options[name]);
if (ctl.attr('data-toggle') === "dropdown") {
ctl.val(value[name]).dropdown('val');
}
else if (ctl.attr('data-toggle') === 'toggle') {
ctl.bootstrapToggle(value[name] ? 'on' : 'off');
}
else if (ctl.attr('data-toggle') === 'lgbSelect') {
ctl.lgbSelect('val', value[name]);
}
else {
ctl.val(value[name]);
}
}
},
reset: function () {
for (name in this.options) {
var ctl = $(this.options[name]);
var dv = ctl.attr("data-default-val");
if (dv === undefined) dv = "";
if (ctl.attr('data-toggle') === "dropdown") {
ctl.val(dv).dropdown('val');
}
else if (ctl.attr('data-toggle') === 'toggle') {
ctl.bootstrapToggle(dv === "true" ? 'on' : 'off');
}
else if (ctl.attr('data-toggle') === 'lgbSelect') {
ctl.lgbSelect('val', dv);
}
else {
ctl.val(dv);
}
}
},
get: function () {
var target = {};
for (name in this.options) {
var ctl = $(this.options[name]);
var dv = ctl.attr('data-default-val');
if (ctl.attr('data-toggle') === 'toggle') {
target[name] = ctl.prop('checked');
continue;
}
else if (dv !== undefined && ctl.val() === "") target[name] = dv;
else target[name] = ctl.val();
// check boolean value
if (ctl.attr('data-bool') === 'true') {
if (target[name] === "true" || target[name] === "True") target[name] = true;
if (target[name] === "false" || target[name] === "False") target[name] = false;
}
}
return target;
}
};
DataTable = function (options) {
var that = this;
this.options = $.extend(true, { delTitle: "删除数据", saveTitle: "保存数据" }, DataTable.settings, options);
this.dataEntity = new DataEntity(options.map);
// handler click event
for (var name in this.options.click) {
$(name).on('click', { handler: this.options.click[name] }, function (e) {
e.preventDefault();
e.data.handler.call(that, this);
});
}
// handler extra click event
for (var cId in this.options.events) {
$(cId).on('click', { handler: this.options.events[cId] }, function (e) {
var options = that.options;
var row = {};
if (options.bootstrapTable !== null) {
var arrselections = options.bootstrapTable.bootstrapTable('getSelections');
if (arrselections.length === 0) {
lgbSwal({ title: '请选择要编辑的数据', type: "warning" });
return;
}
else if (arrselections.length > 1) {
lgbSwal({ title: '请选择一个要编辑的数据', type: "warning" });
return;
}
else {
row = arrselections[0];
}
}
e.data.handler.call(this, row);
});
}
};
DataTable.settings = {
url: undefined,
bootstrapTable: null,
treegridParentId: 'ParentId',
modal: '#dialogNew',
click: {
'#btn_query': function (element) {
if (this.options.bootstrapTable !== null) {
var options = this.options.bootstrapTable.bootstrapTable('getOptions');
if (options.advancedSearchModal) {
$(options.advancedSearchModal).modal('hide');
}
// fix bug: 翻页后再更改查询条件导致页码未更改数据为空
// 更改页码为 1 即可
// https://gitee.com/LongbowEnterprise/BootstrapAdmin/issues/I1A739
var options = this.options.bootstrapTable.data('bootstrap.table').options;
options.pageNumber = 1;
this.options.bootstrapTable.bootstrapTable('refresh');
}
handlerCallback.call(this, null, element, { oper: 'query' });
},
'#btn_reset': function () {
if (this.options.bootstrapTable !== null) {
var options = this.options.bootstrapTable.bootstrapTable('getOptions');
if (options.advancedSearchModal) {
$(options.advancedSearchModal).find('[data-default-val]').each(function (index, element) {
var $ele = $(element);
var val = $ele.attr('data-default-val');
if ($ele.prop('nodeName') === 'INPUT') {
if ($ele.hasClass('form-select-input')) {
$ele.prev().lgbSelect('val', val);
}
else {
$ele.val(val);
}
}
});
}
}
},
'#btn_add': function (element) {
this.dataEntity.reset();
if (this.options.modal.constructor === String) $(this.options.modal).modal("show");
if (this.options.bootstrapTable !== null) this.options.bootstrapTable.bootstrapTable('uncheckAll');
handlerCallback.call(this, null, element, { oper: 'create' });
},
'#btn_edit': function (element) {
var options = this.options;
var data = {};
if (options.bootstrapTable !== null) {
var arrselections = options.bootstrapTable.bootstrapTable('getSelections');
if (arrselections.length === 0) {
lgbSwal({ title: '请选择要编辑的数据', type: "warning" });
return;
}
else if (arrselections.length > 1) {
lgbSwal({ title: '请选择一个要编辑的数据', type: "warning" });
return;
}
else {
data = arrselections[0];
this.dataEntity.load(data);
if (options.modal.constructor === String) $(options.modal).modal("show");
}
}
handlerCallback.call(this, null, element, { oper: 'edit', data: data });
},
'#btn_delete': function (element) {
var that = this;
var options = this.options;
if (options.bootstrapTable !== null) {
var arrselections = options.bootstrapTable.bootstrapTable('getSelections');
if (arrselections.length === 0) {
lgbSwal({ title: '请选择要删除的数据', type: "warning" });
return;
}
else {
swal($.extend({}, swalDeleteOptions)).then(function (result) {
if (result.value) {
var idField = findIdField(options.bootstrapTable);
var iDs = arrselections.map(function (element, index) { return element[idField]; });
$.bc({
url: options.url, data: iDs, method: 'delete', title: options.delTitle, logData: arrselections,
callback: function (result) {
if (result) options.bootstrapTable.bootstrapTable('refresh');
handlerCallback.call(that, null, element, { oper: 'del', success: result, data: arrselections });
}
});
}
});
}
}
},
'#btnSubmit': function (element) {
var that = this;
var options = $.extend(true, {}, this.options, { data: this.dataEntity.get() });
$.bc({
url: options.url, data: options.data, title: options.saveTitle, modal: options.modal, method: "post",
callback: function (result) {
if (result) {
options.bootstrapTable.bootstrapTable('refresh');
handlerCallback.call(that, null, element, { oper: 'save', success: result, data: [options.data] });
}
}
});
}
}
};
DataTable.prototype = {
constructor: DataTable,
idEvents: function () {
var op = {
dataEntity: this.dataEntity,
table: this.options.bootstrapTable,
treegridParentId: this.options.treegridParentId,
modal: this.options.modal,
src: this,
url: this.options.url
};
return {
'click .edit': function (e, value, row, index) {
op.dataEntity.load(row);
op.table.bootstrapTable('uncheckAll');
op.table.bootstrapTable('check', index);
handlerCallback.call(op.src, null, e, { oper: 'edit', data: row });
$(op.modal).modal("show");
},
'click .del': function (e, value, row, index) {
var displayName = "本项目";
if (row.Name) displayName = " <span class='text-danger font-weight-bold'>" + row.Name + "</span> ";
var text = "您确定要删除" + displayName + "吗?";
var data = $.extend({}, row);
data = [data];
// 判断是否为父项菜单
var idField = findIdField(op.table);
var idValue = row[idField];
if (idValue != undefined) {
var nodes = op.table.bootstrapTable('getData').filter(function (row, index, data) {
return idValue == row[op.treegridParentId];
});
if ($.isArray(nodes) && nodes.length > 0) {
$.each(nodes, function (index, element) {
data.push($.extend({}, element));
});
text = "本删除项含有级联子项目</br>您确定要删除 <span class='text-danger font-weight-bold'>" + row.Name + "</span> 以及子项目吗?";
}
}
swal($.extend({}, swalDeleteOptions, { html: text })).then(function (result) {
if (result.value) {
var idField = findIdField(op.table);
var iDs = data.map(function (element, index) {
return element[idField];
});
$.bc({
url: op.url, data: iDs, method: 'delete', title: '删除数据', logData: data,
callback: function (result) {
if (result) op.table.bootstrapTable('refresh');
handlerCallback.call(op.src, null, e, { oper: 'del', success: result, data: data });
}
});
}
});
}
};
}
};
function handlerCallback(callback, element, data) {
if ($.isFunction(callback)) callback.call(e, data);
if ($.isFunction(this.options.callback)) this.options.callback.call(element, data);
}
}(jQuery));

@ -1,341 +0,0 @@
(function ($) {
'use strict';
var Validate = function (element, options) {
var that = this;
this.$element = $(element);
this.options = $.extend({
pendingRequest: 0,
pending: {},
successList: [],
optional: function () { return false; },
invalid: {},
getLength: function (value, element) {
switch (element.nodeName.toLowerCase()) {
case "select":
return $("option:selected", element).length;
case "input":
if (this.checkable(element)) {
return $(element).filter(":checked").length;
}
}
return value.length;
},
checkable: function (element) {
return (/radio|checkbox/i).test(element.type);
},
depend: function (param, element) {
return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
},
dependTypes: {
"boolean": function (param) {
return param;
},
"string": function (param, element) {
return !!$(param, element.form).length;
},
"function": function (param, element) {
return param(element);
}
},
previousValue: function (element, method) {
method = typeof method === "string" && method || "remote";
return $.data(element, "previousValue") || $.data(element, "previousValue", {
old: null,
valid: true,
message: "请修正本字段"
});
},
startRequest: function (element) {
if (!this.pending[element.name]) {
this.pendingRequest++;
$(element).addClass(this.settings.pendingClass);
this.pending[element.name] = true;
}
},
stopRequest: function (element, valid) {
this.pendingRequest--;
// Sometimes synchronization fails, make sure pendingRequest is never < 0
if (this.pendingRequest < 0) {
this.pendingRequest = 0;
}
delete this.pending[element.name];
$(element).removeClass(this.settings.pendingClass);
},
showErrors: function (errors) {
for (var name in errors) {
var element = document.getElementById(name);
var $element = $(element);
that.tooltip.call(that, element, false);
$element.attr('data-original-title', errors[name]).tooltip('show');
}
},
defaultMessage: function (element, rule) {
return that.defaultMessage(element, rule);
},
resetInternals: function () { },
errorsFor: function (element) {
that.tooltip.call(that, element, true);
},
settings: $.validator.defaults
}, this.defaults(), options);
// fix bug Edge
this.$element.find('select' + this.options.childClass).on('input', function (e) {
e.stopPropagation();
}).on('change', function () {
$(this).trigger('input.lgb.validate');
});
this.$element.on('input.lgb.validate', this.options.childClass, function () {
if (!that.validElement(this)) $(this).tooltip('show');
}).on('inserted.bs.tooltip', this.options.childClass, function () {
$('#' + $(this).attr('aria-describedby')).addClass(that.options.errorClass);
});
if (!this.options.validButtons) return;
this.$element.find(this.options.validButtons).on('click.lgb.validate', function (e) {
var valid = that.valid();
$(this).attr(Validate.DEFAULTS.validResult, valid);
if (!valid) {
e.preventDefault();
e.stopImmediatePropagation();
}
});
if (this.options.modal) {
// 关闭 modal 时移除所有验证信息
$(this.options.modal).on('show.bs.modal', function (e) {
that.reset();
});
// bs bug 弹窗内控件值更改后再次点击关闭按钮是 hide.bs.modal 事件不被触发
// 兼容 键盘事件 ESC
var dismissTooltip = function (e) {
// 移除残留 tooltip
var $modal = $(that.options.modal)
$modal.find('[aria-describedby]').each(function (index, ele) {
var tooltipId = $(ele).attr('aria-describedby');
var $tooltip = $('#' + tooltipId);
if ($tooltip.length === 1) {
$tooltip.tooltip('dispose');
}
});
};
$(this.options.modal).on('click', '[data-dismiss="modal"]', dismissTooltip);
$(this.options.modal).on('keydown', function (event) {
// ESC
if (event.which === 27) {
event.preventDefault();
dismissTooltip(event);
}
});
}
};
Validate.VERSION = '2.0';
Validate.DEFAULTS = {
validClass: 'is-valid',
errorClass: 'is-invalid',
ignoreClass: '.ignore',
childClass: '[data-valid="true"]',
validResult: 'data-valid-result'
};
Validate.prototype.defaults = function () {
return $.extend(Validate.DEFAULTS, {
validButtons: this.$element.attr('data-valid-button'),
modal: this.$element.attr('data-valid-modal')
});
};
Validate.prototype.reset = function () {
var css = this.options.validClass + ' ' + this.options.errorClass;
this.$element.find(this.options.childClass).each(function () {
var $this = $(this);
$this.tooltip('dispose');
$this.removeClass(css);
});
};
Validate.prototype.valid = function () {
var that = this;
var op = this.options;
var $firstElement = null;
this.$element.find(op.childClass + ':visible').not(op.ignoreClass).each(function () {
if (!that.validElement(this) && $firstElement === null) $firstElement = $(this);
});
if ($firstElement) $firstElement.tooltip('show');
return $firstElement === null;
};
Validate.prototype.validElement = function (element) {
var result = this.check(element);
this.tooltip(element, result);
return result;
};
Validate.prototype.tooltip = function (element, valid) {
if (valid === "pending") return;
var op = this.options;
var $this = $(element);
if (valid) $this.tooltip('dispose');
else {
if (!$this.hasClass(op.errorClass)) $this.tooltip();
}
if (!valid) {
$this.removeClass(op.validClass).addClass(op.errorClass);
}
else {
$this.removeClass(op.errorClass).addClass(op.validClass);
}
};
Validate.prototype.check = function (element) {
var result = true;
var $this = $(element);
if ($this.is(':hidden')) return result;
var methods = this.rules(element);
var proxy = function (rule) {
if ($.isFunction($.validator.methods[rule])) {
result = $.validator.methods[rule].call(this.options, $this.val(), element, methods[rule]);
if (!result) {
$this.attr('data-original-title', this.defaultMessage(element, { method: rule, parameters: methods[rule] }));
return result;
}
// checkGroup rule
if (rule === 'checkGroup') {
var $checkers = this.$element.find(this.options.childClass).filter(function () {
var $this = $(this);
return $this.hasClass(rule) || $this.attr(rule);
});
$checkers.removeClass(this.options.errorClass).removeClass(this.options.validClass);
if (result) $checkers.tooltip('dispose');
else $checkers.addClass(this.options.errorClass).tooltip();
}
}
else {
console.log('没有匹配的方法 ' + rule);
}
return true;
}
var remote = null;
for (var rule in methods) {
if (rule !== 'remote') {
result = proxy.call(this, rule);
if (!result) return false;
}
else remote = rule;
}
if (remote !== null) result = proxy.call(this, remote);
return result;
};
Validate.prototype.defaultMessage = function (element, rule) {
var message = $(element).attr('data-' + rule.method + '-msg') || rule.method === 'required' && $(element).attr('placeholder') || $.validator.messages[rule.method];
var theregex = /\$?\{(\d+)\}/g;
if (typeof message === "function") {
message = message.call(this, rule.parameters, element);
} else if (theregex.test(message)) {
message = $.validator.format(message.replace(theregex, "{$1}"), rule.parameters);
}
return message;
};
Validate.prototype.attributeRules = function (element, rules) {
var $element = $(element), value;
$.each(["remote"], function () {
var para = $element.attr(this);
if (para) {
if (element.name === "") element.name = element.id;
rules[this] = $.formatUrl(para);
}
});
$.each(["radioGroup", "checkGroup"], function () {
if (rules[this]) {
delete rules.required;
return false;
}
});
return rules;
};
Validate.prototype.rules = function (element) {
var $this = $(element);
var rules = $this.data('lgb.Validate.Rules');
if (!rules) $this.data('lgb.Validate.Rules', rules = this.attributeRules(element, $.validator.normalizeRules($.extend(
{ required: true },
$.validator.classRules(element),
$.validator.attributeRules(element)
))));
return rules;
};
function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data('lgb.Validate');
var options = typeof option === 'object' && option;
if (!data && /valid|defaults/.test(option)) return;
if (!data) $this.data('lgb.Validate', data = new Validate(this, options));
if (typeof option === 'string') data[option]();
});
}
$.fn.lgbValidate = Plugin;
$.fn.lgbValidate.Constructor = Validate;
$.fn.lgbValidator = function () {
return this.data('lgb.Validate');
};
$.fn.lgbValid = function () {
var $this = this;
return $this.attr(Validate.DEFAULTS.validResult) === 'true';
};
$(function () {
if ($.isFunction($.validator)) {
$.validator.addMethod("equalTo", function (value, element, param) {
var target = $(param);
if (this.settings.onfocusout && target.not(".validate-equalTo-blur").length) {
target.addClass("validate-equalTo-blur").on("blur.validate-equalTo", function () {
var validator = $(element).parents('[data-toggle="LgbValidate"]').data('lgb.Validate');
validator.validElement(element);
});
}
return value === target.val();
});
$.validator.addMethod("ip", function (value, element) {
return this.optional(element) || /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value);
}, "请填写正确的IP地址");
$.validator.addMethod("radioGroup", function (value, element) {
return $(element).find(':checked').length === 1;
}, "请选择一个选项");
$.validator.addMethod("checkGroup", function (value, element) {
return $(element).parents('[data-toggle="LgbValidate"]').find(':checked').length >= 1;
}, "请选择一个选项");
$.validator.addMethod("userName", function (value, element) {
return this.optional(element) || /^[a-zA-Z0-9_@.]*$/.test(value);
}, "登录名称不可以包含非法字符");
$.validator.addMethod("greaterThan", function (value, element, target) {
return this.optional(element) || $(target).val() <= value;
}, "");
$.validator.addMethod("lessThan", function (value, element, target) {
return this.optional(element) || $(target).val() >= value;
}, "");
}
$('[data-toggle="LgbValidate"]').lgbValidate();
});
})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -1,36 +0,0 @@
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
define( ["jquery", "../jquery.validate"], factory );
} else if (typeof module === "object" && module.exports) {
module.exports = factory( require( "jquery" ) );
} else {
factory( jQuery );
}
}(function( $ ) {
/*
* Translated default messages for the jQuery validation plugin.
* Locale: ZH (Chinese, 中文 (Zhōngwén), 汉语, 漢語)
*/
$.extend( $.validator.messages, {
required: "这是必填字段",
remote: "请修正此字段",
email: "请输入有效的电子邮件地址",
url: "请输入有效的网址",
date: "请输入有效的日期",
dateISO: "请输入有效的日期 (YYYY-MM-DD)",
number: "请输入有效的数字",
digits: "只能输入数字",
creditcard: "请输入有效的信用卡号码",
equalTo: "你的输入不相同",
extension: "请输入有效的后缀",
maxlength: $.validator.format( "最多可以输入 {0} 个字符" ),
minlength: $.validator.format( "最少要输入 {0} 个字符" ),
rangelength: $.validator.format( "请输入长度在 {0} 到 {1} 之间的字符串" ),
range: $.validator.format( "请输入范围在 {0} 到 {1} 之间的数值" ),
step: $.validator.format( "请输入 {0} 的整数倍值" ),
max: $.validator.format( "请输入不大于 {0} 的数值" ),
min: $.validator.format( "请输入不小于 {0} 的数值" )
} );
return $;
}));

@ -1,4 +0,0 @@
/*! jQuery Validation Plugin - v1.18.0 - 9/9/2018
* https://jqueryvalidation.org/
* Copyright (c) 2018 Jörn Zaefferer; Licensed MIT */
!function(a){"function"==typeof define&&define.amd?define(["jquery","../jquery.validate.min"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return a.extend(a.validator.messages,{required:"这是必填字段",remote:"请修正此字段",email:"请输入有效的电子邮件地址",url:"请输入有效的网址",date:"请输入有效的日期",dateISO:"请输入有效的日期 (YYYY-MM-DD)",number:"请输入有效的数字",digits:"只能输入数字",creditcard:"请输入有效的信用卡号码",equalTo:"你的输入不相同",extension:"请输入有效的后缀",maxlength:a.validator.format("最多可以输入 {0} 个字符"),minlength:a.validator.format("最少要输入 {0} 个字符"),rangelength:a.validator.format("请输入长度在 {0} 到 {1} 之间的字符串"),range:a.validator.format("请输入范围在 {0} 到 {1} 之间的数值"),step:a.validator.format("请输入 {0} 的整数倍值"),max:a.validator.format("请输入不大于 {0} 的数值"),min:a.validator.format("请输入不小于 {0} 的数值")}),a});
Loading…
Cancel
Save