修改荣誉管理、编写课题管理

This commit is contained in:
cxdbz committed 2019-02-22 15:59:13 +08:00
1 parent 0c33aa9345
commit 81aa1b89b0
26 files changed
+1108 -89

No files matched your search

+163 -9
View File
@@ -6,7 +6,7 @@ namespace app\keti\controller;
use app\common\controller\Base;
// 引用课题数据模型
use app\keti\model\Keti as kt;
use app\keti\model\Keti as keti;
class Index extends Base
{
@@ -18,7 +18,7 @@ class Index extends Base
public function index()
{
// 设置数据总数
$list['count'] = kt::count();
$list['count'] = keti::count();
// 设置页面标题
$list['title'] = '课题列表';
@@ -29,6 +29,68 @@ class Index extends Base
return $this->fetch();
}
/**
* 显示课题册列表
*
* @return \think\Response
*/
public function ajaxData()
{
// 获取DT的传值
$getdt = request()->param();
//得到排序的方式
$order = $getdt['order'][0]['dir'];
//得到排序字段的下标
$order_column = $getdt['order'][0]['column'];
//根据排序字段的下标得到排序字段
$order_field = $getdt['columns'][$order_column]['name'];
if($order_field=='')
{
$order_field = $getdt['columns'][$order_column]['data'];
}
//得到limit参数
$limit_start = $getdt['start'];
$limit_length = $getdt['length'];
//得到搜索的关键词
$search = [
'lxdanweiid'=>$getdt['lxdanweiid'],
'category'=>$getdt['category'],
'search'=>$getdt['search']['value'],
'order'=>$order,
'order_field'=>$order_field
];
// 实例化
$keti = new keti;
// 获取荣誉总数
$cnt = $keti->select()->count();
// 查询数据
$data = $keti->search($search);
$datacnt = $data->count();
// 获取当前页数据
$data = $data->slice($limit_start,$limit_length);
// 重组返回内容
$data = [
'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符
'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量)
'recordsFiltered'=>$datacnt, // 符合条件的总数据量
'data'=>$data, //获取到的数据结果
];
return json($data);
}
/**
* 显示创建资源表单页.
*
@@ -36,7 +98,14 @@ class Index extends Base
*/
public function create()
{
//
// 设置页面标题
$list['title'] = '添加课题册';
// 模板赋值
$this->assign('list',$list);
// 渲染
return $this->fetch();
}
/**
@@ -45,9 +114,29 @@ class Index extends Base
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request)
public function save()
{
//
// 获取表单数据
$list = request()->only(['title','category','lxshijian','lxdanweiid'],'post');
// 实例化验证模型
$validate = new \app\keti\validate\Keti;
// 验证表单数据
$result = $validate->check($list);
$msg = $validate->getError();
// 如果验证不通过则停止保存
if(!$result){
return json(['msg'=>$msg,'val'=>0]);;
}
// 保存数据
$data = keti::create($list);
// 根据更新结果设置返回提示信息
$data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
// 返回信息
return json($data);
}
/**
@@ -69,7 +158,15 @@ class Index extends Base
*/
public function edit($id)
{
//
// 获取荣誉册信息
$list = keti::where('id',$id)
->field('id,title,category,lxshijian,lxdanweiid')
->find();
$this->assign('list',$list);
return $this->fetch();
}
/**
@@ -79,9 +176,33 @@ class Index extends Base
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
public function update($id)
{
//
// 获取表单数据
$list = request()->only(['title','category','lxshijian','lxdanweiid'],'put');
$list['id'] = $id;
// 实例化验证类
$validate = new \app\keti\validate\Keti;
// 验证表单数据
$result = $validate->check($list);
$msg = $validate->getError();
// 如果验证不通过则停止保存
if(!$result){
return json(['msg'=>$msg,'val'=>0]);;
}
// 更新数据
$data = keti::update($list);
// 根据更新结果设置返回提示信息
$data ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
// 返回信息
return json($data);
}
/**
@@ -92,6 +213,39 @@ class Index extends Base
*/
public function delete($id)
{
//
if($id == 'm')
{
$id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据
}
$data = keti::destroy($id);
// 根据更新结果设置返回提示信息
$data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
// 返回信息
return json($data);
}
// 设置荣誉状态
public function setStatus()
{
// 获取id变量
$id = request()->post('id');
$value = request()->post('value');
// 获取学生信息
$data = keti::where('id',$id)->update(['status'=>$value]);
// 根据更新结果设置返回提示信息
$data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
// 返回信息
return json($data);
}
}
+184
View File
@@ -0,0 +1,184 @@
<?php
namespace app\keti\controller;
// 引用控制器基类
use app\common\controller\Base;
// 引用课题信息数据模型类
use app\keti\model\KetiInfo as ktinfo;
class KetiInfo extends Base
{
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
// 设置数据总数
$list['count'] = ktinfo::count();
// 设置页面标题
$list['title'] = '课题信息列表';
// 模板赋值
$this->assign('list', $list);
// 渲染模板
return $this->fetch();
}
/**
* 显示课题信息列表
*
* @return \think\Response
*/
public function ajaxData()
{
// 获取DT的传值
$getdt = request()->param();
//得到排序的方式
$order = $getdt['order'][0]['dir'];
//得到排序字段的下标
$order_column = $getdt['order'][0]['column'];
//根据排序字段的下标得到排序字段
$order_field = $getdt['columns'][$order_column]['name'];
if($order_field=='')
{
$order_field = $getdt['columns'][$order_column]['data'];
}
//得到limit参数
$limit_start = $getdt['start'];
$limit_length = $getdt['length'];
//得到搜索的关键词
$search = [
'lxdanweiid'=>$getdt['lxdanweiid'],
'category'=>$getdt['category'],
'fzschool'=>$getdt['fzschool'],
'search'=>$getdt['search']['value'],
'order'=>$order,
'order_field'=>$order_field
];
// 实例化
$keti = new ktinfo;
// 获取荣誉总数
$cnt = $keti->select()->count();
// 查询数据
$data = $keti->search($search);
$datacnt = $data->count();
// 获取当前页数据
$data = $data->slice($limit_start,$limit_length);
// 重组返回内容
$data = [
'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符
'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量)
'recordsFiltered'=>$datacnt, // 符合条件的总数据量
'data'=>$data, //获取到的数据结果
];
return json($data);
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create($id=0)
{
// 设置页面标题
$list['title'] = '添加课题信息';
$list['ketice'] = $id;
// 模板赋值
$this->assign('list',$list);
// 渲染
return $this->fetch();
}
/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request)
{
//
}
// 批量上传立项通知书
public function createall($id){
dump($id);
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
//
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
//
}
// 课题册
public function KetiCe($id)
{
dump($id);
}
}
+93 -1
View File
@@ -5,7 +5,99 @@ namespace app\keti\model;
// 引用数据模型基类
use app\common\model\Base;
class Keti extends Base
{
//
//搜索课题册
public function search($search)
{
// 获取参数
$lxdanweiid = $search['lxdanweiid'];
$category = $search['category'];
$order_field = $search['order_field'];
$order = $search['order'];
$category = $search['category'];
$search = $search['search'];
$data = $this->order([$order_field =>$order])
->when(!empty($lxdanweiid),function($query) use($lxdanweiid){
$query->where('lxdanweiid','in',$lxdanweiid);
})
->when(!empty($category),function($query) use($category){
$query->where('category','in',$category);
})
->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');
},
]
)
->append(['ktcnt','jtcnt'])
->select();
return $data;
}
// 类型关联
public function ktCategory()
{
return $this->belongsTo('\app\system\model\Category','category','id');
}
// 立项单位关联
public function ktLxdanwei()
{
return $this->belongsTo('\app\system\model\School','lxdanweiid','id');
}
// 课题信息关联
public function ktInfo()
{
return $this->hasMany('KetiInfo','ketice','id');
}
// 立项时间获取器
public function getLxshijianAttr($value)
{
if ($value>0)
{
$value = date('Y-m-d',$value);
}else{
$value = "";
}
return $value;
}
// 立项时间
public function setLxshijianAttr($value)
{
return strtotime($value);
}
// 课题数量
public function getKtcntAttr()
{
return $this->ktInfo->count();
}
// 结题课题数量
public function getJtcntAttr()
{
return $this->ktInfo->where('jddengji','>',0)->where('jtshijian','>',0)->count();
}
}
Loaded 3 of 26 files, more files were not shown because too many files have changed in this diff. Show more