diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index f381641..9bc2f59 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -143,11 +143,16 @@ class Article extends AuthController } /** - * 新增页 + * 新增文章 + * @param $category_id * @return string - * @throws \Exception + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 李玉坤 + * @date 2021-03-10 14:46 */ - public function add() + public function add($category_id ='') { $where = [ 'name' => '', @@ -156,6 +161,7 @@ class Article extends AuthController $category = cModel::systemPage($where); $category = get_tree_list($category); $this->assign("category",$category); + $this->assign("category_id",$category_id); return $this->fetch(); } diff --git a/app/admin/view/article/add.html b/app/admin/view/article/add.html index 33642eb..63aa8bb 100644 --- a/app/admin/view/article/add.html +++ b/app/admin/view/article/add.html @@ -36,7 +36,7 @@ diff --git a/app/admin/view/category/index.html b/app/admin/view/category/index.html index 27c97c0..7b58915 100644 --- a/app/admin/view/category/index.html +++ b/app/admin/view/category/index.html @@ -41,10 +41,7 @@
- - + 新增
@@ -80,16 +77,17 @@ showColumns: true, // 是否显示所有的列 showRefresh: true, // 是否显示刷新按钮 columns: [ - { - field: 'check', - checkbox: true - }, + // { + // field: 'check', + // checkbox: true + // }, { field: 'title', title: '名称', - formatter:function (value, row, index) { - return value +' ID:'+row.id; - } + }, + { + field: 'id', + title: 'ID', }, { field: 'display', @@ -115,10 +113,13 @@ title: '操作', align: 'center', events : { - 'click .role-add': function (e, value, row, index) { - iframe.createIframe('添加子分类','/admin/category/add?pid='+row.id); + 'click .category-add': function (e, value, row, index) { + location.href = '/admin/category/add?pid='+row.id; }, - 'click .role-delete': function (e, value, row, index) { + 'click .article-add': function (e, value, row, index) { + location.href = '/admin/article/add?category_id='+row.id; + }, + 'click .category-delete': function (e, value, row, index) { $.alert({ title: '系统提示', content: '删除提醒', @@ -139,7 +140,7 @@ } }); }, - 'click .role-edit': function (e, value, row, index) { + 'click .category-edit': function (e, value, row, index) { iframe.createIframe('修改分类','/admin/category/edit?id='+row.id) } }, @@ -183,9 +184,10 @@ // 操作按钮 function operateFormatter(value, row, index) { return [ - '', - '', - '' + '', + '', + '', + '' ].join(''); } @@ -231,39 +233,6 @@ }); } - // 删除 - function del() { - var checkID = ""; - var selectedItem = $treeTable.bootstrapTable('getSelections'); - if (selectedItem=="") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center'); - for (var i = 0 ; i< selectedItem.length; i++) - { - checkID += selectedItem[i]['id']+","; - } - if (checkID=="") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center'); - $.confirm({ - title: '重要提醒!', - content: '选中项将全部被删除,请谨慎操作!' , - backgroundDismiss: true, - buttons: { - ok: { - text: '确认', - btnClass: 'btn-danger', - action: function () { - $.post("/admin/category/del",data={id:checkID},function (res) { - if (res.status == 200){ lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');location.reload();} - else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center'); - }) - } - }, - cancel: { - text: '取消', - btnClass: 'btn-primary' - } - } - }); - } - $("#search").click(function () { $treeTable.bootstrapTable('refresh', {}); });