feat: 增加健康检查 html 版本
This commit is contained in:
parent
441cdfb336
commit
0bf9f2a4b5
|
@ -0,0 +1,89 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="apple-touch-icon" href="../favicon.png" />
|
||||
<title>健康检查</title>
|
||||
<link href="../libs/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
|
||||
<link href="../_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css" rel="stylesheet">
|
||||
<link href="../libs/bootstrap-table/bootstrap-table.css" rel="stylesheet" />
|
||||
<link href="../css/site.css" rel="stylesheet" />
|
||||
<link href="../css/motronic.css" rel="stylesheet" />
|
||||
<style>
|
||||
@media (min-width: 768px) {
|
||||
|
||||
.card-body .bootstrap-table tr td:nth-child(5),
|
||||
.card-body .bootstrap-table tr th:nth-child(5),
|
||||
.card-body .bootstrap-table tr td:last-child,
|
||||
.card-body .bootstrap-table tr th:last-child {
|
||||
width: 78px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-body .bootstrap-table tr td:first-child {
|
||||
word-break: keep-all;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td:not(:nth-child(3)) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<!--[if lt IE 10 ]>
|
||||
<link href="../css/IE8.css" rel="stylesheet" />
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--[if lt IE 10 ]>
|
||||
<div id="ieAlert" class="alert alert-danger alert-dismissible">
|
||||
<div>当前浏览器版本太低,不支持本系统,请升级到至少IE10 <a href="../browser/IE10.exe" target="_blank">本地下载</a> <a href="https://support.microsoft.com/zh-cn/help/17621/internet-explorer-downloads" target="_blank">微软下载</a>,或者使用Chrome浏览器 <a href="../browser/ChromeSetup.exe" target="_blank">本地下载</a></div>
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
|
||||
</div>
|
||||
<![endif]-->
|
||||
<div class="container-fluid">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
健康检查结果
|
||||
</div>
|
||||
<div class="card-body nobar">
|
||||
<p>耗时:<span id="checkTotalEplsed">--</span></p>
|
||||
<table id="tbCheck"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a id="pathBase" href="../" hidden></a>
|
||||
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="myModalLabel">健康检查明细窗口</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body nobar">
|
||||
<table id="checkDetail"></table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i>
|
||||
<span>关闭</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
|
||||
<script src="../_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
|
||||
<script src="../libs/bootstrap-table/bootstrap-table.js"></script>
|
||||
<script src="../libs/longbow.common.js"></script>
|
||||
<script src="../libs/healths.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
296
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.css
vendored
Normal file
296
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.css
vendored
Normal file
|
@ -0,0 +1,296 @@
|
|||
@charset "UTF-8";
|
||||
/**
|
||||
* @author zhixin wen <wenzhixin2010@gmail.com>
|
||||
* version: 1.15.4
|
||||
* https://github.com/wenzhixin/bootstrap-table/
|
||||
*/
|
||||
.bootstrap-table .fixed-table-toolbar::after {
|
||||
content: "";
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .bs-bars,
|
||||
.bootstrap-table .fixed-table-toolbar .search,
|
||||
.bootstrap-table .fixed-table-toolbar .columns {
|
||||
position: relative;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns .btn-group > .btn-group {
|
||||
display: inline-block;
|
||||
margin-left: -1px !important;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns .btn-group > .btn-group > .btn {
|
||||
border-radius: 0;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns .btn-group > .btn-group:first-child > .btn {
|
||||
border-top-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns .btn-group > .btn-group:last-child > .btn {
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns .dropdown-menu {
|
||||
text-align: left;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
-ms-overflow-style: scrollbar;
|
||||
z-index: 1001;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
display: block;
|
||||
padding: 3px 20px;
|
||||
clear: both;
|
||||
font-weight: normal;
|
||||
line-height: 1.428571429;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns-left {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns-right {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .pull-right .dropdown-menu {
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container {
|
||||
position: relative;
|
||||
clear: both;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table {
|
||||
width: 100%;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table th,
|
||||
.bootstrap-table .fixed-table-container .table td {
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th {
|
||||
vertical-align: bottom;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th:focus {
|
||||
outline: 0 solid transparent;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th.detail {
|
||||
width: 30px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th .th-inner {
|
||||
padding: 0.75rem;
|
||||
vertical-align: bottom;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
cursor: pointer;
|
||||
background-position: right;
|
||||
background-repeat: no-repeat;
|
||||
padding-right: 30px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th .both {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC");
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th .asc {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table thead th .desc {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ");
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table tbody tr.selected td {
|
||||
background-color: rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table tbody tr.no-records-found {
|
||||
text-align: center;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table tbody tr .card-view {
|
||||
display: flex;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table tbody tr .card-view .card-view-title {
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
min-width: 30%;
|
||||
text-align: left !important;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table .bs-checkbox {
|
||||
text-align: center;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table .bs-checkbox label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table input[type=radio],
|
||||
.bootstrap-table .fixed-table-container .table input[type=checkbox] {
|
||||
margin: 0 auto !important;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .table.table-sm .th-inner {
|
||||
padding: 0.3rem;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container.fixed-height:not(.has-footer) {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container.fixed-height.has-card-view {
|
||||
border-top: 1px solid #dee2e6;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container.fixed-height .fixed-table-border {
|
||||
border-left: 1px solid #dee2e6;
|
||||
border-right: 1px solid #dee2e6;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container.fixed-height .table thead th {
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container.fixed-height .table-dark thead th {
|
||||
border-bottom: 1px solid #32383e;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-header {
|
||||
overflow: hidden;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body {
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading {
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
z-index: 1000;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap {
|
||||
align-items: baseline;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .loading-text {
|
||||
font-size: 2rem;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-wrap {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-dot,
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-wrap::after,
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-wrap::before {
|
||||
content: "";
|
||||
animation-duration: 1.5s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-name: LOADING;
|
||||
background: #212529;
|
||||
border-radius: 50%;
|
||||
display: block;
|
||||
height: 5px;
|
||||
margin: 0 4px;
|
||||
opacity: 0;
|
||||
width: 5px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-dot {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading .loading-wrap .animation-wrap::after {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading.table-dark {
|
||||
background: #212529;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading.table-dark .animation-dot,
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading.table-dark .animation-wrap::after,
|
||||
.bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading.table-dark .animation-wrap::before {
|
||||
background: #fff;
|
||||
}
|
||||
.bootstrap-table .fixed-table-container .fixed-table-footer {
|
||||
overflow: hidden;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination::after {
|
||||
content: "";
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination-detail,
|
||||
.bootstrap-table .fixed-table-pagination > .pagination {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination-detail .pagination-info {
|
||||
line-height: 34px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination-detail .page-list {
|
||||
display: inline-block;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination-detail .page-list .btn-group {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination-detail .page-list .btn-group .dropdown-menu {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination {
|
||||
margin: 0;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination a {
|
||||
padding: 6px 12px;
|
||||
line-height: 1.428571429;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination li.page-intermediate a {
|
||||
color: #c8c8c8;
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination li.page-intermediate a::before {
|
||||
content: "⬅";
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination li.page-intermediate a::after {
|
||||
content: "➡";
|
||||
}
|
||||
.bootstrap-table .fixed-table-pagination > .pagination ul.pagination li.disabled a {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
}
|
||||
.bootstrap-table.fullscreen {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 1050;
|
||||
width: 100% !important;
|
||||
background: #fff;
|
||||
height: calc(100vh);
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
/* calculate scrollbar width */
|
||||
div.fixed-table-scroll-inner {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
div.fixed-table-scroll-outer {
|
||||
top: 0;
|
||||
left: 0;
|
||||
visibility: hidden;
|
||||
width: 200px;
|
||||
height: 150px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@keyframes LOADING {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=bootstrap-table.css.map */
|
6924
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.js
vendored
Normal file
6924
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.min.css
vendored
Normal file
10
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
10
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.min.js
vendored
Normal file
10
src/blazor/admin/BootstrapAdmin.Web/wwwroot/libs/bootstrap-table/bootstrap-table.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,91 @@
|
|||
$(function () {
|
||||
$.extend({
|
||||
sendHealths: function (data) {
|
||||
$.bc({ url: 'api/Healths', data: JSON.stringify(data), method: 'post' });
|
||||
}
|
||||
});
|
||||
var healthStatus = ['<button class="btn btn-danger"><i class="fa fa-times-circle"></i><span>不健康</span></button>', '<button class="btn btn-warning"><i class="fa fa-exclamation-circle"></i><span>亚健康</span></button>', '<button class="btn btn-success"><i class="fa fa-check-circle"></i><span>健康</span></button>'];
|
||||
var StatusFormatter = function (value) {
|
||||
return healthStatus[value];
|
||||
};
|
||||
|
||||
var cate = { "db": "数据库", "file": "组件文件", "app-mem": "内存", "sys-mem": "系统", "Gitee": "Gitee 接口", "gc": "垃圾回收器", "dotnet-runtime": "运行时", "environment": "环境变量" };
|
||||
var CategoryFormatter = function (value) {
|
||||
return cate[value];
|
||||
};
|
||||
|
||||
var ExceptionFormatter = function (value) {
|
||||
return value ? JSON.stringify(value) : null;
|
||||
};
|
||||
|
||||
var $table = $('#tbCheck').smartTable({
|
||||
pagination: false,
|
||||
showToggle: false,
|
||||
showRefresh: false,
|
||||
showColumns: false,
|
||||
toolbar: false,
|
||||
search: false,
|
||||
columns: [
|
||||
{ title: "分类", field: "Name", formatter: CategoryFormatter },
|
||||
{ title: "描述", field: "Description" },
|
||||
{ title: "异常信息", field: "Exception", formatter: ExceptionFormatter },
|
||||
{ title: "耗时", field: "Duration" },
|
||||
{ title: "检查结果", field: "Status", formatter: StatusFormatter },
|
||||
{
|
||||
title: "明细数据", field: "Data", formatter: function (value, row, index) {
|
||||
return '<button class="detail btn btn-info"><i class="fa fa-info-circle"></i><span>明细</span></button>';
|
||||
},
|
||||
events: {
|
||||
'click .detail': function (e, value, row, index) {
|
||||
if ($.isEmptyObject(row.Data)) return;
|
||||
|
||||
var content = $.map(row.Data, function (v, name) {
|
||||
return { name: name, value: v };
|
||||
});
|
||||
// 弹出 modal 健康检查明细窗口
|
||||
$checkDetail.bootstrapTable('load', content);
|
||||
$('#dialogNew').modal('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$table.bootstrapTable('showLoading');
|
||||
$('#checkTotalEplsed').text('--');
|
||||
$.bc({
|
||||
url: 'healths',
|
||||
callback: function (result) {
|
||||
// async send result to cloud
|
||||
$.sendHealths(result);
|
||||
var data = $.map(result.Keys, function (name) {
|
||||
return { Name: name, Duration: result.Report.Entries[name].Duration, Status: result.Report.Entries[name].Status, Exception: result.Report.Entries[name].Exception, Description: result.Report.Entries[name].Description, Data: result.Report.Entries[name].Data };
|
||||
});
|
||||
$table.bootstrapTable('hideLoading');
|
||||
$table.bootstrapTable('load', data);
|
||||
$('#checkTotalEplsed').text(result.Report.TotalDuration);
|
||||
$.footer();
|
||||
}
|
||||
});
|
||||
|
||||
// init detail Table
|
||||
var $checkDetail = $('#checkDetail').smartTable({
|
||||
pagination: false,
|
||||
showToggle: false,
|
||||
showRefresh: false,
|
||||
showColumns: false,
|
||||
columns: [
|
||||
{ title: "检查项", field: "name" },
|
||||
{
|
||||
title: "值", field: "value", formatter: function (value, row) {
|
||||
if (row.name === "Exception") value = $.format("<span class='text-danger'>{0}</span>", value);
|
||||
if (row.name === "dotnet --info") {
|
||||
value = value.replace(/\r\n/g, "<br>");
|
||||
value = value.replace(/\n/g, "<br>");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
|
@ -0,0 +1,833 @@
|
|||
(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);
|
Loading…
Reference in New Issue