-
Notifications
You must be signed in to change notification settings - Fork 692
Expand file tree
/
Copy pathCard.vue
More file actions
339 lines (307 loc) · 7.5 KB
/
Card.vue
File metadata and controls
339 lines (307 loc) · 7.5 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<script lang="ts" setup>
import delIcon from '@/assets/svg/icon_delete.svg'
import icon_more_outlined from '@/assets/svg/icon_more_outlined.svg'
import icon_form_outlined from '@/assets/svg/icon_form_outlined.svg'
import icon_chat_outlined from '@/assets/svg/icon_new-chat_outlined.svg'
import { computed, ref, unref } from 'vue'
import { ClickOutside as vClickOutside } from 'element-plus-secondary'
import { dsTypeWithImg } from './js/ds-type'
import edit from '@/assets/svg/icon_edit_outlined.svg'
import icon_recommended_problem from '@/assets/svg/icon_recommended_problem.svg'
import { datasourceApi } from '@/api/datasource.ts'
const props = withDefaults(
defineProps<{
name: string
type: string
typeName: string
num: string
description?: string
id?: string
}>(),
{
name: '-',
type: '-',
description: '-',
id: '-',
typeName: '-',
}
)
const emits = defineEmits([
'edit',
'del',
'question',
'dataTableDetail',
'showTable',
'recommendation',
'startChecking',
'endChecking',
])
const icon = computed(() => {
return (dsTypeWithImg.find((ele) => props.type === ele.type) || {}).img
})
const handleEdit = () => {
emits('edit')
}
const handleRecommendation = () => {
emits('recommendation')
}
const handleDel = () => {
emits('del')
}
const handleQuestion = () => {
//check first
emits('startChecking')
datasourceApi
.check_by_id(props.id)
.then((res: any) => {
if (res) {
emits('question', props.id)
}
})
.finally(() => {
emits('endChecking')
})
}
function runSQL() {
datasourceApi.execSql(
props.id,
'SELECT TO_CHAR(FLOOR("c"."CREDIT_LIMIT" / 10000) * 10000) || \' - \' || TO_CHAR((FLOOR("c"."CREDIT_LIMIT" / 10000) + 1) * 10000) AS "credit_range",\n' +
' COUNT(*) AS "customer_count"\n' +
'FROM "WEI"."CUSTOMERS" "c"\n' +
'WHERE "c"."CREDIT_LIMIT" IS NOT NULL\n' +
'GROUP BY FLOOR("c"."CREDIT_LIMIT" / 10000)\n' +
'ORDER BY FLOOR("c"."CREDIT_LIMIT" / 10000)'
)
}
const dataTableDetail = () => {
emits('dataTableDetail')
}
const buttonRef = ref()
const popoverRef = ref()
const onClickOutside = () => {
unref(popoverRef).popperRef?.delayHide?.()
}
</script>
<template>
<div class="card" @click="dataTableDetail">
<div class="name-icon">
<img :src="icon" width="32px" height="32px" />
<div class="info">
<div :title="name" class="name ellipsis">{{ name }}</div>
<div class="type">{{ typeName }}</div>
</div>
</div>
<div :title="description" class="type-value">
{{ description }}
</div>
<div class="bottom-info">
<div class="form-rate">
<el-icon class="form-icon" size="16">
<icon_form_outlined></icon_form_outlined>
</el-icon>
{{ num }}
</div>
<div click.stop class="methods">
<el-button v-if="false" @click="runSQL">test</el-button>
<el-button type="primary" style="margin-right: 8px" @click.stop="handleQuestion">
<el-icon style="margin-right: 4px" size="16">
<icon_chat_outlined></icon_chat_outlined>
</el-icon>
{{ $t('datasource.open_query') }}
</el-button>
<el-icon
ref="buttonRef"
v-click-outside="onClickOutside"
class="more"
size="16"
style="color: #646a73"
@click.stop
>
<icon_more_outlined></icon_more_outlined>
</el-icon>
<el-popover
ref="popoverRef"
:virtual-ref="buttonRef"
virtual-triggering
trigger="click"
:teleported="false"
popper-class="popover-card_ds"
placement="bottom-end"
>
<div class="content">
<div class="item" @click.stop="handleEdit">
<el-icon size="16">
<edit></edit>
</el-icon>
{{ $t('datasource.edit') }}
</div>
<div class="item" @click.stop="handleRecommendation">
<el-icon size="16">
<icon_recommended_problem></icon_recommended_problem>
</el-icon>
{{ $t('datasource.recommended_problem_configuration') }}
</div>
<div class="item" @click.stop="handleDel">
<el-icon size="16">
<delIcon></delIcon>
</el-icon>
{{ $t('dashboard.delete') }}
</div>
</div>
</el-popover>
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.card {
width: 100%;
border: 1px solid #dee0e3;
padding: 16px;
border-radius: 12px;
cursor: pointer;
&:hover {
box-shadow: 0px 6px 24px 0px #1f232914;
}
.name-icon {
display: flex;
align-items: center;
margin-bottom: 12px;
.info {
margin-left: 12px;
max-width: calc(100% - 50px);
.name {
font-weight: 500;
font-size: 16px;
line-height: 24px;
max-width: 100%;
}
.type {
font-weight: 400;
font-size: 12px;
line-height: 20px;
color: #646a73;
}
}
}
.type-value {
font-weight: 400;
font-size: 14px;
line-height: 22px;
color: #646a73;
height: 44px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
word-break: break-word;
overflow: hidden;
width: 100%;
}
.bottom-info {
margin-top: 16px;
display: flex;
align-items: center;
justify-content: space-between;
height: 32px;
.form-rate {
display: flex;
align-items: center;
color: #646a73;
font-weight: 400;
font-size: 14px;
line-height: 22px;
.form-icon {
margin-right: 8px;
}
}
.methods {
align-items: center;
display: none;
.more {
position: relative;
cursor: pointer;
margin-left: 4px;
width: 32px;
height: 32px;
svg {
position: relative;
z-index: 10;
}
&::after {
content: '';
position: absolute;
border-radius: 6px;
width: 32px;
height: 32px;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
background: #fff;
border: 1px solid #d9dcdf;
}
&:hover {
&::after {
background-color: #f5f6f7;
}
}
}
}
}
&:hover {
.methods {
display: flex;
}
}
}
</style>
<style lang="less">
.popover-card_ds.popover-card_ds.popover-card_ds {
box-shadow: 0px 4px 8px 0px #1f23291a;
border-radius: 4px;
border: 1px solid #dee0e3;
width: fit-content !important;
min-width: 120px !important;
padding: 0;
.content {
position: relative;
&::after {
position: absolute;
content: '';
top: 80px !important;
left: 0;
width: 100%;
height: 1px;
background: #dee0e3;
}
.item {
position: relative;
padding: 0 12px;
height: 40px;
display: flex;
align-items: center;
cursor: pointer;
.ed-icon {
margin-right: 8px;
color: #646a73;
}
&:hover {
&::after {
display: block;
}
}
&::after {
content: '';
width: calc(100% - 8px);
height: 32px;
border-radius: 4px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #1f23291a;
display: none;
}
}
}
}
</style>