api = new api(new CustomMessage(), $this); } public function tran($params) { if (!isset($params['thread_id'])) { return ['code' => 0, 'msg' => '未选择流程']; } $thread = (new api())->getThreadById($params['thread_id']); // $thread = $this->api->getThreadById($thread_id); return (new api())->tranFlow($thread,$params); } public function start($params) { if (!isset($params['flow_id'])) { return ['code' => 0, 'msg' => '未选择流程']; } $startAuth = (new api())->checkStartAuth($params['flow_id']); if (!$startAuth) { return ['code' => 0, 'msg' => '您没有权限发起该流程审批']; } if ($params['ebill_id'] != '') { //先清除之前附加的ebill $ebill_copy_model = new EbillCopy(); $ebill_copy_model->where(['bill' => $params['bill'], "bill_id" => $params['bill_id']])->delete(); $this->appendEbill($params['bill_id'], $params['ebill_id']); } return $this->api->startFlow($params); } public function agree($params) { return $this->api->agreeFlow($params); } public function revoke($params) { return $this->api->revokeFlow($params); } public function back($params) { return $this->api->backFlow($params); } public function sign() { if ($this->request->isGet()) { $thread_id = input('thread_id'); $process = $this->api->getProcess($this->api->getThreadById($thread_id)['process_id']); $flow_id = $process['flow_id']; $scope = $this->api->getSignScope(); $ebill_copy_id = $this->getEbillCopyId($process['bill'], $process['bill_id']); $this->view->assign(['thread_id' => $thread_id, 'flow_id' => $flow_id, 'scope' => $scope, 'ebill_id' => $ebill_copy_id]); $this->assignconfig([ 'bill' => $process['bill'], 'bill_id' => $process['bill_id'], 'thread_id' => $thread_id, 'controller_url' => $this->getBillControllerUrl($process['bill']), 'bill_fields' => $this->getBillFields($process['bill']), 'can_edit_fields' => $this->getCanEditFields($process['bill'], $process['bill_id'], $thread_id), 'ebill_id' => $ebill_copy_id, ]); return $this->view->fetch(); } if ($this->request->isPost()) { return $this->api->signFlow(input('row/a')); } } public function getSelectpageWorkers() { return (new api())->getSelectpageWorkers(); } public function getStartDynamicSteps() { return (new api())->getStartDynamicSteps(); } private function getCanEditFields($bill, $bill_id, $thread_id = null) { return (new api())->getCanEditFields($bill, $bill_id, $thread_id); } private function getBillFields($bill) { return (new api())->getBillFields($bill); } private function getBillControllerUrl($bill) { $flowBillRow = (new \app\admin\model\fastflow\flow\Bill())->where(['bill_table' => $bill])->find(); $url = Loader::parseName($flowBillRow['controller'], 0); $url = str_replace('/_', '/', $url); return $url; } private function appendEbill($bill_id, $ebill_id) { $ebill_row = (new Ebill())->find($ebill_id)->toArray(); $ebill_copy_model = new EbillCopy(); if ($ebill_row) { unset($ebill_row['id']); unset($ebill_row['createtime']); unset($ebill_row['updatetime']); $ebill_row['bill_id'] = $bill_id; $ebill_copy_model->insert($ebill_row); } } private function getEbillCopyId($bill, $bill_id) { $ebill_copy = (new EbillCopy())->where(['bill' => $bill, 'bill_id' => $bill_id])->find(); if ($ebill_copy) { $ebill_copy = $ebill_copy->toArray(); return $ebill_copy['id']; } return null; } //添加签章数据,状态0,待发起 public function addSignature() { $params = input(''); $bill_row = $this->api->getBillRow($params['bill'], $params['bill_id']); return ['code' => 1, 'msg' => '操作成功']; } //发起审批之前回调 public function beforeStartCallback(&$params) { Hook::listen('fastflow_before_start', $params); } //发起审批之后回调 public function afterStartCallback(&$params) { Hook::listen('fastflow_after_start', $params); } //同意之前回调 public function beforeAgreeCallback(&$params) { Hook::listen('fastflow_before_agree', $params); } //同意之后回调 public function afterAgreeCallback(&$params) { Hook::listen('fastflow_after_agree', $params); } //驳回之前回调 public function beforeBackCallback(&$params) { Hook::listen('fastflow_before_back', $params); } //驳回之后回调 public function afterBackCallback(&$params) { Hook::listen('fastflow_after_back', $params); } //会签之前回调 public function beforeSignCallback(&$params) { Hook::listen('fastflow_before_sign', $params); } //会签之后回调 public function afterSignCallback(&$params) { Hook::listen('fastflow_after_sign', $params); } //结束之前回调 public function beforeEndCallback(&$params) { Hook::listen('fastflow_before_end', $params); } //结束之后回调 public function afterEndCallback(&$params) { // halt(123); Hook::listen('fastflow_after_end', $params); } }