From 0e90165e9f42252ad1619112afc55b8fc297314e Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Fri, 18 Sep 2020 17:49:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cm/common/plugin/IApiConsts.java | 2 +- .../apis/position/PositionController.java | 16 ++++++++++++++++ .../main/resources/templates/tree/tree-v2.html | 13 +++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java index 1c4aae5..b82c6e4 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/IApiConsts.java @@ -125,7 +125,7 @@ public interface IApiConsts { /** * 职位zTree */ - String LIST_ZTREE_POSITION = "%s/resource/role/listztreeposition"; + String LIST_ZTREE_POSITION = "%s/resource/position/listztreeposition"; /** * 获取所有用户列表(通过上级区域ID) */ diff --git a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/position/PositionController.java b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/position/PositionController.java index 5d614f5..253879e 100644 --- a/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/position/PositionController.java +++ b/cloud-common-plugin-oauth/src/main/java/com/cm/common/plugin/oauth/controller/apis/position/PositionController.java @@ -8,6 +8,7 @@ import com.cm.common.exception.SearchException; import com.cm.common.plugin.oauth.service.position.IPositionService; import com.cm.common.result.ErrorResult; import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -46,4 +47,19 @@ public class PositionController extends AbstractController { return positionService.listUserPosition(params); } + @ApiOperation(value = "zTree列表", notes = "zTree列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "上级ID", paramType = "query", dataType = "String") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listztreeposition") + public JSONArray listZTreePosition() throws SearchException { + Map params = requestParams(); + String positionParentId = "0"; + if (!StringUtils.isBlank(params.get("id") == null ? null : params.get("id").toString())) { + positionParentId = params.get("id").toString(); + } + return positionService.listZTreePosition(positionParentId); + } + } diff --git a/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html b/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html index b7b0f70..dfcae1e 100644 --- a/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html +++ b/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html @@ -213,7 +213,16 @@ zTree.checkNode(item, false, true); return; } else { - selectedNodes.push(item); + var exist = false; + for(var j = 0, jItem; jItem = selectedNodes[j++];) { + if(item.id === jItem.id) { + exist = true; + break; + } + } + if(!exist) { + selectedNodes.push(item); + } } } // if(treeNode[selectTree.primaryKey] == '0') { @@ -228,7 +237,7 @@ for(var i = 0, item; item = nodes[i++];) { removeSelectNodes(item[selectTree.primaryKey]); } - // removeSelectNodes(treeNode[selectTree.primaryKey]); + // removeSelectNodes(treeNode[selectTree.primaryKey]); } }, onAsyncSuccess: function(event, treeId, treeNode, msg) {