diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php index efbdb73..0db71b5 100644 --- a/app/admin/controller/Article.php +++ b/app/admin/controller/Article.php @@ -2,9 +2,8 @@ namespace app\admin\controller; -use app\admin\model\Document; -use app\admin\model\DocumentArticle; -use app\admin\model\DocumentProduct; +use app\admin\model\Document as aModel; +use app\admin\model\DocumentCategory as cModel; use app\Request; use app\admin\services\UtilService as Util; @@ -17,7 +16,7 @@ use app\admin\services\UtilService as Util; class Article extends AuthController { /** - * 账号列表 + * 文章管理主页 * @return string * @throws \Exception */ @@ -46,7 +45,7 @@ class Article extends AuthController ['page',1], ['limit',20], ]); - return app("json")->layui(Document::systemPage($where)); + return app("json")->layui(aModel::systemPage($where)); } /** @@ -85,7 +84,7 @@ class Article extends AuthController $saveData[$key] = $value; } } - return Document::update($saveData,['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); + return aModel::update($saveData,['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); } /** @@ -100,7 +99,33 @@ class Article extends AuthController if (!$id) return app("json")->fail("参数有误,Id为空!"); $where = Util::postMore([['field',''],['value','']]); if ($where['field'] == '' || $where['value'] =='') return app("json")->fail("参数有误!"); - return Document::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); + return aModel::update([$where['field']=>$where['value']],['id'=>$id]) ? app("json")->success("操作成功") : app("json")->fail("操作失败"); + } + + /** + * 新增页 + * @return string + * @throws \Exception + */ + public function add() + { + $this->assign("category",cModel::selectByType(2)); + return $this->fetch(); + } + + /** + * 编辑页 + * @return string + * @throws \Exception + * @author 李玉坤 + * @date 2021-02-20 17:00 + */ + public function edit(Request $request) + { + $this->assign("category",CModel::selectByType(2)); + $this->assign("info",aModel::get($request->param(['id']))); + return $this->fetch(); + } } \ No newline at end of file diff --git a/app/admin/model/DocumentCategory.php b/app/admin/model/DocumentCategory.php index 51426f3..fbab14a 100644 --- a/app/admin/model/DocumentCategory.php +++ b/app/admin/model/DocumentCategory.php @@ -35,4 +35,24 @@ class DocumentCategory extends BaseModel $data = $model->select(); return $data->toArray() ?: []; } + + /** + * 查询分类选择类型 + * @param int $type + * @param array $ids + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function selectByType(int $type = 0,array $ids = []) + { + $model = new self; + if (!empty($ids)) $model = $model->where("id","not in", $ids); + if ($type != 0) $model = $model->where("type",$type); + $model = $model->where("status",1); + $model = $model->field("id,name"); + $data = $model->select(); + return $data ? $data->toArray() : []; + } } \ No newline at end of file diff --git a/app/admin/view/article/add.html b/app/admin/view/article/add.html new file mode 100644 index 0000000..00dabbc --- /dev/null +++ b/app/admin/view/article/add.html @@ -0,0 +1,231 @@ + + + + + + CMS - 派后台管理系统 + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+ +
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/admin/view/article/edit.html b/app/admin/view/article/edit.html new file mode 100644 index 0000000..73c039b --- /dev/null +++ b/app/admin/view/article/edit.html @@ -0,0 +1,231 @@ + + + + + + CMS - 派后台管理系统 + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+ +
+ + +
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/admin/view/article/index.html b/app/admin/view/article/index.html index 86dc8c4..a92199b 100644 --- a/app/admin/view/article/index.html +++ b/app/admin/view/article/index.html @@ -20,14 +20,6 @@ -
- -
-
- -
-
-
@@ -45,8 +37,8 @@
@@ -132,11 +124,12 @@ title: '操作', formatter:function (value,row,index) { let html ='\n' + - ''; + ''; return html; }, events : { 'click .btn-edit': function (e, value, row, index) { + } } }], @@ -213,30 +206,6 @@ } }); } - function delAll() { - $.confirm({ - title: '重要提醒!', - content: '清空后将不可恢复,请谨慎操作!', - backgroundDismiss: true, - buttons: { - ok: { - text: '确认', - btnClass: 'btn-danger', - action: function () { - $.post("/admin/admin_log/empty",data={},function (res) { - if (res.status == 200 || res.code == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center'); - else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center'); - location.reload(); - }) - } - }, - cancel: { - text: '取消', - btnClass: 'btn-primary' - } - } - }); - } function delSelect() { var checkID = "";