作者 开飞机的舒克

后台大屏管理优化

... ... @@ -27,7 +27,9 @@ class Screen extends Model
protected $append = [
'starttime_text',
'endtime_text',
'is_view_text'
'is_view_text',
'count_time',
'team_info'
];
... ... @@ -69,6 +71,31 @@ class Screen extends Model
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
//倒计时时间
public function getCountTimeAttr($value,$data){
$time = time();
$list = [];
if ($data['starttime']<=$time && $data['endtime']>=$time){
$hour = intval((($data['endtime']-$time)%86400)/3600);
$minute = intval(((($data['endtime']-$time)%86400)%3600)/60);
$second = intval(((($data['endtime']-$time)%86400)%3600)%60);
$list = $hour."时".$minute."分".$second."秒";
}else if ($data['endtime']<=$time){
$list = "00:00:00";
}
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()
{
... ...
... ... @@ -25,13 +25,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'id', title: __('ID')},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'count_time', title: __('倒计时')},
//{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: '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: '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: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
... ...