From 15983407b9b9b24be631856e4db2f08d437ee4f5 Mon Sep 17 00:00:00 2001 From: lhzzforever Date: Thu, 21 Mar 2024 17:29:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feature:=20=E9=BB=98=E8=AE=A4=E5=85=88?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=B1=82=E7=BA=A7=E9=80=89=E6=8B=A9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choose-ip/topology-manual-input.vue | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/choose-ip/topology-manual-input.vue b/frontend/src/components/choose-ip/topology-manual-input.vue index 6365dcc78..74ba9d395 100644 --- a/frontend/src/components/choose-ip/topology-manual-input.vue +++ b/frontend/src/components/choose-ip/topology-manual-input.vue @@ -2,7 +2,8 @@
- +
!['manualInput'].includes(item.id)); const list = this.curAllViewChain.map((v) => v.resource_type_chain).flat(Infinity); + this.typeValue = this.curChain[0].id; this.selectTypeList = list.reduce((prev, curr) => { // eslint-disable-next-line no-unused-expressions curData[`${curr.id}${curr.name}`] ? '' : curData[`${curr.id}${curr.name}`] = true && prev.push(curr); @@ -458,10 +460,9 @@ formatStr = ''; } this.manualValue = cloneDeep(formatStr); - const allViews = this.curAllViewChain.map((item) => item.resource_type_chain); + // const allViews = this.curAllViewChain.map((item) => item.resource_type_chain); // 根据资源类型获取他当前层级 - const curLevel = this.findObjectIndex(allViews, 'id', this.typeValue); - console.log(allViews, curLevel); + // const curLevel = this.findObjectIndex(allViews, 'id', this.typeValue); // 处理手动输入输入多个资源实例,但是是单选的业务场景 const result = this.resourceValue ? [].concat([results[0]]) : results; const list = result.map(item => { @@ -504,13 +505,13 @@ const isAsyncFlag = isAsync || item.child_type !== ''; return new Node( { - ...item, - checked, - disabled, - isRemote, - isExistNoCarryLimit + ...item, + checked, + disabled, + isRemote, + isExistNoCarryLimit }, - curLevel < 0 ? 0 : curLevel, + 0, isAsyncFlag ); }); From d83b30834ed906b06dbeda1593099e9adc2d060c Mon Sep 17 00:00:00 2001 From: lhzzforever Date: Thu, 21 Mar 2024 18:31:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=B1=BB=E5=9E=8B=E7=AC=AC=E4=B8=80=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choose-ip/topology-manual-input.vue | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/choose-ip/topology-manual-input.vue b/frontend/src/components/choose-ip/topology-manual-input.vue index 74ba9d395..4b5e550f1 100644 --- a/frontend/src/components/choose-ip/topology-manual-input.vue +++ b/frontend/src/components/choose-ip/topology-manual-input.vue @@ -2,8 +2,7 @@
- - +
!['manualInput'].includes(item.id)); const list = this.curAllViewChain.map((v) => v.resource_type_chain).flat(Infinity); - this.typeValue = this.curChain[0].id; this.selectTypeList = list.reduce((prev, curr) => { // eslint-disable-next-line no-unused-expressions curData[`${curr.id}${curr.name}`] ? '' : curData[`${curr.id}${curr.name}`] = true && prev.push(curr); return prev; }, []); + if (this.selectTypeList.length) { + this.typeValue = this.selectTypeList[0].id; + } } }, immediate: true @@ -460,9 +461,9 @@ formatStr = ''; } this.manualValue = cloneDeep(formatStr); - // const allViews = this.curAllViewChain.map((item) => item.resource_type_chain); + const allViews = this.curAllViewChain.map((item) => item.resource_type_chain); // 根据资源类型获取他当前层级 - // const curLevel = this.findObjectIndex(allViews, 'id', this.typeValue); + const curLevel = this.findObjectIndex(allViews, 'id', this.typeValue); // 处理手动输入输入多个资源实例,但是是单选的业务场景 const result = this.resourceValue ? [].concat([results[0]]) : results; const list = result.map(item => { @@ -511,7 +512,7 @@ isRemote, isExistNoCarryLimit }, - 0, + curLevel, isAsyncFlag ); }); From fd506dab8c2ea1e065d46317f959e663ca979e96 Mon Sep 17 00:00:00 2001 From: lhzzforever Date: Thu, 21 Mar 2024 19:39:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feature:=20=E5=A4=84=E7=90=86=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E8=BE=93=E5=85=A5=E6=97=B6path=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/choose-ip/grade.vue | 160 +++++++----- .../src/components/choose-ip/grade/index.vue | 242 ++++++++++-------- frontend/src/components/choose-ip/index.vue | 136 ++++++---- 3 files changed, 317 insertions(+), 221 deletions(-) diff --git a/frontend/src/components/choose-ip/grade.vue b/frontend/src/components/choose-ip/grade.vue index 640b0e939..3a5801482 100644 --- a/frontend/src/components/choose-ip/grade.vue +++ b/frontend/src/components/choose-ip/grade.vue @@ -848,17 +848,8 @@ await this.firstFetchResources(); }, - handleTreeSelect (value, node) { + handleTreeSelect (value, node, resourceLen) { const parentChain = _.cloneDeep(node.parentChain); - // const isNeedAny = node.async - // const anyData = (() => { - // const data = this.curChain[node.level + 1] - // if (data) { - // return data - // } - // return this.curChain[this.curChain.length - 1] - // })() - const curChainData = this.curChain[node.level]; const chainLen = this.curChain.length; let id = ''; @@ -873,58 +864,111 @@ name = curChainData.name; systemId = curChainData.system_id; } - - parentChain.forEach((item, index) => { - let id = ''; - if (this.curChain[index]) { - id = this.curChain[index].id; - } else { - id = this.curChain[this.curChain.length - 1].id; - } - item.type = id; - item.type_name = id; - }); - parentChain.push({ - type: id, - type_name: name, - id: node.id, - name: node.name, - system_id: systemId, - child_type: node.childType || '' - }); - // if (isNeedAny) { - // parentChain.push({ - // type: anyData.id, - // type_name: anyData.name, - // id: '*', - // name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, - // system_id: anyData.system_id, - // child_type: anyData.id - // }) - // } - - // 判断是否忽略路径 - // const isNeedIgnore = this.ignorePathFlag && !isNeedAny - // const isNeedIgnore = this.ignorePathFlag - const params = [{ - type: id, - name, - // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], - path: [parentChain], - paths: [parentChain] - }]; - - if (node.isExistNoCarryLimit) { - const p = [parentChain.slice(0, parentChain.length - 1)]; - params.push({ + if (this.isManualInput) { + parentChain.push({ + type: id, + type_name: name, + id: node.id, + name: node.name, + system_id: systemId, + child_type: node.childType || '' + }); + // 判断是否忽略路径 + const curPath = this.ignorePathFlag ? [parentChain.slice(parentChain.length - 1)] : [parentChain]; + const params = [{ type: id, name, - path: p, - paths: p + path: curPath, + paths: curPath + }]; + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + console.log(value, node, parentChain, params, resourceLen); + this.$emit('on-tree-select', value, node, params, resourceLen); + } else { + // const isNeedAny = node.level < this.curChain.length - 1 + const isNeedAny = node.async; + const anyData = (() => { + const data = this.curChain[node.level + 1]; + if (data) { + return data; + } + return this.curChain[this.curChain.length - 1]; + })(); + parentChain.forEach((item, index) => { + let id = ''; + if (this.curChain[index]) { + id = this.curChain[index].id; + } else { + id = this.curChain[this.curChain.length - 1].id; + } + item.type = id; + item.type_name = id; + }); + parentChain.push({ + type: id, + type_name: name, + id: node.id, + name: node.name, + system_id: systemId, + child_type: node.childType || '' }); + if (isNeedAny) { + parentChain.push({ + type: anyData.id, + type_name: anyData.name, + id: '*', + name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, + system_id: anyData.system_id, + child_type: anyData.id + }); + } + // 判断是否忽略路径 + // const isNeedIgnore = this.ignorePathFlag && !isNeedAny + const params = [{ + type: id, + name, + // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], + path: [parentChain], + paths: [parentChain] + }]; + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + console.log(value, node, parentChain, params, resourceLen); + this.$emit('on-tree-select', value, node, params, resourceLen); + } + // 针对资源权限特殊处理 + if (this.resourceValue) { + if (value) { + this.treeData.forEach(item => { + if (item.id !== node.id) { + item.disabled = true; + } + }); + this.resourceNode = node; + this.resourceNeedDisable = true; + } else { + this.treeData.forEach(item => { + item.disabled = false; + }); + this.resourceNode = {}; + this.resourceNeedDisable = false; + } } - - this.$emit('on-tree-select', value, node, params); }, // 单页全选 diff --git a/frontend/src/components/choose-ip/grade/index.vue b/frontend/src/components/choose-ip/grade/index.vue index 5141fcee9..6afb5e8a6 100644 --- a/frontend/src/components/choose-ip/grade/index.vue +++ b/frontend/src/components/choose-ip/grade/index.vue @@ -1160,78 +1160,92 @@ handleTreeSelect (value, node, resourceLen) { const parentChain = _.cloneDeep(node.parentChain); - let isNeedAny = false; - // 用户组以及权限模板这里,除了子节点没有“无限制”,其他节点,包括顶级节点和中间节点都有“无限制” - // 如果顶级节点无数据,那么也有“无限制” - if (this.isTemplateMode) { - // 没有中间节点以及子节点,例如 业务访问 - if (this.curChain.length === 1) { - isNeedAny = node.async; - } else { - // 有父节点 - if (node.parentChain && node.parentChain.length && node.parentId) { - isNeedAny = node.async; - } else { - isNeedAny = node.async; - // 没有子节点并且已经点过展开了 - if (!node.children.length && !node.async) { - isNeedAny = true; - // 这里需要把 node.async 设置为 true - // 下面的 if (node.level === 0 && !node.async) 这个逻辑需要 - node.async = isNeedAny; - } - } - } - } else { - if (node.parentChain && node.parentChain.length && node.parentId) { - isNeedAny = node.async; - } else { - isNeedAny = false; - } - } - // const isNeedAny = node.async && this.isTemplateMode - const anyData = (() => { - const data = this.curChain[node.level + 1]; - if (data) { - return data; - } - return this.curChain[this.curChain.length - 1]; - })(); - const curChainData = this.curChain[node.level]; const chainLen = this.curChain.length; let id = ''; let name = ''; let systemId = ''; - - let parentChainData = null; if (!curChainData) { id = this.curChain[chainLen - 1].id; name = this.curChain[chainLen - 1].name; systemId = this.curChain[chainLen - 1].system_id; - - parentChainData = { + } else { + id = curChainData.id; + name = curChainData.name; + systemId = curChainData.system_id; + } + if (this.isManualInput) { + parentChain.push({ type: id, type_name: name, id: node.id, name: node.name, system_id: systemId, child_type: node.childType || '' - }; + }); + // 判断是否忽略路径 + const curPath = this.ignorePathFlag ? [parentChain.slice(parentChain.length - 1)] : [parentChain]; + const params = [{ + type: id, + name, + path: curPath, + paths: curPath + }]; + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + console.log(value, node, parentChain, params, resourceLen); + this.$emit('on-tree-select', value, node, params, resourceLen); } else { - id = curChainData.id; - name = curChainData.name; - systemId = curChainData.system_id; - if (node.level === 0 && !node.async) { - parentChainData = { - type: this.curChain[chainLen - 1].id, - type_name: this.curChain[chainLen - 1].name, - id: node.id, - name: node.name, - system_id: this.curChain[chainLen - 1].system_id, - child_type: node.childType || '' - }; + let isNeedAny = false; + // 用户组以及权限模板这里,除了子节点没有“无限制”,其他节点,包括顶级节点和中间节点都有“无限制” + // 如果顶级节点无数据,那么也有“无限制” + if (this.isTemplateMode) { + // 没有中间节点以及子节点,例如 业务访问 + if (this.curChain.length === 1) { + isNeedAny = node.async; + } else { + // 有父节点 + if (node.parentChain && node.parentChain.length && node.parentId) { + isNeedAny = node.async; + } else { + isNeedAny = node.async; + // 没有子节点并且已经点过展开了 + if (!node.children.length && !node.async) { + isNeedAny = true; + // 这里需要把 node.async 设置为 true + // 下面的 if (node.level === 0 && !node.async) 这个逻辑需要 + node.async = isNeedAny; + } + } + } } else { + if (node.parentChain && node.parentChain.length && node.parentId) { + isNeedAny = node.async; + } else { + isNeedAny = false; + } + } + // const isNeedAny = node.async && this.isTemplateMode + const anyData = (() => { + const data = this.curChain[node.level + 1]; + if (data) { + return data; + } + return this.curChain[this.curChain.length - 1]; + })(); + let parentChainData = null; + if (!curChainData) { + id = this.curChain[chainLen - 1].id; + name = this.curChain[chainLen - 1].name; + systemId = this.curChain[chainLen - 1].system_id; + parentChainData = { type: id, type_name: name, @@ -1240,66 +1254,76 @@ system_id: systemId, child_type: node.childType || '' }; - } - } - - parentChain.forEach((item, index) => { - let id = ''; - if (this.curChain[index]) { - id = this.curChain[index].id; } else { - id = this.curChain[this.curChain.length - 1].id; + id = curChainData.id; + name = curChainData.name; + systemId = curChainData.system_id; + if (node.level === 0 && !node.async) { + parentChainData = { + type: this.curChain[chainLen - 1].id, + type_name: this.curChain[chainLen - 1].name, + id: node.id, + name: node.name, + system_id: this.curChain[chainLen - 1].system_id, + child_type: node.childType || '' + }; + } else { + parentChainData = { + type: id, + type_name: name, + id: node.id, + name: node.name, + system_id: systemId, + child_type: node.childType || '' + }; + } } - item.type = id; - item.type_name = id; - }); - - parentChain.push(parentChainData); - // parentChain.push({ - // type: id, - // type_name: name, - // id: node.id, - // name: node.name, - // system_id: systemId, - // child_type: node.childType || '' - // }) - - console.log('isNeedAnyisNeedAnyisNeedAny', isNeedAny); - - if (isNeedAny) { - parentChain.push({ - type: anyData.id, - type_name: anyData.name, - id: '*', - name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, - system_id: anyData.system_id, - child_type: anyData.id + parentChain.forEach((item, index) => { + let id = ''; + if (this.curChain[index]) { + id = this.curChain[index].id; + } else { + id = this.curChain[this.curChain.length - 1].id; + } + item.type = id; + item.type_name = id; }); - } - - // 判断是否忽略路径 - // const isNeedIgnore = this.ignorePathFlag && !isNeedAny - const params = [ - { - type: id, - name, - // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], - path: [parentChain], - paths: [parentChain] + parentChain.push(parentChainData); + console.log('isNeedAnyisNeedAnyisNeedAny', isNeedAny); + if (isNeedAny) { + parentChain.push({ + type: anyData.id, + type_name: anyData.name, + id: '*', + name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, + system_id: anyData.system_id, + child_type: anyData.id + }); } - ]; - if (node.isExistNoCarryLimit) { - const p = [parentChain.slice(0, parentChain.length - 1)]; - params.push({ - type: id, - name, - path: p, - paths: p - }); + // 判断是否忽略路径 + // const isNeedIgnore = this.ignorePathFlag && !isNeedAny + const params = [ + { + type: id, + name, + // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], + path: [parentChain], + paths: [parentChain] + } + ]; + + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + this.$emit('on-tree-select', value, node, params, resourceLen); } - - this.$emit('on-tree-select', value, node, params, resourceLen); }, // 单页全选 diff --git a/frontend/src/components/choose-ip/index.vue b/frontend/src/components/choose-ip/index.vue index 78e12678d..65561ca89 100644 --- a/frontend/src/components/choose-ip/index.vue +++ b/frontend/src/components/choose-ip/index.vue @@ -163,6 +163,7 @@ :cur-selected-chain="curSelectedChain" :has-selected-values="hasSelectedValues" :type-list="selectList" + :all-data="renderTopologyData" @on-select="handleTreeSelect" @on-select-all="handleTreeSelectAll" /> @@ -932,16 +933,6 @@ handleTreeSelect (value, node, resourceLen) { const parentChain = _.cloneDeep(node.parentChain); - // const isNeedAny = node.level < this.curChain.length - 1 - const isNeedAny = node.async; - const anyData = (() => { - const data = this.curChain[node.level + 1]; - if (data) { - return data; - } - return this.curChain[this.curChain.length - 1]; - })(); - const curChainData = this.curChain[node.level]; const chainLen = this.curChain.length; let id = ''; @@ -956,56 +947,93 @@ name = curChainData.name; systemId = curChainData.system_id; } - - parentChain.forEach((item, index) => { - let id = ''; - if (this.curChain[index]) { - id = this.curChain[index].id; - } else { - id = this.curChain[this.curChain.length - 1].id; - } - item.type = id; - item.type_name = id; - }); - parentChain.push({ - type: id, - type_name: name, - id: node.id, - name: node.name, - system_id: systemId, - child_type: node.childType || '' - }); - if (isNeedAny) { + if (this.isManualInput) { parentChain.push({ - type: anyData.id, - type_name: anyData.name, - id: '*', - name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, - system_id: anyData.system_id, - child_type: anyData.id + type: id, + type_name: name, + id: node.id, + name: node.name, + system_id: systemId, + child_type: node.childType || '' }); - } - - // 判断是否忽略路径 - // const isNeedIgnore = this.ignorePathFlag && !isNeedAny - const params = [{ - type: id, - name, - // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], - path: [parentChain], - paths: [parentChain] - }]; - - if (node.isExistNoCarryLimit) { - const p = [parentChain.slice(0, parentChain.length - 1)]; - params.push({ + // 判断是否忽略路径 + const curPath = this.ignorePathFlag ? [parentChain.slice(parentChain.length - 1)] : [parentChain]; + const params = [{ type: id, name, - path: p, - paths: p + path: curPath, + paths: curPath + }]; + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + console.log(value, node, parentChain, params, resourceLen); + this.$emit('on-tree-select', value, node, params, resourceLen); + } else { + // const isNeedAny = node.level < this.curChain.length - 1 + const isNeedAny = node.async; + const anyData = (() => { + const data = this.curChain[node.level + 1]; + if (data) { + return data; + } + return this.curChain[this.curChain.length - 1]; + })(); + parentChain.forEach((item, index) => { + let id = ''; + if (this.curChain[index]) { + id = this.curChain[index].id; + } else { + id = this.curChain[this.curChain.length - 1].id; + } + item.type = id; + item.type_name = id; }); + parentChain.push({ + type: id, + type_name: name, + id: node.id, + name: node.name, + system_id: systemId, + child_type: node.childType || '' + }); + if (isNeedAny) { + parentChain.push({ + type: anyData.id, + type_name: anyData.name, + id: '*', + name: `${anyData.name}: ${this.$t(`m.common['无限制']`)}`, + system_id: anyData.system_id, + child_type: anyData.id + }); + } + // 判断是否忽略路径 + // const isNeedIgnore = this.ignorePathFlag && !isNeedAny + const params = [{ + type: id, + name, + // path: isNeedIgnore ? [parentChain.slice(parentChain.length - 1)] : [parentChain], + path: [parentChain], + paths: [parentChain] + }]; + if (node.isExistNoCarryLimit) { + const p = [parentChain.slice(0, parentChain.length - 1)]; + params.push({ + type: id, + name, + path: p, + paths: p + }); + } + console.log(value, node, parentChain, params, resourceLen); + this.$emit('on-tree-select', value, node, params, resourceLen); } - this.$emit('on-tree-select', value, node, params, resourceLen); // 针对资源权限特殊处理 if (this.resourceValue) { if (value) {