forked from TencentBlueKing/blueking-dbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): 资源池问题修复_统计试图 TencentBlueKing#9347
- Loading branch information
Showing
4 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...ontend/src/views/resource-manage/pool/components/summary-view/components/MultLineText.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<div class="ip-mult-line-text"> | ||
<div | ||
ref="rootRef" | ||
class="ip-mult-line-text-wrapper"> | ||
<slot /> | ||
<div | ||
ref="placeholderRef" | ||
class="placeholder"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import type { Instance, SingleTarget } from 'tippy.js'; | ||
import { dbTippy } from '@common/tippy'; | ||
let tippyInst: Instance; | ||
const rootRef = ref<HTMLElement>(); | ||
const placeholderRef = ref<HTMLElement>(); | ||
const calcShowExpand = () => { | ||
nextTick(() => { | ||
const { height: placeholderHeight } = placeholderRef.value!.getBoundingClientRect(); | ||
if (rootHeight < placeholderHeight) { | ||
createTippyInst(); | ||
} | ||
}); | ||
}; | ||
let rootHeight = 0; | ||
const createTippyInst = () => { | ||
const { width } = rootRef.value!.getBoundingClientRect(); | ||
tippyInst = dbTippy(rootRef.value as SingleTarget, { | ||
appendTo: () => document.body, | ||
arrow: true, | ||
content: placeholderRef.value, | ||
maxWidth: width, | ||
zIndex: 999999, | ||
}); | ||
}; | ||
const destroyTippyInst = () => { | ||
if (tippyInst) { | ||
tippyInst.hide(); | ||
tippyInst.unmount(); | ||
tippyInst.destroy(); | ||
} | ||
}; | ||
onMounted(() => { | ||
rootHeight = rootRef.value!.getBoundingClientRect().height; | ||
calcShowExpand(); | ||
}); | ||
onBeforeUpdate(() => { | ||
destroyTippyInst(); | ||
calcShowExpand(); | ||
}); | ||
</script> | ||
<style lang="less"> | ||
.ip-mult-line-text { | ||
.ip-mult-line-text-wrapper { | ||
position: relative; | ||
display: -webkit-box; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: normal; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 3; | ||
} | ||
.placeholder { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
left: 0; | ||
z-index: -1; | ||
word-break: normal; | ||
} | ||
} | ||
</style> |
86 changes: 86 additions & 0 deletions
86
dbm-ui/frontend/src/views/resource-manage/pool/components/summary-view/components/Test.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<div class="test"> | ||
<div class="test-title">{{ t('无规格类型的 IP 共 n 个', { n: 1 }) }}:</div> | ||
<MultLineText> | ||
{{ hostList.join(',') }} | ||
</MultLineText> | ||
<div> | ||
<BkButton | ||
v-bk-tooltips="t('复制')" | ||
class="copy-button ml-4" | ||
text | ||
theme="primary" | ||
@click="handleCopy"> | ||
<DbIcon type="copy" /> | ||
</BkButton> | ||
<BkButton | ||
v-bk-tooltips="t('跳转查看')" | ||
class="link-button ml-4" | ||
text | ||
theme="primary" | ||
@click="handleRedirect"> | ||
<DbIcon type="link" /> | ||
</BkButton> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useI18n } from 'vue-i18n'; | ||
// import type SummaryModel from '@services/model/db-resource/summary'; | ||
import { execCopy } from '@utils'; | ||
import MultLineText from './MultLineText.vue'; | ||
// interface Props { | ||
// data: SummaryModel[]; | ||
// dimension: string; | ||
// } | ||
// defineProps<Props>(); | ||
const router = useRouter(); | ||
const { t } = useI18n(); | ||
const hostList = ['1.2.3.4', '5.5.6.4']; | ||
const handleCopy = () => { | ||
execCopy(hostList.join('\n'), t('复制成功,共n条', { n: hostList.length })); | ||
}; | ||
const handleRedirect = () => { | ||
router.push({ | ||
name: 'resourcePool', | ||
params: { | ||
page: 'host-list', | ||
}, | ||
query: { | ||
hosts: hostList.join(','), | ||
}, | ||
}); | ||
}; | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.test { | ||
display: flex; | ||
padding: 8px 12px; | ||
font-size: 12px; | ||
background: #f0f1f5; | ||
border-radius: 2px; | ||
.test-title { | ||
font-weight: 700; | ||
color: #313238; | ||
} | ||
.copy-button { | ||
font-size: 15px; | ||
} | ||
.link-button { | ||
font-size: 14px; | ||
} | ||
} | ||
</style> |