Browse Source

任务详细

+ 10 months ago
parent
commit
598f9967b7

+ 0 - 37
application/admin/controller/device/Task.php

@@ -1,37 +0,0 @@
-<?php
-
-namespace app\admin\controller\device;
-
-use app\common\controller\Backend;
-
-/**
- * 任务管理
- *
- * @icon fa fa-circle-o
- */
-class Task extends Backend
-{
-
-    /**
-     * Task模型对象
-     * @var \app\admin\model\Task
-     */
-    protected $model = null;
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        $this->model = new \app\admin\model\Task;
-        $this->view->assign("statusList", $this->model->getStatusList());
-    }
-
-
-
-    /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
-     */
-
-
-}

+ 57 - 0
application/admin/controller/task/Steps.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\admin\controller\task;
+
+use app\common\controller\Backend;
+
+/**
+ * 任务步骤管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Steps extends Backend
+{
+
+    /**
+     * Steps模型对象
+     * @var \app\admin\model\TaskSteps
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\TaskSteps;
+        $this->view->assign("statusList", $this->model->getStatusList());
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $list = $this->model
+            ->where($where)
+            ->where('task_id', $this->request->get('task_id'))
+            ->order($sort, $order)
+            ->paginate($limit);
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+
+}

+ 58 - 0
application/admin/controller/task/Task.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace app\admin\controller\task;
+
+use app\common\controller\Backend;
+use fast\Tree;
+
+/**
+ * 任务管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Task extends Backend
+{
+
+    /**
+     * Task模型对象
+     * @var \app\admin\model\Task
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Task;
+        $this->view->assign("statusList", $this->model->getStatusList());
+    }
+
+
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+
+    public function detail(){
+        if ($this->request->isAjax()) {
+            if (!$this->auth->isSuperAdmin()) {
+                $this->error(__('Access is allowed only to the super management group'));
+            }
+            $this->model = model('AuthRule');
+            // 必须将结果集转换为数组
+            $ruleList = \think\Db::name("task_steps")->order('weigh DESC,id ASC')->select();
+            foreach ($ruleList as $k => &$v) {
+                $v['name'] = __($v['name']);
+            }
+            unset($v);
+            Tree::instance()->init($ruleList)->icon = ['&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;&nbsp;&nbsp;&nbsp;'];
+            $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name');
+            $list = $this->rulelist;
+            $total = count($this->rulelist);
+            $result = array("total" => $total, "rows" => $list);
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

+ 14 - 0
application/admin/lang/zh-cn/task/steps.php

@@ -0,0 +1,14 @@
+<?php
+
+return [
+    'Id'         => 'ID',
+    'Task_id'    => '任务ID',
+    'Pid'        => '父ID',
+    'Name'       => '名称',
+    'Starttime'  => '开始时间',
+    'Endtime'    => '结束时间',
+    'Createtime' => '创建时间',
+    'Updatetime' => '更新时间',
+    'Status'     => '状态',
+    'Weigh'      => '权重'
+];

+ 57 - 0
application/admin/model/TaskSteps.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class TaskSteps extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'task_steps';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'integer';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'status_text'
+    ];
+    
+
+    protected static function init()
+    {
+        self::afterInsert(function ($row) {
+            $pk = $row->getPk();
+            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+        });
+    }
+
+    
+    public function getStatusList()
+    {
+        return ['30' => __('Status 30')];
+    }
+
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+}

+ 27 - 0
application/admin/validate/TaskSteps.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class TaskSteps extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 57 - 0
application/admin/view/task/steps/add.html

@@ -0,0 +1,57 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Task_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-task_id" data-rule="required" min="0" data-source="task/index" class="form-control selectpage" name="row[task_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pid" data-rule="required" min="0" class="form-control" name="row[pid]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Starttime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-starttime" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[starttime]" type="text" value="{:date('H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Endtime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-endtime" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[endtime]" type="text" value="{:date('H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="30"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">
+        </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-primary btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 57 - 0
application/admin/view/task/steps/edit.html

@@ -0,0 +1,57 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Task_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-task_id" data-rule="required" min="0" data-source="task/task/index" class="form-control selectpage" name="row[task_id]" type="text" value="{$row.task_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pid" data-rule="required" min="0" class="form-control" name="row[pid]" type="number" value="{$row.pid|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Starttime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-start_time" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[start_time]" type="text" value="{$row.start_time}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Endtime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-end_time" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" name="row[end_time]" type="text" value="{$row.end_time}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            
+            <div class="radio">
+            {foreach name="statusList" item="vo"}
+            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label> 
+            {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
+        </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-primary btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/task/steps/index.html

@@ -0,0 +1,35 @@
+<style>
+    .bootstrap-table tr td .text-muted {color:#888;}
+</style>
+<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">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" data-force-refresh="false"><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('auth/rule/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('auth/rule/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('auth/rule/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <div class="dropdown btn-group {:$auth->check('auth/rule/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>
+<!--                        <a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>-->
+                    </div>
+                    <table id="table" class="table table-bordered table-hover"
+                           data-operate-edit="{:$auth->check('auth/rule/edit')}"
+                           data-operate-del="{:$auth->check('auth/rule/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 0 - 0
application/admin/view/device/task/add.html → application/admin/view/task/task/add.html


+ 35 - 0
application/admin/view/task/task/detail.html

@@ -0,0 +1,35 @@
+<style>
+    .bootstrap-table tr td .text-muted {color:#888;}
+</style>
+<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">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" data-force-refresh="false"><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('auth/rule/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('auth/rule/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('auth/rule/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <div class="dropdown btn-group {:$auth->check('auth/rule/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>
+                        <a href="javascript:;" class="btn btn-danger btn-toggle-all"><i class="fa fa-plus"></i> {:__('Toggle all')}</a>
+                    </div>
+                    <table id="table" class="table table-bordered table-hover"
+                           data-operate-edit="{:$auth->check('auth/rule/edit')}"
+                           data-operate-del="{:$auth->check('auth/rule/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 0 - 0
application/admin/view/device/task/edit.html → application/admin/view/task/task/edit.html


+ 0 - 0
application/admin/view/device/task/index.html → application/admin/view/task/task/index.html


+ 52 - 0
application/api/controller/script/Index.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace app\api\controller\script;
+
+use app\admin\model\Device;
+use app\common\controller\Api;
+
+/**
+ * 首页接口
+ */
+class Index extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 首页
+     *
+     */
+    public function index()
+    {
+        $this->success('请求成功');
+    }
+
+    // 保存编号
+    public function saveNumber()
+    {
+        try {
+            if ($this->request->isPost()) {
+                $number = $this->request->post('number');
+                $row = Device::where('number', $number)->find();
+                if ($row) {
+                    $this->error('编号已存在');
+                } else {
+                    $data['number'] = $number;
+                    $data['createtime'] = time();
+                    $data['updatetime'] = time();
+                    $res = Device::insertGetId($data);
+                }
+                if ($res) {
+                    $this->success('保存成功', ['id' => $res]);
+                } else {
+                    $this->error('保存失败');
+                }
+            }
+        } catch (ValidateException $e) {
+            $this->error($e->getMessage());
+        } catch (PDOException $e) {
+            $this->error($e->getMessage());
+        }
+    }
+}

