作者 开飞机的舒克

后台大屏优化

... ... @@ -2,7 +2,9 @@
namespace app\admin\controller;
use app\admin\model\item\ronda\Rel;
use app\common\controller\Backend;
use mysql_xdevapi\DocResult;
/**
* 数据大屏管理
... ... @@ -69,4 +71,72 @@ class Screen extends Backend
return $this->view->fetch();
}
public function details($ids)
{
$row = $this->model->get(['id'=>$ids]);
if (!$row) {
$this->error(__('No Results were found'));
}
if ($this->request->isAjax()) {
$this->success("Ajax请求成功", null, ['id' => $ids]);
}
$data = $row->toArray();
$res = db('study_score_log l')
->join('team t','l.team_id = t.id')
->where('campus_id',$data['campus_id'])
->field('l.team_id,sum(l.score) as sum_score,t.title')
->group('l.team_id')
->order('sum_score','desc')
->select();
$list = [];
// foreach ($res as $k1){
// foreach ($k1 as $k2 => $v){
//// dump($k2);
//// dump($v);
// $list['title'] = $v;
// $list['score'] = $v;
// }
// }
foreach ($res as $k => $v){
$list['title'] = $v['title'];
$list['score'] = $v['sum_score'];
}
//dump($list);
$this->view->assign("row", $list);
return $this->view->fetch();
}
public function detail($ids)
{
$row = $this->model->get(['id'=>$ids]);
if (!$row) {
$this->error(__('No Results were found'));
}
if ($this->request->isAjax()) {
$this->success("Ajax请求成功", null, ['id' => $ids]);
}
$data = $row->toArray();
$res = db('study_score_log l')
->join('study s','l.study_id = s.id')
->where('campus_id',$data['campus_id'])
->field('l.team_id,sum(l.score) as sum_score,s.name')
->group('l.study_id')
->order('sum_score','desc')
->select();
$list = [];
// foreach ($res as $k1){
// foreach ($k1 as $k2 => $v){
//// dump($k2);
//// dump($v);
// $list['title'] = $v;
// $list['score'] = $v;
// }
// }
foreach ($res as $k => $v){
$list['name'] = $v['name'];
$list['score'] = $v['sum_score'];
}
//dump($list);
$this->view->assign("row", $list);
return $this->view->fetch();
}
}
... ...
... ... @@ -29,7 +29,6 @@ class Screen extends Model
'endtime_text',
'is_view_text',
'count_time',
'team_info'
];
... ... @@ -87,14 +86,14 @@ class Screen extends Model
}
//战队信息
public function getTeamInfoAttr($value,$data){
$list = [];
$value = db('study_score_log')->where('campus_id',$data['campus_id'])->field('team_id')->select();
foreach ($value as $k => $v){
$list = db('team')->where('id',$value[$k]['team_id'])->field('title,score')->find();
}
return $list;
}
// public function getTeamInfoAttr($value,$data){
// $list = [];
// $value = db('study_score_log')->where('campus_id',$data['campus_id'])->field('team_id')->select();
// foreach ($value as $k => $v){
// $list = db('team')->where('id',$value[$k]['team_id'])->field('title,score')->find();
// }
// return $list;
// }
public function campus()
... ...
<table class="table table-striped">
<thead>
<tr>
<th>{:__('个人名称')}</th>
<th>{:__('个人票数')}</th>
</tr>
</thead>
<tbody>
{/*{volist name="row" id="vo"&cc;
<tr>
<td>{$key&cc;</td>
<td style="word-break: break-all;">{$vo|htmlentities&cc;</td>
</tr>
{/volist&cc;*/}
<tr>
<td>{$row.name}</td>
<td style="word-break: break-all;">{$row.score}</td>
</tr>
</tbody>
</table>
<div class="hide layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
</div>
</div>
... ...
<table class="table table-striped">
<thead>
<tr>
<th>{:__('战队名称')}</th>
<th>{:__('战队票数')}</th>
</tr>
</thead>
<tbody>
{/*{volist name="row" id="vo"&cc;
<tr>
<td>{$key&cc;</td>
<td style="word-break: break-all;">{$vo|htmlentities&cc;</td>
</tr>
{/volist&cc;*/}
<tr>
<td>{$row.title}</td>
<td style="word-break: break-all;">{$row.score}</td>
</tr>
</tbody>
</table>
<div class="hide layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="reset" class="btn btn-primary btn-embossed btn-close" onclick="Layer.closeAll();">{:__('Close')}</button>
</div>
</div>
... ...
... ... @@ -57,27 +57,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'user.teach_phone', title: __('User.teach_phone'), operate: false},
{field: 'radar.title', title: __('Radar.title'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'buttons',
width: "120px",
title: __('按钮组'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text: __('弹出窗口打开'),
title: __('弹出窗口打开'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'study_score_log/add',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
}
],
formatter: Table.api.formatter.buttons
},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...
... ... @@ -37,10 +37,41 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
//{field: 'campus_id', title: __('Campus_id')},
{field: 'campus.title', title: __('Campus.title'), operate: 'LIKE'},
{field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'team_info', title: __('战队排行榜')},
//{field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//{field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'is_view', title: __('Is_view'), searchList: {"0":__('Is_view 0'),"1":__('Is_view 1')},formatter:Table.api.formatter.toggle},
{
field: 'buttons',
width: "120px",
title: __('按钮组'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'details',
text: __('战队排行榜'),
title: __('战队排行榜'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'screen/details',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
},
{
name: 'detail',
text: __('个人排行榜'),
title: __('个人排行榜'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'screen/detail',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
}
],
formatter: Table.api.formatter.buttons
},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...