From f690b5fb2e61bee5ceaa82fbe1068401ce979803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Fri, 7 Aug 2020 23:19:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=8F=AD=E7=BA=A7=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E6=B3=95=E3=80=81=E5=A2=9E=E5=8A=A0=E7=8F=AD?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/kaohao/model/Kaohao.php | 8 +-- app/kaohao/model/SearchMore.php | 2 +- app/login/view/index/shangma_log.html | 2 + app/student/model/Student.php | 2 +- app/system/controller/SystemBase.php | 2 +- app/teach/controller/Banji.php | 6 +- app/teach/controller/Subject.php | 4 +- app/teach/model/Banji.php | 60 +++++++++++++++---- app/teach/view/banji/index.html | 9 ++- app/tools/controller/Index.php | 13 ++++ .../migrations/20181010035225_system_base.php | 5 +- 11 files changed, 83 insertions(+), 30 deletions(-) diff --git a/app/kaohao/model/Kaohao.php b/app/kaohao/model/Kaohao.php index 50eccc4d..02a003f0 100644 --- a/app/kaohao/model/Kaohao.php +++ b/app/kaohao/model/Kaohao.php @@ -62,14 +62,10 @@ class Kaohao extends BaseModel { $bj = new \app\teach\model\Banji; - // 获取班级名显示样式 - $sys = new \app\system\model\SystemBase; - $alias = $sys->order('id')->value('classalias'); - if($alias == true) + $alias = \app\facade\Tools::sysClass(); + if($alias->classalias) { - $bj = new \app\teach\model\Banji; $title = $bj->where('id', $this->getAttr('banji_id'))->value('alias'); - if($title == '') { $title = $bj->numToWord($this->getAttr('paixu')) . '班'; diff --git a/app/kaohao/model/SearchMore.php b/app/kaohao/model/SearchMore.php index 6c7ff565..71c9fe23 100644 --- a/app/kaohao/model/SearchMore.php +++ b/app/kaohao/model/SearchMore.php @@ -30,7 +30,7 @@ class SearchMore extends BaseModel // 查询成绩 $kh = new kh(); $data = $kh->where('kaoshi_id', $src['kaoshi_id']) - ->field('id, school_id, student_id, ruxuenian, paixu, kaoshi_id, nianji') + ->field('id, school_id, student_id, ruxuenian, paixu, kaoshi_id, nianji, banji_id') ->where('banji_id', 'in', $src['banji_id']) ->when(strlen($src['searchval']) > 0, function($query) use($src){ $query->where(function($w) use ($src){ diff --git a/app/login/view/index/shangma_log.html b/app/login/view/index/shangma_log.html index c9d9d059..3bb37626 100644 --- a/app/login/view/index/shangma_log.html +++ b/app/login/view/index/shangma_log.html @@ -64,6 +64,8 @@ 取消录入成绩时对十分位的验证
重新整理自定义方法,将不常用的方法归类到相应的模型或控制器中 +
+ 增加最多班级和最多年级设置,增加班级别名设置,部分配置文件中内容移到系统设置页面中

diff --git a/app/student/model/Student.php b/app/student/model/Student.php index e8f8dd22..0b2abc48 100644 --- a/app/student/model/Student.php +++ b/app/student/model/Student.php @@ -104,7 +104,7 @@ class Student extends BaseModel }) ->with([ 'stuBanji'=>function($query){ - $query->field('id, ruxuenian, paixu')->append(['banjiTitle']); + $query->field('id, ruxuenian, paixu, alias')->append(['banjiTitle']); } ]) ->field('id, xingming, sex, shengri, banji_id, kaoshi, status') diff --git a/app/system/controller/SystemBase.php b/app/system/controller/SystemBase.php index 86995144..fe093024 100644 --- a/app/system/controller/SystemBase.php +++ b/app/system/controller/SystemBase.php @@ -58,7 +58,7 @@ class SystemBase extends AdminBase return json(['msg'=>$msg,'val'=>0]);; } - $data = sysbasemod::where('id', $id)->update($list); + $data = sysbasemod::where('id', $id)->cache('key')->update($list); // 根据更新结果设置返回提示信息 $data >= 0 ? $data = ['msg' => '设置成功','val'=>1] diff --git a/app/teach/controller/Banji.php b/app/teach/controller/Banji.php index 273f0c13..93e6097f 100644 --- a/app/teach/controller/Banji.php +++ b/app/teach/controller/Banji.php @@ -118,9 +118,9 @@ class Banji extends AdminBase ->max('paixu'); // 获取班级最大数 - $sys = new \app\system\model\SystemBase; - $cnfMax = $sys->order('id')->value('classmax'); - if($paixumax + $list['bjsum'] > $cnfMax) # 如果增加班级数超过2个,则少加班级 + $cnfMax = \app\facade\Tools::sysClass(); + + if($paixumax + $list['bjsum'] > $cnfMax->classmax) # 如果增加班级数超过2个,则少加班级 { if($paixumax >= $cnfMax) { diff --git a/app/teach/controller/Subject.php b/app/teach/controller/Subject.php index 4c157c17..1b31aa95 100644 --- a/app/teach/controller/Subject.php +++ b/app/teach/controller/Subject.php @@ -145,7 +145,7 @@ class Subject extends AdminBase $list = request()->only([ 'title' ,'jiancheng' - ,'category' + ,'category_id' ,'kaoshi' ,'lieming' ,'paixu' @@ -161,7 +161,7 @@ class Subject extends AdminBase } // 更新数据 - $data = SJ::update($list, $id); + $data = SJ::update($list, ['id'=>$id]); // 根据更新结果设置返回提示信息 $data ? $data = ['msg' => '更新成功', 'val' => 1] diff --git a/app/teach/model/Banji.php b/app/teach/model/Banji.php index 1dae3d20..df89366c 100644 --- a/app/teach/model/Banji.php +++ b/app/teach/model/Banji.php @@ -44,7 +44,7 @@ class Banji extends BaseModel $query->where('status', 1); } ]) - ->append(['banjiTitle', 'banTitle']) + ->append(['banjiTitle', 'banTitle', 'grade', 'ban']) ->select(); return $data; @@ -127,15 +127,51 @@ class Banji extends BaseModel // 班级名获取器 public function getBanjiTitleAttr() { - $nj = $this->getAttr('ruxuenian'); - $bj = $this->getAttr('paixu'); - $title = $this->fClassTitle($nj, time(), $bj, 1); + $njlist = self::gradeName('str', time()); + $title = $njlist[$this->getAttr('ruxuenian')] . self::getBanTitleAttr(); return $title; } // 班名获取器 public function getBanTitleAttr() + { + + $alias = \app\facade\Tools::sysClass(); + if($alias->classalias) + { + $title = $this->alias; + if($title == '') + { + $bj = $this->getAttr('paixu'); + $title = self::numToWord($bj) . '班'; + $del = $this->getAttr('delete_time'); + $del == null ? $title : $title = $title & '(删)' ; + }else{ + $title = $title . '班'; + } + }else{ + $bj = $this->getAttr('paixu'); + $title = self::numToWord($bj) . '班'; + $del = $this->getAttr('delete_time'); + $del == null ? $title : $title = $title & '(删)' ; + } + + return $title; + } + + + // 班级名获取器 + public function getGradeAttr() + { + $njList = $this->gradeName('str', time()); + $title = $njList[$this->getAttr('ruxuenian')]; + return $title; + } + + + // 班名获取器 + public function getBanAttr() { $bj = $this->getAttr('paixu'); $title = self::numToWord($bj) . '班'; @@ -147,7 +183,6 @@ class Banji extends BaseModel } - // /** // * 获取考试时的班级名称(文本格式-一年级十一班) // * $jdshijian 考试开始时间 @@ -195,7 +230,7 @@ class Banji extends BaseModel return false; } // 获取年级、班级列表 - $njlist = $this->gradeName(nwo()); + $njlist = $this->gradeName(now()); $bjlist = $this->className(); $nj = substr($str, 0, 9); @@ -273,21 +308,21 @@ class Banji extends BaseModel $thisday <= $jiedian ? $str = 1 : $str = 0; $nian = $nian - $str; + // 获取年级最大数 + $gradeMax = \app\facade\Tools::sysClass(); + $gradeMax = $gradeMax->grademax; + $njlist = array(); if($value != 'str') { - // 获取年级最大数 - $sys = new \app\system\model\SystemBase; - $gradeMax = $sys->order('id')->value('grademax'); - for($i = 0; $i < $gradeMax; $i ++) { - $njlist[numToWord($i + 1) . '年级'] = $nian - $i; + $njlist[self::numToWord($i + 1) . '年级'] = $nian - $i; } }else{ for($i = 0; $i < $gradeMax; $i ++) { - $njlist[$nian - $i] = numToWord($i + 1) . '年级'; + $njlist[$nian - $i] = self::numToWord($i + 1) . '年级'; } } return $njlist; @@ -348,6 +383,7 @@ class Banji extends BaseModel $chiStr = self::numTo($value, $key) . $chiUni[$key] . $chiStr; } } + $chiStr = str_replace("零零", "零", $chiStr); return $chiStr; } diff --git a/app/teach/view/banji/index.html b/app/teach/view/banji/index.html index 1fbab977..69e08040 100644 --- a/app/teach/view/banji/index.html +++ b/app/teach/view/banji/index.html @@ -61,7 +61,14 @@ options.cols=[[ //表头 {type:'checkbox', fixed: 'left'}, {field: 'id', title: 'ID', minWidth:100,sort: true}, - {field: 'banjiTitle', title: '班级名称', minWidth:100}, + {field: 'banjiTitle', title: '班级名称', minWidth:100,templet:function(d){ + var str=''; + if(d.grade && d.ban) + { + str = d.grade + d.ban; + } + return str; + }}, {field: 'alias', title: '别名', minWidth:60, edit:'text'}, {field: 'school', title: '单位名称',sort: true, minWidth:240,templet:function(d){ var str=''; diff --git a/app/tools/controller/Index.php b/app/tools/controller/Index.php index fd073048..65d6e2f5 100644 --- a/app/tools/controller/Index.php +++ b/app/tools/controller/Index.php @@ -226,4 +226,17 @@ class Index extends BaseController } + // 是否启用别名 + public function sysClass() + { + // 实例化系统设置对象 + $sys = new \app\system\model\SystemBase; + $alias = $sys->order(['id'=>'desc']) + ->field('grademax, classmax, classalias') + ->cache('key') + ->find(); + return $alias; + } + + } diff --git a/database/migrations/20181010035225_system_base.php b/database/migrations/20181010035225_system_base.php index f5c8b492..4bbb6809 100644 --- a/database/migrations/20181010035225_system_base.php +++ b/database/migrations/20181010035225_system_base.php @@ -36,10 +36,9 @@ class SystemBase extends Migrator ->addColumn('keywords','string',['limit'=>60,'null'=>false,'default'=>'尚码成绩管理,录入,统计,查询,管理','comment'=>'关键词']) ->addColumn('description','string',['limit'=>100,'null'=>false,'default'=>'尚码成绩统计系统,包含成绩采集、成绩统计、成绩查询等功能。适合一线的成绩统计系统才是好系统。','comment'=>'网站说明']) ->addColumn('thinks','string',['limit'=>80,'null'=>false,'default'=>'ThinkPHP,X-admin,百度Echarts,jquery','comment'=>'网站感谢']) - ->addColumn('classmax','integer',['limit'=>11,'null'=>false,'default'=>'25','comment'=>'最大班级数']) ->addColumn('danwei','string',['limit'=>20,'null'=>false,'default'=>'大连长兴岛','comment'=>'使用单位']) - ->addColumn('grademax','integer',['limit'=>2,'default'=>'6','null'=>false,'comment'=>'排序']) - ->addColumn('classmax','integer',['limit'=>2,'default'=>'30','null'=>false,'comment'=>'排序']) + ->addColumn('grademax','integer',['limit'=>2,'default'=>6,'null'=>false,'comment'=>'最大年级数']) + ->addColumn('classmax','integer',['limit'=>2,'default'=>30,'null'=>false,'comment'=>'最大班级数']) ->addColumn('classalias','boolean',['limit'=>1,'default'=>0,'null'=>false,'comment'=>'是否开启班级另名']) ->addColumn('create_time','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>false,'default'=>1539158918,'comment'=>'更新时间'])