作者 开飞机的舒克

后台优化

@@ -40,7 +40,7 @@ class Ronda extends Backend @@ -40,7 +40,7 @@ class Ronda extends Backend
40 public function index() 40 public function index()
41 { 41 {
42 //当前是否为关联查询 42 //当前是否为关联查询
43 - $this->relationSearch = false; 43 + $this->relationSearch = true;
44 //设置过滤方法 44 //设置过滤方法
45 $this->request->filter(['strip_tags', 'trim']); 45 $this->request->filter(['strip_tags', 'trim']);
46 if ($this->request->isAjax()) { 46 if ($this->request->isAjax()) {
@@ -51,14 +51,15 @@ class Ronda extends Backend @@ -51,14 +51,15 @@ class Ronda extends Backend
51 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 51 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
52 52
53 $list = $this->model 53 $list = $this->model
54 - 54 + ->with(['campus'])
55 ->where($where) 55 ->where($where)
56 ->order($sort, $order) 56 ->order($sort, $order)
57 ->paginate($limit); 57 ->paginate($limit);
58 58
59 foreach ($list as $row) { 59 foreach ($list as $row) {
60 - $row->visible(['id','title','holdtime']);  
61 - 60 + $row->visible(['id','title','holdtime','images','details']);
  61 + $row->visible(['campus']);
  62 + $row->getRelation('campus')->visible(['title']);
62 } 63 }
63 64
64 $result = array("total" => $list->total(), "rows" => $list->items()); 65 $result = array("total" => $list->total(), "rows" => $list->items());
1 <?php 1 <?php
2 2
3 return [ 3 return [
  4 + 'Campus_id' => '校区id',
4 'Title' => '场次名称', 5 'Title' => '场次名称',
5 'Holdtime' => '举办日期', 6 'Holdtime' => '举办日期',
  7 + 'Images' => '图片',
  8 + 'Details' => '详情',
6 'Createtime' => '创建时间', 9 'Createtime' => '创建时间',
7 - 'Updatetime' => '更新时间' 10 + 'Updatetime' => '更新时间',
  11 + 'Campus.title' => '校区名称'
8 ]; 12 ];
@@ -45,4 +45,8 @@ class Ronda extends Model @@ -45,4 +45,8 @@ class Ronda extends Model
45 } 45 }
46 46
47 47
  48 + public function campus()
  49 + {
  50 + return $this->belongsTo('Campus', 'campus_id', 'id', [], 'LEFT')->setEagerlyType(0);
  51 + }
48 } 52 }
1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 2
3 <div class="form-group"> 3 <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-campus_id" data-rule="required" data-source="campus/index" class="form-control selectpage" data-field="title" name="row[campus_id]" type="text" value="">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
4 <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
5 <div class="col-xs-12 col-sm-8"> 11 <div class="col-xs-12 col-sm-8">
6 <input id="c-title" class="form-control" name="row[title]" type="text"> 12 <input id="c-title" class="form-control" name="row[title]" type="text">
@@ -12,6 +18,26 @@ @@ -12,6 +18,26 @@
12 <input id="c-holdtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[holdtime]" type="text" value="{:date('Y-m-d H:i:s')}"> 18 <input id="c-holdtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[holdtime]" type="text" value="{:date('Y-m-d H:i:s')}">
13 </div> 19 </div>
14 </div> 20 </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <div class="input-group">
  25 + <input id="c-images" class="form-control" size="50" name="row[images]" type="text">
  26 + <div class="input-group-addon no-border no-padding">
  27 + <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  28 + <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  29 + </div>
  30 + <span class="msg-box n-right" for="c-images"></span>
  31 + </div>
  32 + <ul class="row list-inline faupload-preview" id="p-images"></ul>
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
  37 + <div class="col-xs-12 col-sm-8">
  38 + <textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50"></textarea>
  39 + </div>
  40 + </div>
