作者 开飞机的舒克

后台更新

@@ -25,12 +25,7 @@ class Study extends Backend @@ -25,12 +25,7 @@ class Study extends Backend
25 $this->view->assign("genderList", $this->model->getGenderList()); 25 $this->view->assign("genderList", $this->model->getGenderList());
26 } 26 }
27 27
28 - /**  
29 - * 导入  
30 - */  
31 - public function import(){  
32 - return parent::import();  
33 - } 28 +
34 29
35 /** 30 /**
36 * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 31 * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
@@ -56,15 +51,15 @@ class Study extends Backend @@ -56,15 +51,15 @@ class Study extends Backend
56 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 51 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
57 52
58 $list = $this->model 53 $list = $this->model
59 - ->with(['team','user']) 54 + ->with(['school','team'])
60 ->where($where) 55 ->where($where)
61 ->order($sort, $order) 56 ->order($sort, $order)
62 ->paginate($limit); 57 ->paginate($limit);
63 58
64 foreach ($list as $row) { 59 foreach ($list as $row) {
65 60
  61 + $row->getRelation('school')->visible(['title']);
66 $row->getRelation('team')->visible(['title']); 62 $row->getRelation('team')->visible(['title']);
67 - $row->getRelation('user')->visible(['username']);  
68 } 63 }
69 64
70 $result = array("total" => $list->total(), "rows" => $list->items()); 65 $result = array("total" => $list->total(), "rows" => $list->items());
@@ -76,17 +71,12 @@ class Study extends Backend @@ -76,17 +71,12 @@ class Study extends Backend
76 71
77 //导出数据 72 //导出数据
78 public function export(){ 73 public function export(){
79 - if ($this->request->isPost()){  
80 - set_time_limit(0);//设置时间限制  
81 - $ids = $this->request->post('ids'); //获取数据的所有id  
82 - $excel = new \PHPExcel(); // 生成新的excel对象  
83 - $excel->getProperties()  
84 - ->setCreator("FastAdmin") //设置作者  
85 - ->setLastModifiedBy("FastAdmin") //设置上次修改者  
86 - ->setTitle("积分表") //设置表格标题  
87 - ->setSubject("Subject"); //设置主题  
88 - $excel->getDefaultStyle()->getFont()->setName('楷体'); //设置默认字体  
89 - $excel->getDefaultStyle()->getFont()->setSize(15); //设置默认字体大小 74 + if ($this->request->isPost()) {
  75 + set_time_limit(0);
  76 + $ids = $this->request->post('ids');
  77 +
  78 + $excel = new \PHPExcel();
  79 + $excel->getProperties()->setTitle("学校+积分表");
90 $excel->getActiveSheet()->getColumnDimension('A')->setWidth(10); 80 $excel->getActiveSheet()->getColumnDimension('A')->setWidth(10);
91 $excel->getActiveSheet()->getColumnDimension('B')->setWidth(10); 81 $excel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
92 $excel->getActiveSheet()->getColumnDimension('C')->setWidth(10); 82 $excel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
@@ -124,19 +114,21 @@ class Study extends Backend @@ -124,19 +114,21 @@ class Study extends Backend
124 ->setCellValue('H'.$k,$val['earn_score']); 114 ->setCellValue('H'.$k,$val['earn_score']);
125 } 115 }
126 116
127 - $excel->createSheet(); //创建excel表  
128 - $title = "学生成绩".date("Y-m-dHis"); //考勤打卡数据_2023-01-07145656.xlsx  
129 - header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');//表明当前文件是.xlsx  
130 - header('Content-Disposition: attachment;filename="'.$title.'.xlsx"');//文件名称[考勤打卡数据_2023-01-07145656.xlsx]  
131 - header('Cache-Control: max-age=0'); //禁用缓存  
132 - header('Cache-Control: max-age=1'); //通知浏览器:1 秒之内不要烦我,自己从缓冲区中刷新。  
133 - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // 缓存过期时间(禁用缓存)  
134 - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // 上一次修改时间  
135 - header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 缓存控制:必须重新验证  
136 - header('Pragma: public'); // 可被任何缓存所缓存 http1.0协议 117 + $excel->createSheet();
  118 + $title = "学生成绩记录" . date("YmdHis");
  119 + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  120 + header('Content-Disposition: attachment;filename="' . $title . '.xlsx"');
  121 + header('Cache-Control: max-age=0');
  122 + header('Cache-Control: max-age=1');
  123 +
  124 + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  125 + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  126 + header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  127 + header('Pragma: public'); // HTTP/1.0
137 $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); 128 $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
138 - $objWriter->save('php://output'); //保存地址 129 + $objWriter->save('php://output');
139 exit; 130 exit;
  131 + return;
140 } 132 }
141 } 133 }
142 } 134 }
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 2
3 return [ 3 return [
4 'User_id' => '用户id', 4 'User_id' => '用户id',
5 - 'Id' => 'ID',  
6 'Avatar' => '头像', 5 'Avatar' => '头像',
7 'Name' => '姓名', 6 'Name' => '姓名',
8 'Gender' => '性别', 7 'Gender' => '性别',
@@ -10,7 +9,7 @@ return [ @@ -10,7 +9,7 @@ return [
10 'Gender 1' => '男', 9 'Gender 1' => '男',
11 'Birthday' => '生日', 10 'Birthday' => '生日',
12 'Grade' => '班级', 11 'Grade' => '班级',
13 - 'School' => '学校', 12 + 'School_id' => '学校',
14 'Sno' => '学号', 13 'Sno' => '学号',
15 'Team_id' => '所属战队', 14 'Team_id' => '所属战队',
16 'Earn_score' => '总积分', 15 'Earn_score' => '总积分',
@@ -19,6 +18,6 @@ return [ @@ -19,6 +18,6 @@ return [
19 'Barcode' => '条形码', 18 'Barcode' => '条形码',
20 'Createtime' => '创建时间', 19 'Createtime' => '创建时间',
21 'Updatetime' => '更新时间', 20 'Updatetime' => '更新时间',
22 - 'Team.title' => '战队昵称',  
23 - 'User.username' => '用户名' 21 + 'School.title' => '校区名称',
  22 + 'Team.title' => '战队昵称'
24 ]; 23 ];
@@ -46,14 +46,14 @@ class Study extends Model @@ -46,14 +46,14 @@ class Study extends Model
46 46
47 47
48 48
49 - public function team() 49 + public function school()
50 { 50 {
51 - return $this->belongsTo('Team', 'team_id', 'id', [], 'LEFT')->setEagerlyType(0); 51 + return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);
52 } 52 }
53 53
54 54
55 - public function user() 55 + public function team()
56 { 56 {
57 - return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); 57 + return $this->belongsTo('Team', 'team_id', 'id', [], 'LEFT')->setEagerlyType(0);
58 } 58 }
59 } 59 }
@@ -43,9 +43,9 @@ @@ -43,9 +43,9 @@
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')}:</label> 46 + <label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label>
47 <div class="col-xs-12 col-sm-8"> 47 <div class="col-xs-12 col-sm-8">
48 - <input id="c-school" class="form-control" name="row[school]" type="text"> 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="">
49 </div> 49 </div>
50 </div> 50 </div>
51 <div class="form-group"> 51 <div class="form-group">
@@ -66,24 +66,24 @@ @@ -66,24 +66,24 @@
66 <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">
67 </div> 67 </div>
68 </div> 68 </div>
69 -{/* <div class="form-group">*/}  
70 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}  
71 -{/* <div class="col-xs-12 col-sm-8">*/}  
72 -{/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number">*/}  
73 -{/* </div>*/}  
74 -{/* </div>*/}  
75 -{/* <div class="form-group">*/}  
76 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}  
77 -{/* <div class="col-xs-12 col-sm-8">*/}  
78 -{/* <input id="c-unique" class="form-control" name="row[unique]" type="number">*/}  
79 -{/* </div>*/}  
80 -{/* </div>*/}  
81 -{/* <div class="form-group">*/}  
82 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}  
83 -{/* <div class="col-xs-12 col-sm-8">*/}  
84 -{/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text">*/}  
85 -{/* </div>*/}  
86 -{/* </div>*/} 69 + {/* <div class="form-group">*/}
  70 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}
  71 + {/* <div class="col-xs-12 col-sm-8">*/}
  72 + {/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number">*/}
  73 + {/* </div>*/}
  74 + {/* </div>*/}
  75 + {/* <div class="form-group">*/}
  76 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}
  77 + {/* <div class="col-xs-12 col-sm-8">*/}
  78 + {/* <input id="c-unique" class="form-control" name="row[unique]" type="number">*/}
  79 + {/* </div>*/}
  80 + {/* </div>*/}
  81 + {/* <div class="form-group">*/}
  82 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}
  83 + {/* <div class="col-xs-12 col-sm-8">*/}
  84 + {/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text">*/}
  85 + {/* </div>*/}
  86 + {/* </div>*/}
87 <div class="form-group layer-footer"> 87 <div class="form-group layer-footer">
88 <label class="control-label col-xs-12 col-sm-2"></label> 88 <label class="control-label col-xs-12 col-sm-2"></label>
89 <div class="col-xs-12 col-sm-8"> 89 <div class="col-xs-12 col-sm-8">
@@ -44,9 +44,9 @@ @@ -44,9 +44,9 @@
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')}:</label> 47 + <label class="control-label col-xs-12 col-sm-2">{:__('School_id')}:</label>
48 <div class="col-xs-12 col-sm-8"> 48 <div class="col-xs-12 col-sm-8">
49 - <input id="c-school" class="form-control" name="row[school]" type="text" value="{$row.school|htmlentities}"> 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}">
50 </div> 50 </div>
51 </div> 51 </div>
52 <div class="form-group"> 52 <div class="form-group">
@@ -67,24 +67,24 @@ @@ -67,24 +67,24 @@
67 <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$row.phone|htmlentities}"> 67 <input id="c-phone" class="form-control" name="row[phone]" type="text" value="{$row.phone|htmlentities}">
68 </div> 68 </div>
69 </div> 69 </div>
70 -{/* <div class="form-group">*/}  
71 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}  
72 -{/* <div class="col-xs-12 col-sm-8">*/}  
73 -{/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number" value="{$row.earn_score|htmlentities&cc;">*/}  
74 -{/* </div>*/}  
75 -{/* </div>*/}  
76 -{/* <div class="form-group">*/}  
77 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}  
78 -{/* <div class="col-xs-12 col-sm-8">*/}  
79 -{/* <input id="c-unique" class="form-control" name="row[unique]" type="number" value="{$row.unique|htmlentities&cc;">*/}  
80 -{/* </div>*/}  
81 -{/* </div>*/}  
82 -{/* <div class="form-group">*/}  
83 -{/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}  
84 -{/* <div class="col-xs-12 col-sm-8">*/}  
85 -{/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text" value="{$row.barcode|htmlentities&cc;">*/}  
86 -{/* </div>*/}  
87 -{/* </div>*/} 70 + {/* <div class="form-group">*/}
  71 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Earn_score')&cc;:</label>*/}
  72 + {/* <div class="col-xs-12 col-sm-8">*/}
  73 + {/* <input id="c-earn_score" class="form-control" step="0.01" name="row[earn_score]" type="number" value="{$row.earn_score|htmlentities&cc;">*/}
  74 + {/* </div>*/}
  75 + {/* </div>*/}
  76 + {/* <div class="form-group">*/}
  77 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Unique')&cc;:</label>*/}
  78 + {/* <div class="col-xs-12 col-sm-8">*/}
  79 + {/* <input id="c-unique" class="form-control" name="row[unique]" type="number" value="{$row.unique|htmlentities&cc;">*/}
  80 + {/* </div>*/}
  81 + {/* </div>*/}
  82 + {/* <div class="form-group">*/}
  83 + {/* <label class="control-label col-xs-12 col-sm-2">{:__('Barcode')&cc;:</label>*/}
  84 + {/* <div class="col-xs-12 col-sm-8">*/}
  85 + {/* <input id="c-barcode" class="form-control" name="row[barcode]" type="text" value="{$row.barcode|htmlentities&cc;">*/}
  86 + {/* </div>*/}
  87 + {/* </div>*/}
88 <div class="form-group layer-footer"> 88 <div class="form-group layer-footer">
89 <label class="control-label col-xs-12 col-sm-2"></label> 89 <label class="control-label col-xs-12 col-sm-2"></label>
90 <div class="col-xs-12 col-sm-8"> 90 <div class="col-xs-12 col-sm-8">
@@ -91,7 +91,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -91,7 +91,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
91 {field: 'team.title', title: __('Team.title'), operate: 'LIKE'}, 91 {field: 'team.title', title: __('Team.title'), operate: 'LIKE'},
92 {field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"}, 92 {field: 'birthday', title: __('Birthday'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat: "YYYY-MM-DD"},
93 {field: 'grade', title: __('Grade'), operate: 'LIKE'}, 93 {field: 'grade', title: __('Grade'), operate: 'LIKE'},
94 - {field: 'school', title: __('School'), operate: 'LIKE'}, 94 + {field: 'school.title', title: __('School.title'), operate: 'LIKE'},
95 {field: 'sno', title: __('Sno'), operate: 'LIKE'}, 95 {field: 'sno', title: __('Sno'), operate: 'LIKE'},
96 // {field: 'team_id', title: __('Team_id')}, 96 // {field: 'team_id', title: __('Team_id')},
97 {field: 'earn_score', title: __('Earn_score'), operate:false}, 97 {field: 'earn_score', title: __('Earn_score'), operate:false},