作者 开飞机的舒克

学校班级手动输入

... ... @@ -33,6 +33,8 @@ class Study extends Backend
* @var \app\admin\model\Study
*/
protected $model = null;
protected $modelValidate = true; //开启validate,验证默认是fasle
public function _initialize()
{
... ... @@ -74,17 +76,13 @@ class Study extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['grade','school','team'])
->with(['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(['id','avatar','name','gender','birthday','grade','school','sno','team_id','team_rank','earn_score','phone','unique','barcode']);
$row->visible(['team']);
$row->getRelation('team')->visible(['title']);
}
... ... @@ -215,8 +213,7 @@ class Study extends Backend
$id = $this->model->id;
$unique = time();
$barpath = Resource::StudyBar($unique);
$time = date('YmdHi',time());
$this->model->save(['barcode'=>$barpath,'sno'=>$time,'unique'=>time()],['id'=>$id]);
$this->model->save(['barcode'=>$barpath,'unique'=>time()],['id'=>$id]);
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
... ...
<?php
return [
'Title' => '活动标题',
'Campus_id' => '校区id',
'Images' => '背景图',
'Starttime' => '开始时间',
'Endtime' => '结束时间',
'Is_view' => '是否显示',
'Is_view 0' => '否',
'Is_view 1' => '是',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
];
<?php
return [
'Name' => '班级名称',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
];
... ... @@ -19,8 +19,8 @@ return [
'Barcode' => '条形码',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Grade.name' => '班级名称',
'School.title' => '学校名称',
'Grade' => '班级名称',
'School' => '学校名称',
'Team.title' => '所属战队',
'Download' => '批量下载'
];
... ...
... ... @@ -10,21 +10,24 @@ class Study extends Validate
* 验证规则
*/
protected $rule = [
'name'=>'require|/^[\u4e00-\u9fa5]{2,4}$/'
'name'=>'require|max:10',
'phone'=>'max:11',
];
/**
* 提示消息
*/
protected $message = [
'name.require'=>'必填',
'name./^[\u4e00-\u9fa5]{2,4}$/'=>'只能是2-4个字符',
'name.max:10'=>'不能超过10个字符',
'phone' => '手机号只能为11位'
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => ['name'],
'add' => ['name','phone'],
'edit' => ['name','phone'],
];
}
... ...
... ... @@ -37,15 +37,21 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-grade_id" data-rule="required" data-source="grade/index" class="form-control selectpage" name="row[grade_id]" type="text" value="">
<input id="c-grade" data-rule="required" class="form-control" name="row[grade]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-school_id" data-rule="required" data-source="school/index" class="form-control selectpage" data-field="title" name="row[school_id]" type="text" value="">
<input id="c-school" data-rule="required" class="form-control" name="row[school]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sno')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sno" class="form-control" name="row[sno]" type="text" value="">
</div>
</div>
<div class="form-group">
... ... @@ -60,24 +66,6 @@
<input id="c-phone" class="form-control" name="row[phone]" type="text">
</div>
</div>
{/* <div class="form-group">*/}
{/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}
{/* <div class="col-xs-12 col-sm-8">*/}
{/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number">*/}
{/* </div>*/}
{/* </div>*/}
{/* <div class="form-group">*/}
{/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}
{/* <div class="col-xs-12 col-sm-8">*/}
{/* <input id="c-unique" class="form-control" name="row[unique]" type="number">*/}
{/* </div>*/}
{/* </div>*/}
{/* <div class="form-group">*/}
{/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}
{/* <div class="col-xs-12 col-sm-8">*/}
{/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text">*/}
{/* </div>*/}
{/* </div>*/}
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -38,15 +38,15 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
<div class="col-xs-12 col-sm-8">
<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}">
<input id="c-grade" data-rule="required" class="form-control" name="row[grade]" type="text" value="{$row.grade|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-school_id" data-rule="required" data-source="school/index" class="form-control selectpage" data-field="title" name="row[school_id]" type="text" value="{$row.school_id|htmlentities}">
<input id="c-school" data-rule="required" class="form-control" data-field="title" type="text" value="{$row.school|htmlentities}">
</div>
</div>
<div class="form-group">
... ...
... ... @@ -96,8 +96,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
{field: 'team_rank', title: __('Team_rank'),operate: false},
{field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
{field: 'grade.name', title: __('Grade.name'), operate: 'LIKE'},
{field: 'school.title', title: __('School.title'), operate: 'LIKE'},
{field: 'grade', title: __('Grade'), operate: 'LIKE'},
{field: 'school', title: __('School'), operate: 'LIKE'},
{field: 'sno', title: __('Sno'), operate: 'LIKE'},
// {field: 'team_id', title: __('Team_id')},
{field: 'earn_score', title: __('Earn_score'),operate:false},
... ...