15 <div class="form-group layer-footer"> 41 <div class="form-group layer-footer">
16 <label class="control-label col-xs-12 col-sm-2"></label> 42 <label class="control-label col-xs-12 col-sm-2"></label>
17 <div class="col-xs-12 col-sm-8"> 43 <div class="col-xs-12 col-sm-8">
1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 2
3 <div class="form-group"> 3 <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Campus_id')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-campus_id" data-rule="required" data-source="campus/index" class="form-control selectpage" data-field="title" name="row[campus_id]" type="text" value="{$row.campus_id|htmlentities}">
  7 + </div>
  8 + </div>
  9 + <div class="form-group">
4 <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
5 <div class="col-xs-12 col-sm-8"> 11 <div class="col-xs-12 col-sm-8">
6 <input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}"> 12 <input id="c-title" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
@@ -12,6 +18,26 @@ @@ -12,6 +18,26 @@
12 <input id="c-holdtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[holdtime]" type="text" value="{:$row.holdtime?datetime($row.holdtime):''}"> 18 <input id="c-holdtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[holdtime]" type="text" value="{:$row.holdtime?datetime($row.holdtime):''}">
13 </div> 19 </div>
14 </div> 20 </div>
  21 + <div class="form-group">
  22 + <label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
  23 + <div class="col-xs-12 col-sm-8">
  24 + <div class="input-group">
  25 + <input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
  26 + <div class="input-group-addon no-border no-padding">
  27 + <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  28 + <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  29 + </div>
  30 + <span class="msg-box n-right" for="c-images"></span>
  31 + </div>
  32 + <ul class="row list-inline faupload-preview" id="p-images"></ul>
  33 + </div>
  34 + </div>
  35 + <div class="form-group">
  36 + <label class="control-label col-xs-12 col-sm-2">{:__('Details')}:</label>
  37 + <div class="col-xs-12 col-sm-8">
  38 + <textarea id="c-details" class="form-control editor" rows="5" name="row[details]" cols="50">{$row.details|htmlentities}</textarea>
  39 + </div>
  40 + </div>
15 <div class="form-group layer-footer"> 41 <div class="form-group layer-footer">
16 <label class="control-label col-xs-12 col-sm-2"></label> 42 <label class="control-label col-xs-12 col-sm-2"></label>
17 <div class="col-xs-12 col-sm-8"> 43 <div class="col-xs-12 col-sm-8">
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> 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('ronda/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> 10 <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('ronda/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
11 11
12 -  
13 <div class="dropdown btn-group {:$auth->check('ronda/multi')?'':'hide'}"> 12 <div class="dropdown btn-group {:$auth->check('ronda/multi')?'':'hide'}">
14 <ul class="dropdown-menu text-left" role="menu"> 13 <ul class="dropdown-menu text-left" role="menu">
15 <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> 14 <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>
@@ -22,18 +22,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -22,18 +22,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
22 url: $.fn.bootstrapTable.defaults.extend.index_url, 22 url: $.fn.bootstrapTable.defaults.extend.index_url,
23 pk: 'id', 23 pk: 'id',
24 sortName: 'id', 24 sortName: 'id',
25 - showToggle: false,//浏览模式功能关闭  
26 - showColumns: false,//显示隐藏列功能关闭  
27 - //commonSearch: false, //关闭通用搜索按钮  
28 - showExport: false,//导出功能关闭  
29 - clickToSelect: false, //是否启用点击选中  
30 - dblClickToEdit: false, //是否启用双击编辑  
31 columns: [ 25 columns: [
32 [ 26 [
33 {checkbox: true}, 27 {checkbox: true},
34 {field: 'id', title: __('Id')}, 28 {field: 'id', title: __('Id')},
  29 + {field: 'campus.title', title: __('Campus.title'), operate: 'LIKE'},
35 {field: 'title', title: __('Title'), operate: 'LIKE'}, 30 {field: 'title', title: __('Title'), operate: 'LIKE'},
36 - {field: 'holdtime', title: __('Holdtime'), operate: false,addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'}, 31 + {field: 'holdtime', title: __('Holdtime'), operate: 'LIKE',formatter:Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
  32 + {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
37 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 33 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
38 ] 34 ]
39 ] 35 ]