复制id功能
This commit is contained in:
@@ -113,12 +113,12 @@
|
||||
:label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('newHosts.allocationUser')" prop="allocationUser">
|
||||
<!-- <el-form-item :label="t('newHosts.allocationUser')" prop="allocationUser">
|
||||
<el-select v-model="queryParams.userId" :placeholder="t('newHosts.placeAllocationUser')" clearable
|
||||
class="!w-240px">
|
||||
<el-option v-for="(user, index) in allocationUserList" :key="index" :label="user.label" :value="user.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" /> {{ t('newHosts.search') }}
|
||||
@@ -149,6 +149,12 @@
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column :label="t('newHosts.hostsId')" align="center" prop="hostsId" />
|
||||
<el-table-column align="center" prop="hostsId" width="75">
|
||||
<template #default="scope">
|
||||
<el-link type="primary" @click="handleCopy(scope.row.hostsId)">复制</el-link>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('newHosts.hostsLevel')" sortable align="center" prop="hostsLevel" />
|
||||
<el-table-column :label="t('newHosts.invitationType')" align="center" prop="invitationType">
|
||||
<template #default="scope">
|
||||
@@ -402,7 +408,28 @@ function AllocationFun() {
|
||||
getList()
|
||||
})
|
||||
}
|
||||
|
||||
function handleCopy(text) {
|
||||
// fallback 兼容方案
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.value = text
|
||||
textarea.style.position = 'fixed' // 避免跳动
|
||||
textarea.style.opacity = '0'
|
||||
document.body.appendChild(textarea)
|
||||
textarea.select()
|
||||
try {
|
||||
const result = document.execCommand('copy')
|
||||
if (result) {
|
||||
ElMessage.success('✅复制成功 ')
|
||||
} else {
|
||||
ElMessage.error('❌复制失败')
|
||||
}
|
||||
} catch (err) {
|
||||
ElMessage.error('❌复制异常')
|
||||
console.error(err)
|
||||
} finally {
|
||||
document.body.removeChild(textarea)
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user