WIN-2308041133\Administrator 8 months ago
parent
commit
24d5d78943

+ 33 - 39
application/admin/controller/third/Platform.php

@@ -1,75 +1,69 @@
 <?php
 
-namespace app\admin\controller\platform;
+namespace app\admin\controller\third;
 
 use app\common\controller\Backend;
 
-/**
- * 第三方平台列表
- *
- * @icon fa fa-user
- */
 class Platform extends Backend
 {
-
-    protected $relationSearch = true;
-
-
-    /**
-     * @var \app\admin\model\User
-     */
+    // 模型对象
     protected $model = null;
 
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = model('platform');
+        $this->model = new \app\admin\model\third\Platform;
     }
 
-    /**
-     * 查看
-     */
+    // 列表页
     public function index()
     {
-        //设置过滤方法
-
-        $this->request->filter(['strip_tags']);
         if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
             $total = $this->model
-//                ->with('user')
                 ->where($where)
                 ->order($sort, $order)
                 ->count();
             $list = $this->model
-//                ->with('user')
                 ->where($where)
                 ->order($sort, $order)
                 ->limit($offset, $limit)
                 ->select();
-            $result = array("total" => $total, "rows" => $list);
+            $result = [
+                "total" => $total,
+                "rows" => $list,
+            ];
             return json($result);
         }
         return $this->view->fetch();
     }
 
-    /**
-     * 编辑
-     */
-    public function edit($ids = NULL)
-    {
-        $row = $this->model->get($ids);
-        if (!$row)
-            $this->error(__('No Results were found'));
-        return parent::edit($ids);
-    }
+    // 添加/编辑
     public function add()
     {
-        return parent::add();
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if ($params) {
+                $params['createtime'] = time(); // 自动填充时间戳
+                $result = $this->model->save($params);
+                if ($result) {
+                    $this->success();
+                } else {
+                    $this->error(__('Operation failed'));
+                }
+            }
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        return $this->view->fetch();
     }
 
-}
+    // 删除
+    public function del($ids = "")
+    {
+        if ($ids) {
+            $this->model->destroy($ids);
+            $this->success();
+        }
+        $this->error(__('Parameter %s can not be empty', 'ids'));
+    }
+}

+ 21 - 32
application/admin/view/third/platform/add.html

@@ -1,33 +1,22 @@
-<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
-  <div class="form-group">
-    <label for="c-name" class="control-label col-xs-12 col-sm-2">{:__('第三方平台名称')}:</label>
-    <div class="col-xs-12 col-sm-4">
-      <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
-    </div>
+{extend name="../../layout/view.html" /}
+
+{block name="content"}
+<div class="panel panel-default">
+  <div class="panel-heading">添加平台</div>
+  <div class="panel-body">
+    <form class="form-horizontal" method="post">
+      <div class="form-group">
+        <label class="col-sm-2 control-label">平台名称</label>
+        <div class="col-sm-8">
+          <input type="text" name="row[name]" class="form-control" required>
+        </div>
+      </div>
+      <div class="form-group">
+        <div class="col-sm-8 col-sm-offset-2">
+          <button type="submit" class="btn btn-primary">提交</button>
+        </div>
+      </div>
+    </form>
   </div>
-  <div class="form-group">
-    <label for="c-company" class="control-label col-xs-12 col-sm-2">{:__('所属公司')}:</label>
-    <div class="col-xs-12 col-sm-4">
-      <input id="c-company" data-rule="required" class="form-control" name="row[company]" type="text">
-    </div>
-  </div>
-  <div class="form-group">
-    <label for="c-url" class="control-label col-xs-12 col-sm-2">{:__('网址')}:</label>
-    <div class="col-xs-12 col-sm-4">
-      <input id="c-url" data-rule="required" class="form-control" name="row[url]" type="text" value="">
-    </div>
-  </div>
-  <!--    <div class="form-group">-->
-  <!--        <label for="content" class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>-->
-  <!--        <div class="col-xs-12 col-sm-8">-->
-  <!--            {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], 'normal')}-->
-  <!--        </div>-->
-  <!--    </div>-->
-  <div class="form-group layer-footer">
-    <label class="control-label col-xs-12 col-sm-2"></label>
-    <div class="col-xs-12 col-sm-8">
-      <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
-      <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
-    </div>
-  </div>
-</form>
+</div>
+{/block}

+ 33 - 24
application/admin/view/third/platform/index.html

@@ -1,28 +1,37 @@
-<div class="panel panel-default panel-intro">
-  {:build_heading()}
-
-  <div class="panel-body">
-    <div id="myTabContent" class="tab-content">
-      <div class="tab-pane fade active in" id="one">
-        <div class="widget-body no-padding">
-          <div id="toolbar" class="toolbar">
-            {:build_toolbar('refresh,add,edit,del')}
-            <div class="dropdown btn-group {:$auth->check('third/platform/multi')?'':'hide'}">
-              <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
-              <ul class="dropdown-menu text-left" role="menu">
-                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
-                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
-              </ul>
-            </div>
-          </div>
-          <table id="table" class="table table-striped table-bordered table-hover"
-                 data-operate-edit="{:$auth->check('third/platform/edit')}"
-                 data-operate-del="{:$auth->check('third/platform/del')}"
-                 width="100%">
-          </table>
-        </div>
-      </div>
+{extend name="../../layout/view.html" /}
 
+{block name="content"}
+<div class="panel panel-default">
+  <div class="panel-heading">
+    <span class="panel-title">第三方平台列表</span>
+    <div class="pull-right">
+      <a href="{:url('add')}" class="btn btn-primary btn-xs"><i class="fa fa-plus"></i> 添加</a>
     </div>
   </div>
+  <div class="panel-body">
+    <table id="bootstrap-table" class="table table-hover">
+      <thead>
+      <tr>
+        <th>ID</th>
+        <th>平台名称</th>
+        <th>创建时间</th>
+        <th>操作</th>
+      </tr>
+      </thead>
+      <tbody>
+      {volist name="list" id="vo"}
+      <tr>
+        <td>{$vo.id}</td>
+        <td>{$vo.name}</td>
+        <td>{$vo.createtime}</td>
+        <td>
+          <a href="{:url('edit', ['id' => $vo.id])}" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i> 编辑</a>
+          <a href="javascript:;" data-url="{:url('del')}" data-id="{$vo.id}" class="btn btn-xs btn-danger btn-del"><i class="fa fa-trash"></i> 删除</a>
+        </td>
+      </tr>
+      {/volist}
+      </tbody>
+    </table>
+  </div>
 </div>
+{/block}