添加复制且转化

This commit is contained in:
2025-10-22 21:07:52 +08:00
parent 8d316e22ab
commit bd4158ae5d

View File

@@ -132,6 +132,7 @@
<el-button v-else type="danger" @click="handleDeletePageList">
<Icon icon="ep:delete" class="mr-5px" /> 删除本页
</el-button>
<el-switch style="margin-left: 20px;" v-model="isUpdata" />复制且转化
</el-form-item>
</el-form>
</ContentWrap>
@@ -162,7 +163,7 @@
</el-table-column>
<el-table-column align="center" prop="hostsId" width="75">
<template #default="scope">
<el-link type="primary" @click="handleCopy(scope.row.hostsId)">复制</el-link>
<el-link type="primary" @click="handleCopy(scope.row.hostsId, scope.row)">复制</el-link>
</template>
</el-table-column>
@@ -253,7 +254,7 @@
<div class="card-row" style="color:green;">
<b>{{ $t('employee.hostsId') }}</b><span @click="openHtml(item, item.hostsId)"
style=" text-decoration: underline;margin-right: 50px;">{{ item.hostsId }}</span>
<el-link @click="handleCopy(item.hostsId)" type="primary">复制id</el-link>
<el-link @click="handleCopy(item.hostsId, item)" type="primary">复制id</el-link>
</div>
<!-- <div class="card-row"><b>{{ $t('employee.userId') }}</b>{{ item.userId }}</div> -->
@@ -276,9 +277,9 @@
<div class="card-row"><b>{{ $t('employee.updateTime') }}</b>{{ formatTimestamp(item.updateTime) }}</div>
<div class="card-row action-row">
<el-button link type="primary" @click="openForm('update', item.id, index)">{{ $t('employee.edit')
}}</el-button>
}}</el-button>
<el-button link type="danger" @click="handleDelete(item.id)">{{ $t('employee.delete')
}}</el-button>
}}</el-button>
</div>
</div>
</div>
@@ -309,6 +310,7 @@ import MobilePagination from '@/components/MobilePagination.vue'
import { useDictStore } from '@/store/modules/dict' // 如果你项目里有字典 store
const dictStore = useDictStore?.() // 有就用;没有的话把 dictStore 相关行删掉
let isUpdata = ref(false)
// 统一用字符串比较,自动识别并翻译 i18n key
function dictLabelI18n(type: string, val: any) {
const v = val == null ? '' : String(val)
@@ -617,7 +619,7 @@ function AllocationFun() {
console.log(selectHostList.value)
}
function handleCopy(text) {
function handleCopy(text, data) {
// fallback 兼容方案
const textarea = document.createElement('textarea')
textarea.value = text
@@ -629,6 +631,12 @@ function handleCopy(text) {
const result = document.execCommand('copy')
if (result) {
ElMessage.success('✅复制成功 ')
if (isUpdata.value) {
EmployeeHostsApi.updateEmployeeHosts({ id: data.id, userId: data.userId, hostsId: data.hostsId, operationStatus: 1 }).then(res => {
getList()
})
}
} else {
ElMessage.error('❌复制失败')
}