123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use app\admin\model\MajorLevel;
- use app\admin\model\Ztrees;
- use app\common\controller\Backend;
- use think\facade\Db;
- use think\facade\Request;
- use think\facade\View;
- class Training extends Backend
- {
- // todo 培养计划
- //专业管理
- public function index()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $name=input("name", '', 'trim');
- $where["major_id"]=0;
- $list=Db::name("subject")->order("id desc")->where($where)
- ->where("name","like","%".$name."%")
- ->paginate(['list_rows' => $this->pageSize, 'page' => $page])->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'], 'count' => $list['total']];
- }
- return View::fetch();
- }
- // 添加
- public function add_major()
- {
- $name=input("name");
- $pid=input("pid")?:0;
- $update["name"]=$name;
- $update["major_id"]=$pid;
- $result=Db::name("subject")->insertGetId($update);
- if ($result){
- if ($pid==0){// 添加升级等级
- MajorLevel::add_level($result);
- }
- $update["id"]=$result;
- $update["pId"]=$pid;
- json_result(1,"添加成功",$update);
- }
- json_result(2,"添加失败");
- }
- // 修改
- public function update_major()
- {
- $id=input("id");
- $name=input("name");
- $where["id"]=$id;
- $update["name"]=$name;
- $result=Db::name("subject")->where($where)->update($update);
- if ($result){
- json_result(1,"修改成功");
- }
- json_result(2,"修改失败");
- }
- // 删除
- public function del()
- {
- $id=input("id");
- $where["id"]=$id;
- $where_us["major_id"]=$id;
- $cout=Db::name("subject")->where($where_us)->find();
- if ($cout){
- json_result(2,"请先删除下面的科目");
- }
- if ($cout["major_id"]==0){ // 删除专业等级表
- $del_where["subject_id"]=$id;
- Db::name("major_level")->where($del_where)->delete();
- }
- $result=Db::name("subject")->where($where)->delete();
- if ($result){
- json_result(1,"删除成功");
- }
- json_result(2,"删除失败11");
- }
- //课程科目管理
- public function course()
- {
- if (Request::isPost()){
- $page = input("page") ?: 1;
- $limit = input("limit") ?: 10;
- $name=input("name", '', 'trim');
- $where=[];
- if ($name){
- $where[]=["name","like","%".$name."%"];
- }
- $list=Db::name("subject")->order("major_id asc") ->where($where)->select()->toArray();
- // $list=Db::name("subject")->order("major_id asc") ->where($where)->paginate(['list_rows' => $limit, 'page' => $page])->toArray();
- // $list=$list["data"];
- foreach($list as $k=>$v){
- $list[$k]['lay_is_open']=false;
- $list[$k]["pId"]=$v["major_id"];
- $list[$k]["pid"]=$v["major_id"];
- }
- $ztree=Ztrees::sortListTier($list);
- return $result = ['code' => 0, 'msg' => "获取成功", 'data' => $ztree, 'count' => count($list)];
- }
- return View::fetch("text");
- }
- // 升级参数设置
- public function upgrade()
- {
- if (Request::isPost()){
- $page=input("page")?:1;
- $limit=input("limit")?:10;
- $name=input("name", '', 'trim');
- // $where["major_id"]=0;
- $list=Db::name("major_level")->alias("m")->order("m.id desc")
- ->leftJoin("subject su","m.subject_id=su.id")
- ->where("su.name","like","%".$name."%")
- ->field("m.*,su.name pro_name")
- ->paginate(['list_rows' => $limit, 'page' => $page])
- ->toArray();
- return $result = ['code' => 0, 'msg' => lang('get info success'), 'data' => $list['data'], 'count' => $list['total']];
- }
- return View::fetch();
- }
- // 修改
- public function update_upgrade()
- {
- $id=input("id");
- $min=input("min");
- $max=input("max");
- $where["id"]=$id;
- $update["min"]=$min;
- $update["max"]=$max;
- $result=Db::name("major_level")->where($where)->update($update);
- if ($result){
- json_result(1,"修改成功");
- }
- json_result(2,"修改失败");
- }
- }
|