diff --git a/README.md b/README.md index 61f7ca52..e271d244 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ http://xiaoshongshu.cn 更换前端显示,重新整理后端代码。 升级提示 修改 cj_system_base 表 title字段名冲突,修改为 webtitle +authrule 表中的font字段数据需要重新导入 ## 更详细信息请查阅官方手册 diff --git a/application/teach/controller/Banji.php b/application/teach/controller/Banji.php index efcb04bb..d19ba935 100644 --- a/application/teach/controller/Banji.php +++ b/application/teach/controller/Banji.php @@ -12,15 +12,11 @@ class Banji extends Base // 显示班级列表 public function index() { - - // 设置数据总数 - $list['count'] = BJ::count(); - // 设置页面标题 - $list['title'] = '班级列表'; - + // 设置要给模板赋值的信息 + $list['webtitle'] = '班级列表'; // 模板赋值 - $this->assign('list', $list); + $this->assign('list',$list); // 渲染模板 return $this->fetch(); @@ -32,66 +28,40 @@ class Banji extends Base public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); - - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['name']; - if($order_field=='') - { - $order_field = $getdt['columns'][$order_column]['data']; - } - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - //得到搜索的关键词 - $search = $getdt['search']['value']; + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'asc', + 'school'=>'', + 'ruxuenian'=>'', + 'searchval'=>'' + ],'POST'); - // 获取记录集总数 - $cnt = BJ::count(); - //查询数据 - $data =BJ::field('id,school,ruxuenian,paixu,status') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->all(); - - - // 如果需要查询 - if($search){ - $data = BJ::field('id,school,ruxuenian,paixu,status') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - // ->whereOr('title','like','%'.$search.'%') - ->whereOr('school','in',function($query) use($search) - { - $query->name('school') - ->where('title','like','%'.$search.'%') - ->field('id'); - }) - ->where('paixu','<',26) - ->whereOr('ruxuenian',$search) - ->all(); - } - - $datacnt = $data->count(); - //追加班级名称 - $data = $data->append(['title','stusum']); - - - + // 实例化 + $bj = new BJ; + // 查询要显示的数据 + $data = $bj->search($src); + // 获取符合条件记录总数 + $cnt = $data->count(); + // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']-1; + $data = $data->slice($limit_start,$limit_length); + + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } @@ -101,13 +71,17 @@ class Banji extends Base public function create() { // 设置页面标题 - $list['title'] = '添加班级'; + $list['set'] = array( + 'webtitle'=>'添加班级', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/banji', + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } @@ -137,6 +111,10 @@ class Banji extends Base ->where('ruxuenian',$list['ruxuenian']) ->max('paixu'); + if($paixumax + $list['bjsum'] > 25){ + $list['bjsum'] = 25 - $paixumax; + } + $i = 1; while($i<=$list['bjsum']) { diff --git a/application/teach/model/Banji.php b/application/teach/model/Banji.php index f009118f..7b84c26c 100644 --- a/application/teach/model/Banji.php +++ b/application/teach/model/Banji.php @@ -7,6 +7,57 @@ use app\common\model\Base; class Banji extends Base { + + // 查询所有班级 + public function search($src) + { + // 整理变量 + $school = $src['school']; + $ruxuenian = $src['ruxuenian']; + $searchval = $src['searchval']; + + // 查询数据 + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(strlen($school)>0,function($query) use($school){ + $query->where('school',$school); + }) + ->when(strlen($ruxuenian)>0,function($query) use($ruxuenian){ + $query->where('ruxuenian',$ruxuenian); + }) + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title','like','%'.$searchval.'%'); + }) + ->with( + [ + 'glSchool'=>function($query){ + $query->field('id,title'); + }, + 'glStudent'=>function($query){ + $query->count(); + }, + // 'dwXueduan'=>function($query){ + // $query->field('id,title'); + // }, + ] + ) + ->append(['title']) + ->select(); + return $data; + } + + + // 学校关联模型 + public function glSchool(){ + return $this->belongsTo('\app\system\model\School','school','id'); + } + + // 学校关联模型 + public function glStudent(){ + return $this->belongsTo('\app\renshi\model\Student','school','id'); + } + + // 班级名获取器 public function getNumTitleAttr() { @@ -47,13 +98,13 @@ class Banji extends Base // 学校获取器 - public function getSchoolAttr($value) - { - // 查询学校名称 - $schoolname = db('school')->where('id',$value)->value('title'); - // 返回学校名称 - return $schoolname; - } + // public function getSchoolAttr($value) + // { + // // 查询学校名称 + // $schoolname = db('school')->where('id',$value)->value('title'); + // // 返回学校名称 + // return $schoolname; + // } diff --git a/application/teach/view/banji/create.html b/application/teach/view/banji/create.html index eb61de78..7f0e43d6 100644 --- a/application/teach/view/banji/create.html +++ b/application/teach/view/banji/create.html @@ -1,62 +1,55 @@ {extend name="common@create" /} -{block name="formaa"} -
-
- -
- - {php} - $school = schlist('校级','校级'); - {/php} - - -
-
-
- -
- - {php} - $njlist = nianjiList(); - {/php} - - -
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file +{block name="form"} +
+
+ +
+ {php} $schoollist = schlist('校级','校级');{/php} + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+{/block} + +{block name="myjs"} + +{/block} + diff --git a/application/teach/view/banji/index.html b/application/teach/view/banji/index.html index 1fdf3fbd..676e7d0e 100644 --- a/application/teach/view/banji/index.html +++ b/application/teach/view/banji/index.html @@ -1,165 +1,189 @@ + {extend name="common@list" /} -{block name="topnav"} - +{block name="jsset"} + {/block} -{block name="bouttons"} -
- - - - - 批量删除 - - - - - 添加班级 - - - - 共有数据:{$list.count} 条 - +{block name="nav"} + + 教务管理 + 班级管理 + 班级列表 + +{/block} +{block name="search"} + {/block} -{block name="tables"} - - - - - - - - - - - - - - - - -
ID班级名称学校入学年排序学生人数状态操作
- - +{block name="table"} +
{/block} {block name="myjs"} - + + + + {/block} \ No newline at end of file