作者 开飞机的舒克

学校班级手动输入

@@ -33,6 +33,8 @@ class Study extends Backend @@ -33,6 +33,8 @@ class Study extends Backend
33 * @var \app\admin\model\Study 33 * @var \app\admin\model\Study
34 */ 34 */
35 protected $model = null; 35 protected $model = null;
  36 + protected $modelValidate = true; //开启validate,验证默认是fasle
  37 +
36 38
37 public function _initialize() 39 public function _initialize()
38 { 40 {
@@ -74,17 +76,13 @@ class Study extends Backend @@ -74,17 +76,13 @@ class Study extends Backend
74 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 76 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
75 77
76 $list = $this->model 78 $list = $this->model
77 - ->with(['grade','school','team']) 79 + ->with(['team'])
78 ->where($where) 80 ->where($where)
79 ->order($sort, $order) 81 ->order($sort, $order)
80 ->paginate($limit); 82 ->paginate($limit);
81 83
82 foreach ($list as $row) { 84 foreach ($list as $row) {
83 - $row->visible(['id','avatar','name','gender','birthday','grade_id','school_id','sno','team_id','team_rank','earn_score','phone','unique','barcode']);  
84 - $row->visible(['grade']);  
85 - $row->getRelation('grade')->visible(['id','name']);  
86 - $row->visible(['school']);  
87 - $row->getRelation('school')->visible(['title']); 85 + $row->visible(['id','avatar','name','gender','birthday','grade','school','sno','team_id','team_rank','earn_score','phone','unique','barcode']);
88 $row->visible(['team']); 86 $row->visible(['team']);
89 $row->getRelation('team')->visible(['title']); 87 $row->getRelation('team')->visible(['title']);
90 } 88 }
@@ -215,8 +213,7 @@ class Study extends Backend @@ -215,8 +213,7 @@ class Study extends Backend
215 $id = $this->model->id; 213 $id = $this->model->id;
216 $unique = time(); 214 $unique = time();
217 $barpath = Resource::StudyBar($unique); 215 $barpath = Resource::StudyBar($unique);
218 - $time = date('YmdHi',time());  
219 - $this->model->save(['barcode'=>$barpath,'sno'=>$time,'unique'=>time()],['id'=>$id]); 216 + $this->model->save(['barcode'=>$barpath,'unique'=>time()],['id'=>$id]);
220 Db::commit(); 217 Db::commit();
221 } catch (ValidateException|PDOException|Exception $e) { 218 } catch (ValidateException|PDOException|Exception $e) {
222 Db::rollback(); 219 Db::rollback();
1 -<?php  
2 -  
3 -return [  
4 - 'Title' => '活动标题',  
5 - 'Campus_id' => '校区id',  
6 - 'Images' => '背景图',  
7 - 'Starttime' => '开始时间',  
8 - 'Endtime' => '结束时间',  
9 - 'Is_view' => '是否显示',  
10 - 'Is_view 0' => '否',  
11 - 'Is_view 1' => '是',  
12 - 'Createtime' => '创建时间',  
13 - 'Updatetime' => '更新时间'  
14 -];  
1 -<?php  
2 -  
3 -return [  
4 - 'Name' => '班级名称',  
5 - 'Createtime' => '创建时间',  
6 - 'Updatetime' => '更新时间'  
7 -];  
@@ -19,8 +19,8 @@ return [ @@ -19,8 +19,8 @@ return [
19 'Barcode' => '条形码', 19 'Barcode' => '条形码',
20 'Createtime' => '创建时间', 20 'Createtime' => '创建时间',
21 'Updatetime' => '更新时间', 21 'Updatetime' => '更新时间',
22 - 'Grade.name' => '班级名称',  
23 - 'School.title' => '学校名称', 22 + 'Grade' => '班级名称',
  23 + 'School' => '学校名称',
24 'Team.title' => '所属战队', 24 'Team.title' => '所属战队',
25 'Download' => '批量下载' 25 'Download' => '批量下载'
26 ]; 26 ];
@@ -10,21 +10,24 @@ class Study extends Validate @@ -10,21 +10,24 @@ class Study extends Validate
10 * 验证规则 10 * 验证规则
11 */ 11 */
12 protected $rule = [ 12 protected $rule = [
13 - 'name'=>'require|/^[\u4e00-\u9fa5]{2,4}$/' 13 + 'name'=>'require|max:10',
  14 + 'phone'=>'max:11',
  15 +
14 ]; 16 ];
15 /** 17 /**
16 * 提示消息 18 * 提示消息
17 */ 19 */
18 protected $message = [ 20 protected $message = [
19 'name.require'=>'必填', 21 'name.require'=>'必填',
20 - 'name./^[\u4e00-\u9fa5]{2,4}$/'=>'只能是2-4个字符', 22 + 'name.max:10'=>'不能超过10个字符',
  23 + 'phone' => '手机号只能为11位'
21 ]; 24 ];
22 /** 25 /**
23 * 验证场景 26 * 验证场景
24 */ 27 */
25 protected $scene = [ 28 protected $scene = [
26 - 'add' => [],  
27 - 'edit' => ['name'], 29 + 'add' => ['name','phone'],
  30 + 'edit' => ['name','phone'],
28 ]; 31 ];
29 32
30 } 33 }
@@ -37,15 +37,21 @@ @@ -37,15 +37,21 @@
37 </div> 37 </div>
38 </div> 38 </div>
39 <div class="form-group"> 39 <div class="form-group">
40 - <label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label> 40 + <label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
41 <div class="col-xs-12 col-sm-8"> 41 <div class="col-xs-12 col-sm-8">
42 - <input id="c-grade_id" data-rule="required" data-source="grade/index" class="form-control selectpage" name="row[grade_id]" type="text" value=""> 42 + <input id="c-grade" data-rule="required" class="form-control" name="row[grade]" type="text" value="">
43 </div> 43 </div>
44 </div> 44 </div>
45 <div class="form-group"> 45 <div class="form-group">
46 - <label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label> 46 + <label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
47 <div class="col-xs-12 col-sm-8"> 47 <div class="col-xs-12 col-sm-8">
48 - <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=""> 48 + <input id="c-school" data-rule="required" class="form-control" name="row[school]" type="text" value="">
  49 + </div>
  50 + </div>
  51 + <div class="form-group">
  52 + <label class="control-label col-xs-12 col-sm-2">{:__('Sno')}:</label>
  53 + <div class="col-xs-12 col-sm-8">
  54 + <input id="c-sno" class="form-control" name="row[sno]" type="text" value="">
