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

View File

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

View File

@ -77,6 +77,16 @@
</div> </div>
</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"> <script type="text/html" id="table-bar">
<button class="pear-btn pear-btn-xs pear-btn-primary" lay-event="select">选择</button> <button class="pear-btn pear-btn-xs pear-btn-primary" lay-event="select">选择</button>
@ -89,6 +99,7 @@
// 相关接口 // 相关接口
const PRIMARY_KEY = 'id'; const PRIMARY_KEY = 'id';
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
const SELECT_API = "/app/admin/upload/select"; const SELECT_API = "/app/admin/upload/select";
const UPDATE_API = "/app/admin/upload/update"; const UPDATE_API = "/app/admin/upload/update";
const DELETE_API = "/app/admin/upload/delete"; const DELETE_API = "/app/admin/upload/delete";
@ -96,7 +107,7 @@
const UPDATE_URL = "/app/admin/upload/update"; 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 table = layui.table;
let form = layui.form; let form = layui.form;
let $ = layui.$; let $ = layui.$;
@ -104,35 +115,39 @@
let util = layui.util; let util = layui.util;
// 字段 上传时间 created_at // 字段 上传时间 created_at
layui.laydate.render({ layui.use(["laydate"], function() {
elem: "#created_at", layui.laydate.render({
range: ["#created_at-date-start", "#created_at-date-end"], elem: "#created_at",
type: 'datetime', range: ["#created_at-date-start", "#created_at-date-end"],
}); type: 'datetime',
});
})
// 字段 类别 category // 字段 类别 category
$.ajax({ layui.use(["jquery", "xmSelect"], function() {
url: "/app/admin/dict/get/upload", layui.$.ajax({
dataType: "json", url: "/app/admin/dict/get/upload",
success: function (e) { dataType: "json",
let value = layui.$("#category").attr("value"); success: function (e) {
let initValue = value ? value.split(",") : []; let value = layui.$("#category").attr("value");
layui.xmSelect.render({ let initValue = value ? value.split(",") : [];
el: "#category", layui.xmSelect.render({
name: "category", el: "#category",
initValue: initValue, name: "category",
data: e.data, initValue: initValue,
model: {"icon":"hidden","label":{"type":"text"}}, data: e.data,
clickClose: 'true', model: {"icon":"hidden","label":{"type":"text"}},
radio: 'true', clickClose: 'true',
on: function(data){ radio: 'true',
let value = data.arr[0] ? data.arr[0].value : ''; on: function(data){
table.reload('data-table', { let value = data.arr[0] ? data.arr[0].value : '';
where: {category: value} table.reload('data-table', {
}) where: {category: value}
}, })
}) },
} })
}
});
}); });
// 表头参数 // 表头参数
@ -208,11 +223,11 @@
field: "updated_at", field: "updated_at",
hide: true, hide: true,
},{ },{
title: "操作", title: "操作",
toolbar: "#table-bar", toolbar: "#table-bar",
align: "center", align: "center",
fixed: "right", fixed: "right",
} }
]; ];
// 渲染表格 // 渲染表格
@ -230,6 +245,7 @@
cols: [cols], cols: [cols],
skin: "line", skin: "line",
size: "lg", size: "lg",
toolbar: "#table-toolbar",
autoSort: false, autoSort: false,
where: {ext: searchExt}, where: {ext: searchExt},
defaultToolbar: [{ defaultToolbar: [{
@ -277,12 +293,15 @@
render(); render();
} }
// 编辑删除行事件 // 编辑删除或选择行事件
table.on('tool(data-table)', function(obj) { table.on('tool(data-table)', function(obj) {
let index = parent.layer.getFrameIndex(window.name); if (obj.event === 'remove') {
let callback = parent.layui.$("#layui-layer" + index).data("callback"); remove(obj);
callback(obj.data); } else if (obj.event === 'edit') {
parent.layer.close(index); 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) { window.refreshTable = function(param) {
table.reloadData('data-table', { table.reloadData('data-table', {

View File

@ -107,6 +107,7 @@
// 相关接口 // 相关接口
const PRIMARY_KEY = 'id'; const PRIMARY_KEY = 'id';
const CONTROLLER = "plugin\\admin\\app\\controller\\UploadController";
const SELECT_API = "/app/admin/upload/select"; const SELECT_API = "/app/admin/upload/select";
const UPDATE_API = "/app/admin/upload/update"; const UPDATE_API = "/app/admin/upload/update";
const DELETE_API = "/app/admin/upload/delete"; const DELETE_API = "/app/admin/upload/delete";
@ -224,11 +225,11 @@
field: "updated_at", field: "updated_at",
hide: true, hide: true,
},{ },{
title: "操作", title: "操作",
toolbar: "#table-bar", toolbar: "#table-bar",
align: "center", align: "center",
fixed: "right", fixed: "right",
} }
]; ];
// 渲染表格 // 渲染表格
@ -288,7 +289,7 @@
render(); render();
} }
// 编辑删除行事件 // 编辑删除或选择行事件
table.on('tool(data-table)', function(obj) { table.on('tool(data-table)', function(obj) {
if (obj.event === 'remove') { if (obj.event === 'remove') {
remove(obj); remove(obj);

View File

@ -83,7 +83,21 @@ return [
'href' => '/app/admin/config/index', 'href' => '/app/admin/config/index',
'type' => 1, 'type' => 1,
'weight' => 700, '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,
],
] ]
], ],
[ [