✨ 支持批量连接终端
This commit is contained in:
parent
be0ee9e86e
commit
1cb0313cbd
@ -107,28 +107,23 @@ const handleSSH = async ({ host }) => {
|
|||||||
$router.push({ path: '/terminal', query: { host } })
|
$router.push({ path: '/terminal', query: { host } })
|
||||||
}
|
}
|
||||||
|
|
||||||
// let selectHosts = ref([])
|
let selectHosts = ref([])
|
||||||
// 由于table数据内部字段更新后table组件会自动取消勾选,所以这里需要手动set勾选
|
|
||||||
// watch(() => props.hosts, () => {
|
|
||||||
// // console.log('hosts change')
|
|
||||||
// nextTick(() => {
|
|
||||||
// selectHosts.value.forEach(row => {
|
|
||||||
// tableRef.value.toggleRowSelection && tableRef.value.toggleRowSelection(row, true)
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// }, { immediate: true, deep: true })
|
|
||||||
|
|
||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
// console.log('select: ', val)
|
// console.log('select: ', val)
|
||||||
// selectHosts.value = val
|
selectHosts.value = val
|
||||||
emit('select-change', val)
|
emit('select-change', val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getSelectHosts = () => {
|
||||||
|
return selectHosts.value
|
||||||
|
}
|
||||||
|
|
||||||
const clearSelection = () => {
|
const clearSelection = () => {
|
||||||
tableRef.value.clearSelection()
|
tableRef.value.clearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
getSelectHosts,
|
||||||
clearSelection
|
clearSelection
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
:hidden-ip="hiddenIp"
|
:hidden-ip="hiddenIp"
|
||||||
@update-host="handleUpdateHost"
|
@update-host="handleUpdateHost"
|
||||||
@update-list="handleUpdateList"
|
@update-list="handleUpdateList"
|
||||||
@select-change="handleSelectChange"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
@ -100,22 +99,33 @@ let handleUpdateList = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let handleSelectChange = (val) => {
|
// 收集选中的实例
|
||||||
selectHosts.value = val
|
let collectSelectHost = () => {
|
||||||
|
let allSelectHosts = []
|
||||||
|
hostTableRefs.value.map(item => {
|
||||||
|
if (item) allSelectHosts = allSelectHosts.concat(item.getSelectHosts())
|
||||||
|
})
|
||||||
|
selectHosts.value = allSelectHosts
|
||||||
}
|
}
|
||||||
|
|
||||||
let handleBatchSSH = () => {
|
let handleBatchSSH = () => {
|
||||||
let ips = selectHosts.value.map(item => item.host)
|
collectSelectHost()
|
||||||
|
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
|
||||||
|
let ips = selectHosts.value.filter(item => item.isConfig).map(item => item.host)
|
||||||
|
if (!ips.length) return $message.warning('所选实例未配置ssh连接信息')
|
||||||
|
if (ips.length < selectHosts.value.length) $message.warning('部分实例未配置ssh连接信息,已忽略')
|
||||||
$router.push({ path: '/terminal', query: { host: ips.join(',') } })
|
$router.push({ path: '/terminal', query: { host: ips.join(',') } })
|
||||||
}
|
}
|
||||||
|
|
||||||
let handleBatchModify = async () => {
|
let handleBatchModify = async () => {
|
||||||
|
collectSelectHost()
|
||||||
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
|
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
|
||||||
isBatchModify.value = true
|
isBatchModify.value = true
|
||||||
hostFormVisible.value = true
|
hostFormVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
let handleBatchRemove = async () => {
|
let handleBatchRemove = async () => {
|
||||||
|
collectSelectHost()
|
||||||
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
|
if (!selectHosts.value.length) return $message.warning('请选择要批量操作的实例')
|
||||||
let ips = selectHosts.value.map(item => item.host)
|
let ips = selectHosts.value.map(item => item.host)
|
||||||
let names = selectHosts.value.map(item => item.name)
|
let names = selectHosts.value.map(item => item.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user