添加复制id
This commit is contained in:
@@ -96,6 +96,12 @@
|
||||
v-hasPermi="['server:employee-big-brother:export']">
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
<el-button @click="exportAi(1)">
|
||||
<Icon icon="ep:copy-document" class="mr-5px" /> 批量复制大哥id
|
||||
</el-button>
|
||||
<el-button @click="exportAi(2)">
|
||||
<Icon icon="ep:copy-document" class="mr-5px" /> 批量复制主播id
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
@@ -191,6 +197,7 @@ const queryParams = reactive({
|
||||
createTimeEnd: '',
|
||||
operationStatus: undefined
|
||||
})
|
||||
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
let selectBigList = ref([])
|
||||
@@ -309,6 +316,57 @@ function openHtml(item, id) {
|
||||
window.open(`https://www.tiktok.com/@${id}`)
|
||||
|
||||
}
|
||||
|
||||
|
||||
function exportAi(type) {
|
||||
if (selectBigList.value.length === 0) {
|
||||
ElMessage.error('请选择主播')
|
||||
return
|
||||
}
|
||||
let data = ''
|
||||
if (type == 1) {
|
||||
data = selectBigList.value.map(item => item.displayId).join('\n')
|
||||
} else {
|
||||
data = selectBigList.value.map(item => item.hostDisplayId).join('\n')
|
||||
}
|
||||
|
||||
|
||||
const copyToClipboard = async (text) => {
|
||||
// 优先使用 Clipboard API
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
ElMessage.success('✅ 复制成功 ' + selectBigList.value.length + ' 条数据')
|
||||
} catch (err) {
|
||||
ElMessage.error('❌ 复制失败')
|
||||
console.error(err)
|
||||
}
|
||||
} else {
|
||||
// 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('✅(兼容模式)复制成功 ' + selectBigList.value.length + ' 条数据')
|
||||
} else {
|
||||
ElMessage.error('❌(兼容模式)复制失败')
|
||||
}
|
||||
} catch (err) {
|
||||
ElMessage.error('❌(兼容模式)复制异常')
|
||||
console.error(err)
|
||||
} finally {
|
||||
document.body.removeChild(textarea)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyToClipboard(data)
|
||||
}
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
|
||||
Reference in New Issue
Block a user