From 4bc6141b8b42e71636e5b47a3072e06a371fca8a Mon Sep 17 00:00:00 2001
From: 1099438829 <1099438829@qq.com>
Date: Wed, 10 Mar 2021 14:56:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=81=8C=E4=BD=8D=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=92=8C=E5=88=86=E7=B1=BB=E6=B7=BB=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/admin/controller/Article.php | 12 +++--
app/admin/view/article/add.html | 2 +-
app/admin/view/category/index.html | 71 +++++++++---------------------
3 files changed, 30 insertions(+), 55 deletions(-)
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', {});
});