choose-template.vue
8.78 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<template>
<!--新建配置-->
<a-modal width="80%" :modal-style="{height:'85%'}" :body-style="{height:'92%'}" v-model:visible="props.visible"
:closable="false" @cancel="handleCancel" @ok="handleOk">
<!-- <template #title></template>-->
<div v-if="props.visible">
<!--通用模板-->
<a-card title="通用模板">
<a-row :gutter="[16, 16]">
<a-col :span="6" class='item-wrapper'
v-for="(item,index) in globalTemplate"
:key="index" @click="selectTemplateItem(item)">
<dl>
<dd>{{ item.title }}</dd>
<dt>
<img :src="item.url" alt="找不到了">
</dt>
</dl>
<a-button class="choose-button" size="mini">选择</a-button>
</a-col>
</a-row>
</a-card>
<!--专用模板-->
<a-card title="专用模板" style="margin-top: 20px">
<a-row :gutter="[16, 16]">
<a-col class="item-wrapper dedicated"
v-for="(item,index) in specializedTemplate"
:key="index"
:span="item.layout_span"
@click="selectTemplateItem(item)">
<dl>
<dd>{{ item.title }}</dd>
<dt :style="{height:index < 4 ? '26vh':''}">
<img :src="item.url" alt="找不到了">
</dt>
</dl>
<a-button class="choose-button" size="mini">选择</a-button>
</a-col>
</a-row>
</a-card>
</div>
</a-modal>
</template>
<script lang="ts" setup>
import line from '@/assets/charts/line.png'
import strip from '@/assets/charts/bar.png'
import bar from "@/assets/dashboard/bar.png";
import stack from '@/assets/charts/stack.png'
import area from '@/assets/charts/area.png'
import kLine from '@/assets/charts/k-line.png'
import rank from '@/assets/charts/rank.png'
import single from '@/assets/charts/single.png'
import gauge from "@/assets/dashboard/gauge.png";
import pie from "@/assets/dashboard/pie.png";
import pieAnnular from "@/assets/dashboard/pie-annular.png";
import status from "@/assets/dashboard/status.png";
import water from "@/assets/dashboard/water.png";
import section from '@/assets/dashboard/section.png'
import sankey from '@/assets/dashboard/sankey.png'
import workOrderStatistics from "@/assets/dashboard/work-order-statistics.png";
import polar from "@/assets/dashboard/polar.png";
import fixed from "@/assets/dashboard/fixed.png";
import table from "@/assets/dashboard/table.png";
import tableSimple from "@/assets/dashboard/table-simple.png";
import workOrder from "@/assets/dashboard/work-order.png";
import workOrderSimple from "@/assets/dashboard/work-order-simple.png";
import pieStatistics from "@/assets/dashboard/pie-statistics.png";
import bar1 from "@/assets/dashboard/bar1.png";
import bar2 from "@/assets/dashboard/bar2.png";
import bar3 from "@/assets/dashboard/bar3.png";
import bar4 from "@/assets/dashboard/bar4.png";
import pie1 from "@/assets/dashboard/pie1.png";
import pie2 from "@/assets/dashboard/pie2.png";
import {nextTick, onMounted, ref} from "vue";
interface IItem {
chartType: number,
url: any,
title: string,
layout_span?: number,
staticType?: number,
headType?: number,
layout: {
w: number,
h: number
}
}
const props = defineProps({
visible: {
type: Boolean,
default: false
}
});
const emit = defineEmits(['cancel', 'select']);
const myScrollingDiv = ref<HTMLElement | null>(null);
// 通用模板
const globalTemplate: IItem[] = [
{
chartType: 1,
url: line,
title: '折线图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 3,
url: strip,
title: '条形图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 2,
url: bar,
title: '柱状图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 4,
url: stack,
title: '堆叠图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 5,
url: area,
title: '面积图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 10,
url: sankey,
title: '桑基图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 11,
url: section,
title: '分段图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 7,
url: kLine,
title: 'K线图',
layout: {
w: 6,
h: 8
}
},
{
chartType: 12,
url: rank,
title: '排行榜',
layout: {
w: 6,
h: 8
}
},
{
chartType: 14,
url: single,
title: '单值图',
layout: {
w: 2,
h: 4
}
},
{
chartType: 19,
url: polar,
title: '极坐标',
layout: {
w: 3,
h: 8
}
},
{
chartType: 6,
url: pieAnnular,
title: '饼图',
layout: {
w: 3,
h: 8
}
},
{
chartType: 9,
url: gauge,
title: '仪表盘',
layout: {
w: 3,
h: 8
}
},
{
chartType: 8,
url: water,
title: '水滴图',
layout: {
w: 3,
h: 8
}
},
{
chartType: 13,
url: status,
title: '状态量',
layout: {
w: 1,
h: 4
}
},
{
chartType: 21,
url: fixed,
title: '固定值',
layout: {
w: 1,
h: 4
}
}
];
// 专用模板
const specializedTemplate: IItem[] = [
{
chartType: 15,
url: table,
title: '实时报警',
layout_span: 16,
headType: 1,
layout: {
w: 8,
h: 8
}
},
{
chartType: 15,
url: tableSimple,
title: '实时报警',
layout_span: 8,
headType: 2,
layout: {
w: 4,
h: 8
}
},
{
chartType: 16,
url: workOrder,
title: '工单信息',
layout_span: 16,
headType: 1,
layout: {
w: 8,
h: 8
}
},
{
chartType: 16,
url: workOrderSimple,
title: '工单信息',
layout_span: 8,
headType: 2,
layout: {
w: 4,
h: 8
}
},
{
chartType: 17,
url: pie1,
title: '报警统计(按级别)',
layout_span: 6,
staticType: 1,
layout: {
w: 3,
h: 8
}
},
{
chartType: 17,
url: bar1,
title: '报警统计(按类型)',
layout_span: 6,
staticType: 2,
layout: {
w: 3,
h: 8
}
},
{
chartType: 17,
url: bar2,
title: '报警统计(按日期)',
layout_span: 6,
staticType: 3,
layout: {
w: 3,
h: 8
}
},
{
chartType: 18,
url: pie2,
title: '工单统计(按类别)',
layout_span: 6,
staticType: 1,
layout: {
w: 3,
h: 8
}
},
{
chartType: 18,
url: bar3,
title: '工单统计(按日期)',
layout_span: 6,
staticType: 2,
layout: {
w: 3,
h: 8
}
},
{
chartType: 18,
url: bar4,
title: '工单统计(按状态)',
layout_span: 6,
staticType: 3,
layout: {
w: 3,
h: 8
}
},
];
// 选择模板
const selectTemplateItem = (item: IItem) => {
const {chartType, layout, layout_span} = item;
emit('select', {
chartType,
layout,
layout_span,
headType: item.headType ? item.headType : undefined,
staticType: item.staticType ? item.staticType : undefined
});
}
const scrollToTop = async () => {
// 使用nextTick确保DOM更新后再执行滚动操作
await nextTick();
if (myScrollingDiv.value) {
// 使用scrollTo方法滚动到顶部
myScrollingDiv.value.scrollTo(0, 0);
}
};
const handleOk = () => {
scrollToTop()
emit('cancel');
}
const handleCancel = () => {
emit('cancel');
}
onMounted(() => {
})
</script>
<style lang="less" scoped>
.dedicated {
img {
height: auto !important;
}
}
.item-wrapper {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
dl {
padding: 0;
margin: 0;
width: 100%;
flex: 1;
box-sizing: border-box;
border: 1px solid var(--color-neutral-4);
border-radius: 4px;
dd {
padding: 0;
margin: 0;
line-height: 24px;
text-align: center;
color: var(--color-neutral-10);
background-color: var(--color-neutral-4);
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
dt {
padding: 0;
margin: 0;
overflow: hidden;
display: flex;
width: 100%;
//height: 160px;
justify-content: center;
align-items: center;
img {
width: 100%;
//height: 106px;
object-fit: contain;
}
}
}
button {
margin-top: 8px;
}
}
.item-wrapper:hover {
dl {
border-color: var(--color-neutral-6);
}
.choose-button {
background: var(--color-neutral-3);
}
}
.disabled-item:hover {
cursor: not-allowed;
dl {
border: 1px solid var(--color-neutral-4);
}
.choose-button {
background: none;
}
}
</style>