作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

后台消息管理

  1 +<?php
  2 +
  3 +namespace app\admin\controller\mobile;
  4 +
  5 +use app\common\controller\Backend;
  6 +
  7 +/**
  8 + * 消息管理
  9 + *
  10 + * @icon fa fa-circle-o
  11 + */
  12 +class Message extends Backend
  13 +{
  14 +
  15 + /**
  16 + * Message模型对象
  17 + * @var \app\admin\model\mobile\Message
  18 + */
  19 + protected $model = null;
  20 +
  21 + public function _initialize()
  22 + {
  23 + parent::_initialize();
  24 + $this->model = new \app\admin\model\mobile\Message;
  25 + $this->view->assign("isReadList", $this->model->getIsReadList());
  26 + }
  27 +
  28 + /**
  29 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  30 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  31 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  32 + */
  33 +
  34 +
  35 + /**
  36 + * 查看
  37 + */
  38 + public function index()
  39 + {
  40 + //当前是否为关联查询
  41 + $this->relationSearch = true;
  42 + //设置过滤方法
  43 + $this->request->filter(['strip_tags', 'trim']);
  44 + if ($this->request->isAjax())
  45 + {
  46 + //如果发送的来源是Selectpage,则转发到Selectpage
  47 + if ($this->request->request('keyField'))
  48 + {
  49 + return $this->selectpage();
  50 + }
  51 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  52 + $total = $this->model
  53 + ->with(['user'])
  54 + ->where('message_admin_id',$this->request->request('message_admin_id'))
  55 + ->where($where)
  56 + ->order($sort, $order)
  57 + ->count();
  58 +
  59 + $list = $this->model
  60 + ->with(['user'])
  61 + ->where('message_admin_id',$this->request->request('message_admin_id'))
  62 + ->where($where)
  63 + ->order($sort, $order)
  64 + ->limit($offset, $limit)
  65 + ->select();
  66 +
  67 + foreach ($list as $row) {
  68 + $row->visible(['id','user_id','title','is_read','createtime']);
  69 + $row->visible(['user']);
  70 + $row->getRelation('user')->visible(['nickname']);
  71 + }
  72 + $list = collection($list)->toArray();
  73 + $result = array("total" => $total, "rows" => $list);
  74 +
  75 + return json($result);
  76 + }
  77 + return $this->view->fetch();
  78 + }
  79 +}
  1 +<?php
  2 +
  3 +namespace app\admin\controller\mobile;
  4 +
  5 +use app\common\controller\Backend;
  6 +use think\Db;
  7 +
  8 +/**
  9 + * 后台消息管理
  10 + *
  11 + * @icon fa fa-circle-o
  12 + */
  13 +class MessageAdmin extends Backend
  14 +{
  15 +
  16 + /**
  17 + * MessageAdmin模型对象
  18 + * @var \app\admin\model\mobile\MessageAdmin
  19 + */
  20 + protected $model = null;
  21 +
  22 + public function _initialize()
  23 + {
  24 + parent::_initialize();
  25 + $this->model = new \app\admin\model\mobile\MessageAdmin;
  26 +
  27 + }
  28 +
  29 + /**
  30 + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  31 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  32 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  33 + */
  34 +
  35 +
  36 + /**
  37 + * 查看
  38 + */
  39 + public function index()
  40 + {
  41 + //当前是否为关联查询
  42 + $this->relationSearch = false;
  43 + //设置过滤方法
  44 + $this->request->filter(['strip_tags', 'trim']);
  45 + if ($this->request->isAjax())
  46 + {
  47 + //如果发送的来源是Selectpage,则转发到Selectpage
  48 + if ($this->request->request('keyField'))
  49 + {
  50 + return $this->selectpage();
  51 + }
  52 + list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  53 + $total = $this->model
  54 +
  55 + ->where($where)
  56 + ->order($sort, $order)
  57 + ->count();
  58 +
  59 + $list = $this->model
  60 +
  61 + ->where($where)
  62 + ->order($sort, $order)
  63 + ->limit($offset, $limit)
  64 + ->select();
  65 +
  66 + foreach ($list as $row) {
  67 + $row->visible(['id','title','createtime']);
  68 +
  69 + }
  70 + $list = collection($list)->toArray();
  71 + $result = array("total" => $total, "rows" => $list);
  72 +
  73 + return json($result);
  74 + }
  75 + return $this->view->fetch();
  76 + }
  77 +
  78 + /**
  79 + * 添加
  80 + */
  81 + public function add()
  82 + {
  83 + if ($this->request->isPost()) {
  84 + $params = $this->request->post("row/a");
  85 + if ($params) {
  86 + $params = $this->preExcludeFields($params);
  87 +
  88 + if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
  89 + $params[$this->dataLimitField] = $this->auth->id;
  90 + }
  91 + $result = false;
  92 + Db::startTrans();
  93 + try {
  94 + //是否采用模型验证
  95 + if ($this->modelValidate) {
  96 + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
  97 + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
  98 + $this->model->validateFailException(true)->validate($validate);
  99 + }
  100 + if($params['register_time']){
  101 + $register_time = str_replace(' - ', ',', $params['register_time']);
  102 + $arr = array_slice(explode(',', $register_time), 0, 2);
  103 + $where['createtime'] = ['between time',$arr];
  104 + }
  105 + if($params['group_id'] != 'all'){
  106 + $where['group_id'] = $params['group_id'];
  107 + }
  108 + $user_id_arr = \app\admin\model\User::where($where)->column('id');
  109 + if(!$user_id_arr){
  110 + $this->error('未查询到用户');
  111 + }
  112 + $result = $this->model->allowField(true)->save($params);
  113 + if($user_id_arr){
  114 + $message = [];
  115 + foreach ($user_id_arr as $user_id){
  116 + $message[] = [
  117 + 'message_admin_id' => $this->model['id'],
  118 + 'user_id' => $user_id,
  119 + 'title' => $this->model['title'],
  120 + 'content' => $this->model['content'],
  121 + ];
  122 + }
  123 + (new \app\admin\model\mobile\Message)->saveAll($message);
  124 + }
  125 + Db::commit();
  126 + } catch (ValidateException $e) {
  127 + Db::rollback();
  128 + $this->error($e->getMessage());
  129 + } catch (PDOException $e) {
  130 + Db::rollback();
  131 + $this->error($e->getMessage());
  132 + } catch (Exception $e) {
  133 + Db::rollback();
  134 + $this->error($e->getMessage());
  135 + }
  136 + if ($result !== false) {
  137 + $this->success();
  138 + } else {
  139 + $this->error(__('No rows were inserted'));
  140 + }
  141 + }
  142 + $this->error(__('Parameter %s can not be empty', ''));
  143 + }
  144 + return $this->view->fetch();
  145 + }
  146 +
  147 + /**
  148 + * 订单详情
  149 + */
  150 + public function info($ids = null)
  151 + {
  152 + $info = $this->model->get($ids);
  153 + if (!$info) {
  154 + $this->error(__('No Results were found'));
  155 + }
  156 + $this->view->assign("row", $info);
  157 + return $this->view->fetch();
  158 + }
  159 +
  160 + /**
  161 + * 删除
  162 + */
  163 + public function del($ids = "")
  164 + {
  165 + if (!$this->request->isPost()) {
  166 + $this->error(__("Invalid parameters"));
  167 + }
  168 + $ids = $ids ? $ids : $this->request->post("ids");
  169 + if ($ids) {
  170 + $pk = $this->model->getPk();
  171 + $adminIds = $this->getDataLimitAdminIds();
  172 + if (is_array($adminIds)) {
  173 + $this->model->where($this->dataLimitField, 'in', $adminIds);
  174 + }
  175 + $list = $this->model->where($pk, 'in', $ids)->select();
  176 +
  177 + $count = 0;
  178 + Db::startTrans();
  179 + try {
  180 + $message_model = new \app\admin\model\mobile\Message;
  181 + foreach ($list as $k => $v) {
  182 + $message_model->where('message_admin_id',$v['id'])->delete();
  183 + $count += $v->delete();
  184 + }
  185 + Db::commit();
  186 + } catch (PDOException $e) {
  187 + Db::rollback();
  188 + $this->error($e->getMessage());
  189 + } catch (Exception $e) {
  190 + Db::rollback();
  191 + $this->error($e->getMessage());
  192 + }
  193 + if ($count) {
  194 + $this->success();
  195 + } else {
  196 + $this->error(__('No rows were deleted'));
  197 + }
  198 + }
  199 + $this->error(__('Parameter %s can not be empty', 'ids'));
  200 + }
  201 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => 'ID',
  5 + 'Message_admin_id' => '后台消息ID',
  6 + 'User_id' => '用户ID',
  7 + 'Title' => '标题',
  8 + 'Content' => '内容',
  9 + 'Is_read' => '是否已读',
  10 + 'Is_read 0' => '否',
  11 + 'Is_read 1' => '是',
  12 + 'Createtime' => '创建时间',
  13 + 'Updatetime' => '更新时间',
  14 + 'User.nickname' => '昵称'
  15 +];
  1 +<?php
  2 +
  3 +return [
  4 + 'Id' => 'ID',
  5 + 'Title' => '标题',
  6 + 'Content' => '内容',
  7 + 'Createtime' => '创建时间',
  8 + 'Updatetime' => '更新时间'
  9 +];
  1 +<?php
  2 +
  3 +namespace app\admin\model\mobile;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class Message extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'mobile_message';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'int';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 + 'is_read_text'
  29 + ];
  30 +
  31 +
  32 +
  33 + public function getIsReadList()
  34 + {
  35 + return ['0' => __('Is_read 0'), '1' => __('Is_read 1')];
  36 + }
  37 +
  38 +
  39 + public function getIsReadTextAttr($value, $data)
  40 + {
  41 + $value = $value ? $value : (isset($data['is_read']) ? $data['is_read'] : '');
  42 + $list = $this->getIsReadList();
  43 + return isset($list[$value]) ? $list[$value] : '';
  44 + }
  45 +
  46 +
  47 +
  48 +
  49 + public function user()
  50 + {
  51 + return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  52 + }
  53 +}
  1 +<?php
  2 +
  3 +namespace app\admin\model\mobile;
  4 +
  5 +use think\Model;
  6 +
  7 +
  8 +class MessageAdmin extends Model
  9 +{
  10 +
  11 +
  12 +
  13 +
  14 +
  15 + // 表名
  16 + protected $name = 'mobile_message_admin';
  17 +
  18 + // 自动写入时间戳字段
  19 + protected $autoWriteTimestamp = 'int';
  20 +
  21 + // 定义时间戳字段名
  22 + protected $createTime = 'createtime';
  23 + protected $updateTime = 'updatetime';
  24 + protected $deleteTime = false;
  25 +
  26 + // 追加属性
  27 + protected $append = [
  28 +
  29 + ];
  30 +
  31 +
  32 +
  33 +
  34 +
  35 +
  36 +
  37 +
  38 +
  39 +
  40 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate\mobile;
  4 +
  5 +use think\Validate;
  6 +
  7 +class Message extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<?php
  2 +
  3 +namespace app\admin\validate\mobile;
  4 +
  5 +use think\Validate;
  6 +
  7 +class MessageAdmin extends Validate
  8 +{
  9 + /**
  10 + * 验证规则
  11 + */
  12 + protected $rule = [
  13 + ];
  14 + /**
  15 + * 提示消息
  16 + */
  17 + protected $message = [
  18 + ];
  19 + /**
  20 + * 验证场景
  21 + */
  22 + protected $scene = [
  23 + 'add' => [],
  24 + 'edit' => [],
  25 + ];
  26 +
  27 +}
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Message_admin_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-message_admin_id" data-rule="required" data-source="message/admin/index" class="form-control selectpage" name="row[message_admin_id]" type="text" value="">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_read')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 +
  31 + <select id="c-is_read" data-rule="required" class="form-control selectpicker" name="row[is_read]">
  32 + {foreach name="isReadList" item="vo"}
  33 + <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
  34 + {/foreach}
  35 + </select>
  36 +
  37 + </div>
  38 + </div>
  39 + <div class="form-group layer-footer">
  40 + <label class="control-label col-xs-12 col-sm-2"></label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  43 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  44 + </div>
  45 + </div>
  46 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Message_admin_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-message_admin_id" data-rule="required" data-source="message/admin/index" class="form-control selectpage" name="row[message_admin_id]" type="text" value="{$row.message_admin_id|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
  13 + </div>
  14 + </div>
  15 + <div class="form-group">
  16 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_read')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 +
  31 + <select id="c-is_read" data-rule="required" class="form-control selectpicker" name="row[is_read]">
  32 + {foreach name="isReadList" item="vo"}
  33 + <option value="{$key}" {in name="key" value="$row.is_read"}selected{/in}>{$vo}</option>
  34 + {/foreach}
  35 + </select>
  36 +
  37 + </div>
  38 + </div>
  39 + <div class="form-group layer-footer">
  40 + <label class="control-label col-xs-12 col-sm-2"></label>
  41 + <div class="col-xs-12 col-sm-8">
  42 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  43 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  44 + </div>
  45 + </div>
  46 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 +<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('mobile/message/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
  11 +<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('mobile/message/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
  12 +<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('mobile/message/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
  13 +
  14 +
  15 + </div>
  16 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  17 + data-operate-edit="{:$auth->check('mobile/message/edit')}"
  18 + data-operate-del="{:$auth->check('mobile/message/del')}"
  19 + width="100%">
  20 + </table>
  21 + </div>
  22 + </div>
  23 +
  24 + </div>
  25 + </div>
  26 +</div>
  1 +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('注册时间')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-register_time" class="form-control datetimerange" name="row[register_time]" type="text">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('用户角色')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 +
  13 + <select id="c-group_id" data-rule="required" class="form-control selectpicker" name="row[group_id]">
  14 + <option value="all" selected>全部</option>
  15 + <option value="0">普通用户</option>
  16 + <option value="1">企业管理员</option>
  17 + </select>
  18 +
  19 + </div>
  20 + </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
  25 + </div>
  26 + </div>
  27 + <div class="form-group">
  28 + <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
  29 + <div class="col-xs-12 col-sm-8">
  30 + <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
  31 + </div>
  32 + </div>
  33 + <div class="form-group layer-footer">
  34 + <label class="control-label col-xs-12 col-sm-2"></label>
  35 + <div class="col-xs-12 col-sm-8">
  36 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  37 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  38 + </div>
  39 + </div>
  40 +</form>
  1 +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2 +
  3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
  10 + <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
  11 + <div class="col-xs-12 col-sm-8">
  12 + <textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
  13 + </div>
  14 + </div>
  15 + <div class="form-group layer-footer">
  16 + <label class="control-label col-xs-12 col-sm-2"></label>
  17 + <div class="col-xs-12 col-sm-8">
  18 + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
  19 + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  20 + </div>
  21 + </div>
  22 +</form>
  1 +<div class="panel panel-default panel-intro">
  2 + {:build_heading()}
  3 +
  4 + <div class="panel-body">
  5 + <div id="myTabContent" class="tab-content">
  6 + <div class="tab-pane fade active in" id="one">
  7 + <div class="widget-body no-padding">
  8 + <div id="toolbar" class="toolbar">
  9 + <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
  10 + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('mobile/message_admin/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
  11 +<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('mobile/message_admin/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
  12 + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('mobile/message_admin/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
  13 +
  14 +
  15 + </div>
  16 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  17 + data-operate-edit="false"
  18 + data-operate-del="{:$auth->check('mobile/message_admin/del')}"
  19 + width="100%">
  20 + </table>
  21 + </div>
  22 + </div>
  23 +
  24 + </div>
  25 + </div>
  26 +</div>
  1 +<div class="ibox-content order-info">
  2 +
  3 + <div class="row">
  4 + <div class="col-sm-12">
  5 + <div class="panel panel-default">
  6 + <div class="panel-heading">
  7 + 标题
  8 + </div>
  9 + <div class="panel-body">
  10 + <div class="row show-grid">
  11 + <div class="col-xs-12" >{$row.title}</div>
  12 + </div>
  13 + </div>
  14 + </div>
  15 + </div>
  16 + <div class="col-sm-12">
  17 + <div class="panel panel-default">
  18 + <div class="panel-heading">
  19 + 内容
  20 + </div>
  21 + <div class="panel-body">
  22 + <div class="row show-grid">
  23 + <div class="col-xs-12" >{$row.content}</div>
  24 + </div>
  25 + </div>
  26 + </div>
  27 + </div>
  28 + </div>
  29 +</div>
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'mobile/message/index' + location.search,
  9 + add_url: 'mobile/message/add',
  10 + edit_url: 'mobile/message/edit',
  11 + del_url: 'mobile/message/del',
  12 + multi_url: 'mobile/message/multi',
  13 + table: 'mobile_message',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id')},
  28 + {field: 'user.nickname', title: __('用户')},
  29 + {field: 'title', title: __('Title')},
  30 + {field: 'is_read', title: __('Is_read'), searchList: {"0":__('Is_read 0'),"1":__('Is_read 1')}, formatter: Table.api.formatter.normal},
  31 + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  32 + // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  33 + ]
  34 + ]
  35 + });
  36 +
  37 + // 为表格绑定事件
  38 + Table.api.bindevent(table);
  39 + },
  40 + add: function () {
  41 + Controller.api.bindevent();
  42 + },
  43 + edit: function () {
  44 + Controller.api.bindevent();
  45 + },
  46 + api: {
  47 + bindevent: function () {
  48 + Form.api.bindevent($("form[role=form]"));
  49 + }
  50 + }
  51 + };
  52 + return Controller;
  53 +});
  1 +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2 +
  3 + var Controller = {
  4 + index: function () {
  5 + // 初始化表格参数配置
  6 + Table.api.init({
  7 + extend: {
  8 + index_url: 'mobile/message_admin/index' + location.search,
  9 + add_url: 'mobile/message_admin/add',
  10 + edit_url: 'mobile/message_admin/edit',
  11 + del_url: 'mobile/message_admin/del',
  12 + multi_url: 'mobile/message_admin/multi',
  13 + table: 'mobile_message_admin',
  14 + }
  15 + });
  16 +
  17 + var table = $("#table");
  18 +
  19 + // 初始化表格
  20 + table.bootstrapTable({
  21 + url: $.fn.bootstrapTable.defaults.extend.index_url,
  22 + pk: 'id',
  23 + sortName: 'id',
  24 + columns: [
  25 + [
  26 + {checkbox: true},
  27 + {field: 'id', title: __('Id')},
  28 + {field: 'title', title: __('Title')},
  29 + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  30 + //操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
  31 + {
  32 + field: 'operate',
  33 + title: __('Operate'),
  34 + table: table,
  35 + events: Table.api.events.operate,
  36 + buttons: [
  37 + {
  38 + name: 'info',
  39 + text: __('查看详情'),
  40 + title: __('查看详情'),
  41 + classname: 'btn btn-xs btn-info btn-dialog',
  42 + icon: 'fa fa-book',
  43 + url: 'mobile/message_admin/info?order_id={id}'
  44 + },
  45 + {
  46 + text: '发送用户',
  47 + title: '发送用户',
  48 + classname: 'btn btn-xs btn-primary btn-dialog',
  49 + icon: 'fa fa-list',
  50 + url: 'mobile/message?message_admin_id={id}',
  51 + }
  52 + ],
  53 + formatter: Table.api.formatter.operate
  54 + }
  55 + ]
  56 + ]
  57 + });
  58 +
  59 + // 为表格绑定事件
  60 + Table.api.bindevent(table);
  61 + },
  62 + add: function () {
  63 + Controller.api.bindevent();
  64 + },
  65 + edit: function () {
  66 + Controller.api.bindevent();
  67 + },
  68 + api: {
  69 + bindevent: function () {
  70 + Form.api.bindevent($("form[role=form]"));
  71 + }
  72 + }
  73 + };
  74 + return Controller;
  75 +});