提交复制组件

This commit is contained in:
Wenchao Gong 2021-09-10 23:04:12 +08:00
parent 5e7d11092c
commit ff1c729385
3 changed files with 54 additions and 37 deletions

View File

@ -0,0 +1,48 @@
<template>
<div>
<template v-if="data">
<span :title="data" v-text="handleData()"/>
<i class="el-icon-copy-document" @click="handleCopy()" title="复制"/>
</template>
</div>
</template>
<script>
export default {
name: "CopyTag",
props: {
data: {
required: true,
type: String
},
maxLength: {
type: Number,
default: 40,
}
},
methods: {
handleData() {
return this.data && this.data.length > this.maxLength ? this.data.substring(0, this.maxLength - 3) + '...' : this.data;
},
handleCopy() {
let oInput = document.createElement('input')
oInput.value = this.data;
document.body.appendChild(oInput)
oInput.select()
document.execCommand('copy')
this.$message({
message: '复制成功',
type: 'success'
})
oInput.remove()
},
},
};
</script>
<style lang="scss" scoped>
.el-icon-copy-document {
color: #4A8DFF;
cursor:pointer;
margin-left: 5px;
}
</style>

View File

@ -84,9 +84,7 @@
</el-table-column>
<el-table-column label="应用密钥" align="center" prop="accessKey">
<template slot-scope="scope">
<span>{{ scope.row.accessKey }} </span>
<i class="el-icon-copy-document" style="color: #4A8DFF;cursor:pointer" v-if="scope.row.accessKey"
@click="handleCopy(scope.row.accessKey)" title="复制"/>
<copy-tag :data="scope.row.accessKey"/>
</template>
</el-table-column>
<el-table-column label="更新者" align="center" prop="updateBy" />
@ -143,9 +141,11 @@
<script>
import { listApplication, getApplication, delApplication, addApplication, updateApplication } from "@/api/isc/application";
import CopyTag from '@/components/CopyTag';
export default {
name: "Application",
components: {CopyTag},
data() {
return {
// loading
@ -260,19 +260,6 @@ export default {
this.title = "修改应用信息";
});
},
// ak
handleCopy(data) {
let oInput = document.createElement('input')
oInput.value = data
document.body.appendChild(oInput)
oInput.select()
document.execCommand('copy')
this.$message({
message: '复制成功',
type: 'success'
})
oInput.remove()
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {

View File

@ -90,9 +90,7 @@
<el-table-column label="服务名称" align="left" prop="serviceName" />
<el-table-column label="虚拟地址" align="left" prop="virtualAddr">
<template slot-scope="scope">
<span :title="scope.row.virtualAddr" v-text="handleVirtualAddr(scope.row.virtualAddr)"/>
<i class="el-icon-copy-document" v-if="scope.row.virtualAddr" style="color: #4A8DFF;cursor:pointer"
@click="handleCopy(scope.row.virtualAddr)" title="复制"/>
<copy-tag :data="scope.row.virtualAddr"/>
</template>
</el-table-column>
<el-table-column label="审核状态" align="center" prop="status" width="100">
@ -289,10 +287,11 @@
import { listAppservice, getAppservice, delAppservice, addAppservice, updateAppservice, treeselect } from "@/api/isc/appservice";
import { getApplication } from "@/api/isc/application";
import Treeselect from "@riophae/vue-treeselect";
import CopyTag from '@/components/CopyTag';
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Appservice",
components: { Treeselect },
components: { Treeselect, CopyTag },
data() {
return {
// loading
@ -489,23 +488,6 @@ export default {
this.openView = true;
});
},
/** 复制地址 */
handleCopy(data) {
let oInput = document.createElement('input')
oInput.value = data
document.body.appendChild(oInput)
oInput.select()
document.execCommand('copy')
this.$message({
message: '复制成功',
type: 'success'
})
oInput.remove()
},
//
handleVirtualAddr(data) {
return data && data.length > 40 ? data.substring(0, 37) + '...' : data;
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {