EipChartSetting.vue
18.6 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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<template>
<el-dialog
top="10vh"
width="80%"
title="设置列"
append-to-body
:visible="dialogVisible"
:before-close="beforeClose"
:close-on-click-modal="false"
>
<el-row v-loading="loading" style="height: 600px">
<el-col :span="8" style="height: 100%">
<el-card class="box-card" shadow="never" style="height: 100%;">
<div slot="header">
<span>获取字段信息</span>
</div>
<div>
<el-table
:data="table"
max-height="440px"
@row-dblclick="rowDBClick"
@selection-change="handleSelectionChange"
ref="multipleTable"
class="table-field"
>
<el-table-column
align="center"
type="selection"
></el-table-column>
<el-table-column label="字段" :prop="isCustomQuery?'field':'fieldName'"></el-table-column>
<el-table-column label="注解" prop="comment"></el-table-column>
</el-table>
</div>
</el-card>
</el-col>
<el-col :span="1" style="height: 100%">
<div class="right-arrow">
<el-button
circle
type="primary"
icon="el-icon-right"
@click="addToField"
/>
</div>
</el-col>
<el-col :span="15">
<el-card class="box-card" shadow="never" style="height: 100%">
<div slot="header">
<span>字段设置</span>
</div>
<div>
<el-tabs type="card" v-model="activeName">
<el-tab-pane label="Y轴取值字段" name="yAxis">
<el-table :data="yAxisField" max-height="440px">
<el-table-column label="字段名" prop="field">
</el-table-column>
<el-table-column label="显示名">
<template #default="{ row }">
<el-input
v-model="row.comment"
clearable
maxlength="50"
show-word-limit
/>
</template>
</el-table-column>
<el-table-column label="回归曲线" v-if="chartStyle === 6">
<template slot="header">
回归曲线
<el-tooltip
class="item"
effect="dark"
content="注:在数据展示中选择列数据展示与数值轴时才生效"
placement="top-start"
>
<i class="el-icon-warning"></i>
</el-tooltip>
</template>
<template #default="{ row }">
<ht-select
style="width:150px"
v-model="row.regression"
:options="[
{key: 'none', value: '无'},
{key: 'linear', value: '线性回归'},
{key: 'exponential', value: '指数回归'},
{key: 'logarithmic', value: '对数回归'}
]"
/>
</template>
</el-table-column>
<el-table-column
label="类型"
v-if="chartStyle === 1 || chartStyle === 2"
>
<template #default="{ row }">
<ht-select
style="width:150px"
v-model="row.yAxis"
:options="[
{label: '第一Y轴', value: 1},
{label: '第二Y轴', value: 2}
]"
:validate="{required: true}"
:props="{key: 'value', value: 'label'}"
/>
</template>
</el-table-column>
<el-table-column
label="轴"
v-if="chartStyle === 1 || chartStyle === 2"
>
<template #default="{ row }">
<ht-select
style="width:150px"
v-model="row.type"
:options="[
{label: '折线图', value: 'line'},
{label: '柱状图', value: 'bar'}
]"
:validate="{required: true}"
:props="{key: 'value', value: 'label'}"
/>
</template>
</el-table-column>
<el-table-column label="管理" width="100">
<template #default="{ $index }">
<el-button
icon="el-icon-close"
type="primary"
@click="deleteRow($index, yAxisField)"
/>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="X轴取值字段" name="xAxis">
<el-table :data="xAxisField" max-height="440px">
<el-table-column label="字段名" prop="field">
</el-table-column>
<el-table-column label="显示名">
<template #default="{ row }">
<el-input
v-model="row.comment"
clearable
maxlength="50"
show-word-limit
/>
</template>
</el-table-column>
<el-table-column label="管理" width="100">
<template #default="{ $index }">
<el-button
icon="el-icon-close"
type="primary"
@click="deleteRow($index, xAxisField)"
/>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="条件字段" name="condition">
<span slot="label">
<el-tooltip
content="只对设置为x轴和y轴的取值字段有效"
placement="top"
>
<i class="el-icon-info"></i>
</el-tooltip>
条件字段
</span>
<el-table :data="conditionField" max-height="440px">
<el-table-column prop="field" label="字段名" width="150">
</el-table-column>
<el-table-column label="显示名" width="150">
<template #default="{ row }">
<el-input
clearable
maxlength="50"
show-word-limit
v-model="row.comment"
:disabled="isCustomQuery"
/>
</template>
</el-table-column>
<el-table-column label="条件">
<template #default="{ row }">
<ht-select
v-model="row.condition"
:options="numberOptionList"
:props="{key: 'key', value: 'value'}"
v-if="['int', 'number'].includes(row.dbType)"
style="width: 100%"
:disabled="isCustomQuery"
/>
<ht-select
v-model="row.condition"
:options="stringOptionList"
:props="{key: 'key', value: 'value'}"
v-if="['clob', 'varchar'].includes(row.dbType)"
style="width: 100%"
:disabled="isCustomQuery"
/>
<ht-select
v-model="row.condition"
:options="dateOptionList"
:props="{key: 'key', value: 'value'}"
v-if="row.dbType === 'date'"
style="width: 100%"
:disabled="isCustomQuery"
/>
</template>
</el-table-column>
<el-table-column label="值来源">
<template #default="{ row }">
<ht-select
v-model="row.defaultType"
:options="valueSourceList"
:props="{key: 'key', value: 'value'}"
style="width: 100px"
:disabled="isCustomQuery"
/>
</template>
</el-table-column>
<el-table-column label="默认值" width="200">
<template #default="{ row }">
<span v-if="row.defaultType === '1'">文本框输入</span>
<ht-input
v-model="row.defaultValue"
:maxlength="50"
:showWordLimit="true"
:disabled="isCustomQuery"
v-if="
(row.defaultType == '2' && row.dbType != 'date') ||
row.defaultType === '3'
"
/>
<ht-date
v-model="row.defaultValue"
:disabled="isCustomQuery"
format="yyyy-MM-dd"
v-if="row.defaultType === '2' && row.dbType === 'date'"
/>
<span
v-if="
row.defaultType === '2' &&
row.dbType === 'date' &&
row.condition === 'BETWEEN'
"
>
至
<ht-date v-model="row.endDate" :disabled="isCustomQuery" format="yyyy-MM-dd" />
</span>
</template>
</el-table-column>
<el-table-column label="管理" width="100" v-if="!isCustomQuery">
<template #default="{ $index }">
<el-button
icon="el-icon-close"
type="primary"
@click="deleteRow($index, conditionField)"
/>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="排序字段" name="sort">
<el-table :data="sortField" max-height="440px">
<el-table-column prop="field" label="字段" />
<el-table-column label="排序类型">
<template #default="{ row }">
<ht-select
v-model="row.sortType"
:options="sortOptionList"
:disabled="isCustomQuery"
:props="{key: 'key', value: 'value'}"
/>
</template>
</el-table-column>
<el-table-column label="管理" width="100" v-if="!isCustomQuery">
<template #default="{ $index }">
<el-button
icon="el-icon-close"
type="primary"
@click="deleteRow($index, sortField)"
/>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</div>
</el-card>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{
$t('eip.common.cancel')
}}</el-button>
<el-button type="primary" @click="save">{{
$t('eip.common.save')
}}</el-button>
</div>
</el-dialog>
</template>
<script>
import form from '@/api/form.js'
import utils from '@/hotent-ui-util.js'
export default {
props: {
param: Object,
yAxis: Array,
xAxis: Array,
sort: Array,
condition: Array,
chartStyle: Number,
isCustomQuery:{
type: Boolean,
default: false
},
},
mounted() {
window.temp1 = this
},
data() {
return {
dialogVisible: false,
table: [],
selections: [],
xAxisField: [],
yAxisField: [],
conditionField: [],
sortField: [],
loading: false,
activeName: 'yAxis',
numberOptionList: [
{
key: 'EQ',
value: '等于'
},
{
key: 'GE',
value: '大于等于'
},
{
key: 'LE',
value: '小于等于'
}
],
stringOptionList: [
{
key: 'LK',
value: 'like'
},
{
key: 'EQ',
value: '等于'
},
{
key: 'IN',
value: 'in'
}
],
dateOptionList: [
{
key: 'EQ',
value: '等于'
},
{
key: 'BETWEEN',
value: 'between'
},
{
key: 'GE',
value: '大于等于'
},
{
key: 'LE',
value: '小于等于'
}
],
valueSourceList: [
{
key: '2',
value: '固定值'
},
{
key: '1',
value: '动态传入'
}
],
sortOptionList: [
{
key: 'asc',
value: '升序'
},
{
key: 'desc',
value: '降序'
}
]
}
},
methods: {
async initData(customQueryData) {
if(this.isCustomQuery){
this.table =JSON.parse(customQueryData.resultfield)
this.conditionField =JSON.parse(customQueryData.conditionfield)
this.sortField = JSON.parse(customQueryData.sortfield)
}else{
let result = await form.getTable(this.param)
this.table = result.table.columnList
this.conditionField = [...this.condition]
this.sortField = [...this.sort]
}
this.yAxisField = [...this.yAxis]
this.xAxisField = [...this.xAxis]
},
rowDBClick(row) {
this.selections = []
this.selections.push(row)
this.addToField()
},
handleSelectionChange(val) {
this.selections = val
},
addToField() {
if (this.activeName === 'yAxis') {
this.addToYAxisField()
} else if (this.activeName === 'xAxis') {
this.addToXAxisField()
} else if (this.activeName === 'condition') {
if(this.isCustomQuery){
this.$message.warning('关联查询不允许编辑条件字段!')
return
}else{
this.addToConditionField()
}
} else if (this.activeName === 'sort') {
if(this.isCustomQuery){
this.$message.warning('关联查询不允许编辑排序字段!')
return
}else{
this.addToSortField()
}
}
this.$refs.multipleTable.clearSelection()
},
addToYAxisField() {
for (let i = 0; i < this.selections.length; i++) {
let item = {
comment: this.selections[i].comment,
dbType: this.selections[i].columnType,
field:this.isCustomQuery?this.selections[i].field:this.selections[i].fieldName,
nameKey: '0'
}
if (this.chartStyle === 1) {
item.type = 'line'
item.yAxis = 1
}
var isXField = false
if (
this.xAxisField.length > 0 &&
JSON.stringify(item.field) == JSON.stringify(this.xAxisField[0].field)
) {
isXField = true
this.$message.error('该字段已经被设为x轴字段')
}
if (!isXField) {
this.yAxisField.push(item)
}
}
this.yAxisField = this.yAxisField.unique('field')
},
addToXAxisField() {
let item = [
{
comment: this.selections[0].comment,
dbType: this.selections[0].columnType,
field: this.isCustomQuery?this.selections[0].field:this.selections[0].fieldName,
nameKey: '0'
}
]
var isYField = false
for (var i = 0; i < this.yAxisField.length; i++) {
if (
this.yAxisField.length > 0 &&
JSON.stringify(item[0].field) ==
JSON.stringify(this.yAxisField[i].field)
) {
isYField = true
this.$message.error('该字段已经被设为y轴字段')
}
}
if (!isYField) {
this.xAxisField = [...item]
}
},
addToConditionField() {
for (let i = 0; i < this.selections.length; i++) {
let item = {
comment: this.selections[i].comment,
dbType: this.selections[i].columnType,
field: this.isCustomQuery?this.selections[i].field:this.selections[i].fieldName,
condition: 'LK',
defaultType: '1',
defaultValue: ''
}
this.conditionField.push(item)
}
this.conditionField = this.conditionField.unique('field')
},
addToSortField() {
for (let i = 0; i < this.selections.length; i++) {
let item = {
field: this.isCustomQuery?this.selections[i].field:this.selections[i].fieldName,
sortType: 'asc'
}
this.sortField.push(item)
}
this.sortField = this.sortField.unique('field')
},
deleteRow(index, rows) {
rows.splice(index, 1)
},
save() {
this.$emit('save', {
yAxisField: this.yAxisField,
xAxisField: this.xAxisField,
conditionField: this.conditionField,
sortField: this.sortField
})
this.dialogVisible = false
},
beforeClose() {
this.dialogVisible = false
},
handleOpen(customQueryData) {
this.dialogVisible = true
this.loading = true
this.$nextTick(() => {
this.initData(customQueryData)
})
this.loading = false
}
}
}
</script>
<style lang="scss" scoped>
.right-arrow {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
/deep/ .table-field {
.el-table__row {
cursor: pointer;
}
}
/deep/ .el-dialog__body {
padding: 10px 20px;
}
</style>