49 </div> 55 </div>
50 </div> 56 </div>
51 <div class="form-group"> 57 <div class="form-group">
@@ -60,24 +66,6 @@ @@ -60,24 +66,6 @@
60 <input id="c-phone" class="form-control" name="row[phone]" type="text"> 66 <input id="c-phone" class="form-control" name="row[phone]" type="text">
61 </div> 67 </div>
62 </div> 68 </div>
63 - {/* <div class="form-group">*/}  
64 - {/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}  
65 - {/* <div class="col-xs-12 col-sm-8">*/}  
66 - {/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number">*/}  
67 - {/* </div>*/}  
68 - {/* </div>*/}  
69 - {/* <div class="form-group">*/}  
70 - {/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}  
71 - {/* <div class="col-xs-12 col-sm-8">*/}  
72 - {/* <input id="c-unique" class="form-control" name="row[unique]" type="number">*/}  
73 - {/* </div>*/}  
74 - {/* </div>*/}  
75 - {/* <div class="form-group">*/}  
76 - {/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}  
77 - {/* <div class="col-xs-12 col-sm-8">*/}  
78 - {/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text">*/}  
79 - {/* </div>*/}  
80 - {/* </div>*/}  
81 <div class="form-group layer-footer"> 69 <div class="form-group layer-footer">
82 <label class="control-label col-xs-12 col-sm-2"></label> 70 <label class="control-label col-xs-12 col-sm-2"></label>
83 <div class="col-xs-12 col-sm-8"> 71 <div class="col-xs-12 col-sm-8">
@@ -38,15 +38,15 @@ @@ -38,15 +38,15 @@
38 </div> 38 </div>
39 </div> 39 </div>
40 <div class="form-group"> 40 <div class="form-group">
41 - <label class="control-label col-xs-12 col-sm-2">{:__('Grade_id')}:</label> 41 + <label class="control-label col-xs-12 col-sm-2">{:__('Grade')}:</label>
42 <div class="col-xs-12 col-sm-8"> 42 <div class="col-xs-12 col-sm-8">
43 - <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}"> 43 + <input id="c-grade" data-rule="required" class="form-control" name="row[grade]" type="text" value="{$row.grade|htmlentities}">
44 </div> 44 </div>
45 </div> 45 </div>
46 <div class="form-group"> 46 <div class="form-group">
47 - <label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label> 47 + <label class="control-label col-xs-12 col-sm-2">{:__('School')}:</label>
48 <div class="col-xs-12 col-sm-8"> 48 <div class="col-xs-12 col-sm-8">
49 - <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}"> 49 + <input id="c-school" data-rule="required" class="form-control" data-field="title" type="text" value="{$row.school|htmlentities}">
50 </div> 50 </div>
51 </div> 51 </div>
52 <div class="form-group"> 52 <div class="form-group">
@@ -96,8 +96,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -96,8 +96,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
96 {field: 'team.title', title: __('Team.title'), operate: 'LIKE'}, 96 {field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
97 {field: 'team_rank', title: __('Team_rank'),operate: false}, 97 {field: 'team_rank', title: __('Team_rank'),operate: false},
98 {field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"}, 98 {field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
99 - {field: 'grade.name', title: __('Grade.name'), operate: 'LIKE'},  
100 - {field: 'school.title', title: __('School.title'), operate: 'LIKE'}, 99 + {field: 'grade', title: __('Grade'), operate: 'LIKE'},
  100 + {field: 'school', title: __('School'), operate: 'LIKE'},
101 {field: 'sno', title: __('Sno'), operate: 'LIKE'}, 101 {field: 'sno', title: __('Sno'), operate: 'LIKE'},
102 // {field: 'team_id', title: __('Team_id')}, 102 // {field: 'team_id', title: __('Team_id')},
103 {field: 'earn_score', title: __('Earn_score'),operate:false}, 103 {field: 'earn_score', title: __('Earn_score'),operate:false},