作者 开飞机的舒克

后台功能修改

... ... @@ -3,10 +3,6 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use app\common\controller\Resource;
use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
* 学生管理
... ... @@ -55,14 +51,18 @@ class Study extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['school', 'team'])
->with(['grade','school','team'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id','avatar','name','gender','birthday','grade_id','school_id','sno','team_id','team_rank','earn_score','phone','unique','barcode']);
$row->visible(['grade']);
$row->getRelation('grade')->visible(['id','name']);
$row->visible(['school']);
$row->getRelation('school')->visible(['title']);
$row->visible(['team']);
$row->getRelation('team')->visible(['title']);
}
... ... @@ -73,8 +73,6 @@ class Study extends Backend
return $this->view->fetch();
}
//导出数据
public function export()
{
... ...
... ... @@ -8,16 +8,18 @@ return [
'Gender 0' => '女',
'Gender 1' => '男',
'Birthday' => '生日',
'Grade' => '班级',
'Grade_id' => '班级',
'School_id' => '学校',
'Sno' => '学号',
'Team_id' => '所属战队',
'Team_rank' => '战队内排名',
'Earn_score' => '总积分',
'Phone' => '手机号',
'Unique' => '手环ID',
'Barcode' => '条形码',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Grade.name' => '班级名称',
'School.title' => '校区名称',
'Team.title' => '战队昵称'
];
... ...
... ... @@ -46,6 +46,12 @@ class Study extends Model
public function grade()
{
return $this->belongsTo('Grade', 'grade_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function school()
{
return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);
... ...
... ... @@ -37,9 +37,9 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-grade" class="form-control" name="row[grade]" type="text">
<input id="c-grade_id" data-rule="required" data-source="grade/index" class="form-control selectpage" name="row[grade_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -38,9 +38,9 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-grade" class="form-control" name="row[grade]" type="text" value="{$row.grade|htmlentities}">
<input id="c-grade_id" data-rule="required" data-source="grade/index" class="form-control selectpage" name="row[grade_id]" type="text" value="{$row.grade_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -89,8 +89,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'phone', title: __('Phone'), operate: 'LIKE'},
{field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
{field: 'team_rank', title: __('Team_rank')},
{field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
{field: 'grade', title: __('Grade'), operate: 'LIKE'},
{field: 'grade.name', title: __('Grade.name'), operate: 'LIKE'},
{field: 'school.title', title: __('School.title'), operate: 'LIKE'},
{field: 'sno', title: __('Sno'), operate: 'LIKE'},
// {field: 'team_id', title: __('Team_id')},
... ...