1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
<div
v-if="module"
class="my-custom-module-com"
@mouseenter="showDelete = true"
@mouseleave="showDelete = false"
>
<component
:is="componentName"
:module="module"
/>
<div :class="['delete-box', showDelete && 'show']">
<img src="/images/navagations/delete-icon.png" alt="" @click.stop="remove">
</div>
</div>
</template>
<script>
import { unCollectUserModel } from '@/api/usercenter.js'
export default {
props: {
module: {
type: Object,
default() {
return null
}
}
},
data() {
return {
showDelete: false,
componentName: null
}
},
watch: {
module: {
handler: async function(val) {
this.componentName = await this.$utils.loadComponent(val.serverName, val.condPath, 'view')
},
immediate: true
}
},
methods: {
remove() {
this.$utils.showConfirm(
'是否删除选中的定制模块?',
'提示',
'warning',
'确定',
'取消',
() => {
unCollectUserModel(this.module.code).then(res => {
this.$utils.showMessageSuccess('删除成功')
this.$emit('getUserModule')
})
}
)
}
}
}
</script>
<style lang="scss">
.my-custom-module-com {
position: relative;
overflow: hidden;
border-radius: 4px;
.custom-module-bottom {
display: flex;
align-items: center;
color: #6f6f6f;
font-size: 14px;
.custom-module-bottom-item {
flex: 1;
display: flex;
align-items: center;
border-right: 1px solid #6f6f6f;
padding: 0 10px;
box-sizing: border-box;
&:last-child {
border-right: none;
}
.custom-module-bottom-item-name {
margin-right: 4px;
white-space: nowrap;
}
}
}
.delete-box {
position: absolute;
bottom: -32px;
left: 0;
width: 100%;
height: 32px;
// background-color: rgba(5, 65, 110, 0.5);
transition: bottom 0.3s;
padding-right: 10px;
box-sizing: border-box;
display: flex;
justify-content: flex-end;
align-items: center;
&.show {
bottom: 0;
transition: bottom 0.3s;
}
img {
height: 18px;
cursor: pointer;
}
}
}
</style>