From afa1988d24c195771a022e0416af7aaee32bc5ba Mon Sep 17 00:00:00 2001 From: liuli Date: Mon, 20 Dec 2021 20:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=20feat:=20=E6=94=AF=E6=8C=81=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?=E7=A9=BA=E9=97=B2=E6=9C=BA=E6=A8=A1=E5=9D=97=E5=88=B0=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/modal/permission-main.vue | 8 +- src/ui/src/components/modal/permission.vue | 5 +- src/ui/src/dictionary/iam-auth.js | 28 +++-- src/ui/src/i18n/lang/cn.json | 3 +- src/ui/src/i18n/lang/en.json | 3 +- src/ui/src/store/modules/api/host-relation.js | 7 ++ .../host/across-business-module-selector.vue | 34 ++++-- .../views/resource/transfer/transfer-menu.vue | 112 +++++++++++++++--- 8 files changed, 162 insertions(+), 38 deletions(-) diff --git a/src/ui/src/components/modal/permission-main.vue b/src/ui/src/components/modal/permission-main.vue index 7d727eb25b..0c6d2858bf 100644 --- a/src/ui/src/components/modal/permission-main.vue +++ b/src/ui/src/components/modal/permission-main.vue @@ -86,9 +86,11 @@ const allRelationPath = [] relatedResourceTypes.forEach(({ instances = [] }) => { instances.forEach((fullPaths) => { - // 数据格式[type, id, label] - // eslint-disable-next-line max-len - const topoPath = fullPaths.map(pathData => [pathData.type, pathData.id, IAM_VIEWS_NAME[pathData.type][languageIndex]]) + const topoPath = fullPaths.map((pathData) => { + const { type, id } = pathData + const label = IAM_VIEWS_NAME[type][languageIndex] + return [type, id, label] + }) allRelationPath.push(topoPath) }) }) diff --git a/src/ui/src/components/modal/permission.vue b/src/ui/src/components/modal/permission.vue index 373b34a0ab..1bce02297d 100644 --- a/src/ui/src/components/modal/permission.vue +++ b/src/ui/src/components/modal/permission.vue @@ -18,6 +18,7 @@ import { IAM_VIEWS } from '@/dictionary/iam-auth' import permissionMixins from '@/mixins/permission' import PermissionMain from './permission-main.vue' + import uniqBy from 'lodash/uniqBy' export default { name: 'permissionModal', components: { @@ -72,7 +73,7 @@ const { related_resource_types: relatedResourceTypes = [] } = action const newInstances = [] relatedResourceTypes.forEach(({ instances = [] }) => { - const insts = instances.filter((fullPaths) => { + let insts = instances.filter((fullPaths) => { const matched = fullPaths.find(item => batchInstTypes.includes(item.type)) if (matched) { const authed = authResults.find(item => String(item.resource_id) === matched.id) @@ -80,7 +81,7 @@ } return true }) - + insts = uniqBy(insts, inst => inst[0].id) newInstances.push(insts) }) diff --git a/src/ui/src/dictionary/iam-auth.js b/src/ui/src/dictionary/iam-auth.js index 310293b0d3..d541535efe 100644 --- a/src/ui/src/dictionary/iam-auth.js +++ b/src/ui/src/dictionary/iam-auth.js @@ -426,16 +426,24 @@ export const IAM_ACTIONS = { instances: [IAM_VIEWS.BIZ] }], transform: (cmdbAction, relationIds) => { - const [[[currentBizId], [targetBizId]]] = relationIds - const verifyMeta = basicTransform(cmdbAction) - verifyMeta.parent_layers = [{ - resource_id: currentBizId, - resource_type: 'biz' - }, { - resource_id: targetBizId, - resource_type: 'biz' - }] - return verifyMeta + const verifyMetas = [] + + relationIds.forEach((relationId) => { + const [[currentBizId], [targetBizId]] = relationId + const verifyMeta = basicTransform(cmdbAction) + + verifyMeta.parent_layers = [{ + resource_id: currentBizId, + resource_type: 'biz' + }, { + resource_id: targetBizId, + resource_type: 'biz' + }] + + verifyMetas.push(verifyMeta) + }) + + return verifyMetas } }, diff --git a/src/ui/src/i18n/lang/cn.json b/src/ui/src/i18n/lang/cn.json index c328f574e5..93641125fd 100644 --- a/src/ui/src/i18n/lang/cn.json +++ b/src/ui/src/i18n/lang/cn.json @@ -1469,5 +1469,6 @@ "重置成功": "重置成功", "转移至": "转移至", "追加至": "追加至", - "追加主机到业务模块": "追加主机到业务模块" + "追加主机到业务模块": "追加主机到业务模块", + "仅允许业务下空闲机跨业务转移": "仅允许业务下{idleModule}跨业务转移" } diff --git a/src/ui/src/i18n/lang/en.json b/src/ui/src/i18n/lang/en.json index df19398830..9b4ad764f3 100644 --- a/src/ui/src/i18n/lang/en.json +++ b/src/ui/src/i18n/lang/en.json @@ -1464,5 +1464,6 @@ "重置成功": "Successful restored", "转移至": "Transfer to", "追加至": "Append to", - "追加主机到业务模块": "Append to Business Modules" + "追加主机到业务模块": "Append to Business Modules", + "仅允许业务下空闲机跨业务转移": "Only {idleModule} under the business allowed to transfer across businesses" } diff --git a/src/ui/src/store/modules/api/host-relation.js b/src/ui/src/store/modules/api/host-relation.js index 39b40fee3f..6c84a79441 100644 --- a/src/ui/src/store/modules/api/host-relation.js +++ b/src/ui/src/store/modules/api/host-relation.js @@ -103,6 +103,13 @@ const actions = { */ transferHostToMutipleBizModule({ commit, state, dispatch }, { params, config }) { return $http.post('hosts/modules/biz/mutilple', params, config) + }, + + /** + * 跨业务转移空闲机到空闲机模块 + */ + transferHostToOtherBizModule({ commit, state, dispatch }, { params, config }) { + return $http.post('hosts/resource/cross/biz', params, config) } } diff --git a/src/ui/src/views/business-topology/host/across-business-module-selector.vue b/src/ui/src/views/business-topology/host/across-business-module-selector.vue index ee750155b5..ef88e2a910 100644 --- a/src/ui/src/views/business-topology/host/across-business-module-selector.vue +++ b/src/ui/src/views/business-topology/host/across-business-module-selector.vue @@ -19,7 +19,7 @@ :key="item.bk_biz_id" :id="item.bk_biz_id" :name="`[${item.bk_biz_id}] ${item.bk_biz_name}`" - :auth="{ type: $OPERATION.HOST_TRANSFER_ACROSS_BIZ, relation: [[[bizId], [item.bk_biz_id]]] }"> + :auth="{ type: $OPERATION.HOST_TRANSFER_ACROSS_BIZ, relation: item.relation }">