mirror of https://gitee.com/karson/fastadmin.git
优化菜单规则管理
parent
2c66c67d71
commit
31a6a47dc3
|
|
@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
||||||
[
|
[
|
||||||
{field: 'state', checkbox: true,},
|
{field: 'state', checkbox: true,},
|
||||||
{field: 'id', title: 'ID'},
|
{field: 'id', title: 'ID'},
|
||||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
|
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title, clickToSelect: !false},
|
||||||
{field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon},
|
{field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon},
|
||||||
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||||
{field: 'weigh', title: __('Weigh')},
|
{field: 'weigh', title: __('Weigh')},
|
||||||
|
|
@ -92,18 +92,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//显示隐藏子节点
|
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||||
$(document).on("click", ".btn-node-sub", function (e) {
|
//显示隐藏子节点
|
||||||
var status = $(this).data("shown") ? true : false;
|
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
var status = $(this).data("shown") ? true : false;
|
||||||
$(this).closest("tr").toggle(!status);
|
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||||
|
$(this).closest("tr").toggle(!status);
|
||||||
|
});
|
||||||
|
if (status) {
|
||||||
|
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||||
|
}
|
||||||
|
$(this).data("shown", !status);
|
||||||
|
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
if (status) {
|
|
||||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
|
||||||
}
|
|
||||||
$(this).data("shown", !status);
|
|
||||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//隐藏子节点
|
//隐藏子节点
|
||||||
|
|
@ -155,7 +157,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
||||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||||
|
|
||||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||||
return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Toggle sub menu') + '" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||||
},
|
},
|
||||||
name: function (value, row, index) {
|
name: function (value, row, index) {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
{field: 'id', title: __('Id')},
|
{field: 'id', title: __('Id')},
|
||||||
{field: 'pid', title: __('Pid'), visible: false},
|
{field: 'pid', title: __('Pid'), visible: false},
|
||||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
|
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
|
||||||
{field: 'name', title: __('Name'), align: 'left'},
|
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||||
{field: 'remark', title: __('Remark')},
|
{field: 'remark', title: __('Remark')},
|
||||||
// {field: 'ismenu', title: __('Ismenu'), formatter: Table.api.formatter.toggle},
|
// {field: 'ismenu', title: __('Ismenu'), formatter: Table.api.formatter.toggle},
|
||||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||||
|
|
@ -49,18 +49,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
// 为表格绑定事件
|
// 为表格绑定事件
|
||||||
Table.api.bindevent(table);
|
Table.api.bindevent(table);
|
||||||
|
|
||||||
//显示隐藏子节点
|
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||||
$(document).on("click", ".btn-node-sub", function (e) {
|
//显示隐藏子节点
|
||||||
var status = $(this).data("shown") ? true : false;
|
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
var status = $(this).data("shown") ? true : false;
|
||||||
$(this).closest("tr").toggle(!status);
|
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||||
|
$(this).closest("tr").toggle(!status);
|
||||||
|
});
|
||||||
|
if (status) {
|
||||||
|
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||||
|
}
|
||||||
|
$(this).data("shown", !status);
|
||||||
|
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
if (status) {
|
|
||||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
|
||||||
}
|
|
||||||
$(this).data("shown", !status);
|
|
||||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//隐藏子节点
|
//隐藏子节点
|
||||||
|
|
@ -107,9 +109,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||||
|
|
||||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||||
return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Toggle sub menu') + '" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||||
}
|
},
|
||||||
|
name: function (value, row, index) {
|
||||||
|
return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
bindevent: function () {
|
bindevent: function () {
|
||||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue