作者 开飞机的舒克

后台大屏管理优化

@@ -27,7 +27,9 @@ class Screen extends Model @@ -27,7 +27,9 @@ class Screen extends Model
27 protected $append = [ 27 protected $append = [
28 'starttime_text', 28 'starttime_text',
29 'endtime_text', 29 'endtime_text',
30 - 'is_view_text' 30 + 'is_view_text',
  31 + 'count_time',
  32 + 'team_info'
31 ]; 33 ];
32 34
33 35
@@ -69,6 +71,31 @@ class Screen extends Model @@ -69,6 +71,31 @@ class Screen extends Model
69 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); 71 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
70 } 72 }
71 73
  74 + //倒计时时间
  75 + public function getCountTimeAttr($value,$data){
  76 + $time = time();
  77 + $list = [];
  78 + if ($data['starttime']<=$time && $data['endtime']>=$time){
  79 + $hour = intval((($data['endtime']-$time)%86400)/3600);
  80 + $minute = intval(((($data['endtime']-$time)%86400)%3600)/60);
  81 + $second = intval(((($data['endtime']-$time)%86400)%3600)%60);
  82 + $list = $hour."时".$minute."分".$second."秒";
  83 + }else if ($data['endtime']<=$time){
  84 + $list = "00:00:00";
  85 + }
  86 + return $list;
  87 + }
  88 +
  89 + //战队信息
  90 + public function getTeamInfoAttr($value,$data){
  91 + $list = [];
  92 + $value = db('study_score_log')->where('campus_id',$data['campus_id'])->field('team_id')->select();
  93 + foreach ($value as $k => $v){
  94 + $list = db('team')->where('id',$value[$k]['team_id'])->field('title,score')->find();
  95 + }
  96 + return $list;
  97 + }
  98 +
72 99
73 public function campus() 100 public function campus()
74 { 101 {
@@ -25,13 +25,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -25,13 +25,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
25 columns: [ 25 columns: [
26 [ 26 [
27 {checkbox: true}, 27 {checkbox: true},
28 - {field: 'id', title: __('Id')}, 28 + {field: 'id', title: __('ID')},
29 {field: 'title', title: __('Title'), operate: 'LIKE'}, 29 {field: 'title', title: __('Title'), operate: 'LIKE'},
  30 + {field: 'count_time', title: __('倒计时')},
30 //{field: 'campus_id', title: __('Campus_id')}, 31 //{field: 'campus_id', title: __('Campus_id')},
31 {field: 'campus.title', title: __('Campus.title'), operate: 'LIKE'}, 32 {field: 'campus.title', title: __('Campus.title'), operate: 'LIKE'},
32 {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, 33 {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
33 - {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},  
34 - {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, 34 + {field: 'team_info', title: __('战队排行榜')},
  35 + //{field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36 + //{field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
35 {field: 'is_view', title: __('Is_view'), searchList: {"0":__('Is_view 0'),"1":__('Is_view 1')},formatter:Table.api.formatter.toggle}, 37 {field: 'is_view', title: __('Is_view'), searchList: {"0":__('Is_view 0'),"1":__('Is_view 1')},formatter:Table.api.formatter.toggle},
36 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 38 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
37 ] 39 ]