Browse Source

notice未完成

sugangqiang 2 years ago
parent
commit
12ef7af4fa

+ 63 - 0
app/admin/controller/Notice.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\admin\common\AdminController;
+use app\common\api\NoticeApi;
+
+/**
+ * Description of Notice
+ *
+ * @author sgq
+ */
+class Notice extends AdminController {
+
+    public function index() {
+        return view();
+    }
+
+    public function list() {
+        $res = NoticeApi::getList($this->request->param());
+        return json($res);
+    }
+
+    /**
+     * @auth {{/notice/add}}
+     * @return type
+     */
+    public function add() {
+        if ($this->request->isPost()) {
+            try {
+                
+            } catch (\think\exception $e) {
+                return json(["msg" => $e->getMessage()]);
+            }
+            NoticeApi::update($this->request->param());
+            exit();
+        }
+        return view();
+    }
+
+    /**
+     * @auth {{/notice/update}}
+     * @return type
+     */
+    public function edit() {
+        if ($this->request->isPost()) {
+            exit();
+        }
+        return view();
+    }
+
+    /**
+     * @auth {{/notice/delete}}
+     * @return type
+     */
+    public function delete() {
+        if ($this->request->isPost()) {
+            $params = $this->request->param();
+            $id = $params["id"];
+        }
+    }
+
+}

+ 18 - 0
app/admin/validate/Notice.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class Notice extends Validate {
+
+    protected $rule = [
+        'title' => 'require',
+        'content' => 'require'
+    ];
+    protected $message = [
+        'title.require' => '标题必需填写!',
+        'content.max' => '内容必需填写!',
+    ];
+
+}

+ 42 - 0
app/admin/view/notice/add.html

@@ -0,0 +1,42 @@
+{extend name="layout/content"}
+{block name="content"}
+<div class="ibox float-e-margins">
+    <div class="ibox-content">
+        <div class="form-horizontal" id="noticeInfoForm">
+            <input type="hidden" id="id" value="">
+            <div class="row">
+                <div class="col-sm-12">
+                    <div class="form-group">
+                        <label class="col-sm-1 control-label">标题</label>
+                        <div class="col-sm-11">
+                            <input class="form-control" id="title" name="title" type="text">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-1 control-label">内容</label>
+                        <div class="col-sm-11">
+                            <div id="editor" class="editorHeight">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row btn-group-m-t">
+                <div class="col-sm-12" style="text-align: center">
+                    <button type="button" class="btn btn-sm btn-info" onclick="NoticeInfoDlg.addSubmit()" id="ensure">
+                        <i class="fa fa-check"></i>&nbsp;提交
+                    </button>
+                    <button type="button" class="btn btn-sm btn-danger" onclick="NoticeInfoDlg.close()" id="cancel">
+                        <i class="fa fa-eraser"></i>&nbsp;取消
+                    </button>
+                </div>
+            </div>
+        </div>
+
+    </div>
+</div>
+<script type="text/javascript">
+    document.write('<script src="/static/js/plugins/wangEditor/wangEditor.js?v=' + (new Date()).getTime() + '"><\/script>');
+    document.write('<script src="/static/modular/system/notice/notice_info.js?v=' + (new Date()).getTime() + '"><\/script>');
+</script>
+{/block}

+ 41 - 0
app/admin/view/notice/edit.html

@@ -0,0 +1,41 @@
+{extend name="layout/content"}
+{block name="content"}
+<div class="ibox float-e-margins">
+    <div class="ibox-content">
+        <div class="form-horizontal" id="noticeInfoForm">
+            <input type="hidden" id="id" value="{$notice.id}">
+            <input type="hidden" id="contentVal" value='{$notice.content}'>
+            <div class="row">
+                <div class="col-sm-12">
+                    <div class="form-group">
+                        <label class="col-sm-1 control-label">标题</label>
+                        <div class="col-sm-11">
+                            <input class="form-control" id="title" name="title" type="text" value="{$notice.title}">
+
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-1 control-label">内容</label>
+                        <div class="col-sm-11">
+                            <div id="editor" class="editorHeight">
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row btn-group-m-t">
+                <div class="col-sm-12" style="text-align: center">
+                    <button type="button" class="btn btn-sm btn-info" onclick="NoticeInfoDlg.editSubmit()" id="ensure">
+                        <i class="fa fa-check"></i>&nbsp;提交
+                    </button>
+                    <button type="button" class="btn btn-sm btn-danger" onclick="NoticeInfoDlg.close()" id="cancel">
+                        <i class="fa fa-eraser"></i>&nbsp;取消
+                    </button>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script type="text/javascript" src="/static/js/plugins/wangEditor/wangEditor.js"></script>
+<script src="/static/modular/system/notice/notice_info.js"></script>
+{/block}

