From e7e0f7b34fd08976c2163da7c8688b95c6c1bafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Thu, 11 Apr 2019 17:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=A7=91=E7=AE=A1=E7=90=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/Admin.php | 4 +- application/admin/view/index/index.html | 21 +- application/system/controller/School.php | 1 - application/teach/controller/Subject.php | 116 ++++---- application/teach/model/Subject.php | 35 ++- application/teach/view/subject/create.html | 153 ++++++----- application/teach/view/subject/index.html | 251 ++++++++++-------- .../migrations/20181030024954_subject.php | 2 +- 8 files changed, 305 insertions(+), 278 deletions(-) diff --git a/application/admin/model/Admin.php b/application/admin/model/Admin.php index f2854748..866da1e0 100644 --- a/application/admin/model/Admin.php +++ b/application/admin/model/Admin.php @@ -85,13 +85,13 @@ class Admin extends Base // 最后登录时间取器 public function getLasttimeAttr($value) { - return date('Y年m月d日 h:i:s',$value); + return date('Y年m月d日 H:i:s',$value); } // 本次登录时间取器 public function getThistimeAttr($value) { - return date('Y年m月d日 h:i:s',$value); + return date('Y年m月d日 H:i:s',$value); } diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index 6941ddb9..e50dea0e 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -21,15 +21,6 @@ autocomplete="off" class="layui-input"> -
- -
- {php} $category = getCategory(101);{/php} - {volist name="category" id="vo"} - - {/volist} -
-
{/block} {block name="table"} @@ -88,8 +79,16 @@ layui.use(['table','laypage','form','cjgl'], function(){ } }}, {title: '用户组',templet:function(d){ - if(d.ad_school){ - return d.ad_school.jiancheng; + if(d.gl_group){ + var str = ''; + for (var k = 0, length = d.gl_group.length; k < length; k++) { + if(k == 0){ + str = d.gl_group[k].title; + }else{ + str =str+'、'+d.gl_group[k].title; + } + } + return str; } }}, {field: 'phone', title: '联系电话', sort: true}, diff --git a/application/system/controller/School.php b/application/system/controller/School.php index 4d3cba05..264c58bc 100644 --- a/application/system/controller/School.php +++ b/application/system/controller/School.php @@ -140,7 +140,6 @@ class School extends Base $this->assign('list',$list); // 渲染 return $this->fetch('create'); - } // 更新单位信息 diff --git a/application/teach/controller/Subject.php b/application/teach/controller/Subject.php index d7b33c56..68864910 100644 --- a/application/teach/controller/Subject.php +++ b/application/teach/controller/Subject.php @@ -12,18 +12,14 @@ class Subject extends Base // 显示学期列表 public function index() { - - // 设置数据总数 - $list['count'] = SJ::count(); - // 设置页面标题 - $list['title'] = '学科列表'; - + // 设置要给模板赋值的信息 + $list['webtitle'] = '学科列表'; // 模板赋值 - $this->assign('list', $list); + $this->assign('list',$list); // 渲染模板 - return $this->fetch(); + return $this->fetch(); } @@ -31,63 +27,37 @@ class Subject extends Base public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'asc', + 'xingzhi'=>array(), + 'searchval'=>'' + ],'POST'); - //得到排序的方式 - $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']; - - - // 获取记录集总数 - $cnt = SJ::count(); - //查询数据 - $data =SJ::field('id,title,jiancheng,category,paixu,kaoshi,status') - ->append(['suj_category.title']) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->select(); - - - // 如果需要查询 - if($search){ - $data = SJ::field('id,title,jiancheng,category,paixu,kaoshi,status') - ->append(['suj_category.title']) - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->whereOr('title','like','%'.$search.'%') - ->whereOr('category','in',function($query) use($search) - { - $query->name('category') - ->where('title','like','%'.$search.'%') - ->field('id'); - }) - ->select(); - } - - $datacnt = $data->count(); - + // 实例化 + $sj = new SJ; + // 查询要显示的数据 + $data = $sj->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, // 符合条件的总数据量 - 'data'=>$data, // 获取到的数据结果 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, //获取到的数据结果 ]; - return json($data); } @@ -97,13 +67,17 @@ class Subject extends Base public function create() { // 设置页面标题 - $list['title'] = '添加学科'; + $list['set'] = array( + 'webtitle'=>'添加学科', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/subject', + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } @@ -153,13 +127,21 @@ class Subject extends Base { // 获取学期信息 - $list = SJ::field('id,title,jiancheng,category,kaoshi,paixu,status') - ->get($id); + $list['data'] = SJ::field('id,title,jiancheng,category,kaoshi,paixu,status') + ->find($id); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑学科', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/subject/'.$id, + ); + // 模板赋值 $this->assign('list',$list); - - return $this->fetch(); + // 渲染 + return $this->fetch('create'); } diff --git a/application/teach/model/Subject.php b/application/teach/model/Subject.php index 8f9331de..55804e1e 100644 --- a/application/teach/model/Subject.php +++ b/application/teach/model/Subject.php @@ -6,19 +6,30 @@ use app\common\model\Base; class Subject extends Base { - // 类别获取器 + // 查询所有单位 + public function search($src) + { + // 整理变量 + $searchval = $src['searchval']; + + // 查询数据 + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title|jiancheng','like','%'.$searchval.'%'); + }) + ->with([ + 'sujCategory'=>function($query){ + $query->field('id,title'); + } + ]) + ->select(); + return $data; + } + + // 大类别关联 public function sujCategory() { return $this->belongsTo('\app\system\model\Category','category','id'); - } - - - // 是否参加考试获取器 - public function getKaoshiAttr($value) - { - $data = [1=>'是',0=>'否']; - - return $data[$value]; - } - + } } diff --git a/application/teach/view/subject/create.html b/application/teach/view/subject/create.html index c5151dc5..94255988 100644 --- a/application/teach/view/subject/create.html +++ b/application/teach/view/subject/create.html @@ -1,73 +1,84 @@ {extend name="common@create" /} -{block name="formaa"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- - {php}$list = getCategory(110);{/php} - - -
-
-
- -
-
- - -
-
- - -
-
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file +{block name="form"} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {php} $category = getCategory(110);{/php} + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+{/block} + +{block name="myjs"} + +{/block} + diff --git a/application/teach/view/subject/index.html b/application/teach/view/subject/index.html index aa0b37c5..22daf3e9 100644 --- a/application/teach/view/subject/index.html +++ b/application/teach/view/subject/index.html @@ -1,126 +1,151 @@ + {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"} - - - - - - - - - - - - - - - -
标题简称分类排序是否参加考试状态操作
- - +{block name="table"} +
{/block} {block name="myjs"} - + + + + {/block} \ No newline at end of file diff --git a/database/migrations/20181030024954_subject.php b/database/migrations/20181030024954_subject.php index 6bd77691..6dca4b11 100644 --- a/database/migrations/20181030024954_subject.php +++ b/database/migrations/20181030024954_subject.php @@ -37,7 +37,7 @@ class Subject extends Migrator ->addColumn('jiancheng','string',['limit'=>6,'null'=>false,'comment'=>'简称']) ->addColumn('lieming','string',['limit'=>46,'null'=>false,'comment'=>'列名']) ->addColumn('category','string',['limit'=>11,'null'=>false,'comment'=>'大学科类别']) - ->addColumn('kaoshi','boolean',['limit'=>1,'null'=>false,'default'=>false,'comment'=>'大学科类别']) + ->addColumn('kaoshi','boolean',['limit'=>1,'null'=>false,'default'=>false,'comment'=>'是否参与考试']) ->addColumn('paixu','integer',['limit'=>4,'default'=>'999','null'=>false,'comment'=>'排序']) ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间'])