From d4516f82aa1e5c9e9ad327aa4e9cb3e10ee702db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Thu, 28 Feb 2019 15:23:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E9=A2=98=E5=AE=8C=E6=88=90=E3=80=81?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E4=BF=A1=E6=81=AF=E6=9D=A1=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/keti/controller/KetiInfo.php | 121 +++++++- application/keti/model/Keti.php | 6 +- application/keti/model/KetiInfo.php | 23 +- application/keti/validate/KetiInfo.php | 6 +- application/keti/view/keti_info/index.html | 38 ++- application/keti/view/keti_info/jie_ti.html | 274 ++++++++++++++++++ .../keti/view/keti_info/keti_list.html | 5 +- application/renshi/model/Student.php | 6 +- application/rongyu/model/DwRongyu.php | 8 +- application/rongyu/model/JsRongyu.php | 6 +- application/rongyu/model/JsRongyuInfo.php | 10 +- route/keti.php | 5 +- 12 files changed, 469 insertions(+), 39 deletions(-) create mode 100644 application/keti/view/keti_info/jie_ti.html diff --git a/application/keti/controller/KetiInfo.php b/application/keti/controller/KetiInfo.php index 5e38691b..501cdd87 100644 --- a/application/keti/controller/KetiInfo.php +++ b/application/keti/controller/KetiInfo.php @@ -85,6 +85,7 @@ class KetiInfo extends Base 'fzdanweiid'=>$getdt['fzdanweiid'], 'subject'=>$getdt['subject'], 'category'=>$getdt['category'], + 'jddengji'=>$getdt['jddengji'], 'ketice'=>$getdt['ketice'], 'search'=>$getdt['search']['value'], 'order'=>$order, @@ -177,10 +178,15 @@ class KetiInfo extends Base // 添加新的获奖人与参与人信息 - $data->ktZcr()->saveAll($canyulist); + $cy = $data->ktZcr()->saveAll($canyulist); // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + if($cy){ + $data=['msg'=>'添加成功','val'=>1]; + }else{ + $data=['msg'=>'数据处理错误','val'=>0]; + $data->delete(true); + } // 返回信息 return json($data); @@ -312,24 +318,20 @@ class KetiInfo extends Base $data = ktinfo::update($list); // 删除原来的获奖人与参与人信息 - $data->ktZcr() - ->where('ketiinfoid',$list['id']) - ->where('category',1) - ->delete(true); + $data->ktZcr()->delete(true); // 声明教师数组 $teacherlist = []; // 循环组成获奖教师信息 foreach ($list['hjteachers'] as $key => $value) { $canyulist[] = [ 'teacherid' => $value, - 'rongyuid' => $list['id'], 'category' => 1, ]; } // 添加新的获奖人与参与人信息 - $data->ktZcr()->saveAll($canyulist); + $data = $data->ktZcr()->saveAll($canyulist); // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -382,5 +384,108 @@ class KetiInfo extends Base } + // 结题页面 + public function jieTi($id) + { + // 获取课题信息 + $list = ktinfo::where('id',$id) + ->field('id,title,jddengji,jtshijian,jtpic') + ->with([ + 'ktCy'=>function($query){ + $query->field('ketiinfoid,teacherid') + ->with(['teacher'=>function($query){ + $query->field('id,xingming'); + }]); + }, + ]) + ->find(); + + // 模板赋值 + $this->assign('list',$list); + + // 渲染模板 + return $this->fetch(); + } + + + // 更新结题信息 + public function jtUpdate($id) + { + // 获取表单数据 + $list = request()->only(['jtpic','jddengji','jtshijian','cyteachers'],'PUT'); + $list['id'] = $id; + + + // 实例化验证类 + $validate = new \app\keti\validate\KetiInfo; + // 验证表单数据 + $result = $validate->scene('jieti')->check($list); + $msg = $validate->getError(); + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]); + } + + + // 更新数据 + $data = ktinfo::update($list); + + // 删除原来的获奖人与参与人信息 + $data->ktCy()->delete(true); + // 声明教师数组 + $teacherlist = []; + // 循环组成获奖教师信息 + foreach ($list['cyteachers'] as $key => $value) { + $canyulist[] = [ + 'teacherid' => $value, + 'category' => 2, + ]; + } + + + // 添加新的获奖人与参与人信息 + $data = $data->ktCy()->saveAll($canyulist); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + + + } + + + /** + * 上传荣誉图片并保存 + * + * @param \think\Request $request + * @return \think\Response + */ + public function jtupload() + { + + // 获取表单上传文件 例如上传了001.jpg + $file = request()->file('file'); + // 移动到框架应用根目录/uploads/ 目录下 + $info = $file->validate(['size'=>2*1024*1024,'ext'=>'jpg,png,gif,jpeg'])->move('uploads\keti\jieti'); + + if($info){ + // 成功上传后 获取上传信息 + $list['url'] = $info->getSaveName(); + $list['url'] = str_replace('\\','/',$list['url']); + // 如果图片上传成功,则返回 + $data = array('msg'=>'上传成功','val'=>true,'url'=>$list['url']); + }else{ + // 上传失败获取错误信息 + $data = array('msg'=>$file->getError(),'val'=>false,'url'=>null); + } + + // 返回信息 + return json($data); + } + + } diff --git a/application/keti/model/Keti.php b/application/keti/model/Keti.php index ada2c6d1..63fa88a3 100644 --- a/application/keti/model/Keti.php +++ b/application/keti/model/Keti.php @@ -20,13 +20,13 @@ class Keti extends Base $search = $search['search']; $data = $this->order([$order_field =>$order]) - ->when(!empty($lxdanweiid),function($query) use($lxdanweiid){ + ->when(strlen($lxdanweiid)>0,function($query) use($lxdanweiid){ $query->where('lxdanweiid','in',$lxdanweiid); }) - ->when(!empty($category),function($query) use($category){ + ->when(strlen($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($search)>0,function($query) use($search){ $query->where('title','like',$search); }) ->with( diff --git a/application/keti/model/KetiInfo.php b/application/keti/model/KetiInfo.php index ec0a8d48..08cc2ee8 100644 --- a/application/keti/model/KetiInfo.php +++ b/application/keti/model/KetiInfo.php @@ -16,35 +16,39 @@ class KetiInfo extends Base $fzdanweiid = $search['fzdanweiid']; $subject = $search['subject']; $category = $search['category']; + $jddengji = $search['jddengji']; $ketice = $search['ketice']; $order_field = $search['order_field']; $order = $search['order']; $search = $search['search']; $data = $this->order([$order_field =>$order]) - ->when(!empty($lxdanweiid),function($query) use($lxdanweiid){ + ->when(strlen($lxdanweiid)>0,function($query) use($lxdanweiid){ $query->where('ketice','in',function ($q) use($lxdanweiid){ $q->name('keti')->where('lxdanweiid','in',$lxdanweiid)->field('id'); }); }) - ->when(!empty($lxcategory),function($query) use($lxcategory){ + ->when(strlen($lxcategory)>0,function($query) use($lxcategory){ $query->where('ketice','in',function($q) use($lxcategory){ $q->name('keti')->where('category','in',$lxcategory)->field('id'); }); }) - ->when(!empty($fzdanweiid),function($query) use($fzdanweiid){ + ->when(strlen($fzdanweiid)>0,function($query) use($fzdanweiid){ $query->where('fzdanweiid','in',$fzdanweiid); }) - ->when(!empty($subject),function($query) use($subject){ + ->when(strlen($subject)>0,function($query) use($subject){ $query->where('subject','in',$subject); }) - ->when(!empty($category),function($query) use($category){ + ->when(strlen($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(!empty($ketice),function($query) use($ketice){ + ->when(strlen($ketice)>0,function($query) use($ketice){ $query->where('ketice','in',$ketice); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($jddengji)>0,function($query) use($jddengji){ + $query->where('jddengji','in',$jddengji); + }) + ->when(strlen($search)>0,function($query) use($search){ $query->where('title','like',$search); }) ->with( @@ -84,6 +88,11 @@ class KetiInfo extends Base { return $this->hasMany('\app\keti\model\KetiCanyu','ketiinfoid','id')->where('category',1); } + // 课题参与人关联 + public function ktCy() + { + return $this->hasMany('\app\keti\model\KetiCanyu','ketiinfoid','id')->where('category',2); + } // 立项单位关联 public function fzSchool() diff --git a/application/keti/validate/KetiInfo.php b/application/keti/validate/KetiInfo.php index e08c7f52..fd10c444 100644 --- a/application/keti/validate/KetiInfo.php +++ b/application/keti/validate/KetiInfo.php @@ -23,6 +23,9 @@ class KetiInfo extends Validate 'category|课题研究类型' => 'require|number', 'jhjtshijian|计划结题时间' => 'require|date', 'cyteachers|参与人' => 'array', + 'jtpic|结题鉴定图片' => 'length:1,100', + 'jtshijian|结题时间' => 'require|date', + 'jddengji|鉴定等级' => 'require|number', ]; /** @@ -36,6 +39,7 @@ class KetiInfo extends Validate // 验证场景 protected $scene = [ 'add' => ['ketice','title','bianhao','fzdanweiid','subject','category','jhjtshijian','hjteachers'], - 'edit' => ['id','title','hjteachers','hjschool','subject','hjshijian','jiangxiang','cyteachers'], + 'edit' => ['id','title','hjteachers','hjschool','subject','hjshijian','jiangxiang'], + 'jieti' => ['id','jtpic','jddengji','jtshijian','cyteachers'], ]; } diff --git a/application/keti/view/keti_info/index.html b/application/keti/view/keti_info/index.html index 01409a42..0378690e 100644 --- a/application/keti/view/keti_info/index.html +++ b/application/keti/view/keti_info/index.html @@ -107,6 +107,30 @@ +
+ {php}$category = getCategory(117);{/php} + +
+
+ + + + +
+ +
{/block} @@ -121,7 +145,7 @@ 立项单位 负责单位 立项类型 - 研究状态 + 鉴定结果 立项时间 状态 操作 @@ -191,6 +215,16 @@ }); return chk; }, + jddengji:function(){ + var chk = []; + $('input[name="jddengji"]:checked').each(function(){ + if(typeof($(this).val()) != "undefined") + { + chk.push($(this).val()); + } + }); + return chk; + }, ketice:"", }, @@ -232,7 +266,7 @@ // 编辑按钮 editbut = ''; // 编辑按钮 - jtbut = ''; + jtbut = ''; // 删除 delbut = ''; if(row.status == '已停用') diff --git a/application/keti/view/keti_info/jie_ti.html b/application/keti/view/keti_info/jie_ti.html new file mode 100644 index 00000000..b83efcd3 --- /dev/null +++ b/application/keti/view/keti_info/jie_ti.html @@ -0,0 +1,274 @@ +{extend name="common@create" /} +{block name="mycss"} +{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.css" /} +{/block} +{block name="formaa"} +
+ {if strlen($list.jtpic)>0 } + + {else /} + + {/if} +
+
+
+ +
+
+
+
选择文件
+ +
+
+
+
+
+ +
+ +
+ +
+ {volist name="list.kt_cy" id="vo"} + + + + + {/volist} +
+
+
+
+
+ +
+ + + +
+
+
+ +
+ +
+
+
+
+ +
+
+
+{/block} +{block name="yanzheng"} +{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.js"} + +{/block} \ No newline at end of file diff --git a/application/keti/view/keti_info/keti_list.html b/application/keti/view/keti_info/keti_list.html index cfe2cad7..2b00e0dc 100644 --- a/application/keti/view/keti_info/keti_list.html +++ b/application/keti/view/keti_info/keti_list.html @@ -42,7 +42,7 @@ 负责单位 研究类型 所属学科 - 研究状态 + 鉴定结果 计划结题时间 结题时间 状态 @@ -68,6 +68,7 @@ fzdanweiid:"", subject:"", category:"", + jddengji:"", ketice:"{$list.id}", }, @@ -110,7 +111,7 @@ // 编辑按钮 editbut = ''; // 编辑按钮 - jtbut = ''; + jtbut = ''; // 删除 delbut = ''; if(row.status == '已停用') diff --git a/application/renshi/model/Student.php b/application/renshi/model/Student.php index ea72971f..cbf6df67 100644 --- a/application/renshi/model/Student.php +++ b/application/renshi/model/Student.php @@ -71,13 +71,13 @@ class Student extends Base $data = $this->field('id,xingming,sex,shengri,banji,school,status') - ->when(!empty($schoolid),function($query) use($schoolid){ + ->when(strlen($schoolid)>0,function($query) use($schoolid){ $query->where('school','in',$schoolid); }) - ->when(!empty($banji),function($query) use($banji){ + ->when(count($banji)>0,function($query) use($banji){ $query->where('banji','in',$banji); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($search)>0,function($query) use($search){ $query->where('xingming','like','%'.$search.'%')->field('id'); }) ->order([$order_field=>$order]) diff --git a/application/rongyu/model/DwRongyu.php b/application/rongyu/model/DwRongyu.php index e9dbff59..e3eccee1 100644 --- a/application/rongyu/model/DwRongyu.php +++ b/application/rongyu/model/DwRongyu.php @@ -20,16 +20,16 @@ class DwRongyu extends Base $search = $search['search']; $data = $this->order([$order_field =>$order]) - ->when(!empty($hjschool),function($query) use($hjschool){ + ->when(strlen($hjschool)>0,function($query) use($hjschool){ $query->where('hjschool','in',$hjschool); }) - ->when(!empty($fzschool),function($query) use($fzschool){ + ->when(strlen($fzschool)>0,function($query) use($fzschool){ $query->where('fzschool','in',$fzschool); }) - ->when(!empty($category),function($query) use($category){ + ->when(strlen($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($search)>0,function($query) use($search){ $query->where('title','like',$search); }) ->with( diff --git a/application/rongyu/model/JsRongyu.php b/application/rongyu/model/JsRongyu.php index b02c7a48..8bdff7db 100644 --- a/application/rongyu/model/JsRongyu.php +++ b/application/rongyu/model/JsRongyu.php @@ -19,13 +19,13 @@ class JsRongyu extends Base $search = $search['search']; $data = $this->order([$order_field =>$order]) - ->when(!empty($fzschool),function($query) use($fzschool){ + ->when(strlen($fzschool)>0,function($query) use($fzschool){ $query->where('fzschool','in',$fzschool); }) - ->when(!empty($category),function($query) use($category){ + ->when(strlen($category)>0,function($query) use($category){ $query->where('category','in',$category); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($search)>0,function($query) use($search){ $query->where('title','like',$search); }) ->with( diff --git a/application/rongyu/model/JsRongyuInfo.php b/application/rongyu/model/JsRongyuInfo.php index f1b460b0..2dab0dcb 100644 --- a/application/rongyu/model/JsRongyuInfo.php +++ b/application/rongyu/model/JsRongyuInfo.php @@ -22,24 +22,24 @@ class JsRongyuInfo extends Base $data = $this->order([$order_field =>$order]) - ->when(!empty($hjschool),function($query) use($hjschool){ + ->when(strlen($hjschool)>0,function($query) use($hjschool){ $query->where('hjschool','in',$hjschool); }) - ->when(!empty($fzschool),function($query) use($fzschool){ + ->when(strlen($fzschool)>0,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){ + ->when(strlen($category)>0,function($query) use($category){ $query->where('rongyuce','in',function($q) use($category){ $q->name('JsRongyu')->where('category','in',$category)->field('id'); }); }) - ->when(!empty($rongyuce),function($query) use($rongyuce){ + ->when(strlen($rongyuce)>0,function($query) use($rongyuce){ $query->where('rongyuce',$rongyuce); }) - ->when(!empty($search),function($query) use($search){ + ->when(strlen($search)>0,function($query) use($search){ $query->where('title','like',$search); }) ->with( diff --git a/route/keti.php b/route/keti.php index 5922abac..7ee24197 100644 --- a/route/keti.php +++ b/route/keti.php @@ -13,8 +13,11 @@ Route::resource('kt','keti/Index'); Route::resource('ktinfo','keti/KetiInfo'); -// 荣誉册中课题列表 +// 课题册中课题列表 Route::get('ktlist/:id','keti/KetiInfo/ketilist'); +// 结题编辑 +Route::get('ktjt/:id/edit','keti/KetiInfo/jieTi'); +Route::put('ktjt/:id','keti/KetiInfo/jtUpdate'); // 添加立项信息 Route::get('ktinfoadd/:id','keti/KetiInfo/create'); // 批量添加立项图片