This commit is contained in:
walkor 2022-12-06 17:29:48 +08:00
parent 0e5b192ff3
commit 5f7ede6b28
5 changed files with 95 additions and 48 deletions

View File

@ -219,6 +219,7 @@ class AdminRuleController extends Crud
return view('admin-rule/insert');
}
$data = $this->insertInput($request);
$data['key'] = str_replace('\\\\', '\\', $data['key']);
$key = $data['key'] ?? '';
if ($this->model->where('key', $key)->first()) {
return $this->json(1, "菜单标识 $key 已经存在");
@ -247,6 +248,9 @@ class AdminRuleController extends Crud
if ($data['pid'] == $row['id']) {
return $this->json(2, '不能将自己设置为上级菜单');
}
if (isset($data['key'])) {
$data['key'] = str_replace('\\\\', '\\', $data['key']);
}
$this->doUpdate($id, $data);
return $this->json(0);
}

View File

@ -67,6 +67,7 @@
<script>
// 相关接口
const CONTROLLER = 'plugin\\admin\\app\\controller\\DictController';
const SELECT_API = "/app/admin/dict/select";
const UPDATE_API = "/app/admin/dict/update";
const DELETE_API = "/app/admin/dict/delete";

View File

@ -77,6 +77,16 @@
</div>
</div>
<!-- 表格顶部工具栏 -->
<script type="text/html" id="table-toolbar">
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="insert">
<i class="layui-icon layui-icon-add-1"></i>新增
</button>
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="delete">
<i class="layui-icon layui-icon-delete"></i>删除
</button>
</script>
<!-- 表格行工具栏 -->
<script type="text/html" id="table-bar">
<button class="pear-btn pear-btn-xs pear-btn-primary" lay-event="select">选择</button>
@ -89,6 +99,7 @@
// 相关接口
const PRIMARY_KEY = 'id';
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
const SELECT_API = "/app/admin/upload/select";
const UPDATE_API = "/app/admin/upload/update";
const DELETE_API = "/app/admin/upload/delete";
@ -96,7 +107,7 @@
const UPDATE_URL = "/app/admin/upload/update";
// 表格渲染
layui.use(['table', 'form', 'common', 'popup', 'util', 'laydate', 'xmSelect'], function() {
layui.use(['table', 'form', 'common', 'popup', 'util'], function() {
let table = layui.table;
let form = layui.form;
let $ = layui.$;
@ -104,14 +115,17 @@
let util = layui.util;
// 字段 上传时间 created_at
layui.use(["laydate"], function() {
layui.laydate.render({
elem: "#created_at",
range: ["#created_at-date-start", "#created_at-date-end"],
type: 'datetime',
});
})
// 字段 类别 category
$.ajax({
layui.use(["jquery", "xmSelect"], function() {
layui.$.ajax({
url: "/app/admin/dict/get/upload",
dataType: "json",
success: function (e) {
@ -133,6 +147,7 @@
},
})
}
});
});
// 表头参数
@ -230,6 +245,7 @@
cols: [cols],
skin: "line",
size: "lg",
toolbar: "#table-toolbar",
autoSort: false,
where: {ext: searchExt},
defaultToolbar: [{
@ -277,12 +293,15 @@
render();
}
// 编辑删除行事件
// 编辑删除或选择行事件
table.on('tool(data-table)', function(obj) {
let index = parent.layer.getFrameIndex(window.name);
let callback = parent.layui.$("#layui-layer" + index).data("callback");
callback(obj.data);
parent.layer.close(index);
if (obj.event === 'remove') {
remove(obj);
} else if (obj.event === 'edit') {
edit(obj);
} else if (obj.event === 'select') {
select(obj);
}
});
// 表格顶部工具栏事件
@ -387,6 +406,14 @@
});
}
// 选择行
let select = function (obj) {
let index = parent.layer.getFrameIndex(window.name);
let callback = parent.layui.$("#layui-layer" + index).data("callback");
callback(obj.data);
parent.layer.close(index);
};
// 刷新表格数据
window.refreshTable = function(param) {
table.reloadData('data-table', {

View File

@ -107,6 +107,7 @@
// 相关接口
const PRIMARY_KEY = 'id';
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
const SELECT_API = "/app/admin/upload/select";
const UPDATE_API = "/app/admin/upload/update";
const DELETE_API = "/app/admin/upload/delete";
@ -288,7 +289,7 @@
render();
}
// 编辑删除行事件
// 编辑删除或选择行事件
table.on('tool(data-table)', function(obj) {
if (obj.event === 'remove') {
remove(obj);

View File

@ -83,7 +83,21 @@ return [
'href' => '/app/admin/config/index',
'type' => 1,
'weight' => 700,
]
],
[
'title' => '附件管理',
'key' => 'plugin\\admin\\app\\controller\\UploadController',
'href' => '/app/admin/upload/index',
'type' => 1,
'weight' => 600,
],
[
'title' => '字典设置',
'key' => 'plugin\\admin\\app\\controller\\DictController',
'href' => '/app/admin/dict/index',
'type' => 1,
'weight' => 500,
],
]
],
[