+ 61 - 0
app/admin/view/notice/index.html

@@ -0,0 +1,61 @@
+{extend name="layout/content"}
+{block name="content"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h5>通知管理</h5>
+            </div>
+            <div class="ibox-content">
+                <div class="row row-lg">
+                    <div class="col-sm-12">
+                        <div class="row">
+                            <div class="col-sm-3">
+                                <div class="input-group input-group-sm">
+                                    <div class="input-group-btn">
+                                        <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">名称</button>
+                                    </div>
+                                    <input type="text" class="form-control" id="condition" placeholder="" />
+                                </div>
+                            </div>
+                            <div class="col-sm-3">
+                                <button type="button" class="btn btn-sm btn-primary" onclick="Notice.search()">
+                                    <i class="fa fa-search"></i>&nbsp;搜索
+                                </button>
+                            </div>
+                        </div>
+                        <div class="hidden-xs" id="NoticeTableToolbar" role="group">
+                            {if condition="chkCommission('/admin/notice/add','/notice/add')"}
+                            <button type="button" class="btn btn-sm btn-primary" onclick="Notice.openAddNotice()" id="ensure">
+                                <i class="fa fa-plus"></i>&nbsp;添加
+                            </button>
+                            {/if}
+                            {if condition="chkCommission('/admin/notice/edit','/notice/update')"}
+                            <button type="button" class="btn btn-sm btn-primary" onclick="Notice.openNoticeDetail()" id="ensure">
+                                <i class="fa fa-edit"></i>&nbsp;修改
+                            </button>
+                            {/if}
+                            {if condition="chkCommission('/admin/notice/delete','/notice/delete')"}
+                            <button type="button" class="btn btn-sm btn-primary" onclick="Notice.delete()" id="ensure">
+                                <i class="fa fa-delete"></i>&nbsp;删除
+                            </button>
+                            {/if}
+                            <button type="button" class="btn btn-sm btn-primary" onclick="Notice.top()">
+                                <i class="fa fa-hand-o-up"></i>&nbsp;置顶
+                            </button>
+                        </div>
+                        <table id="NoticeTable" class="table-condensed" style="font-size: 10px;table-layout: fixed!important;" data-mobile-responsive="true" data-click-to-select="true">
+                            <thead>
+                                <tr>
+                                    <th data-field="selectItem" data-checkbox="true"></th>
+                                </tr>
+                            </thead>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="/static/modular/system/notice/notice.js"></script>
+{/block}

+ 35 - 0
app/common/api/NoticeApi.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\common\api;
+
+use app\admin\model\Notice;
+
+/**
+ * Description of NoticeApi
+ *
+ * @author sgq
+ */
+class NoticeApi {
+
+    public static function getList($params = []) {
+        $where = [];
+        $condition = $params["condition"];
+        $order = $params["order"] ?: "desc";
+        $offset = $params["offset"] ?: 0;
+        $limit = $params["limit"] ?: 10;
+        if ($condition) {
+            $where[] = ["n.title", "like", "%{$condition}%"];
+            $where[] = ["n.content", "like", "%{$condition}%"];
+        }
+        $count = Notice::alias("n")->whereOr($where)->count();
+        $list = Notice::alias("n")->whereOr($where)
+                        ->leftJoin("sys_user u", "u.id=n.creater")
+                        ->leftJoin("sys_company c", "c.id=u.companyId")
+                        ->order(["n.isTop" => $order, "n.topTime" => $order, "n.createTime" => $order])
+                        ->limit($offset, $limit)
+                        ->field("n.*,concat(u.name,'(',c.name,')') as createrName")
+                        ->select()->toArray();
+        return ["total" => $count, "rows" => $list];
+    }
+
+}

+ 13 - 13
public/static/modular/system/notice/notice.js

@@ -2,8 +2,8 @@
  * 通知管理初始化
  * 通知管理初始化
  */
  */
 var Notice = {
 var Notice = {
-    id: "NoticeTable",	//表格id
-    seItem: null,		//选中的条目
+    id: "NoticeTable", //表格id
+    seItem: null, //选中的条目
     table: null,
     table: null,
     layerIndex: -1
     layerIndex: -1
 };
 };
@@ -46,7 +46,7 @@ Notice.openAddNotice = function () {
         area: ['800px', '500px'], //宽高
         area: ['800px', '500px'], //宽高
         fix: false, //不固定
         fix: false, //不固定
         maxmin: true,
         maxmin: true,
-        content: Feng.ctxPath + '/notice/notice_add'
+        content: Feng.ctxPath + '/admin/notice/add'
     });
     });
     this.layerIndex = index;
     this.layerIndex = index;
 };
 };
