Merge branch 'dev-table'

# Conflicts:
#	src/admin/Bootstrap.Admin/wwwroot/css/site.css
This commit is contained in:
Argo Zhang 2020-01-18 17:48:19 +08:00
commit cae1be17c6
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
18 changed files with 124 additions and 34 deletions

View File

@ -270,6 +270,12 @@
"Code": "1",
"Define": NumberInt(0)
},
{
"Category": "网站设置",
"Name": "固定表头",
"Code": "1",
"Define": NumberInt(0)
},
{
"Category": "网站设置",
"Name": "OAuth 认证登录",

View File

@ -32,6 +32,7 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '前台
-- 网站UI设置
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '侧边栏状态', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '卡片标题状态', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '固定表头', '1', 0);
-- 登录配置
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '短信验证码登录', '1', 0);

View File

@ -32,6 +32,7 @@ INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVA
-- 网站UI设置
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '侧边栏状态', '1', 0);
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '卡片标题状态', '1', 0);
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '固定表头', '1', 0);
-- 登录配置
INSERT INTO Dicts (Id, Category, Name, Code, Define) Values (SEQ_DICTS_ID.NEXTVAL, '网站设置', '短信验证码登录', '1', 0);

View File

@ -32,6 +32,7 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '前台
-- 网站UI设置
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '侧边栏状态', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '卡片标题状态', '1', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '固定表头', '1', 0);
-- 登录配置
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('网站设置', '短信验证码登录', '1', 0);

View File

@ -32,6 +32,7 @@ INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置
-- 网站UI设置
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '侧边栏状态', '1', 0);
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '卡片标题状态', '1', 0);
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '固定表头', '1', 0);
-- 登录配置
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('网站设置', '短信验证码登录', '1', 0);

View File

@ -35,6 +35,7 @@ INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设
-- 网站UI设置
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'侧边栏状态', N'1', 0)
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'卡片标题状态', N'1', 0)
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'固定表头', N'1', 0)
-- 登录配置
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'网站设置', N'短信验证码登录', N'1', 0)

View File

@ -19,11 +19,11 @@ namespace Bootstrap.Admin.Controllers.Api
/// <summary>
/// 保存网站设置方法
/// </summary>
/// <param name="value"></param>
/// <param name="values"></param>
/// <returns></returns>
[HttpPost]
[ButtonAuthorize(Url = "~/Admin/Settings", Auth = "saveTitle,saveFooter,saveTheme,saveUISettings,clearCache,clearAllCache,loginSettings,lockScreen,defaultApp,blazor")]
public bool Post([FromBody]BootstrapDict value) => DictHelper.SaveSettings(value);
public bool Post([FromBody]IEnumerable<BootstrapDict> values) => DictHelper.SaveSettings(values);
/// <summary>
/// 获取网站缓存站点集合

View File

@ -28,6 +28,7 @@ namespace Bootstrap.Admin.Models
ShowOAuth = AllowOAuth ? "" : "oauth";
LockScreenPeriod = DictHelper.RetrieveAutoLockScreenPeriod();
EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen();
FixedTableHeader = DictHelper.RetrieveFixedTableHeader() ? "" : "scroll";
}
/// <summary>
@ -89,5 +90,10 @@ namespace Bootstrap.Admin.Models
/// 获得 自动锁屏功能是否自动开启 默认关闭
/// </summary>
public bool EnableAutoLockScreen { get; }
/// <summary>
/// 获得 是否固定表头
/// </summary>
public string FixedTableHeader { get; }
}
}

View File

@ -83,6 +83,10 @@
<label class="control-label" for="cardTitle">标题设置</label>
<Toggle @bind-Value="@Model.ShowCardTitle" OnText="显示" OffText="关闭"></Toggle>
</div>
<div class="form-group col-6">
<label class="control-label" for="cardTitle">固定表头</label>
<Toggle @bind-Value="@Model.FixedTableHeader" OnText="固定" OffText="跟随"></Toggle>
</div>
</div>
</div>
<div class="modal-footer text-right">

