InformationController.php
6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\home\controller;
use think\Db;
use think\Validate;
use cmf\controller\RestBaseController;
use app\portal\model\CheckModel;
/**
* @title 消息审批
*/
class InformationController extends RestBaseController
{
/**
* @title 甲方领导消息审批列表
* @description 接口说明
* @author 开发者
* @url /api/home/information/informationList
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:page type:inter require:1 default: other desc:分页页码
* @param name:type type:inter require:1 default: other desc:工作类型(1:月检,2:维修改造,3:培训演习)
*
* @return data:列表@
* @data id:列表id project_id:项目id project_name:项目名称 ins_m_time:月检时间 user_group:项目组
* @return type:工作类型 (1:月检,2:维修改造,3:培训演习)
*/
public function informationList(){
if($this->request->isGet()){
$page = $this->request->get('page');
$type = $this->request->get('type');
$rule = config('site.type');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['type'=>$type,'page'=>$page])) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//如果不是甲方领导,则没有权限操作
if($user['identity'] != config('site.a_leader')){
$this->error('无权操作');
}
//查看甲方领导的对应的乙方
if($type == 1){
//月检
$b_company_id = $common->getCompany(['pid'=>$user['company_id']],'id');
$res['data'] = $common->getCheckByCompanyBId($b_company_id['id'],$page);
}else if($type == 2){
//维修改造
}else{
//培新演习
}
//查找乙方项目组下的乙方员工
foreach($res['data'] as &$value){
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
//工作类型
$res['type'] = $type;
$this->success('成功',$res);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 甲方领导确认申请
* @description 接口说明
* @author 开发者
* @url /api/home/information/confirm
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:id type:inter require:1 default: other desc:列表id
* @param name:type type:inter require:1 default: other desc:工作类型(1:月检,2:维修改造,3:培训演习)
*/
public function confirm(){
if($this->request->isGet()){
$id = $this->request->get('id');
$type = $this->request->get('type');
$rule = config('site.confirm');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['type'=>$type,'id'=>$id])) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//如果不是甲方领导,则没有权限操作
if($user['identity'] != config('site.a_leader')){
$this->error('无权操作');
}
if($type == 1){
//月检
$checkModel = new CheckModel();
$res = $checkModel->where(['id'=>$id,'status'=>0])->update(['a_leader'=>$this->userId,'status'=>2,'l_confirm_time'=>time()]);
}else if($type == 2){
//维修改造
}else{
//培新演习
}
if($res){
$this->success('成功');
}else{
$this->error('失败');
}
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 甲方领导驳回申请
* @description 接口说明
* @author 开发者
* @url /api/home/information/reject
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:id type:inter require:1 default: other desc:列表id
* @param name:type type:inter require:1 default: other desc:工作类型(1:月检,2:维修改造,3:培训演习)
*/
public function reject(){
if($this->request->isGet()){
$id = $this->request->get('id');
$type = $this->request->get('type');
$rule = config('site.confirm');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['type'=>$type,'id'=>$id])) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//如果不是甲方领导,则没有权限操作
if($user['identity'] != config('site.a_leader')){
$this->error('无权操作');
}
if($type == 1){
//月检
$checkModel = new CheckModel();
$data = ['a_leader'=>$this->userId,'status'=>1,'reject_time'=>time()];
$res = $checkModel->where(['id'=>$id,'status'=>0])->update($data);
}else if($type == 2){
//维修改造
}else{
//培新演习
}
if($res){
$this->success('成功');
}else{
$this->error('失败');
}
}else{
$this->error('请求方式错误!');
}
}
}