@@ -62,7 +62,7 @@ Notice.openNoticeDetail = function () {
             area: ['800px', '420px'], //宽高
             area: ['800px', '420px'], //宽高
             fix: false, //不固定
             fix: false, //不固定
             maxmin: true,
             maxmin: true,
-            content: Feng.ctxPath + '/notice/notice_update/' + Notice.seItem.id
+            content: Feng.ctxPath + '/admin/notice/edit/id/' + Notice.seItem.id
         });
         });
         this.layerIndex = index;
         this.layerIndex = index;
     }
     }
@@ -74,14 +74,14 @@ Notice.openNoticeDetail = function () {
 Notice.delete = function () {
 Notice.delete = function () {
     if (this.check()) {
     if (this.check()) {
 
 
-        var operation = function(){
-            var ajax = new $ax(Feng.ctxPath + "/notice/delete", function (data) {
+        var operation = function () {
+            var ajax = new $ax(Feng.ctxPath + "/admin/notice/delete", function (data) {
                 Feng.success("删除成功!");
                 Feng.success("删除成功!");
                 Notice.table.refresh();
                 Notice.table.refresh();
             }, function (data) {
             }, function (data) {
                 Feng.error("删除失败!" + data.responseJSON.message + "!");
                 Feng.error("删除失败!" + data.responseJSON.message + "!");
             });
             });
-            ajax.set("noticeId", Notice.seItem.id);
+            ajax.set("id", Notice.seItem.id);
             ajax.start();
             ajax.start();
         };
         };
 
 
@@ -89,16 +89,16 @@ Notice.delete = function () {
     }
     }
 };
 };
 
 
-Notice.top = function(){
+Notice.top = function () {
     if (this.check()) {
     if (this.check()) {
-        var operation = function(){
-            var ajax = new $ax(Feng.ctxPath + "/notice/top", function (data) {
+        var operation = function () {
+            var ajax = new $ax(Feng.ctxPath + "/admin/notice/top", function (data) {
                 Feng.success("置顶成功!");
                 Feng.success("置顶成功!");
                 Notice.table.refresh();
                 Notice.table.refresh();
             }, function (data) {
             }, function (data) {
                 Feng.error("置顶成功!" + data.responseJSON.message + "!");
                 Feng.error("置顶成功!" + data.responseJSON.message + "!");
             });
             });
-            ajax.set("noticeId", Notice.seItem.id);
+            ajax.set("id", Notice.seItem.id);
             ajax.start();
             ajax.start();
         };
         };
 
 
@@ -118,7 +118,7 @@ Notice.search = function () {
 
 
 $(function () {
 $(function () {
     var defaultColunms = Notice.initColumn();
     var defaultColunms = Notice.initColumn();
-    var table = new BSTable(Notice.id, "/notice/list", defaultColunms);
-    table.setPaginationType("client");
+    var table = new BSTable(Notice.id, "/admin/notice/list", defaultColunms);
+    //table.setPaginationType("client");
     Notice.table = table.init();
     Notice.table = table.init();
 });
 });