+ 1 - 1
public/assets/js/backend/device/device.js

@@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'group.name', title: __('Group')},
+                        {field: 'group.name', title: __('设备分组')},
                         {field: 'number', title: __('Number')},
                         {field: 'task.name', title: __('任务')},
                         {

+ 0 - 54
public/assets/js/backend/device/task.js

@@ -1,54 +0,0 @@
-define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
-
-    var Controller = {
-        index: function () {
-            // 初始化表格参数配置
-            Table.api.init({
-                extend: {
-                    index_url: 'device/task/index' + location.search,
-                    add_url: 'device/task/add',
-                    edit_url: 'device/task/edit',
-                    del_url: 'device/task/del',
-                    multi_url: 'device/task/multi',
-                    import_url: 'device/task/import',
-                    table: 'task',
-                }
-            });
-
-            var table = $("#table");
-
-            // 初始化表格
-            table.bootstrapTable({
-                url: $.fn.bootstrapTable.defaults.extend.index_url,
-                pk: 'id',
-                sortName: 'id',
-                columns: [
-                    [
-                        {checkbox: true},
-                        {field: 'id', title: __('Id')},
-                        {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
-                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
-                        {field: 'status', title: __('Status'), searchList: {"30":__('Status 30')}, formatter: Table.api.formatter.status},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
-                    ]
-                ]
-            });
-
-            // 为表格绑定事件
-            Table.api.bindevent(table);
-        },
-        add: function () {
-            Controller.api.bindevent();
-        },
-        edit: function () {
-            Controller.api.bindevent();
-        },
-        api: {
-            bindevent: function () {
-                Form.api.bindevent($("form[role=form]"));
-            }
-        }
-    };
-    return Controller;
-});

