Apply.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class Apply extends Base
  7. {
  8. // 用户流程申请
  9. public function save(){
  10. model('Apply')->add();
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 查询用户审批申请
  14. public function detail(){
  15. $id = input('id/d',0);
  16. $ret = model('Apply')->info($id,$this->userId,$this->orgId);
  17. HelpHander::success($ret);
  18. }
  19. // 我发起的审批
  20. public function list(){
  21. $page = input('page/d',1);
  22. $size = input('size/d',10);
  23. $status = input('status/d',0);
  24. $approvalId = input('approvalId/d',0);
  25. $info = input('info','','trim');
  26. $startTime = input('startTime','','trim');
  27. $endTime = input('endTime','','trim');
  28. $ret = model('Apply')->lists($page,$size,$this->userId,$this->orgId,$status,$approvalId,$info,$startTime,$endTime);
  29. HelpHander::success($ret);
  30. }
  31. // 我发起的审批流程列表APP
  32. public function queryUserApplyList(){
  33. $page = input('page/d',1);
  34. $size = input('size/d',10);
  35. $param = input('param','','trim');
  36. $ret = model('Apply')->queryUserApplyList($page,$size,$param,$this->userId,$this->orgId);
  37. HelpHander::success($ret);
  38. }
  39. // 我审批的流程列表APP
  40. public function appMyApplyList(){
  41. $page = input('page/d',1);
  42. $size = input('size/d',10);
  43. $param = input('searchInfo','','trim');
  44. $type = input('type/d',-1);
  45. $ret = model('Apply')->appMyApplyList($page,$size,$param,$type,$this->userId,$this->orgId);
  46. HelpHander::success($ret);
  47. }
  48. // 抄送我的审批流列表 APP
  49. public function queryCopyUserApply(){
  50. $page = input('page/d',1);
  51. $size = input('size/d',10);
  52. $param = input('param','','trim');
  53. $status = input('status/d',-1);
  54. $ret = model('Apply')->queryCopyUserApply($page,$size,$param,$status,3,$this->userId,$this->orgId);
  55. HelpHander::success($ret);
  56. }
  57. // 执行人列表 APP
  58. public function queryExecuteList(){
  59. $page = input('page/d',1);
  60. $size = input('size/d',10);
  61. $param = input('param','','trim');
  62. $status = input('status/d',-1);
  63. $ret = model('Apply')->queryCopyUserApply($page,$size,$param,$status,9,$this->userId,$this->orgId);
  64. HelpHander::success($ret);
  65. }
  66. // 我审批的流程列表
  67. public function userApplyList(){
  68. $page = input('page/d',1);
  69. $size = input('size/d',10);
  70. $status = input('status/d',-1);
  71. $type = input('type/d',0);
  72. $approvalId = input('approvalId/d',0);
  73. $info = input('info','','trim');
  74. $startTime = input('startTime','','trim');
  75. $endTime = input('endTime','','trim');
  76. $ret = model('Apply')->userApplyList($page,$size,$this->userId,$this->orgId,$type,$status,$approvalId,$info,$startTime,$endTime);
  77. HelpHander::success($ret);
  78. }
  79. // 指定组织下的流程
  80. public function queryApplyList(){
  81. $page = input('page/d',1);
  82. $size = input('size/d',10);
  83. $status = input('status/d',0);
  84. $approvalId = input('approvalId/d',0);
  85. $info = input('info','','trim');
  86. $startTime = input('startTime','','trim');
  87. $endTime = input('endTime','','trim');
  88. $ret = model('Apply')->lists($page,$size,0,$this->orgId,$status,$approvalId,$info,$startTime,$endTime);
  89. HelpHander::success($ret);
  90. }
  91. //打回上一级
  92. public function back(){
  93. $id = input('applyRecordId/d',0);
  94. model('ApplyRecord')->back($id,$this->userId);
  95. HelpHander::success([],'操作成功');
  96. }
  97. // 同意
  98. public function audit(){
  99. $id = input('applyRecordId/d',0);
  100. $content = input('content','','trim');
  101. $userList = input('userList','','trim');
  102. $formJson = input('formJson','','trim');
  103. model('ApplyRecord')->audit($id,$this->userId,$content,$formJson,$userList);
  104. HelpHander::success([],'操作成功');
  105. }
  106. // 打回
  107. public function toBack(){
  108. $applyId = input('applyId/d',0);
  109. $content = input('content','','trim');
  110. model('ApplyRecord')->toBack($applyId,$this->userId,$content);
  111. HelpHander::success([],'操作成功');
  112. }
  113. // 加签
  114. public function addSign(){
  115. $id = input('applyRecordId/d',0);
  116. $addUserId = input('addUserId/d',0);
  117. $type = input('type/d',0); // 0=往前加签 1=往后加签
  118. model('ApplyRecord')->addSign($id,$this->userId,$addUserId,$type);
  119. HelpHander::success([],'操作成功');
  120. }
  121. // 会签
  122. public function aggregationApproval(){
  123. $id = input('applyRecordId/d',0);
  124. $userIds = input('userIds','','trim');
  125. if(!$userIds){
  126. HelpHander::error('未选择会签人员');
  127. }
  128. model('ApplyRecord')->aggregationApproval($id,$this->userId,$userIds);
  129. HelpHander::success([],'操作成功');
  130. }
  131. // 转交
  132. public function transferApply(){
  133. $id = input('applyRecordId/d',0);
  134. $transferUserId = input('transferUserId/d',0);
  135. model('ApplyRecord')->transferApply($id,$this->userId,$transferUserId);
  136. HelpHander::success([],'操作成功');
  137. }
  138. // 管理员撤销
  139. public function updateStatusById(){
  140. $applyId = input('applyId/d',0);
  141. model('Apply')->undo($applyId,$this->userId,0);
  142. HelpHander::success([],'操作成功');
  143. }
  144. // 用户撤销审批
  145. public function undo(){
  146. $applyId = input('applyId/d',0);
  147. model('Apply')->undo($applyId,$this->userId,1);
  148. HelpHander::success([],'操作成功');
  149. }
  150. // 用户删除审批
  151. public function del(){
  152. $applyId = input('id/d',0);
  153. model('Apply')->del($applyId,$this->userId);
  154. HelpHander::success([],'操作成功');
  155. }
  156. // 关联审批单
  157. public function selectApplyListByType(){
  158. $page = input('page/d',1);
  159. $size = input('size/d',10);
  160. $type = input('type/d',0);
  161. $approvalId = input('approvalId/d',0);
  162. $param = input('param','','trim');
  163. $ret = model('Apply')->selectApplyListByType($page,$size,$this->userId,$this->orgId,$type,$approvalId,$param);
  164. HelpHander::success($ret);
  165. }
  166. // 关联主合同审批单
  167. public function selectContractByType(){
  168. $page = input('page/d',1);
  169. $size = input('size/d',10);
  170. $type = input('type/d',0);
  171. $param = input('param','','trim');
  172. $ret = model('Apply')->selectContractByType($page,$size,$this->userId,$this->orgId,$type,$param);
  173. HelpHander::success($ret);
  174. }
  175. // 关联未结算清合同审批单
  176. public function selectContractFinishByType(){
  177. $page = input('page/d',1);
  178. $size = input('size/d',10);
  179. $type = input('type/d',0);
  180. $param = input('param','','trim');
  181. $ispay = input('ispay/d',1); // 1=付款 2=收款
  182. $ret = model('Apply')->selectContractFinishByType($page,$size,$this->userId,$this->orgId,$type,$param,$ispay);
  183. HelpHander::success($ret);
  184. }
  185. // 催办
  186. public function remindAudit(){
  187. $applyId = input('applyId/d',0);
  188. model('Apply')->remindAudit($applyId,$this->userId);
  189. HelpHander::success([],'操作成功');
  190. }
  191. // 待办事项菜单及数量
  192. public function untodoMenu(){
  193. $count1 = Db::name('apply')
  194. ->where('del',0)
  195. ->where('status',1)
  196. ->where('create_user_id',$this->userId)
  197. ->count();
  198. $count2 = Db::name('apply_record')
  199. ->alias('ar')
  200. ->join('apply a','a.id = ar.apply_id')
  201. ->where('a.del',0)
  202. ->where('ar.type','in',[2,8])
  203. ->where('ar.status',0)
  204. ->where('ar.del',0)
  205. ->where('ar.user_id',$this->userId)
  206. ->count();
  207. $count3 = Db::name('apply_record')
  208. ->alias('ar')
  209. ->join('apply a','a.id = ar.apply_id')
  210. ->where('a.del',0)
  211. ->where('ar.type',3)
  212. ->where('ar.status',0)
  213. ->where('ar.del',0)
  214. ->where('ar.user_id',$this->userId)
  215. ->count();
  216. $count4 = Db::name('salary_apply_record')
  217. ->alias('sar')
  218. ->join('salary_record sr','sr.id = sar.salary_record_id and sr.cur_node = sar.salary_apply_id')
  219. ->where('sar.user_id',$this->userId)
  220. ->where('sr.del',0)
  221. ->where('sr.status',0)
  222. ->where('sar.del',0)
  223. ->count();
  224. $count5 = Db::name('important_record')
  225. ->alias('ir')
  226. ->join('important i','i.id = ir.important_id')
  227. ->where('ir.user_id',$this->userId)
  228. ->where('i.del',0)
  229. ->where('i.status',0)
  230. ->where('ir.status','in',[0,1,2])
  231. ->count();
  232. $count6 = Db::name('work_news_receiver')
  233. ->alias('wnr')
  234. ->join('work_news wn','wn.id = wnr.work_news_id')
  235. ->where('wnr.user_id',$this->userId)
  236. ->where('wnr.is_read',0)
  237. ->where('wn.status',1)
  238. ->count();
  239. $data = [
  240. [
  241. 'id' => 2,
  242. 'title' => $count2>0?'待我审批('.$count2.')':'待我审批'
  243. ],
  244. [
  245. 'id' => 1,
  246. 'title' => $count1>0?'我发起的('.$count1.')':'我发起的'
  247. ],
  248. [
  249. 'id' => 3,
  250. 'title' => $count3>0?'抄送我的('.$count3.')':'抄送我的'
  251. ],
  252. [
  253. 'id' => 4,
  254. 'title' => $count4>0?'工资审批('.$count4.')':'工资审批'
  255. ],
  256. [
  257. 'id' => 5,
  258. 'title' => $count5>0?'重要事项办理('.$count5.')':'重要事项办理'
  259. ],
  260. [
  261. 'id' => 6,
  262. 'title' => $count6>0?'工作动态报送('.$count6.')':'工作动态报送'
  263. ]
  264. ];
  265. HelpHander::success($data,'成功');
  266. }
  267. }