diff --git a/lib/feishuapi/feishuapi.class.php b/lib/feishuapi/feishuapi.class.php index d98a80fd76..8eb3a06cc9 100644 --- a/lib/feishuapi/feishuapi.class.php +++ b/lib/feishuapi/feishuapi.class.php @@ -11,9 +11,8 @@ class feishuapi /** * Construct * - * @param string $appKey + * @param string $appId * @param string $appSecret - * @param string $agentId * @param string $apiUrl * @access public * @return void @@ -147,6 +146,7 @@ class feishuapi /** * Get department tree structure. * + * @param string $departmentID * @access public * @return array */ @@ -191,7 +191,7 @@ class feishuapi /* Gets the enterprise name. */ $response = $this->queryAPI($this->apiUrl . "tenant/v2/tenant/query", '', array(CURLOPT_CUSTOMREQUEST => "GET")); $company = array('id' => '1', 'pId' => '0', 'name' => $response->data->tenant->name, 'open' => 1); - $depts = array($company); + $depts = array($company); $departmentIdList = $this->getScopes(); @@ -229,7 +229,7 @@ class feishuapi while(true) { - $response = $this->queryAPI($this->apiUrl . "contact/v3/scopes" . "?user_id_type=open_id&department_id_type=open_department_id&page_token={$pageToken}&page_size=100", '', array(CURLOPT_CUSTOMREQUEST => "GET")); + $response = $this->queryAPI($this->apiUrl . "contact/v3/scopes" . "?user_id_type=open_id&department_id_type=open_department_id&page_token={$pageToken}&page_size=100", '', array(CURLOPT_CUSTOMREQUEST => "GET")); $departmentIds = isset($response->data->department_ids) ? $response->data->department_ids : array(); foreach($departmentIds as $id) $departmentIdList[] = $id; @@ -243,12 +243,13 @@ class feishuapi /** * Handle the concurrency of requests. * + * @param array $urls * @access public * @return array */ public function multiRequest($urls) { - $curl = curl_multi_init(); + $curl = curl_multi_init(); $urlHandlers = array(); $urlData = array(); @@ -276,7 +277,7 @@ class feishuapi } while($mrc == CURLM_CALL_MULTI_PERFORM); - while($active && $mrc == CURLM_OK) + while($active and $mrc == CURLM_OK) { usleep(50000); if(curl_multi_select($curl) != -1) @@ -325,13 +326,13 @@ class feishuapi * @access public * @return string */ - public function queryAPI($url, $data = '', $opt = array()) + public function queryAPI($url, $data = '', $options = array()) { $headers = array(); $headers[] = "Content-Type: application/json"; if($this->token) $headers[] = "Authorization:Bearer {$this->token}"; - $response = common::http($url, $data, $opt, $headers); + $response = common::http($url, $data, $options, $headers); $errors = commonModel::$requestErrors; $response = json_decode($response); @@ -342,8 +343,17 @@ class feishuapi if(isset($response->code)) $this->errors[$response->code] = "Errcode:{$response->code}, Errmsg:{$response->msg}"; if(!empty($this->errors)) { - echo js::error(array_shift($this->errors)); - die(js::locate(helper::createLink('webhook', 'browse'))); + if(helper::isAjaxRequest()) + { + http_response_code(500); + echo array_shift($this->errors); + die(); + } + else + { + echo js::error(array_shift($this->errors)); + die(js::locate(helper::createLink('webhook', 'browse'))); + } } return false; } diff --git a/module/execution/view/storyestimate.html.php b/module/execution/view/storyestimate.html.php index c86a11a9dc..d919b6935e 100644 --- a/module/execution/view/storyestimate.html.php +++ b/module/execution/view/storyestimate.html.php @@ -14,7 +14,7 @@ #showAverage {margin: 0;} .chosen-container-single .chosen-single div b {top: 8px !important;} .chosen-container .chosen-drop {bottom: auto !important;} -.pull-left {margin: 24px 0px;} +.pull-left {margin: 12px 0px;} diff --git a/module/webhook/view/choosedept.html.php b/module/webhook/view/choosedept.html.php index ea19d3b19f..28d91d7cc4 100644 --- a/module/webhook/view/choosedept.html.php +++ b/module/webhook/view/choosedept.html.php @@ -69,8 +69,9 @@ $(function() { beforeClick: ztreeBeforeClick, beforeAsync: ztreeBeforeAsync, - onClick: ztreeOnAsyncSuccess, - onAsyncSuccess: zTreeOnAsyncSuccess + onClick: ztreeOnClick, + onAsyncSuccess: zTreeOnAsyncSuccess, + onAsyncError: zTreeOnAsyncError } }; @@ -101,8 +102,12 @@ $(function() return true; } - function ztreeOnAsyncSuccess(event, treeId, treeNode) + function ztreeOnClick(event, treeId, treeNode) { + var treeID = treeNode.tId; + if($('#' + treeID).hasClass('loading')) return false; + $('#' + treeID).addClass('loading'); + if(treeNode == undefined) { departmentID = "0"; @@ -151,6 +156,12 @@ $(function() $("#loadPrompt").remove(); } + function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) + { + var errorMsg = XMLHttpRequest.responseText; + alert(errorMsg); + } + var ztreeObj = $.fn.zTree.init($("#deptList"), setting); } else