View File

@ -51,6 +51,7 @@ namespace Bootstrap.Pages.Admin.Components
Model.LockScreenPeriod = DictHelper.RetrieveAutoLockScreenPeriod();
Model.DefaultApp = DictHelper.RetrieveDefaultApp();
Model.EnableBlazor = DictHelper.RetrieveEnableBlazor();
Model.FixedTableHeader = DictHelper.RetrieveFixedTableHeader();
Model.Themes = DictHelper.RetrieveThemes();
}
@ -59,7 +60,7 @@ namespace Bootstrap.Pages.Admin.Components
/// </summary>
protected void SaveBlazor()
{
var ret = DictHelper.SaveSettings(new BootstrapDict() { Category = "网站设置", Name = "Blazor", Code = Model.EnableBlazor ? "1" : "0" });
var ret = DictHelper.SaveSettings(new BootstrapDict[] { new BootstrapDict() { Category = "网站设置", Name = "Blazor", Code = Model.EnableBlazor ? "1" : "0" } });
if (Model.EnableBlazor) ShowMessage("Blazor 设置保存", ret);
else
{
@ -73,8 +74,11 @@ namespace Bootstrap.Pages.Admin.Components
/// </summary>
protected void SaveSidebar()
{
var ret = DictHelper.SaveSettings(new BootstrapDict() { Category = "网站调整", Name = "侧边栏状态", Code = Model.ShowSideBar ? "1" : "0" }) &&
DictHelper.SaveSettings(new BootstrapDict() { Category = "网站调整", Name = "卡片标题状态", Code = Model.ShowCardTitle ? "1" : "0" });
var ret = DictHelper.SaveSettings(new BootstrapDict[]{
new BootstrapDict() { Category = "网站调整", Name = "侧边栏状态", Code = Model.ShowSideBar ? "1" : "0" },
new BootstrapDict() { Category = "网站调整", Name = "卡片标题状态", Code = Model.ShowCardTitle ? "1" : "0" },
new BootstrapDict() { Category = "网站调整", Name = "固定表头", Code = Model.FixedTableHeader ? "1" : "0" }
});
ShowMessage("网站调整 设置保存", ret);
}
/// <summary>
@ -137,6 +141,11 @@ namespace Bootstrap.Pages.Admin.Components
/// </summary>
public bool EnableBlazor { get; set; }
/// <summary>
/// 获得/设置 是否固定表头
/// </summary>
public bool FixedTableHeader { get; set; }
/// <summary>
/// 获得/设置 系统样式集合
/// </summary>

View File

@ -93,6 +93,10 @@
<label class="control-label" for="cardTitle">标题设置</label>
<input id="cardTitle" hidden type="checkbox" data-default-val="@Model.ShowCardTitle" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="显示" data-off="关闭" />
</div>
<div class="form-group col-6">
<label class="control-label" for="tableHeader">固定表头</label>
<input id="tableHeader" hidden type="checkbox" data-default-val="@Model.FixedTableHeader" data-toggle="toggle" data-width="120" data-onstyle="success" data-on="固定" data-off="跟随" />
</div>
</div>
</div>
<div class="modal-footer text-right">

View File

@ -94,7 +94,7 @@
</div>
<div class="card-body">
@await RenderSectionAsync("cardbody", false)
<table></table>
<table data-fixedHeader="@Model.FixedTableHeader"></table>
</div>
</div>
<div id="tableButtons" class="d-none">

View File

@ -11,7 +11,7 @@ $(function () {
case 'footer':
data = dataBinder.get();
$.bc({
url: Settings.url, data: { name: '网站页脚', code: data.Footer, category: '网站设置' }, title: '保存网站页脚', method: "post",
url: Settings.url, data: [{ name: '网站页脚', code: data.Footer, category: '网站设置' }], title: '保存网站页脚', method: "post",
callback: function (result) {
if (result) $('#websiteFooter').text(data.Footer);
}
@ -20,7 +20,7 @@ $(function () {
case 'title':
data = dataBinder.get();
$.bc({
url: Settings.url, data: { name: '网站标题', code: data.Title, category: '网站设置' }, title: '保存网站标题', method: "post",
url: Settings.url, data: [{ name: '网站标题', code: data.Title, category: '网站设置' }], title: '保存网站标题', method: "post",
callback: function (result) {
if (result) $('#websiteTitle').text(data.Title);
}
@ -29,7 +29,7 @@ $(function () {
case 'css':
var cssDefine = $css.val();
$.bc({
url: Settings.url, data: { name: '使用样式', code: cssDefine, category: '当前样式' }, title: '保存网站样式', method: "post",
url: Settings.url, data: [{ name: '使用样式', code: cssDefine, category: '当前样式' }], title: '保存网站样式', method: "post",
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
@ -39,12 +39,14 @@ $(function () {
break;
case 'UISettings':
var uiSettings = $('#sider').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: '侧边栏状态', code: uiSettings, category: '网站设置' }, method: "post"
});
var cardTitle = $('#cardTitle').prop('checked') ? "1" : "0";
var fixedTableHeader = $('#tableHeader').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: '卡片标题状态', code: cardTitle, category: '网站设置' }, title: '保存网站设置', method: "post",
url: Settings.url, data: [
{ name: '卡片标题状态', code: cardTitle, category: '网站设置' },
{ name: '侧边栏状态', code: uiSettings, category: '网站设置' },
{ name: '固定表头', code: fixedTableHeader, category: '网站设置' }
], title: '保存网站设置', method: "post",
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
@ -54,21 +56,15 @@ $(function () {
break;
case 'loginSettings':
var mobile = $('#mobile').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: '短信验证码登录', code: mobile, category: '网站设置' }, method: "post"
});
var oauth = $('#oauth').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: 'OAuth 认证登录', code: oauth, category: '网站设置' }, title: '登录设置', method: "post"
url: Settings.url, data: [{ name: 'OAuth 认证登录', code: oauth, category: '网站设置' }, { name: '短信验证码登录', code: mobile, category: '网站设置' }], title: '登录设置', method: "post"
});
break;
case 'saveAutoLock':
var autoLock = $('#lockScreen').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: '自动锁屏', code: autoLock, category: '网站设置' }, method: "post"
});
$.bc({
url: Settings.url, data: { name: '自动锁屏时长', code: $('#lockPeriod').val(), category: '网站设置' }, title: '保存自动锁屏设置', method: "post",
url: Settings.url, data: [{ name: '自动锁屏', code: autoLock, category: '网站设置' }, { name: '自动锁屏时长', code: $('#lockPeriod').val(), category: '网站设置' }], title: '保存自动锁屏设置', method: "post",
callback: function (result) {
if (result) {
window.setTimeout(function () { window.location.reload(true); }, 1000);
@ -79,13 +75,13 @@ $(function () {
case 'saveDefaultApp':
var defaultApp = $('#defaultApp').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: '默认应用程序', code: defaultApp, category: '网站设置' }, title: '保存默认应用程序设置', method: "post"
url: Settings.url, data: [{ name: '默认应用程序', code: defaultApp, category: '网站设置' }], title: '保存默认应用程序设置', method: "post"
});
break;
case 'saveBlazor':
var blazor = $('#blazor').prop('checked') ? "1" : "0";
$.bc({
url: Settings.url, data: { name: 'Blazor', code: blazor, category: '网站设置' }, title: 'Blazor 设置', method: "post",
url: Settings.url, data: [{ name: 'Blazor', code: blazor, category: '网站设置' }], title: 'Blazor 设置', method: "post",
callback: function (result) {
if (result) {
// 导航到 Blazor 页面

View File

@ -90,7 +90,7 @@
};
$.extend({
"format": function (source, params) {
format: function (source, params) {
if (params === undefined || params === null) {
return null;
}
@ -354,7 +354,11 @@
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,
@ -367,6 +371,16 @@
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);
@ -420,7 +434,41 @@
}
});
}
// 判断是否固定表头
var fixHeader = this.attr('data-fixedHeader') === '';
var $tabContainer = $(settings.tableContainer);
if (fixHeader && settings.height === undefined) {
if (settings.calcHeight === undefined) {
settings.calcHeight = function () {
var marginHeight = 0;
if ($tabContainer.length === 1) {
marginHeight = $tabContainer.outerHeight() - $tabContainer.height();
}
// 38: card-header
return Math.max(settings.minHeight, $(window).height() - $('header').height() - $('footer').height() - (marginHeight * 2) - 38 - 32 - 10);
};
}
// 设置最小高度为
settings.height = settings.calcHeight();
// 设置 onresize 事件
$(window).on('resize', this, function (event) {
event.data.bootstrapTable('resetView', { height: settings.calcHeight() });
});
}
// 加载数据
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');

View File

@ -56,13 +56,13 @@ namespace Bootstrap.DataAccess.MongoDB
}
/// <summary>
///
/// 保存网站设置方法
/// </summary>
/// <param name="dict"></param>
/// <param name="dicts"></param>
/// <returns></returns>
public override bool SaveSettings(BootstrapDict dict)
public override bool SaveSettings(IEnumerable<BootstrapDict> dicts)
{
DbManager.Dicts.FindOneAndUpdate(md => md.Category == dict.Category && md.Name == dict.Name, Builders<BootstrapDict>.Update.Set(md => md.Code, dict.Code));
dicts.ToList().ForEach(dict => DbManager.Dicts.FindOneAndUpdate(md => md.Category == dict.Category && md.Name == dict.Name, Builders<BootstrapDict>.Update.Set(md => md.Code, dict.Code)));
return true;
}

View File

@ -48,12 +48,12 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 保存网站个性化设置
/// </summary>
/// <param name="dict"></param>
/// <param name="dicts"></param>
/// <returns></returns>
public virtual bool SaveSettings(BootstrapDict dict)
public virtual bool SaveSettings(IEnumerable<BootstrapDict> dicts)
{
using var db = DbManager.Create();
db.Update<BootstrapDict>("set Code = @Code where Category = @Category and Name = @Name", dict);
dicts.ToList().ForEach(dict => db.Update<BootstrapDict>("set Code = @Code where Category = @Category and Name = @Name", dict));
return true;
}
@ -290,5 +290,11 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <returns></returns>
public bool RetrieveEnableBlazor() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "Blazor" && d.Define == 0)?.Code ?? "0") == "1";
/// <summary>
/// 获得是否开启 固定表头 功能 默认开启
/// </summary>
/// <returns></returns>
public bool RetrieveFixedTableHeader() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "固定表头" && d.Define == 0)?.Code ?? "1") == "1";
}
}

View File

@ -106,11 +106,11 @@ namespace Bootstrap.DataAccess
/// <summary>
/// 保存网站个性化设置
/// </summary>
/// <param name="dict"></param>
/// <param name="dicts"></param>
/// <returns></returns>
public static bool SaveSettings(BootstrapDict dict)
public static bool SaveSettings(IEnumerable<BootstrapDict> dicts)
{
var ret = DbContextManager.Create<Dict>()?.SaveSettings(dict) ?? false;
var ret = DbContextManager.Create<Dict>()?.SaveSettings(dicts) ?? false;
if (ret) CacheCleanUtility.ClearCache(dictIds: new List<string>());
return ret;
}
@ -275,5 +275,11 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <returns></returns>
public static bool RetrieveEnableBlazor() => DbContextManager.Create<Dict>()?.RetrieveEnableBlazor() ?? false;
/// <summary>
/// 获得是否开启 固定表头 默认开启
/// </summary>
/// <returns></returns>
public static bool RetrieveFixedTableHeader() => DbContextManager.Create<Dict>()?.RetrieveFixedTableHeader() ?? false;
}
}