作者 开飞机的舒克

后台修改

<?php
return [
'Title' => '名称',
'Radar_id' => '所属维度',
'User_id' => '所属老师',
'Score' => '积分',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
'Campus_id' => '所属校区',
'Ronda_id' => '场次',
'Title' => '名称',
'Radar_id' => '所属维度',
'User_id' => '所属老师',
'Details' => '详情',
'Score' => '积分',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'User.username' => '用户名',
'User.teach_phone' => '老师手机号',
'Ronda.title' => '场次名称',
'Radar.title' => '维度名称',
'Campus.title' => '校区名称'
];
... ...
... ... @@ -25,9 +25,9 @@ class Team extends Model
// 追加属性
protected $append = [
'rank_text'
];
protected static function init()
{
... ... @@ -37,6 +37,17 @@ class Team extends Model
});
}
public function getRankTextAttr($value,$data){
$list = $this->order('score','desc')->column('id');
$value = 0;
foreach ($list as $k => $v){
if ($data['id'] == $v){
$value = $k+1;
break;
}
}
return $value;
}
... ...
... ... @@ -95,23 +95,19 @@ class Activity extends Api
*/
public function getItemRonda()
{
$row = $this->request->param('row');
$page = $this->request->param('page');
$row = $row ? $row : 10;
$page = $page ? $page : 1;
$id = $this->request->param('id');
if (empty($id)) {
$this->error('参数错误', ['status' => 2]);
}
$data = db('item_ronda_rel')
->field('campus_id,ronda_id,item_id')
->where('campus_id',$id)
->paginate($row,false,['page'=>$page])
$data = db('item i')
->join('item_details d','d.item_id = i.id')
->join('ronda r','i.ronda_id = r.id')
->join('campus c','c.id = i.campus_id')
->field('c.title as campus_title,i.campus_id,i.ronda_id,i.title,i.details,d.images,r.title as ronda_title,r.holdtime as ronda_holdtime')
->where('i.campus_id',$id)
->paginate(10)
->each(function ($item,$key){
$item['ronda'] = db('ronda')->where('id',$item['ronda_id'])->field('title,holdtime')->find();
$item['item'] = db('item')->where('id',$item['item_id'])->value('title');
$item['item_details'] = db('item_details')->where('item_id',$item['item_id'])->field('images,details')->find();
$item['item_details']['images'] = cdnurl($item['item_details']['images'], true);
$item['images'] = cdnurl($item['images'],true);
return $item;
});
$this->success('项目场次日期', $data);
... ... @@ -138,8 +134,11 @@ class Activity extends Api
public function getItemDetails()
{
$id = $this->request->param('id');
$data = db('item_details')
->where('item_id', $id)
$data = db('item i')
->join('item_details d','d.item_id = i.id')
->join('campus c','c.id = i.campus_id')
->field('c.title as campus_title,d.images,i.details')
->where('i.id', $id)
->find();
$data['images'] = cdnurl($data['images'], true);
$this->success('', $data);
... ...
... ... @@ -157,8 +157,7 @@ class Bind extends Api
$this->error('参数错误', ['status' => 2]);
}
$study = db('study')->where('unique', $unique)->field('id,grade,name,sno,team_id,earn_score')->find();
$rel = \db('item_ronda_rel')->where('item_id', $items_id)->find();
$item = db('item')->where('id', $rel['item_id'])->field('score,title')->find();
$item = db('item')->where('id', $items_id)->field('score,title,campus_id')->find();
$team = \db('team')->where('id', $study['team_id'])->field('title,score')->find();
$sum1 = $team['score'] + $item['score']; //合计战队总分
$sum2 = $study['earn_score'] + $item['score']; //合计个人总分
... ... @@ -166,7 +165,7 @@ class Bind extends Api
try {
db('study_score_log')->insert([
'item_id' => $items_id,
'campus_id' => $rel['campus_id'],
'campus_id' => $item['campus_id'],
'study_id' => $study['id'],
'team_id' => $study['team_id'],
'score' => $item['score'],
... ...
此 diff 太大无法显示。
... ... @@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'id', title: __('Id')},
{field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'score', title: __('Score'), operate:'BETWEEN'},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'rank_text', title: __('排名'), operate: false},
//{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
// {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}
... ...