123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class Apply extends Base
- {
- // 用户流程申请
- public function save(){
- model('Apply')->add();
- HelpHander::success([],'操作成功');
- }
- // 查询用户审批申请
- public function detail(){
- $id = input('id/d',0);
- $ret = model('Apply')->info($id,$this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 我发起的审批
- public function list(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $status = input('status/d',0);
- $approvalId = input('approvalId/d',0);
- $info = input('info','','trim');
- $startTime = input('startTime','','trim');
- $endTime = input('endTime','','trim');
- $ret = model('Apply')->lists($page,$size,$this->userId,$this->orgId,$status,$approvalId,$info,$startTime,$endTime);
- HelpHander::success($ret);
- }
- // 我发起的审批流程列表APP
- public function queryUserApplyList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $param = input('param','','trim');
- $ret = model('Apply')->queryUserApplyList($page,$size,$param,$this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 我审批的流程列表APP
- public function appMyApplyList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $param = input('searchInfo','','trim');
- $type = input('type/d',-1);
- $ret = model('Apply')->appMyApplyList($page,$size,$param,$type,$this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 抄送我的审批流列表 APP
- public function queryCopyUserApply(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $param = input('param','','trim');
- $status = input('status/d',-1);
- $ret = model('Apply')->queryCopyUserApply($page,$size,$param,$status,3,$this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 执行人列表 APP
- public function queryExecuteList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $param = input('param','','trim');
- $status = input('status/d',-1);
- $ret = model('Apply')->queryCopyUserApply($page,$size,$param,$status,9,$this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 我审批的流程列表
- public function userApplyList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $status = input('status/d',-1);
- $type = input('type/d',0);
- $approvalId = input('approvalId/d',0);
- $info = input('info','','trim');
- $startTime = input('startTime','','trim');
- $endTime = input('endTime','','trim');
- $ret = model('Apply')->userApplyList($page,$size,$this->userId,$this->orgId,$type,$status,$approvalId,$info,$startTime,$endTime);
- HelpHander::success($ret);
- }
- // 指定组织下的流程
- public function queryApplyList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $status = input('status/d',0);
- $approvalId = input('approvalId/d',0);
- $info = input('info','','trim');
- $startTime = input('startTime','','trim');
- $endTime = input('endTime','','trim');
- $ret = model('Apply')->lists($page,$size,0,$this->orgId,$status,$approvalId,$info,$startTime,$endTime);
- HelpHander::success($ret);
- }
- //打回上一级
- public function back(){
- $id = input('applyRecordId/d',0);
- model('ApplyRecord')->back($id,$this->userId);
- HelpHander::success([],'操作成功');
- }
- // 同意
- public function audit(){
- $id = input('applyRecordId/d',0);
- $content = input('content','','trim');
- $userList = input('userList','','trim');
- $formJson = input('formJson','','trim');
- model('ApplyRecord')->audit($id,$this->userId,$content,$formJson,$userList);
- HelpHander::success([],'操作成功');
- }
- // 打回
- public function toBack(){
- $applyId = input('applyId/d',0);
- $content = input('content','','trim');
- model('ApplyRecord')->toBack($applyId,$this->userId,$content);
- HelpHander::success([],'操作成功');
- }
- // 加签
- public function addSign(){
- $id = input('applyRecordId/d',0);
- $addUserId = input('addUserId/d',0);
- $type = input('type/d',0); // 0=往前加签 1=往后加签
- model('ApplyRecord')->addSign($id,$this->userId,$addUserId,$type);
- HelpHander::success([],'操作成功');
- }
- // 会签
- public function aggregationApproval(){
- $id = input('applyRecordId/d',0);
- $userIds = input('userIds','','trim');
- if(!$userIds){
- HelpHander::error('未选择会签人员');
- }
- model('ApplyRecord')->aggregationApproval($id,$this->userId,$userIds);
- HelpHander::success([],'操作成功');
- }
- // 转交
- public function transferApply(){
- $id = input('applyRecordId/d',0);
- $transferUserId = input('transferUserId/d',0);
- model('ApplyRecord')->transferApply($id,$this->userId,$transferUserId);
- HelpHander::success([],'操作成功');
- }
- // 管理员撤销
- public function updateStatusById(){
- $applyId = input('applyId/d',0);
- model('Apply')->undo($applyId,$this->userId,0);
- HelpHander::success([],'操作成功');
- }
- // 用户撤销审批
- public function undo(){
- $applyId = input('applyId/d',0);
- model('Apply')->undo($applyId,$this->userId,1);
- HelpHander::success([],'操作成功');
- }
- // 用户删除审批
- public function del(){
- $applyId = input('id/d',0);
- model('Apply')->del($applyId,$this->userId);
- HelpHander::success([],'操作成功');
- }
- // 关联审批单
- public function selectApplyListByType(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $type = input('type/d',0);
- $approvalId = input('approvalId/d',0);
- $param = input('param','','trim');
- $ret = model('Apply')->selectApplyListByType($page,$size,$this->userId,$this->orgId,$type,$approvalId,$param);
- HelpHander::success($ret);
- }
- // 关联主合同审批单
- public function selectContractByType(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $type = input('type/d',0);
- $param = input('param','','trim');
- $ret = model('Apply')->selectContractByType($page,$size,$this->userId,$this->orgId,$type,$param);
- HelpHander::success($ret);
- }
- // 关联未结算清合同审批单
- public function selectContractFinishByType(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $type = input('type/d',0);
- $param = input('param','','trim');
- $ispay = input('ispay/d',1); // 1=付款 2=收款
- $ret = model('Apply')->selectContractFinishByType($page,$size,$this->userId,$this->orgId,$type,$param,$ispay);
- HelpHander::success($ret);
- }
- // 催办
- public function remindAudit(){
- $applyId = input('applyId/d',0);
- model('Apply')->remindAudit($applyId,$this->userId);
- HelpHander::success([],'操作成功');
- }
- // 待办事项菜单及数量
- public function untodoMenu(){
- $count1 = Db::name('apply')
- ->where('del',0)
- ->where('status',1)
- ->where('create_user_id',$this->userId)
- ->count();
- $count2 = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('a.del',0)
- ->where('ar.type','in',[2,8])
- ->where('ar.status',0)
- ->where('ar.del',0)
- ->where('ar.user_id',$this->userId)
- ->count();
- $count3 = Db::name('apply_record')
- ->alias('ar')
- ->join('apply a','a.id = ar.apply_id')
- ->where('a.del',0)
- ->where('ar.type',3)
- ->where('ar.status',0)
- ->where('ar.del',0)
- ->where('ar.user_id',$this->userId)
- ->count();
- $count4 = Db::name('salary_apply_record')
- ->alias('sar')
- ->join('salary_record sr','sr.id = sar.salary_record_id and sr.cur_node = sar.salary_apply_id')
- ->where('sar.user_id',$this->userId)
- ->where('sr.del',0)
- ->where('sr.status',0)
- ->where('sar.del',0)
- ->count();
- $count5 = Db::name('important_record')
- ->alias('ir')
- ->join('important i','i.id = ir.important_id')
- ->where('ir.user_id',$this->userId)
- ->where('i.del',0)
- ->where('i.status',0)
- ->where('ir.status','in',[0,1,2])
- ->count();
- $count6 = Db::name('work_news_receiver')
- ->alias('wnr')
- ->join('work_news wn','wn.id = wnr.work_news_id')
- ->where('wnr.user_id',$this->userId)
- ->where('wnr.is_read',0)
- ->where('wn.status',1)
- ->count();
- $data = [
- [
- 'id' => 2,
- 'title' => $count2>0?'待我审批('.$count2.')':'待我审批'
- ],
- [
- 'id' => 1,
- 'title' => $count1>0?'我发起的('.$count1.')':'我发起的'
- ],
- [
- 'id' => 3,
- 'title' => $count3>0?'抄送我的('.$count3.')':'抄送我的'
- ],
- [
- 'id' => 4,
- 'title' => $count4>0?'工资审批('.$count4.')':'工资审批'
- ],
- [
- 'id' => 5,
- 'title' => $count5>0?'重要事项办理('.$count5.')':'重要事项办理'
- ],
- [
- 'id' => 6,
- 'title' => $count6>0?'工作动态报送('.$count6.')':'工作动态报送'
- ]
- ];
- HelpHander::success($data,'成功');
- }
- }
|