diff --git a/application/rongyu/controller/JsRongyuInfo.php b/application/rongyu/controller/JsRongyuInfo.php index f3a97b8a..41a632f3 100644 --- a/application/rongyu/controller/JsRongyuInfo.php +++ b/application/rongyu/controller/JsRongyuInfo.php @@ -275,7 +275,7 @@ class JsRongyuInfo extends Base $data = ryinfo::update($list); // 删除原来的获奖人与参与人信息 - $data->allJsry()->delete(true); + $data->allJsry()->where('rongyuid',$list['id'])->delete(true); // 声明教师数组 $teacherlist = []; // 循环组成获奖教师信息 @@ -286,14 +286,17 @@ class JsRongyuInfo extends Base 'category' => 1, ]; } - // 循环组成参与教师信息 - foreach ($list['cyteachers'] as $key => $value) { - $canyulist[] = [ - 'teacherid' => $value, - 'rongyuid' => $list['id'], - 'category' => 2, - ]; + if(!empty($list['cyteachers'])){ + // 循环组成参与教师信息 + foreach ($list['cyteachers'] as $key => $value) { + $canyulist[] = [ + 'teacherid' => $value, + 'rongyuid' => $list['id'], + 'category' => 2, + ]; + } } + // 添加新的获奖人与参与人信息 $data->allJsry()->saveAll($canyulist); @@ -302,7 +305,7 @@ class JsRongyuInfo extends Base $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; // 返回信息 - return json($data&1); + return json($data); } /** diff --git a/application/rongyu/model/JsRongyuInfo.php b/application/rongyu/model/JsRongyuInfo.php index 451cf62a..c9adb149 100644 --- a/application/rongyu/model/JsRongyuInfo.php +++ b/application/rongyu/model/JsRongyuInfo.php @@ -10,7 +10,7 @@ class JsRongyuInfo extends Base //搜索单位获奖荣誉 public function search($search) { - // 获取参数 + // 获取参数 $hjschool = $search['hjschool']; $fzschool = $search['fzschool']; $category = $search['category']; @@ -19,15 +19,21 @@ class JsRongyuInfo extends Base $category = $search['category']; $search = $search['search']; + $data = $this->order([$order_field =>$order]) ->when(!empty($hjschool),function($query) use($hjschool){ $query->where('hjschool','in',$hjschool); }) - // ->when(!empty($fzschool),function($query) use($fzschool){ - // $query->where('fzschool','in',$fzschool); - // }) + ->when(!empty($fzschool),function($query) use($fzschool){ + $query->where('rongyuce','in',function($q) use($fzschool){ + $q->name('JsRongyu')->where('fzschool','in',$fzschool)->field('id'); + }); + + }) ->when(!empty($category),function($query) use($category){ - $query->where('category','in',$category); + $query->where('rongyuce','in',function($q) use($category){ + $q->name('JsRongyu')->where('category','in',$category)->field('id'); + }); }) ->when(!empty($search),function($query) use($search){ $query->where('title','like',$search); diff --git a/application/rongyu/view/js_rongyu/create.html b/application/rongyu/view/js_rongyu/create.html index 5ffbe321..1a01acf8 100644 --- a/application/rongyu/view/js_rongyu/create.html +++ b/application/rongyu/view/js_rongyu/create.html @@ -13,7 +13,7 @@