Update: (步骤备份)部门管理更新完成

This commit is contained in:
wojiaoyishang
2025-01-21 12:07:37 +08:00
parent b6a64f15dc
commit fa7e62b12b
4 changed files with 135 additions and 40 deletions
+97 -25
View File
@@ -102,36 +102,66 @@
{field: 'sort', title: '排序', width: 50},
{title: '操作', templet: '#dept-bar', width: 150, align: 'center'}
]
]
],
done: function (res, curr, count, origin) {
treeTable.expandAll('dept-table', true)
}
})
}
form.on('submit(dept-query)', function (data) {
var keyword = data.field.deptName
var $tds = $('#dept-table').next('.treeTable').find('.layui-table-body tbody tr td')
if (!keyword) {
$tds.css('background-color', 'transparent')
layer.msg('请输入关键字', {icon: 5})
return
var keyword = data.field.deptName;
if (!keyword) {
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('dept-table', false);
var expandNotes = [];
treeTable.getNodesByFilter('dept-table', function (item) {
if (item.dept_name.indexOf(keyword) !== -1) {
treeTable.setRowChecked('dept-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('dept-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('#dept-table')
}
return false
treeTable.expandAll('dept-table', false);
expandNotes.forEach(function (note_id) {
treeTable.expandNode('dept-table', {
index: note_id,
expandFlag: true
});
})
return false;
})
render()
@@ -150,8 +180,7 @@
} else if (obj.event === 'refresh') {
window.refresh()
} else if (obj.event === 'batchRemove') {
{#window.batchRemove(obj)#}
console.log(table.checkStatus(obj.config.id).data)
window.batchRemove(obj)
}
})
@@ -212,7 +241,7 @@
layer.close(loading)
if (result.success) {
popup.success(result.msg, function () {
obj.del()
treeTable.removeNode('dept-table', obj.data.LAY_DATA_INDEX)
})
} else {
popup.failure(result.msg)
@@ -221,6 +250,49 @@
})
})
}
window.batchRemove = function (obj) {
let data = treeTable.checkStatus(obj.config.id).data
if (data.length === 0) {
layer.msg('未选中数据', {
icon: 3,
time: 1000
})
return false
}
var ids = []
var hasCheck = treeTable.checkStatus('dept-table')
var hasCheckData = hasCheck.data
if (hasCheckData.length > 0) {
$.each(hasCheckData, function (index, element) {
ids.push(element.id)
})
}
layer.confirm('确定要删除选中部门', {
icon: 3,
title: '提示'
}, function (index) {
layer.close(index)
let loading = layer.load()
$.ajax({
url: MODULE_PATH + 'batchRemove',
data: {ids: ids},
dataType: 'json',
type: 'delete',
success: function (result) {
layer.close(loading)
if (result.success) {
popup.success(result.msg, function () {
treeTable.reload('dept-table');
})
} else {
popup.failure(result.msg)
}
}
})
})
}
})
</script>
</html>
+1 -2
View File
@@ -248,8 +248,7 @@
layer.close(loading)
if (result.success) {
popup.success(result.msg, function () {
console.log(obj)
obj.del()
treeTable.removeNode('power-table', obj.data.LAY_DATA_INDEX)
})
} else {
popup.failure(result.msg)