From b7824dab348705b25a04fceb02e4490989b433c9 Mon Sep 17 00:00:00 2001 From: teukkk Date: Mon, 18 Nov 2024 15:58:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83=E7=AE=A1=E7=90=86-=E6=B7=BB=E5=8A=A0http?= =?UTF-8?q?=E9=87=8C=E6=A8=A1=E5=9D=97=E4=B8=8B=E6=8B=89-=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=BE=93=E5=85=A5=E6=A1=86=E5=88=A0=E9=99=A4=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=80=BC=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/business/ms-tree/index.vue | 5 ++- .../components/pure/ms-tree-select/index.vue | 33 ++++++++++++---- .../components/envParams/HttpTab.vue | 22 ++++++----- .../envParams/popUp/AddHttpDrawer.vue | 38 ------------------- .../environmental/locale/en-US.ts | 2 + .../environmental/locale/zh-CN.ts | 2 + 6 files changed, 46 insertions(+), 56 deletions(-) diff --git a/frontend/src/components/business/ms-tree/index.vue b/frontend/src/components/business/ms-tree/index.vue index 54bfdf8a0f..60f525a1fd 100644 --- a/frontend/src/components/business/ms-tree/index.vue +++ b/frontend/src/components/business/ms-tree/index.vue @@ -35,7 +35,9 @@ , checkedNodes: MsTreeNodeData) { if (props.showContainChildModule) { + if (checkedNodes.node.disabled) return; const realNode = findNodeByKey(treeData.value, checkedNodes.node.id, 'id'); if (!realNode) return; if (checkedNodes.checked) { @@ -167,15 +170,20 @@ checkNode(_checkedKeys, checkedNodes); } + // 当前节点“包含新增子模块”取消勾选,下面一层的子级取消禁用 + function updateNodeState(nodeId: string | number) { + const realNode = findNodeByKey(treeData.value, nodeId, 'id'); + if (!realNode) return; + realNode.containChildModule = false; + realNode.children?.forEach((child) => { + child.disabled = false; + }); + } + function handleSelectCurrent(nodeData: MsTreeNodeData) { if (props.showContainChildModule && checkedKeys.value.includes(nodeData.id)) { - // 取消当前,“包含新增子模块”取消勾选,下面一层的子级取消禁用 - const realNode = findNodeByKey(treeData.value, nodeData.id, 'id'); - if (!realNode) return; - realNode.containChildModule = false; - realNode.children?.forEach((child) => { - child.disabled = false; - }); + // 取消当前 + updateNodeState(nodeData.id); } selectParent(nodeData, !!checkedKeys.value.includes(nodeData.id)); } @@ -294,11 +302,20 @@ } } } - function handleChange() { + function handleChange(val: string | number | LabelValue | Array | LabelValue[] | undefined) { if (props.multiple) { nextTick(() => { inputValue.value = tempInputValue.value; }); + if (props.showContainChildModule) { + const deletedIds = selectValue.value.filter( + (item: string | number) => !(val as (string | number)[]).includes(item) + ); + // 如果是输入框删除一个 + if (deletedIds.length === 1) { + updateNodeState(deletedIds[0]); + } + } } } function handleKeyup(e: KeyboardEvent) { diff --git a/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue b/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue index b1dda068db..45a6f18657 100644 --- a/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue +++ b/frontend/src/views/project-management/environmental/components/envParams/HttpTab.vue @@ -91,13 +91,7 @@ - +