From 6798d1f31c182df6eb2c87af95844b79e11a9390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Wed, 27 Feb 2019 16:52:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E8=AF=BE=E9=A2=98=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=AE=8C=E6=88=90=E3=80=81=E4=BF=AE=E6=94=B9=E8=8D=A3?= =?UTF-8?q?=E8=AA=89=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/keti/controller/Index.php | 2 +- application/keti/controller/KetiInfo.php | 59 ++++- application/keti/model/KetiInfo.php | 119 ++++++++- application/keti/view/index/index.html | 2 +- application/keti/view/index/read.html | 154 ++++++++++++ application/keti/view/keti_info/create.html | 24 +- application/keti/view/keti_info/create1.html | 164 ------------- application/keti/view/keti_info/edit.html | 156 +++++++++--- application/keti/view/keti_info/index.html | 33 ++- application/keti/view/keti_info/read.html | 230 ------------------ .../rongyu/controller/JsRongyuInfo.php | 2 +- .../rongyu/view/js_rongyu_info/create.html | 7 +- .../rongyu/view/js_rongyu_info/edit.html | 5 +- .../rongyu/view/js_rongyu_info/index.html | 4 +- .../rongyu/view/js_rongyu_info/read.html | 6 +- .../migrations/20190222040223_keti_info.php | 4 +- 16 files changed, 493 insertions(+), 478 deletions(-) create mode 100644 application/keti/view/index/read.html delete mode 100644 application/keti/view/keti_info/create1.html delete mode 100644 application/keti/view/keti_info/read.html diff --git a/application/keti/controller/Index.php b/application/keti/controller/Index.php index c78c3569..e5408335 100644 --- a/application/keti/controller/Index.php +++ b/application/keti/controller/Index.php @@ -159,7 +159,7 @@ class Index extends Base // 模板赋值 $this->assign('list',$list); - return $this->fetch('keti_info/read'); + return $this->fetch('read'); } /** diff --git a/application/keti/controller/KetiInfo.php b/application/keti/controller/KetiInfo.php index 8d0a1b57..e8a0f66c 100644 --- a/application/keti/controller/KetiInfo.php +++ b/application/keti/controller/KetiInfo.php @@ -62,6 +62,7 @@ class KetiInfo extends Base 'fzdanweiid'=>$getdt['fzdanweiid'], 'subject'=>$getdt['subject'], 'category'=>$getdt['category'], + 'ketice'=>$getdt['ketice'], 'search'=>$getdt['search']['value'], 'order'=>$order, 'order_field'=>$order_field @@ -193,7 +194,7 @@ class KetiInfo extends Base // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移动到框架应用根目录/uploads/ 目录下 - $info = $file->validate(['size'=>2*1024*1024,'ext'=>'jpg,png,gif,jpeg'])->move('uploads\ketilixiang'); + $info = $file->validate(['size'=>2*1024*1024,'ext'=>'jpg,png,gif,jpeg'])->move('uploads\keti\lixiang'); @@ -207,7 +208,7 @@ class KetiInfo extends Base $data = ktinfo::create(['lxpic'=>$list['url'],'ketice'=>$ketice]); $id = $data->id; - $id ? $data = array('msg'=>'上传成功','val'=>true,'url'=>$list['url'],'ryid'=>$id) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); + $id ? $data = array('msg'=>'上传成功','val'=>true,'url'=>$list['url'],'ktid'=>$id) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); }else{ // 上传失败获取错误信息 $data = array('msg'=>$file->getError(),'val'=>false,'url'=>null); @@ -239,7 +240,7 @@ class KetiInfo extends Base { // 获取课题信息 $list = ktinfo::where('id',$id) - ->field('title','bianhao','fzdanweiid','subject','category','jhjtshijian') + ->field('id,title,fzdanweiid,bianhao,subject,category,jhjtshijian,lxpic') ->with([ 'ktZcr'=>function($query){ $query->field('ketiinfoid,teacherid') @@ -249,10 +250,12 @@ class KetiInfo extends Base }, ]) ->find(); + - + // 模板赋值 $this->assign('list',$list); + // 渲染模板 return $this->fetch(); } @@ -263,9 +266,53 @@ class KetiInfo extends Base * @param int $id * @return \think\Response */ - public function update(Request $request, $id) + public function update($id) { - // + // 获取表单数据 + $list = request()->only(['ketice','title','bianhao','fzdanweiid','subject','category','jhjtshijian','hjteachers','lxpic'],'PUT'); + $list['id'] = $id; + + + // 实例化验证类 + $validate = new \app\keti\validate\KetiInfo; + // 验证表单数据 + $result = $validate->scene('edit')->check($list); + $msg = $validate->getError(); + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]); + } + + + // 更新数据 + $data = ktinfo::update($list); + + // 删除原来的获奖人与参与人信息 + $data->ktZcr() + ->where('ketiinfoid',$list['id']) + ->where('category',1) + ->delete(true); + // 声明教师数组 + $teacherlist = []; + // 循环组成获奖教师信息 + foreach ($list['hjteachers'] as $key => $value) { + $canyulist[] = [ + 'teacherid' => $value, + 'rongyuid' => $list['id'], + 'category' => 1, + ]; + } + + + // 添加新的获奖人与参与人信息 + $data->ktZcr()->saveAll($canyulist); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); } /** diff --git a/application/keti/model/KetiInfo.php b/application/keti/model/KetiInfo.php index 549f697f..ec0a8d48 100644 --- a/application/keti/model/KetiInfo.php +++ b/application/keti/model/KetiInfo.php @@ -16,6 +16,7 @@ class KetiInfo extends Base $fzdanweiid = $search['fzdanweiid']; $subject = $search['subject']; $category = $search['category']; + $ketice = $search['ketice']; $order_field = $search['order_field']; $order = $search['order']; $search = $search['search']; @@ -40,19 +41,36 @@ class KetiInfo extends Base ->when(!empty($category),function($query) use($category){ $query->where('category','in',$category); }) + ->when(!empty($ketice),function($query) use($ketice){ + $query->where('ketice','in',$ketice); + }) ->when(!empty($search),function($query) use($search){ $query->where('title','like',$search); }) - // ->with( - // [ - // 'ktCategory'=>function($query){ - // $query->field('id,title'); - // }, - // 'ktLxdanwei'=>function($query){ - // $query->field('id,title'); - // }, - // ] - // ) + ->with( + [ + 'fzSchool'=>function($query){ + $query->field('id,jiancheng'); + }, + 'KtCe'=>function($query){ + $query->field('id,lxdanweiid,category,lxshijian') + ->with([ + 'ktCategory' => function($q){ + $q->field('id,title'); + }, + 'ktLxdanwei' => function($q){ + $q->field('id,jiancheng'); + } + ]); + }, + 'ktCategory'=>function($query){ + $query->field('id,title'); + }, + 'ktSubject'=>function($query){ + $query->field('id,title'); + }, + ] + ) ->append(['zcrName']) ->select(); @@ -67,6 +85,49 @@ class KetiInfo extends Base return $this->hasMany('\app\keti\model\KetiCanyu','ketiinfoid','id')->where('category',1); } + // 立项单位关联 + public function fzSchool() + { + return $this->belongsTo('\app\system\model\School','fzdanweiid','id'); + } + + + // 研究类型关联 + public function ktCategory() + { + return $this->belongsTo('\app\system\model\Category','category','id'); + } + + + // 所属学科关联 + public function ktSubject() + { + return $this->belongsTo('\app\system\model\Category','subject','id'); + } + + + // 课题册关联 + public function ktCe() + { + return $this->belongsTo('\app\keti\model\Keti','ketice','id'); + } + + + + // 结题等级获取器 + public function getJddengjiAttr($value) + { + // 结题数组 + $jtdj = array('0'=>'研究中','1'=>'合格','2'=>'优秀','3'=>'流失'); + // 获取结题鉴定等级 + $str = $jtdj[$value]; + // 返回结题等级 + return $str; + } + + + // 立项 + // 课题主持人名单整理 public function getZcrNameAttr($value) @@ -90,5 +151,43 @@ class KetiInfo extends Base } + // 计划结题时间修改器 + public function setJhjtshijianAttr($value) + { + return strtotime($value); + } + + // 计划结题时间获取器 + public function getJhjtshijianAttr($value) + { + if ($value>0) + { + $value = date('Y-m-d',$value); + }else{ + $value = ""; + } + return $value; + } + + // 结题时间修改器 + public function setJtshijianAttr($value) + { + return strtotime($value); + } + + // 结题时间获取器 + public function getJtshijianAttr($value) + { + if ($value>0) + { + $value = date('Y-m-d',$value); + }else{ + $value = ""; + } + return $value; + } + + + } diff --git a/application/keti/view/index/index.html b/application/keti/view/index/index.html index bdaed7e2..d4470b2b 100644 --- a/application/keti/view/index/index.html +++ b/application/keti/view/index/index.html @@ -158,7 +158,7 @@ // 上图图片按钮 picbut = ''; // 添加荣誉 - addbut = ''; + addbut = ''; // 编辑按钮 editbut = ''; delbut = ''; diff --git a/application/keti/view/index/read.html b/application/keti/view/index/read.html new file mode 100644 index 00000000..e3c1f54c --- /dev/null +++ b/application/keti/view/index/read.html @@ -0,0 +1,154 @@ +{extend name="common@list" /} +{block name="topnav"} + +{/block} +{block name="bouttons"} +
+ + + + + 批量删除 + + + + + 添加课题信息 + + + + 共有数据:{$list.count} 条 + +
+{/block} +{block name="tables"} + + + + + + + + + + + + + + + + + + + +
主持人课题名称课题编号负责单位研究类型所属学科研究状态计划结题时间结题时间状态操作
+ + +{/block} +{block name="myjs"} + +{/block} \ No newline at end of file diff --git a/application/keti/view/keti_info/create.html b/application/keti/view/keti_info/create.html index 35149912..27a622e0 100644 --- a/application/keti/view/keti_info/create.html +++ b/application/keti/view/keti_info/create.html @@ -101,10 +101,14 @@ // 设置表单验证规则 var myrules = { title:{ - maxlength:40, - }, - hjshijian:{ required:true, + maxlength:60, + }, + bianhao:{ + required:true, + rangelength:[1,10] + }, + jhjtshijian:{ dateISO:true }, }; @@ -141,7 +145,7 @@ resize: false, //上传时提交自身需要的字段并传递到后台。 formData: { - rongyuce : "{$list.ketice}", + ketice : "{$list.ketice}", }, // 只允许选择图片文件。 accept: { @@ -197,8 +201,8 @@ uploader.on( 'uploadAccept', function( file, response ) { $('#lxpic').val(response.url); - $('#id').val(response.ryid); - $('#form-member-add').attr('action','/ktinfo/'+response.ryid); + $('#id').val(response.ktid); + $('#form-member-add').attr('action','/ktinfo/'+response.ktid); $('#form-member-add').attr('method','PUT'); mytype = 'PUT'; }); @@ -239,7 +243,7 @@ }); - // 获取获奖教师列表 + // 获取课题主持教师列表 function hjSelect(obj) { $('#hjSelect').empty(); @@ -281,6 +285,12 @@ $('#addHj').append(myhtml); $('#addHj').children("span").last().append(obj); } + + // 删除参与人 + function delCy(obj) + { + $(obj).parent().remove(); + } // 匹配用户名 diff --git a/application/keti/view/keti_info/create1.html b/application/keti/view/keti_info/create1.html deleted file mode 100644 index 7e0890b1..00000000 --- a/application/keti/view/keti_info/create1.html +++ /dev/null @@ -1,164 +0,0 @@ -{extend name="common@create" /} -{block name="mycss"} -{/block} -{block name="formaa"} -
-
- -
-
-
-
选择文件
- -
-
-
-
-
- - - -
- -
- -
-
-
- -
- -
-
-
-
- -
- -
- -
-
-
- -
- - {php} $school = schlist('校级','区级');{/php} - - -
-
-
- -
- - {php}$category = getCategory(116);{/php} - - -
-
-
- -
- - {php}$category = getCategory(117);{/php} - - -
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/keti/view/keti_info/edit.html b/application/keti/view/keti_info/edit.html index 22696216..52fb0b69 100644 --- a/application/keti/view/keti_info/edit.html +++ b/application/keti/view/keti_info/edit.html @@ -1,21 +1,74 @@ {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"} -
+
+ +
+
- +
- + +
+ +
+ {volist name="list.kt_zcr" id="vo"} + + + + + {/volist} +
+
+
+
+
+ +
+ +
+
+
+ +
+ + {php} $school = schlist('校级','区级');{/php} + + +
+
+
+
- {php}$category = getCategory(115);{/php} + {php}$category = getCategory(116);{/php} + + +
+
+
+ +
+ + {php}$category = getCategory(117);{/php} - - {volist name="school" id="vo"} - - {/volist} - - -
-
-
- +
- +
@@ -51,20 +90,20 @@ {/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/index.html b/application/keti/view/keti_info/index.html index 277cc9c7..be832af2 100644 --- a/application/keti/view/keti_info/index.html +++ b/application/keti/view/keti_info/index.html @@ -117,12 +117,11 @@ 主持人 课题名称 + 课题编号 立项单位 负责单位 - 课题类型 - 研究方向 - 学科 - 结题数量 + 立项类型 + 研究状态 立项时间 状态 操作 @@ -192,6 +191,7 @@ }); return chk; }, + ketice:"", }, }; @@ -201,13 +201,12 @@ { "data": "id" }, { "data": "zcrName","name":"id","defaultContent": ""}, { "data": "title","defaultContent": "" }, - { "data": "kt_lxdanwei.title" ,"name":"lxdanweiid","defaultContent": ""}, - { "data": "kt_lxdanwei.title" ,"name":"lxdanweiid","defaultContent": ""}, - { "data": "kt_category.title","name":"category","defaultContent": ""}, - { "data": "ktcnt","name":"id","defaultContent": ""}, - { "data": "jtcnt","name":"id","defaultContent": ""}, - { "data": "jtcnt","name":"id","defaultContent": ""}, - { "data": "lxshijian","name":"lxshijian","defaultContent": ""}, + { "data": "bianhao","defaultContent": "" }, + { "data": "kt_ce.kt_lxdanwei.jiancheng" ,"name":"id","defaultContent": ""}, + { "data": "fz_school.jiancheng" ,"name":"fzdanweiid","defaultContent": ""}, + { "data": "kt_ce.kt_category.title","name":"id","defaultContent": ""}, + { "data": "jddengji","defaultContent": ""}, + { "data": "kt_ce.lxshijian","name":"id","defaultContent": ""}, { "data": "status" }, { "data": "id" }, ]; @@ -229,14 +228,10 @@ stopbut = ''; // 启用按钮 startbut = ''; - - // 上图图片按钮 - picbut = ''; - // 添加荣誉 - addbut = ''; + // 编辑按钮 - editbut = ''; - delbut = ''; + editbut = ''; + delbut = ''; if(row.status == '已停用') { buts = startbut; @@ -244,7 +239,7 @@ buts = stopbut; } - return buts + picbut + addbut + editbut + delbut; + return buts + editbut + delbut; } }, { diff --git a/application/keti/view/keti_info/read.html b/application/keti/view/keti_info/read.html deleted file mode 100644 index e36101a1..00000000 --- a/application/keti/view/keti_info/read.html +++ /dev/null @@ -1,230 +0,0 @@ -{extend name="common@list" /} -{block name="topnav"} - -{/block} -{block name="bouttons"} -
- - - - - 批量删除 - - - - - 共有数据:{$list.count} 条 - -
-
-
筛选课题册信息
-
-
- {php} - $school = schlist('区级','部级'); - {/php} - -
-
- {foreach $school as $key=>$vo } - - {/foreach} -
- -
-
- {php}$category = getCategory(115);{/php} - -
-
- {foreach $category as $key=>$vo } - - {/foreach} -
- -
-
- {php} - $school = schlist('校级','区级'); - {/php} - -
-
- {foreach $school as $key=>$vo } - - {/foreach} -
- -
-
-
-{/block} -{block name="tables"} - - - - - - - - - - - - - - - - - - -
主持人课题名称立项单位课题类型研究方向学科结题数量立项时间状态操作
- - -{/block} -{block name="myjs"} - -{/block} \ No newline at end of file diff --git a/application/rongyu/controller/JsRongyuInfo.php b/application/rongyu/controller/JsRongyuInfo.php index 96dcedad..11c44282 100644 --- a/application/rongyu/controller/JsRongyuInfo.php +++ b/application/rongyu/controller/JsRongyuInfo.php @@ -249,7 +249,7 @@ class JsRongyuInfo extends Base { // 获取荣誉信息 $list = ryinfo::where('id',$id) - ->field('id,title,rongyuce,bianhao,hjschool,subject,jiangxiang,hjshijian,pic') + ->field('id,title,bianhao,hjschool,subject,jiangxiang,hjshijian,pic') ->with([ 'hjJsry'=>function($query){ $query->field('rongyuid,teacherid') diff --git a/application/rongyu/view/js_rongyu_info/create.html b/application/rongyu/view/js_rongyu_info/create.html index 7794231f..bbf3a9e1 100644 --- a/application/rongyu/view/js_rongyu_info/create.html +++ b/application/rongyu/view/js_rongyu_info/create.html @@ -16,8 +16,8 @@
- - + +
@@ -118,6 +118,9 @@ required:true, dateISO:true }, + bianhao:{ + maxlength:15, + }, }; // 设置表单提交方式 diff --git a/application/rongyu/view/js_rongyu_info/edit.html b/application/rongyu/view/js_rongyu_info/edit.html index d0bc4fa7..756bc140 100644 --- a/application/rongyu/view/js_rongyu_info/edit.html +++ b/application/rongyu/view/js_rongyu_info/edit.html @@ -3,7 +3,7 @@ {css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.css" /} {/block} {block name="formaa"} -
+
@@ -351,6 +351,9 @@ required:true, dateISO:true }, + bianhao:{ + maxlength:15, + }, }; // 设置表单提交方式 diff --git a/application/rongyu/view/js_rongyu_info/index.html b/application/rongyu/view/js_rongyu_info/index.html index 42499b74..bf1a4c16 100644 --- a/application/rongyu/view/js_rongyu_info/index.html +++ b/application/rongyu/view/js_rongyu_info/index.html @@ -178,8 +178,8 @@ // 启用按钮 startbut = ''; // 编辑按钮 - editbut = ''; - delbut = ''; + editbut = ''; + delbut = ''; if(row.status == '已停用') { buts = startbut; diff --git a/application/rongyu/view/js_rongyu_info/read.html b/application/rongyu/view/js_rongyu_info/read.html index 5dfa1916..d26a7e58 100644 --- a/application/rongyu/view/js_rongyu_info/read.html +++ b/application/rongyu/view/js_rongyu_info/read.html @@ -21,10 +21,10 @@ 批量删除 - + 添加教师荣誉信息 + 共有数据:{$list.count} 条 diff --git a/database/migrations/20190222040223_keti_info.php b/database/migrations/20190222040223_keti_info.php index 6fe0c231..8e5522c2 100644 --- a/database/migrations/20190222040223_keti_info.php +++ b/database/migrations/20190222040223_keti_info.php @@ -33,7 +33,7 @@ class KetiInfo extends Migrator // 添加当前表字段 $table - ->addColumn('title','string',['limit'=>60,'null'=>false,'default'=>0,'comment'=>'课题名称']) + ->addColumn('title','string',['limit'=>60,'null'=>false,'comment'=>'课题名称']) ->addColumn('ketice','integer',['limit'=>11,'null'=>false,'default'=>0,'comment'=>'课题册id']) ->addColumn('bianhao','string',['limit'=>11,'null'=>false,'comment'=>'课题编号']) ->addColumn('lxpic','string',['limit'=>100,'null'=>false,'comment'=>'立项证书图片']) @@ -42,7 +42,7 @@ class KetiInfo extends Migrator ->addColumn('category','integer',['limit'=>11,'null'=>false,'comment'=>'研究类型']) ->addColumn('jhjtshijian','integer',['limit'=>11,'null'=>false,'comment'=>'计划结题时间']) ->addColumn('jtshijian','integer',['limit'=>11,'null'=>false,'comment'=>'结题时间']) - ->addColumn('jddengji','integer',['limit'=>1,'null'=>false,'default'=>0,'comment'=>'鉴定等级:0=>未结题,1=>合格,2=>优秀,3=>流失']) + ->addColumn('jddengji','integer',['limit'=>1,'null'=>false,'default'=>0,'comment'=>'鉴定等级:0=>研究中,1=>合格,2=>优秀,3=>流失']) ->addColumn('jtpic','string',['limit'=>100,'null'=>false,'comment'=>'结题证书图片']) ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间'])