diff --git a/app/controller/manager/Area.php b/app/controller/manager/Area.php new file mode 100644 index 0000000..ab6ca8c --- /dev/null +++ b/app/controller/manager/Area.php @@ -0,0 +1,39 @@ +request->isPost()) { + $menus = AreaModel::getAllList(); + $res = [ + 'code' => 0, + 'msg' => 'success', + 'count' => $menus->count(), + 'data' => $menus->toArray(), + ]; + return json($res); + } + return $this->view(); + } +} \ No newline at end of file diff --git a/app/model/Area.php b/app/model/Area.php index 6c78557..5fa5f66 100644 --- a/app/model/Area.php +++ b/app/model/Area.php @@ -3,6 +3,8 @@ namespace app\model; +use think\Collection; + class Area extends Base { @@ -17,9 +19,16 @@ class Area extends Base */ public static function getByPCode($PCode,bool $filter = false) { - return self::where("pcode",$PCode ) ->when($filter,function ($q){ + return self::where("pcode",$PCode) ->when($filter,function ($q){ $q->where("status",self::COMMON_ON); })->order("id asc")->select(); } + + // 获取列表 + public static function getAllList(): Collection + { + return self::order('id', 'asc') + ->select(); + } } diff --git a/public/static/manager/js/area.js b/public/static/manager/js/area.js new file mode 100644 index 0000000..baa0c99 --- /dev/null +++ b/public/static/manager/js/area.js @@ -0,0 +1,110 @@ +layui.use(['laytpl', 'treeTable', 'jquery', 'iconPickerFa', 'form', 'miniTab', 'xmSelect'], function () { + let $ = layui.jquery, + form = layui.form, + treeTable = layui.treeTable, + iconPickerFa = layui.iconPickerFa, + layer = layui.layer, + miniTab = layui.miniTab, + xmSelect = layui.xmSelect; + + + + /**** index begin ***/ + //index页面 + if ($('.location-index-page').length > 0) { + miniTab.listen(); + + // 渲染表格 + let listUrl = $('#menu-table').data('url'); + let insTb = treeTable.render({ + elem: '#menu-table', + toolbar: '#toolbar-tpl', + defaultToolbar: [], + method: 'POST', + url: listUrl, + page: false, + tree: { + iconIndex: 1, // 折叠图标显示在第几列 + isPidData: true, // 是否是id、pid形式数据 + idName: 'code', // id字段名称 + pidName: 'pcode', // pid字段名称 + Spid: '86' // pid字段名称 + }, + cols: [[ + {type: 'checkbox'}, + {field: 'title', title: '菜单名称', minWidth: 150, singleLine: true}, + {title: '图标', width: 50, templet: '