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