Update: (步骤备份)修复权限搜索
This commit is contained in:
@@ -7,17 +7,17 @@
|
|||||||
<body class="pear-container">
|
<body class="pear-container">
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<form class="layui-form" action="">
|
<div class="layui-form-item" style="margin-bottom: unset;">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">部门名称</label>
|
<label class="layui-form-label">部门名称</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input type="text" name="deptName" placeholder="" class="layui-input">
|
<input type="text" name="deptName" placeholder="" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="dept-query">
|
<button class="layui-btn layui-btn-md layui-btn-primary" lay-submit lay-filter="dept-query">
|
||||||
<i class="layui-icon layui-icon-search"></i>
|
<i class="layui-icon layui-icon-search"></i>
|
||||||
查询
|
查询
|
||||||
</button>
|
</button>
|
||||||
<button type="reset" class="pear-btn pear-btn-md">
|
<button type="reset" class="layui-btn layui-btn-md">
|
||||||
<i class="layui-icon layui-icon-refresh"></i>
|
<i class="layui-icon layui-icon-refresh"></i>
|
||||||
重置
|
重置
|
||||||
</button>
|
</button>
|
||||||
@@ -34,13 +34,13 @@
|
|||||||
|
|
||||||
<script type="text/html" id="dept-toolbar">
|
<script type="text/html" id="dept-toolbar">
|
||||||
{% if authorize("system:dept:edit") %}
|
{% if authorize("system:dept:edit") %}
|
||||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
<button class="layui-btn layui-btn-primary layui-btn-md" lay-event="add">
|
||||||
<i class="layui-icon layui-icon-add-1"></i>
|
<i class="layui-icon layui-icon-add-1"></i>
|
||||||
新增
|
新增
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if authorize("system:dept:remove") %}
|
{% if authorize("system:dept:remove") %}
|
||||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
<button class="layui-btn layui-btn-md" lay-event="batchRemove">
|
||||||
<i class="layui-icon layui-icon-delete"></i>
|
<i class="layui-icon layui-icon-delete"></i>
|
||||||
删除
|
删除
|
||||||
</button>
|
</button>
|
||||||
@@ -49,12 +49,12 @@
|
|||||||
|
|
||||||
<script type="text/html" id="dept-bar">
|
<script type="text/html" id="dept-bar">
|
||||||
{% if authorize("system:dept:edit") %}
|
{% if authorize("system:dept:edit") %}
|
||||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
|
<button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="edit"><i
|
||||||
class="layui-icon layui-icon-edit"></i>
|
class="layui-icon layui-icon-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if authorize("system:dept:remove") %}
|
{% if authorize("system:dept:remove") %}
|
||||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
|
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="remove"><i
|
||||||
class="layui-icon layui-icon-delete"></i>
|
class="layui-icon layui-icon-delete"></i>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -71,17 +71,17 @@
|
|||||||
{% include 'system/common/footer.html' %}
|
{% include 'system/common/footer.html' %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.use(['table', 'form', 'jquery', 'treetable', 'popup'], function () {
|
layui.use(['table', 'form', 'jquery', 'popup'], function () {
|
||||||
let table = layui.table
|
let table = layui.table
|
||||||
let form = layui.form
|
let form = layui.form
|
||||||
let $ = layui.jquery
|
let $ = layui.jquery
|
||||||
let treetable = layui.treetable
|
let treeTable = layui.treeTable
|
||||||
let popup = layui.popup
|
let popup = layui.popup
|
||||||
|
|
||||||
let MODULE_PATH = '/system/dept/'
|
let MODULE_PATH = '/system/dept/'
|
||||||
|
|
||||||
window.render = function () {
|
window.render = function () {
|
||||||
treetable.render({
|
treeTable.render({
|
||||||
treeColIndex: 1,
|
treeColIndex: 1,
|
||||||
treeSpid: 0,
|
treeSpid: 0,
|
||||||
treeIdName: 'id',
|
treeIdName: 'id',
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
if (searchCount === 0) {
|
if (searchCount === 0) {
|
||||||
layer.msg('没有匹配结果', {icon: 5})
|
layer.msg('没有匹配结果', {icon: 5})
|
||||||
} else {
|
} else {
|
||||||
treetable.expandAll('#dept-table')
|
treeTable.expandAll('#dept-table')
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -122,31 +122,58 @@
|
|||||||
render()
|
render()
|
||||||
|
|
||||||
form.on('submit(power-query)', function (data) {
|
form.on('submit(power-query)', function (data) {
|
||||||
var keyword = data.field.powerName
|
var keyword = data.field.powerName;
|
||||||
var $tds = $('#power-table').next('.treeTable').find('.layui-table-body tbody tr td')
|
|
||||||
if (!keyword) {
|
if (!keyword) {
|
||||||
$tds.css('background-color', 'transparent')
|
layer.msg('搜索内容为空', {
|
||||||
layer.msg('请输入关键字', {icon: 5})
|
icon: 3,
|
||||||
return
|
time: 1000
|
||||||
|
})
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
var searchCount = 0
|
|
||||||
$tds.each(function () {
|
treeTable.checkAllNodes('power-table', false);
|
||||||
$(this).css('background-color', 'transparent')
|
|
||||||
if ($(this).text().indexOf(keyword) >= 0) {
|
var expandNotes = [];
|
||||||
$(this).css('background-color', 'rgba(250,230,160,0.5)')
|
|
||||||
if (searchCount === 0) {
|
treeTable.getNodesByFilter('power-table', function (item) {
|
||||||
$('body,html').stop(true)
|
if (item.name.indexOf(keyword) !== -1) {
|
||||||
$('body,html').animate({scrollTop: $(this).offset().top - 150}, 500)
|
treeTable.setRowChecked('power-table', {index: item, checked: true});
|
||||||
|
|
||||||
|
// 遍历其全部父元素
|
||||||
|
var parent_id = item.parent_id;
|
||||||
|
|
||||||
|
while (parent_id !== 0) {
|
||||||
|
|
||||||
|
if (!expandNotes.includes(parent_id)) {
|
||||||
|
expandNotes.push(item.LAY_DATA_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
item = treeTable.getNodeById('power-table', item.parent_id).data;
|
||||||
|
parent_id = item.parent_id;
|
||||||
}
|
}
|
||||||
searchCount++
|
|
||||||
|
|
||||||
|
if (!expandNotes.includes(parent_id)) {
|
||||||
|
expandNotes.push(item.LAY_DATA_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
if (searchCount === 0) {
|
|
||||||
layer.msg('没有匹配结果', {icon: 5})
|
treeTable.expandAll('power-table', false);
|
||||||
} else {
|
|
||||||
treeTable.expandAll('#power-table')
|
expandNotes.forEach(function (note_id) {
|
||||||
}
|
treeTable.expandNode('power-table', {
|
||||||
return false
|
index: note_id,
|
||||||
|
expandFlag: true
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
return false;
|
||||||
})
|
})
|
||||||
|
|
||||||
treeTable.on('tool(power-table)', function (obj) {
|
treeTable.on('tool(power-table)', function (obj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user