first commit
This commit is contained in:
89
pgserver/application/admin/controller/BranchReport.php
Normal file
89
pgserver/application/admin/controller/BranchReport.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class BranchReport extends Base
|
||||
{
|
||||
// 报告列表
|
||||
public function list()
|
||||
{
|
||||
$params = input('post.');
|
||||
$where = ['del_tag' => 0];
|
||||
|
||||
// 权限过滤
|
||||
if ($this->userInfo['role'] == 1) { // 普通用户只能看自己的
|
||||
$where['upload_user_id'] = $this->userInfo['id'];
|
||||
}
|
||||
|
||||
if (!empty($params['status'])) {
|
||||
$where['status'] = $params['status'];
|
||||
}
|
||||
|
||||
$list = Db::name('pg_branch_report')
|
||||
->where($where)
|
||||
->order('upload_time desc')
|
||||
->select();
|
||||
|
||||
return $this->buildSuccess(['list' => $list]);
|
||||
}
|
||||
|
||||
// 添加报告
|
||||
public function add()
|
||||
{
|
||||
$data = input('post.');
|
||||
$data['upload_time'] = date('Y-m-d H:i:s');
|
||||
$data['upload_user_id'] = $this->userInfo['id'];
|
||||
$data['status'] = 1; // 默认待审核
|
||||
|
||||
$result = Db::name('pg_branch_report')->insert($data);
|
||||
if ($result) {
|
||||
return $this->buildSuccess([], '报告上传成功');
|
||||
}
|
||||
return $this->buildFailed('报告上传失败');
|
||||
}
|
||||
|
||||
// 审核报告
|
||||
public function review()
|
||||
{
|
||||
$params = input('post.');
|
||||
if (empty($params['id']) || empty($params['status'])) {
|
||||
return $this->buildFailed('参数错误');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'status' => $params['status'],
|
||||
'review_time' => date('Y-m-d H:i:s'),
|
||||
'review_user_id' => $this->userInfo['id']
|
||||
];
|
||||
|
||||
$result = Db::name('pg_branch_report')
|
||||
->where('id', $params['id'])
|
||||
->update($data);
|
||||
|
||||
return $result ? $this->buildSuccess([], '操作成功')
|
||||
: $this->buildFailed('操作失败');
|
||||
}
|
||||
|
||||
// 删除报告(逻辑删除)
|
||||
public function delete()
|
||||
{
|
||||
$id = input('post.id');
|
||||
if (empty($id)) {
|
||||
return $this->buildFailed('参数错误');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'del_tag' => 2,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
||||
$result = Db::name('pg_branch_report')
|
||||
->where('id', $id)
|
||||
->update($data);
|
||||
|
||||
return $result ? $this->buildSuccess([], '删除成功')
|
||||
: $this->buildFailed('删除失败');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user