-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathSelectSnippetDialog.vue
More file actions
94 lines (85 loc) · 1.91 KB
/
Copy pathSelectSnippetDialog.vue
File metadata and controls
94 lines (85 loc) · 1.91 KB
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
<template>
<el-dialog
v-if="visible"
:title="$tc('SelectSQL')"
:visible.sync="iVisible"
width="40%"
:modal="false"
>
<span>
<el-table :data="snippets">
<el-table-column property="name" :label="$tc('Name')" width="120px" />
<el-table-column show-overflow-tooltip property="args" :label="$tc('Content')" />
<el-table-column width="80px" label="">
<template slot-scope="scope">
<el-button type="text" size="small" @click="onSelectSnippet(scope.row)">{{
$tc('Insert')
}}</el-button>
</template>
</el-table-column>
</el-table>
</span>
</el-dialog>
</template>
<script>
import store from '@/store'
import { getSnippets } from '@/api/jms'
export default {
name: 'SelectSnippetDialog',
props: {
visible: {
type: Boolean,
default: false
}
},
data() {
return {
snippets: []
}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
mounted() {
this.loadSnippets()
},
methods: {
loadSnippets() {
const sqlType = store.getters.profile?.dbType
getSnippets().then(data => {
this.snippets = data.filter(item => item.module.value === sqlType)
})
},
onSelectSnippet(item) {
this.$emit('select', item.args)
}
}
}
</script>
<style scoped>
::v-deep .el-table tr {
background-color: #383a3c;
}
::v-deep .el-table tr:hover {
background-color: #7c7c7e !important;
}
::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
background-color: #7c7c7e !important;
}
::v-deep .el-table td.el-table__cell, .el-table th.el-table__cell.is-leaf {
border-bottom: 1px solid #7c7c7e
}
::v-deep .el-table th.el-table__cell {
background-color: #383a3c;
}
.el-table {
color: #e9e9e9;
}
</style>