diff --git a/application/common.php b/application/common.php index 14cd2f30..e4ba95f7 100644 --- a/application/common.php +++ b/application/common.php @@ -233,7 +233,7 @@ function upload($list,$file,$isSave=false) $data = array( 'msg'=>'上传成功' ,'val'=>true - ,'url'=>$list['serurl'].$list['url'] + ,'url'=>$list['url'] ); }else{ $data = array( @@ -245,7 +245,7 @@ function upload($list,$file,$isSave=false) $data = array( 'msg'=>'上传成功' ,'val'=>true - ,'url'=>$list['serurl'].$list['url'] + ,'url'=>$list['url'] ); } diff --git a/application/renshi/view/index/create_all.html b/application/renshi/view/index/create_all.html index 0c033043..959efee2 100644 --- a/application/renshi/view/index/create_all.html +++ b/application/renshi/view/index/create_all.html @@ -55,7 +55,7 @@ layui.use('upload', function(){ ,url: "{:url('upload')}" //上传接口 ,done: function(res){ if(res.val == 1){ - $('#url').val(res.url); + $('#url').val('..\\public\\uploads\\teacher\\' + res.url); } layer.msg(res.msg); } diff --git a/application/renshi/view/student/create_all.html b/application/renshi/view/student/create_all.html index 03826671..dbb0614b 100644 --- a/application/renshi/view/student/create_all.html +++ b/application/renshi/view/student/create_all.html @@ -55,7 +55,7 @@ layui.use('upload', function(){ ,url: "{:url('upload')}" //上传接口 ,done: function(res){ if(res.val == 1){ - $('#url').val(res.url); + $('#url').val('..\\public\\uploads\\student\\' + res.url); } layer.msg(res.msg); } diff --git a/application/rongyu/controller/DwRongyu.php b/application/rongyu/controller/DwRongyu.php index 5b30d425..c2039e13 100644 --- a/application/rongyu/controller/DwRongyu.php +++ b/application/rongyu/controller/DwRongyu.php @@ -102,40 +102,32 @@ class DwRongyu extends Base public function save() { // 获取表单数据 - $list = request()->only(['id','url','title','teachers','hjschool','category','fzshijian','fzschool','jiangxiang'],'post'); + $list = request()->only(['url','title','teachers','hjschool','category','fzshijian','fzschool','jiangxiang'],'post'); // 实例化验证模型 $validate = new \app\rongyu\validate\DwRongyu; // 验证表单数据 - $result = $validate->check($list); + $result = $validate->scene('add')->check($list); $msg = $validate->getError(); // 如果验证不通过则停止保存 if(!$result){ - dwry::destroy($list['id'],true); return json(['msg'=>$msg,'val'=>0]); } // 保存数据 - $data = dwry::update($list); + $data = dwry::create($list); - if(!empty($list['teachers'])) - { - // 单位荣誉参与数据模型 - // $dwrycy = new \app\rongyu\model\DwRongyuCanyu; - // 声明参与教师数组 - $canyulist = []; - // 循环组成参与信息 - foreach ($list['teachers'] as $key => $value) { - $canyulist[] = [ - 'teacherid' => $value, - 'rongyuid' => $list['id'], - ]; - } - - $data->cyDwry()->saveAll($canyulist); + // 重组教师id + $teachers = array(); + foreach ($list['teachers'] as $key => $value) { + $teachers[]['teacherid'] = $value; } + + $data->cyDwry()->saveAll($teachers); + + // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -241,7 +233,7 @@ class DwRongyu extends Base public function update($id) { // 获取表单数据 - $list = request()->only(['title','category','hjschool','fzshijian','fzschool','jiangxiang','teachers'],'put'); + $list = request()->scene('edit')->only(['title','category','hjschool','fzshijian','fzschool','jiangxiang','teachers'],'put'); $list['id'] = $id; @@ -272,7 +264,6 @@ class DwRongyu extends Base foreach ($list['teachers'] as $key => $value) { $canyulist[] = [ 'teacherid' => $value, - 'rongyuid' => $list['id'], ]; } diff --git a/application/rongyu/model/DwRongyu.php b/application/rongyu/model/DwRongyu.php index b9350c61..fc2faacb 100644 --- a/application/rongyu/model/DwRongyu.php +++ b/application/rongyu/model/DwRongyu.php @@ -39,7 +39,12 @@ class DwRongyu extends Base $query->field('id,jiancheng'); }, 'fzSchool'=>function($query){ - $query->field('id,jiancheng'); + $query->field('id,jiancheng,jibie') + ->with([ + 'dwJibie'=>function($query){ + $query->field('id,title'); + }, + ]); }, 'lxCategory'=>function($query){ $query->field('id,title'); @@ -49,7 +54,6 @@ class DwRongyu extends Base } ] ) - ->append(['jibie']) ->select(); return $data; } @@ -85,18 +89,6 @@ class DwRongyu extends Base return $this->hasMany('\app\rongyu\model\DwRongyuCanyu','rongyuid','id'); } - // 荣誉级别 - public function getJibieAttr() - { - $jibie = ''; - - if($this->fzschool){ - $jibie = $this->fzSchool->jibie; - } - - return $jibie; - } - // 发证时间修改器 public function setFzshijianAttr($value) diff --git a/application/rongyu/validate/DwRongyu.php b/application/rongyu/validate/DwRongyu.php index b86a03b5..27ea3db6 100644 --- a/application/rongyu/validate/DwRongyu.php +++ b/application/rongyu/validate/DwRongyu.php @@ -32,4 +32,10 @@ class DwRongyu extends Validate * @var array */ protected $message = []; + + // 验证场景 + protected $scene = [ + 'add' => ['title','category','hjschool','fzshijian','fzschool','jiangxiang'], + 'edit' => ['id','title','category','hjschool','fzshijian','fzschool','jiangxiang' ], + ]; } diff --git a/application/rongyu/view/dw_rongyu/create.html b/application/rongyu/view/dw_rongyu/create.html index c70c3cc0..356218ca 100644 --- a/application/rongyu/view/dw_rongyu/create.html +++ b/application/rongyu/view/dw_rongyu/create.html @@ -26,6 +26,13 @@ {/block} {block name="form"} +
+ {present name="$list.data.url"} + + {else /} + + {/present} +
- +
{php} $category = getCategory(112);{/php} - {volist name="category" id="vo"} -{/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/rongyu/view/dw_rongyu/index.html b/application/rongyu/view/dw_rongyu/index.html index ac9b6072..3d3e65f9 100644 --- a/application/rongyu/view/dw_rongyu/index.html +++ b/application/rongyu/view/dw_rongyu/index.html @@ -75,32 +75,46 @@ layui.use(['table','laypage','form','cjgl'], function(){ cols: [[ //表头 {type:'checkbox', fixed: 'left'}, {field: 'title', title: '荣誉名称',sort: true, minWidth:240}, - {field: 'hjschool', title: '获奖单位', minWidth:100,sort: true}, + {field: 'hjschool', title: '获奖单位', minWidth:100,sort: true,templet:function(d){ + var str=''; + if(d.hj_school) + { + str = d.hj_school.jiancheng; + } + return str; + }}, {field: "category",title: '荣誉类别',sort: true,templet:function(d){ var str=''; - if(d.dw_xingzhi) + if(d.lx_category) { - str = d.dw_xingzhi.title; + str = d.lx_category.title; } return str; }}, {field: 'jiangxiang', title: '奖项',sort: true,templet:function(d){ var str=''; - if(d.dw_jibie) + if(d.jx_category) { - str = d.dw_jibie.title; + str = d.jx_category.title; } return str; }} , {field: 'fzschool', title: '发证单位',sort: true,templet:function(d){ var str=''; - if(d.dw_xueduan) + if(d.fz_school) { - str = d.dw_xueduan.title; + str = d.fz_school.jiancheng; + } + return str; + }}, + {title: '级别',templet:function(d){ + var str=''; + if(d.fz_school) + { + str = d.fz_school.dw_jibie.title; } return str; }}, - {field: 'paixu', title: '级别', sort: true}, {field: 'fzshijian', title: '发证时间', sort: true}, {field: 'status', title: '状态',templet:'#status', sort: true}, {field: 'id', title: '操作',toolbar: '#barDemo',minWidth:140} diff --git a/public/uploads/.gitignore b/public/uploads/.gitignore index 8451e5b5..4841e159 100644 --- a/public/uploads/.gitignore +++ b/public/uploads/.gitignore @@ -3,6 +3,4 @@ !/teacher/TeacherInfo.xlsx /student !/student/student_template.xlsx -/rongyu_teacher -!/rongyu_teacher/404.png /rongyu_school diff --git a/public/uploads/rongyu_teacher/.gitignore b/public/uploads/rongyu_teacher/.gitignore new file mode 100644 index 00000000..25eb986a --- /dev/null +++ b/public/uploads/rongyu_teacher/.gitignore @@ -0,0 +1,3 @@ +! 404.png +! .gitignore +/ diff --git a/public/uploads/rongyu_teacher/404.png b/public/uploads/rongyu_teacher/404.png new file mode 100644 index 00000000..e642b34f Binary files /dev/null and b/public/uploads/rongyu_teacher/404.png differ