+ 203 - 0
public/assets/js/backend/task/steps.js

@@ -0,0 +1,203 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'task/steps/index' + location.search,
+                    add_url: 'task/steps/add',
+                    edit_url: 'task/steps/edit',
+                    del_url: 'task/steps/del',
+                    multi_url: 'task/steps/multi',
+                    import_url: 'task/steps/import',
+                    table: 'task_steps',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'weigh',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {field: 'state', checkbox: true,},
+                        {field: 'id', title: 'ID'},
+                        {
+                            field: 'name',
+                            title: __('名称'),
+                            align: 'left',
+                        },
+                        {field: 'start_time', title: __('开始时间'), align: 'left',},
+                        {field: 'end_time', title: __('结束时间'), align: 'left'},
+                        {
+                            field: 'operate',
+                            title: __('Operate'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            formatter: Table.api.formatter.operate
+                        }
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        a:function () {
+        // 初始化表格参数配置
+        Table.api.init({
+            extend: {
+                "index_url": "task/task/detail",
+                "add_url": "auth/rule/add",
+                "edit_url": "auth/rule/edit",
+                "del_url": "auth/rule/del",
+                "multi_url": "auth/rule/multi",
+                "table": "task_steps"
+            }
+        });
+
+        var table = $("#table");
+
+        // 初始化表格
+        table.bootstrapTable({
+            url: $.fn.bootstrapTable.defaults.extend.index_url,
+            sortName: '',
+            escape: false,
+            columns: [
+                [
+                    {field: 'state', checkbox: true,},
+                    {field: 'id', title: 'ID'},
+                    {
+                        field: 'name',
+                        title: __('名称'),
+                        align: 'left',
+                    },
+                    // {field: 'start-time', title: __('开始时间'), align: 'left',},
+                    // {field: 'end-time', title: __('结束时间'), align: 'left'},
+                    {
+                        field: 'operate',
+                        title: __('Operate'),
+                        table: table,
+                        events: Table.api.events.operate,
+                        formatter: Table.api.formatter.operate
+                    }
+                ]
+            ],
+            pagination: false,
+            search: false,
+            commonSearch: false,
+            rowAttributes: function (row, index) {
+                return row.pid == 0 ? {} : {style: "display:none"};
+            }
+        });
+
+        // 为表格绑定事件
+        Table.api.bindevent(table);
+
+        var btnSuccessEvent = function (data, ret) {
+            if ($(this).hasClass("btn-change")) {
+                var index = $(this).data("index");
+                var row = Table.api.getrowbyindex(table, index);
+                row.ismenu = $("i.fa.text-gray", this).length > 0 ? 1 : 0;
+                table.bootstrapTable("updateRow", {index: index, row: row});
+            } else if ($(this).hasClass("btn-delone")) {
+                if ($(this).closest("tr[data-index]").find("a.btn-node-sub.disabled").length > 0) {
+                    $(this).closest("tr[data-index]").remove();
+                } else {
+                    table.bootstrapTable('refresh');
+                }
+            } else if ($(this).hasClass("btn-dragsort")) {
+                table.bootstrapTable('refresh');
+            }
+            Fast.api.refreshmenu();
+            return false;
+        };
+
+        //表格内容渲染前
+        table.on('pre-body.bs.table', function (e, data) {
+            var options = table.bootstrapTable("getOptions");
+            options.escape = true;
+        });
+
+        //当内容渲染完成后
+        table.on('post-body.bs.table', function (e, data) {
+            var options = table.bootstrapTable("getOptions");
+            options.escape = false;
+
+            //点击切换/排序/删除操作后刷新左侧菜单
+            $(".btn-change[data-id],.btn-delone,.btn-dragsort").data("success", btnSuccessEvent);
+
+        });
+
+        table.on('post-body.bs.table', function (e, settings, json, xhr) {
+            //显示隐藏子节点
+            $(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
+                var status = $(this).data("shown") ? true : false;
+                $("a[data-pid='" + $(this).data("id") + "']").each(function () {
+                    $(this).closest("tr").toggle(!status);
+                });
+                if (status) {
+                    $("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
+                }
+                $(this).data("shown", !status);
+                $("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
+                return false;
+            });
+        });
+
+        //隐藏子节点
+        $(document).on("collapse", ".btn-node-sub", function () {
+            if ($("i", this).length > 0) {
+                $("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
+            }
+            $("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
+            $(this).data("shown", false);
+            $(this).closest("tr").toggle(false);
+        });
+
+        //批量删除后的回调
+        $(".toolbar > .btn-del,.toolbar .btn-more~ul>li>a").data("success", function (e) {
+            Fast.api.refreshmenu();
+        });
+
+        //展开隐藏一级
+        $(document.body).on("click", ".btn-toggle", function (e) {
+            $("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
+            var that = this;
+            var show = $("i", that).hasClass("fa-chevron-down");
+            $("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
+            $("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
+            $(".btn-node-sub[data-pid=0]").data("shown", show);
+        });
+
+        //展开隐藏全部
+        $(document.body).on("click", ".btn-toggle-all", function (e) {
+            var that = this;
+            var show = $("i", that).hasClass("fa-plus");
+            $("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
+            $(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
+            $(".btn-node-sub").data("shown", show);
+            $(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
+        });
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 119 - 0
public/assets/js/backend/task/task.js

@@ -0,0 +1,119 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'task/task/index' + location.search,
+                    add_url: 'task/task/add',
+                    edit_url: 'task/task/edit',
+                    del_url: 'task/task/del',
+                    multi_url: 'task/task/multi',
+                    import_url: 'task/task/import',
+                    table: 'task',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {
+                            field: 'name',
+                            title: __('Name'),
+                            operate: 'LIKE',
+                            table: table,
+                            class: 'autocontent',
+                            formatter: Table.api.formatter.content
+                        },
+                        {
+                            field: 'createtime',
+                            title: __('Createtime'),
+                            operate: 'RANGE',
+                            addclass: 'datetimerange',
+                            autocomplete: false,
+                            formatter: Table.api.formatter.datetime
+                        },
+                        {
+                            field: 'updatetime',
+                            title: __('Updatetime'),
+                            operate: 'RANGE',
+                            addclass: 'datetimerange',
+                            autocomplete: false,
+                            formatter: Table.api.formatter.datetime
+                        },
+                        {
+                            field: 'status',
+                            title: __('Status'),
+                            searchList: {"30": __('Status 30')},
+                            formatter: Table.api.formatter.status
+                        },
+                        {
+                            field: 'operate',
+                            title: __('Operate'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            formatter: Table.api.formatter.operate,
+                            buttons: [{
+                                name: 'detail',
+                                text: '详情',
+                                title: '详情',
+                                classname: 'btn btn-xs btn-primary btn-info',
+                                icon: 'fa fa-list',
+                                url: function (data) {
+                                    return 'steps?task_id=' + data.id;
+                                },
+                                callback: function (data) {
+                                    Layer.alert(data.title);
+                                }
+                            }, {
+                                name: 'edit',
+                                text: '编辑',
+                                title: '编辑',
+                                classname: 'btn btn-xs btn-success btn-editone',
+                                icon: 'fa fa-pencil',
+                                url: 'task/task/edit',
+                                callback: function (data) {
+                                    Layer.alert(data.title);
+                                }
+                            }, {
+                                name: 'del',
+                                text: '删除',
+                                title: '删除',
+                                classname: 'btn btn-xs btn-danger btn-delone',
+                                icon: 'fa fa-trash',
+                                url: 'task/task/del',
+                                callback: function (data) {
+                                    Layer.alert(data.title);
+                                }
+                            }]
+                        }
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});