diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php
index a8e36ba3..bdf1c496 100644
--- a/application/renshi/controller/Index.php
+++ b/application/renshi/controller/Index.php
@@ -283,6 +283,7 @@ class Index extends Base
$teacherlist[$i]['zhicheng'] = srcZc($value[6]);
$teacherlist[$i]['danwei'] = $list['school'];
$teacherlist[$i]['biye'] = $value[8];
+ $teacherlist[$i]['subject'] = srcSubject($value[7]);
$teacherlist[$i]['zhuanye'] = $value[9];
$teacherlist[$i]['xueli'] = srcXl($value[10]);
$teacherlist[$i]['quanpin'] = $value[11];
diff --git a/application/rongyu/controller/JsRongyu.php b/application/rongyu/controller/JsRongyu.php
index d30b0bbf..186b9e24 100644
--- a/application/rongyu/controller/JsRongyu.php
+++ b/application/rongyu/controller/JsRongyu.php
@@ -123,7 +123,7 @@ class JsRongyu extends Base
$msg = $validate->getError();
// 如果验证不通过则停止保存
if(!$result){
- return json(['msg'=>$msg,'val'=>0]);;
+ return json(['msg'=>$msg,'val'=>0]);
}
// 保存数据
@@ -166,7 +166,18 @@ class JsRongyu extends Base
*/
public function read($id)
{
- //
+ // 获取变量
+ $list['id'] = $id;
+ // 设置页面标题
+ $list['title'] = '教师荣誉信息';
+ // 设置数据总数
+ $jsryinfo = new jsryinfo();
+ $list['count'] = $jsryinfo->where('rongyuce',$id)->count();
+
+ // 模板赋值
+ $this->assign('list',$list);
+
+ return $this->fetch('js_rongyu_info/read');
}
/**
diff --git a/application/rongyu/controller/JsRongyuInfo.php b/application/rongyu/controller/JsRongyuInfo.php
index 32d1092e..19484e4d 100644
--- a/application/rongyu/controller/JsRongyuInfo.php
+++ b/application/rongyu/controller/JsRongyuInfo.php
@@ -111,30 +111,57 @@ class JsRongyuInfo extends Base
* @param \think\Request $request
* @return \think\Response
*/
- // public function save1()
- // {
- // // 获取表单数据
- // $list = request()->only(['id','title','category','hjschool','subject','fzshijian','jiangxiang'],'post');
+ public function save()
+ {
+
+ // 获取表单数据
+ $list = request()->only(['rongyuce','title','bianhao','category','hjschool','subject','hjshijian','jiangxiang','hjteachers','cyteachers','pic'],'put');
- // // 实例化验证模型
- // $validate = new \app\rongyu\validate\JsRongyu;
- // // 验证表单数据
- // $result = $validate->check($list);
- // $msg = $validate->getError();
- // // 如果验证不通过则停止保存
- // if(!$result){
- // return json(['msg'=>$msg,'val'=>0]);;
- // }
- // // 保存数据
- // $data = ryinfo::create($list);
+ // 实例化验证类
+ $validate = new \app\rongyu\validate\JsRongyuInfo;
+ // 验证表单数据
+ $result = $validate->scene('save')->check($list);
+ $msg = $validate->getError();
- // // 根据更新结果设置返回提示信息
- // $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
+ // 如果验证不通过则停止保存
+ if(!$result){
+ return json(['msg'=>$msg,'val'=>0]);
+ }
- // // 返回信息
- // return json($data);
- // }
+
+ // 更新数据
+ $data = ryinfo::create($list);
+
+ // 声明教师数组
+ $teacherlist = [];
+ // 循环组成获奖教师信息
+ foreach ($list['hjteachers'] as $key => $value) {
+ $canyulist[] = [
+ 'teacherid' => $value,
+ 'category' => 1,
+ ];
+ }
+ if(!empty($list['cyteachers'])){
+ // 循环组成参与教师信息
+ foreach ($list['cyteachers'] as $key => $value) {
+ $canyulist[] = [
+ 'teacherid' => $value,
+ 'category' => 2,
+ ];
+ }
+ }
+
+
+ // 添加新的获奖人与参与人信息
+ $data->allJsry()->saveAll($canyulist);
+
+ // 根据更新结果设置返回提示信息
+ $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
+
+ // 返回信息
+ return json($data);
+ }
/**
* 批量上传教师荣誉册图片
@@ -200,14 +227,14 @@ class JsRongyuInfo extends Base
}
/**
- * 显示指定的资源
+ * 荣誉册中荣誉信息列表
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
- //
+
}
/**
@@ -252,7 +279,7 @@ class JsRongyuInfo extends Base
public function update($id)
{
// 获取表单数据
- $list = request()->only(['title','category','hjschool','subject','hjshijian','jiangxiang','hjteachers','cyteachers','pic'],'put');
+ $list = request()->only(['rongyuce','bianhao','title','category','hjschool','subject','hjshijian','jiangxiang','hjteachers','cyteachers','pic'],'put');
$list['id'] = $id;
diff --git a/application/rongyu/validate/JsRongyuInfo.php b/application/rongyu/validate/JsRongyuInfo.php
index 00a05ca6..6468bb84 100644
--- a/application/rongyu/validate/JsRongyuInfo.php
+++ b/application/rongyu/validate/JsRongyuInfo.php
@@ -14,6 +14,7 @@ class JsRongyuInfo extends Validate
*/
protected $rule = [
'id|请先上传图片' => 'require',
+ 'rongyuce|荣誉册ID丢失' => 'require',
'title|荣册标题' => 'require|length:1,30',
'hjteachers|获奖人' => 'require|array',
'hjschool|荣誉所在单位' => 'require|number',
@@ -30,4 +31,9 @@ class JsRongyuInfo extends Validate
* @var array
*/
protected $message = [];
+
+ // 验证场景
+ protected $scene = [
+ 'save' => ['rongyuce','title','hjteachers','hjschool','subject','hjshijian','jiangxiang','cyteachers'],
+ ];
}
diff --git a/application/rongyu/view/js_rongyu/create.html b/application/rongyu/view/js_rongyu/create.html
index 1a01acf8..4aa9d888 100644
--- a/application/rongyu/view/js_rongyu/create.html
+++ b/application/rongyu/view/js_rongyu/create.html
@@ -3,6 +3,7 @@
{/block}
{block name="formaa"}