evui 3.3.36 → 3.3.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +40 -40
- package/dist/evui.common.js +1907 -1832
- package/dist/evui.common.js.map +1 -1
- package/dist/evui.umd.js +1907 -1832
- package/dist/evui.umd.js.map +1 -1
- package/dist/evui.umd.min.js +1 -1
- package/dist/evui.umd.min.js.map +1 -1
- package/dist/img/{EVUI.7f3588fb.svg → EVUI.b82ee81a.svg} +292 -292
- package/dist/img/{icon_mysql.7ea26d5d.svg → icon_mysql.1085fdc9.svg} +78 -78
- package/dist/img/{icon_oracle.9009b108.svg → icon_oracle.0572d3ee.svg} +13 -13
- package/dist/img/{icon_postgresql.f8fffba9.svg → icon_postgresql.ee12bde8.svg} +58 -58
- package/package.json +61 -61
- package/src/common/emitter.js +20 -20
- package/src/common/utils.debounce.js +223 -223
- package/src/common/utils.js +134 -134
- package/src/common/utils.table.js +78 -78
- package/src/common/utils.throttle.js +83 -83
- package/src/common/utils.tree.js +18 -18
- package/src/components/button/Button.vue +198 -198
- package/src/components/button/index.js +7 -7
- package/src/components/buttonGroup/ButtonGroup.vue +11 -11
- package/src/components/buttonGroup/index.js +7 -7
- package/src/components/calendar/Calendar.vue +661 -661
- package/src/components/calendar/index.js +7 -7
- package/src/components/calendar/uses.js +1272 -1272
- package/src/components/chart/Chart.vue +189 -192
- package/src/components/chart/chart.core.js +870 -870
- package/src/components/chart/element/element.bar.js +524 -524
- package/src/components/chart/element/element.bar.time.js +156 -156
- package/src/components/chart/element/element.heatmap.js +533 -533
- package/src/components/chart/element/element.line.js +339 -339
- package/src/components/chart/element/element.pie.js +197 -197
- package/src/components/chart/element/element.scatter.js +184 -184
- package/src/components/chart/element/element.tip.js +550 -542
- package/src/components/chart/helpers/helpers.canvas.js +265 -265
- package/src/components/chart/helpers/helpers.constant.js +206 -206
- package/src/components/chart/helpers/helpers.util.js +346 -338
- package/src/components/chart/index.js +9 -9
- package/src/components/chart/model/index.js +4 -4
- package/src/components/chart/model/model.series.js +93 -93
- package/src/components/chart/model/model.store.js +977 -967
- package/src/components/chart/plugins/plugins.interaction.js +769 -769
- package/src/components/chart/plugins/plugins.legend.gradient.js +602 -602
- package/src/components/chart/plugins/plugins.legend.js +1155 -1151
- package/src/components/chart/plugins/plugins.pie.js +254 -254
- package/src/components/chart/plugins/plugins.title.js +56 -56
- package/src/components/chart/plugins/plugins.tooltip.js +692 -692
- package/src/components/chart/scale/scale.js +848 -848
- package/src/components/chart/scale/scale.linear.js +38 -38
- package/src/components/chart/scale/scale.logarithmic.js +128 -128
- package/src/components/chart/scale/scale.step.js +336 -336
- package/src/components/chart/scale/scale.time.category.js +277 -277
- package/src/components/chart/scale/scale.time.js +48 -48
- package/src/components/chart/style/chart.scss +312 -312
- package/src/components/chart/uses.js +264 -252
- package/src/components/checkbox/Checkbox.vue +200 -200
- package/src/components/checkbox/index.js +7 -7
- package/src/components/checkboxGroup/CheckboxGroup.vue +44 -44
- package/src/components/checkboxGroup/index.js +7 -7
- package/src/components/contextMenu/ContextMenu.vue +80 -80
- package/src/components/contextMenu/MenuList.vue +149 -149
- package/src/components/contextMenu/index.js +7 -7
- package/src/components/contextMenu/uses.js +203 -203
- package/src/components/datePicker/DatePicker.vue +437 -437
- package/src/components/datePicker/index.js +7 -7
- package/src/components/datePicker/uses.js +419 -419
- package/src/components/grid/Grid.vue +827 -827
- package/src/components/grid/grid.filter.window.vue +493 -493
- package/src/components/grid/grid.pagination.vue +75 -75
- package/src/components/grid/grid.summary.vue +265 -265
- package/src/components/grid/grid.toolbar.vue +26 -26
- package/src/components/grid/index.js +11 -11
- package/src/components/grid/style/grid.scss +263 -263
- package/src/components/grid/uses.js +1002 -1007
- package/src/components/icon/Icon.vue +49 -49
- package/src/components/icon/index.js +8 -8
- package/src/components/inputNumber/InputNumber.vue +212 -212
- package/src/components/inputNumber/index.js +7 -7
- package/src/components/inputNumber/uses.js +217 -217
- package/src/components/loading/Loading.vue +125 -125
- package/src/components/loading/index.js +7 -7
- package/src/components/menu/Menu.vue +68 -68
- package/src/components/menu/MenuItem.vue +187 -187
- package/src/components/menu/index.js +7 -7
- package/src/components/message/Message.vue +223 -223
- package/src/components/message/index.js +31 -31
- package/src/components/messageBox/MessageBox.vue +358 -358
- package/src/components/messageBox/index.js +22 -22
- package/src/components/notification/Notification.vue +316 -316
- package/src/components/notification/index.js +49 -49
- package/src/components/pagination/Pagination.vue +271 -271
- package/src/components/pagination/index.js +7 -7
- package/src/components/pagination/pageButton.vue +30 -30
- package/src/components/progress/Progress.vue +139 -139
- package/src/components/progress/index.js +7 -7
- package/src/components/radio/Radio.vue +159 -159
- package/src/components/radio/index.js +7 -7
- package/src/components/radioGroup/RadioGroup.vue +41 -41
- package/src/components/radioGroup/index.js +7 -7
- package/src/components/scheduler/Scheduler.vue +149 -149
- package/src/components/scheduler/index.js +7 -7
- package/src/components/scheduler/uses.js +183 -183
- package/src/components/select/Select.vue +440 -440
- package/src/components/select/index.js +7 -7
- package/src/components/select/uses.js +270 -270
- package/src/components/slider/Slider.vue +505 -505
- package/src/components/slider/index.js +7 -7
- package/src/components/slider/uses.js +390 -390
- package/src/components/tabPanel/TabPanel.vue +74 -74
- package/src/components/tabPanel/index.js +7 -7
- package/src/components/tabs/Tabs.vue +517 -517
- package/src/components/tabs/index.js +7 -7
- package/src/components/textField/TextField.vue +375 -375
- package/src/components/textField/index.js +7 -7
- package/src/components/timePicker/TimePicker.vue +352 -352
- package/src/components/timePicker/index.js +7 -7
- package/src/components/toggle/Toggle.vue +115 -115
- package/src/components/toggle/index.js +7 -7
- package/src/components/tree/Tree.vue +313 -313
- package/src/components/tree/TreeNode.vue +293 -293
- package/src/components/tree/index.js +7 -7
- package/src/components/treeGrid/TreeGrid.vue +758 -758
- package/src/components/treeGrid/TreeGridNode.vue +275 -275
- package/src/components/treeGrid/index.js +9 -9
- package/src/components/treeGrid/style/treeGrid.scss +261 -261
- package/src/components/treeGrid/treeGrid.toolbar.vue +26 -26
- package/src/components/treeGrid/uses.js +867 -867
- package/src/components/window/Window.vue +329 -329
- package/src/components/window/index.js +7 -7
- package/src/components/window/uses.js +899 -899
- package/src/directives/clickoutside.js +90 -90
- package/src/main.js +116 -116
- package/src/style/components/input.scss +108 -108
- package/src/style/functions.scss +3 -3
- package/src/style/index.scss +6 -6
- package/src/style/lib/fonts/EVUI.svg +292 -292
- package/src/style/lib/icon.css +888 -888
- package/src/style/mixins.scss +94 -94
- package/src/style/themes.scss +67 -67
- package/src/style/variables.scss +22 -22
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="grid-pagination">
|
|
3
|
-
<ev-pagination
|
|
4
|
-
v-model="currentValue"
|
|
5
|
-
:total="total"
|
|
6
|
-
:per-page="perPage"
|
|
7
|
-
:visible-page="visiblePage"
|
|
8
|
-
:show-page-info="showPageInfo"
|
|
9
|
-
:order="order"
|
|
10
|
-
@change="changePage"
|
|
11
|
-
>
|
|
12
|
-
</ev-pagination>
|
|
13
|
-
</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
import { ref, watch } from 'vue';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'EvGridPagination',
|
|
21
|
-
props: {
|
|
22
|
-
total: {
|
|
23
|
-
type: [Number, String],
|
|
24
|
-
default: 0,
|
|
25
|
-
},
|
|
26
|
-
visiblePage: {
|
|
27
|
-
type: [Number, String],
|
|
28
|
-
default: 8,
|
|
29
|
-
},
|
|
30
|
-
perPage: {
|
|
31
|
-
type: [Number, String],
|
|
32
|
-
default: 20,
|
|
33
|
-
},
|
|
34
|
-
modelValue: {
|
|
35
|
-
type: [Number, String],
|
|
36
|
-
default: 1,
|
|
37
|
-
},
|
|
38
|
-
showPageInfo: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: false,
|
|
41
|
-
},
|
|
42
|
-
order: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'left',
|
|
45
|
-
validator: val => ['left', 'right', 'center'].includes(val),
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
emits: {
|
|
49
|
-
'update:modelValue': null,
|
|
50
|
-
},
|
|
51
|
-
setup(props, { emit }) {
|
|
52
|
-
const currentValue = ref(props.modelValue);
|
|
53
|
-
const changePage = (page) => {
|
|
54
|
-
currentValue.value = page > 0 ? page : 1;
|
|
55
|
-
emit('update:modelValue', currentValue.value);
|
|
56
|
-
};
|
|
57
|
-
watch(
|
|
58
|
-
() => props.modelValue,
|
|
59
|
-
(value) => {
|
|
60
|
-
currentValue.value = value;
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
return {
|
|
64
|
-
currentValue,
|
|
65
|
-
changePage,
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<style lang="scss" scoped>
|
|
72
|
-
.grid-pagination {
|
|
73
|
-
padding-top: 8px;
|
|
74
|
-
}
|
|
75
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="grid-pagination">
|
|
3
|
+
<ev-pagination
|
|
4
|
+
v-model="currentValue"
|
|
5
|
+
:total="total"
|
|
6
|
+
:per-page="perPage"
|
|
7
|
+
:visible-page="visiblePage"
|
|
8
|
+
:show-page-info="showPageInfo"
|
|
9
|
+
:order="order"
|
|
10
|
+
@change="changePage"
|
|
11
|
+
>
|
|
12
|
+
</ev-pagination>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import { ref, watch } from 'vue';
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: 'EvGridPagination',
|
|
21
|
+
props: {
|
|
22
|
+
total: {
|
|
23
|
+
type: [Number, String],
|
|
24
|
+
default: 0,
|
|
25
|
+
},
|
|
26
|
+
visiblePage: {
|
|
27
|
+
type: [Number, String],
|
|
28
|
+
default: 8,
|
|
29
|
+
},
|
|
30
|
+
perPage: {
|
|
31
|
+
type: [Number, String],
|
|
32
|
+
default: 20,
|
|
33
|
+
},
|
|
34
|
+
modelValue: {
|
|
35
|
+
type: [Number, String],
|
|
36
|
+
default: 1,
|
|
37
|
+
},
|
|
38
|
+
showPageInfo: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
order: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: 'left',
|
|
45
|
+
validator: val => ['left', 'right', 'center'].includes(val),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
emits: {
|
|
49
|
+
'update:modelValue': null,
|
|
50
|
+
},
|
|
51
|
+
setup(props, { emit }) {
|
|
52
|
+
const currentValue = ref(props.modelValue);
|
|
53
|
+
const changePage = (page) => {
|
|
54
|
+
currentValue.value = page > 0 ? page : 1;
|
|
55
|
+
emit('update:modelValue', currentValue.value);
|
|
56
|
+
};
|
|
57
|
+
watch(
|
|
58
|
+
() => props.modelValue,
|
|
59
|
+
(value) => {
|
|
60
|
+
currentValue.value = value;
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
return {
|
|
64
|
+
currentValue,
|
|
65
|
+
changePage,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<style lang="scss" scoped>
|
|
72
|
+
.grid-pagination {
|
|
73
|
+
padding-top: 8px;
|
|
74
|
+
}
|
|
75
|
+
</style>
|
|
@@ -1,265 +1,265 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="summaryRef"
|
|
4
|
-
:class="{
|
|
5
|
-
'grid-summary': true,
|
|
6
|
-
'non-border': styleInfo.borderStyle === 'none',
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
9
|
-
<ul class="column-list">
|
|
10
|
-
<li
|
|
11
|
-
v-if="showCheckbox"
|
|
12
|
-
:class="{
|
|
13
|
-
'column': true,
|
|
14
|
-
'non-border': !!styleInfo.borderStyle,
|
|
15
|
-
}"
|
|
16
|
-
:style="{
|
|
17
|
-
'width': `${styleInfo.minWidth}px`,
|
|
18
|
-
'line-height': `${styleInfo.rowHeight}px`
|
|
19
|
-
}"
|
|
20
|
-
>
|
|
21
|
-
<span :style="{'height': `${styleInfo.rowHeight}px`}" />
|
|
22
|
-
</li>
|
|
23
|
-
<template
|
|
24
|
-
v-for="(column, index) in columns"
|
|
25
|
-
:key="`summary_${index}`"
|
|
26
|
-
>
|
|
27
|
-
<li
|
|
28
|
-
v-if="!column.hide"
|
|
29
|
-
:class="{
|
|
30
|
-
column: true,
|
|
31
|
-
'non-border': !!styleInfo.borderStyle,
|
|
32
|
-
[column.type]: column.type,
|
|
33
|
-
[column.align]: column.align,
|
|
34
|
-
}"
|
|
35
|
-
:style="{
|
|
36
|
-
width: `${column.width}px`,
|
|
37
|
-
'min-width': `${styleInfo.minWidth}px`,
|
|
38
|
-
'line-height': `${styleInfo.rowHeight}px`,
|
|
39
|
-
}"
|
|
40
|
-
>
|
|
41
|
-
<span
|
|
42
|
-
v-if="column.summaryType || column.summaryRenderer"
|
|
43
|
-
:style="{
|
|
44
|
-
width: '100%',
|
|
45
|
-
height: `${styleInfo.rowHeight}px`,
|
|
46
|
-
}"
|
|
47
|
-
>
|
|
48
|
-
<div
|
|
49
|
-
v-if="column.summaryRenderer"
|
|
50
|
-
:title="getSummaryRenderer(column)"
|
|
51
|
-
>
|
|
52
|
-
{{ getSummaryRenderer(column) }}
|
|
53
|
-
</div>
|
|
54
|
-
<div
|
|
55
|
-
v-else
|
|
56
|
-
:title="getSummaryValue(column, column.summaryType)"
|
|
57
|
-
>
|
|
58
|
-
{{ getSummaryValue(column, column.summaryType)}}
|
|
59
|
-
</div>
|
|
60
|
-
</span>
|
|
61
|
-
<span
|
|
62
|
-
v-else
|
|
63
|
-
:style="{'height': `${styleInfo.rowHeight}px`}"
|
|
64
|
-
/>
|
|
65
|
-
</li>
|
|
66
|
-
</template>
|
|
67
|
-
</ul>
|
|
68
|
-
</div>
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<script>
|
|
72
|
-
import { computed, watch, ref, nextTick } from 'vue';
|
|
73
|
-
import { numberWithComma } from '@/common/utils';
|
|
74
|
-
|
|
75
|
-
export default {
|
|
76
|
-
name: 'EvGridSummary',
|
|
77
|
-
props: {
|
|
78
|
-
stores: {
|
|
79
|
-
type: Object,
|
|
80
|
-
default: () => ({}),
|
|
81
|
-
},
|
|
82
|
-
orderedColumns: {
|
|
83
|
-
type: Object,
|
|
84
|
-
default: () => ({}),
|
|
85
|
-
},
|
|
86
|
-
useCheckbox: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: false,
|
|
89
|
-
},
|
|
90
|
-
styleOption: {
|
|
91
|
-
type: Object,
|
|
92
|
-
default: () => ({}),
|
|
93
|
-
},
|
|
94
|
-
isTree: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
default: false,
|
|
97
|
-
},
|
|
98
|
-
scrollLeft: {
|
|
99
|
-
type: Number,
|
|
100
|
-
default: 0,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
setup(props) {
|
|
104
|
-
const summaryRef = ref();
|
|
105
|
-
const ROW_DATA_INDEX = 2;
|
|
106
|
-
const stores = computed(() => props.stores);
|
|
107
|
-
const columns = computed(() => props.orderedColumns);
|
|
108
|
-
const showCheckbox = computed(() => props.useCheckbox);
|
|
109
|
-
const styleInfo = computed(() => props.styleOption);
|
|
110
|
-
const getConvertValue = (column, value) => {
|
|
111
|
-
let convertValue = value;
|
|
112
|
-
|
|
113
|
-
if (column.type === 'number') {
|
|
114
|
-
convertValue = numberWithComma(value);
|
|
115
|
-
convertValue = convertValue === false ? value : convertValue;
|
|
116
|
-
} else if (column.type === 'float') {
|
|
117
|
-
const floatValue = convertValue.toFixed(column.decimal ?? 3);
|
|
118
|
-
convertValue = floatValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return convertValue;
|
|
122
|
-
};
|
|
123
|
-
const getColumnIndex = field => columns.value.findIndex(column => column.field === field);
|
|
124
|
-
const getSummaryValue = (column, summaryType) => {
|
|
125
|
-
let result = '';
|
|
126
|
-
const columnIndex = getColumnIndex(column.field);
|
|
127
|
-
if (columnIndex >= 0) {
|
|
128
|
-
if (summaryType === 'count') {
|
|
129
|
-
return stores.value.store.length;
|
|
130
|
-
}
|
|
131
|
-
if (column.type === 'number' || column.type === 'float') {
|
|
132
|
-
let columnValues = [];
|
|
133
|
-
if (props.isTree) {
|
|
134
|
-
columnValues = stores.value.store.map(node => node.data?.[column.field]);
|
|
135
|
-
} else {
|
|
136
|
-
columnValues = stores.value.store.map(row => row[ROW_DATA_INDEX][columnIndex]);
|
|
137
|
-
}
|
|
138
|
-
switch (summaryType) {
|
|
139
|
-
case 'sum':
|
|
140
|
-
result = columnValues.reduce((prev, curr) => {
|
|
141
|
-
const value = Number(curr);
|
|
142
|
-
if (!Number.isNaN(value)) {
|
|
143
|
-
return prev + value;
|
|
144
|
-
}
|
|
145
|
-
return prev;
|
|
146
|
-
}, 0);
|
|
147
|
-
break;
|
|
148
|
-
case 'average':
|
|
149
|
-
result = columnValues.reduce((prev, curr) => {
|
|
150
|
-
const value = Number(curr);
|
|
151
|
-
if (!Number.isNaN(value)) {
|
|
152
|
-
return prev + value;
|
|
153
|
-
}
|
|
154
|
-
return prev;
|
|
155
|
-
}, 0) / columnValues.length;
|
|
156
|
-
if (result % 1 !== 0) {
|
|
157
|
-
result = result.toFixed(1);
|
|
158
|
-
}
|
|
159
|
-
break;
|
|
160
|
-
case 'max':
|
|
161
|
-
result = Math.max(...columnValues);
|
|
162
|
-
break;
|
|
163
|
-
case 'min':
|
|
164
|
-
result = Math.min(...columnValues);
|
|
165
|
-
break;
|
|
166
|
-
default:
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
result = getConvertValue(column, result);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
const getSummaryRenderer = (column) => {
|
|
175
|
-
const str = column.summaryRenderer;
|
|
176
|
-
const summaryData = column.summaryData ? column.summaryData : [];
|
|
177
|
-
const fields = [column.field, ...summaryData];
|
|
178
|
-
let result = str;
|
|
179
|
-
fields.forEach((name, idx) => {
|
|
180
|
-
const columnIndex = getColumnIndex(name);
|
|
181
|
-
if (columnIndex >= 0) {
|
|
182
|
-
const value = getSummaryValue(
|
|
183
|
-
stores.value.orderedColumns[columnIndex],
|
|
184
|
-
column.summaryType,
|
|
185
|
-
);
|
|
186
|
-
result = result.replace(`{${idx}}`, value);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return result;
|
|
190
|
-
};
|
|
191
|
-
watch(
|
|
192
|
-
() => props.scrollLeft,
|
|
193
|
-
(val) => {
|
|
194
|
-
nextTick(() => {
|
|
195
|
-
summaryRef.value.scrollLeft = val;
|
|
196
|
-
});
|
|
197
|
-
},
|
|
198
|
-
);
|
|
199
|
-
return {
|
|
200
|
-
columns,
|
|
201
|
-
styleInfo,
|
|
202
|
-
showCheckbox,
|
|
203
|
-
summaryRef,
|
|
204
|
-
getSummaryValue,
|
|
205
|
-
getSummaryRenderer,
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
</script>
|
|
210
|
-
|
|
211
|
-
<style lang="scss" scoped>
|
|
212
|
-
@import 'style/grid.scss';
|
|
213
|
-
.grid-summary {
|
|
214
|
-
width: 100%;
|
|
215
|
-
overflow: hidden;
|
|
216
|
-
|
|
217
|
-
@include evThemify() {
|
|
218
|
-
border-bottom: 1px solid evThemed('disabled');
|
|
219
|
-
background-color: evThemed('background-lighten');
|
|
220
|
-
}
|
|
221
|
-
.non-border {
|
|
222
|
-
border-bottom: none !important;
|
|
223
|
-
}
|
|
224
|
-
span {
|
|
225
|
-
display: inline-block;
|
|
226
|
-
overflow: hidden;
|
|
227
|
-
text-overflow: ellipsis;
|
|
228
|
-
font-size: 14px;
|
|
229
|
-
> div {
|
|
230
|
-
white-space: nowrap;
|
|
231
|
-
overflow: hidden;
|
|
232
|
-
text-overflow: ellipsis;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@include evThemify() {
|
|
236
|
-
color: evThemed('font-color-base');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
.column {
|
|
240
|
-
&.number,
|
|
241
|
-
&.float {
|
|
242
|
-
text-align: right;
|
|
243
|
-
}
|
|
244
|
-
&.string,
|
|
245
|
-
&.stringNumber {
|
|
246
|
-
text-align: left;
|
|
247
|
-
}
|
|
248
|
-
&.center {
|
|
249
|
-
text-align: center;
|
|
250
|
-
}
|
|
251
|
-
&.left {
|
|
252
|
-
text-align: left;
|
|
253
|
-
.wrap {
|
|
254
|
-
justify-content: flex-start;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
&.right {
|
|
258
|
-
text-align: right;
|
|
259
|
-
.wrap {
|
|
260
|
-
justify-content: flex-end;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="summaryRef"
|
|
4
|
+
:class="{
|
|
5
|
+
'grid-summary': true,
|
|
6
|
+
'non-border': styleInfo.borderStyle === 'none',
|
|
7
|
+
}"
|
|
8
|
+
>
|
|
9
|
+
<ul class="column-list">
|
|
10
|
+
<li
|
|
11
|
+
v-if="showCheckbox"
|
|
12
|
+
:class="{
|
|
13
|
+
'column': true,
|
|
14
|
+
'non-border': !!styleInfo.borderStyle,
|
|
15
|
+
}"
|
|
16
|
+
:style="{
|
|
17
|
+
'width': `${styleInfo.minWidth}px`,
|
|
18
|
+
'line-height': `${styleInfo.rowHeight}px`
|
|
19
|
+
}"
|
|
20
|
+
>
|
|
21
|
+
<span :style="{'height': `${styleInfo.rowHeight}px`}" />
|
|
22
|
+
</li>
|
|
23
|
+
<template
|
|
24
|
+
v-for="(column, index) in columns"
|
|
25
|
+
:key="`summary_${index}`"
|
|
26
|
+
>
|
|
27
|
+
<li
|
|
28
|
+
v-if="!column.hide"
|
|
29
|
+
:class="{
|
|
30
|
+
column: true,
|
|
31
|
+
'non-border': !!styleInfo.borderStyle,
|
|
32
|
+
[column.type]: column.type,
|
|
33
|
+
[column.align]: column.align,
|
|
34
|
+
}"
|
|
35
|
+
:style="{
|
|
36
|
+
width: `${column.width}px`,
|
|
37
|
+
'min-width': `${styleInfo.minWidth}px`,
|
|
38
|
+
'line-height': `${styleInfo.rowHeight}px`,
|
|
39
|
+
}"
|
|
40
|
+
>
|
|
41
|
+
<span
|
|
42
|
+
v-if="column.summaryType || column.summaryRenderer"
|
|
43
|
+
:style="{
|
|
44
|
+
width: '100%',
|
|
45
|
+
height: `${styleInfo.rowHeight}px`,
|
|
46
|
+
}"
|
|
47
|
+
>
|
|
48
|
+
<div
|
|
49
|
+
v-if="column.summaryRenderer"
|
|
50
|
+
:title="getSummaryRenderer(column)"
|
|
51
|
+
>
|
|
52
|
+
{{ getSummaryRenderer(column) }}
|
|
53
|
+
</div>
|
|
54
|
+
<div
|
|
55
|
+
v-else
|
|
56
|
+
:title="getSummaryValue(column, column.summaryType)"
|
|
57
|
+
>
|
|
58
|
+
{{ getSummaryValue(column, column.summaryType)}}
|
|
59
|
+
</div>
|
|
60
|
+
</span>
|
|
61
|
+
<span
|
|
62
|
+
v-else
|
|
63
|
+
:style="{'height': `${styleInfo.rowHeight}px`}"
|
|
64
|
+
/>
|
|
65
|
+
</li>
|
|
66
|
+
</template>
|
|
67
|
+
</ul>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
import { computed, watch, ref, nextTick } from 'vue';
|
|
73
|
+
import { numberWithComma } from '@/common/utils';
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
name: 'EvGridSummary',
|
|
77
|
+
props: {
|
|
78
|
+
stores: {
|
|
79
|
+
type: Object,
|
|
80
|
+
default: () => ({}),
|
|
81
|
+
},
|
|
82
|
+
orderedColumns: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: () => ({}),
|
|
85
|
+
},
|
|
86
|
+
useCheckbox: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
},
|
|
90
|
+
styleOption: {
|
|
91
|
+
type: Object,
|
|
92
|
+
default: () => ({}),
|
|
93
|
+
},
|
|
94
|
+
isTree: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
scrollLeft: {
|
|
99
|
+
type: Number,
|
|
100
|
+
default: 0,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
setup(props) {
|
|
104
|
+
const summaryRef = ref();
|
|
105
|
+
const ROW_DATA_INDEX = 2;
|
|
106
|
+
const stores = computed(() => props.stores);
|
|
107
|
+
const columns = computed(() => props.orderedColumns);
|
|
108
|
+
const showCheckbox = computed(() => props.useCheckbox);
|
|
109
|
+
const styleInfo = computed(() => props.styleOption);
|
|
110
|
+
const getConvertValue = (column, value) => {
|
|
111
|
+
let convertValue = value;
|
|
112
|
+
|
|
113
|
+
if (column.type === 'number') {
|
|
114
|
+
convertValue = numberWithComma(value);
|
|
115
|
+
convertValue = convertValue === false ? value : convertValue;
|
|
116
|
+
} else if (column.type === 'float') {
|
|
117
|
+
const floatValue = convertValue.toFixed(column.decimal ?? 3);
|
|
118
|
+
convertValue = floatValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return convertValue;
|
|
122
|
+
};
|
|
123
|
+
const getColumnIndex = field => columns.value.findIndex(column => column.field === field);
|
|
124
|
+
const getSummaryValue = (column, summaryType) => {
|
|
125
|
+
let result = '';
|
|
126
|
+
const columnIndex = getColumnIndex(column.field);
|
|
127
|
+
if (columnIndex >= 0) {
|
|
128
|
+
if (summaryType === 'count') {
|
|
129
|
+
return stores.value.store.length;
|
|
130
|
+
}
|
|
131
|
+
if (column.type === 'number' || column.type === 'float') {
|
|
132
|
+
let columnValues = [];
|
|
133
|
+
if (props.isTree) {
|
|
134
|
+
columnValues = stores.value.store.map(node => node.data?.[column.field]);
|
|
135
|
+
} else {
|
|
136
|
+
columnValues = stores.value.store.map(row => row[ROW_DATA_INDEX][columnIndex]);
|
|
137
|
+
}
|
|
138
|
+
switch (summaryType) {
|
|
139
|
+
case 'sum':
|
|
140
|
+
result = columnValues.reduce((prev, curr) => {
|
|
141
|
+
const value = Number(curr);
|
|
142
|
+
if (!Number.isNaN(value)) {
|
|
143
|
+
return prev + value;
|
|
144
|
+
}
|
|
145
|
+
return prev;
|
|
146
|
+
}, 0);
|
|
147
|
+
break;
|
|
148
|
+
case 'average':
|
|
149
|
+
result = columnValues.reduce((prev, curr) => {
|
|
150
|
+
const value = Number(curr);
|
|
151
|
+
if (!Number.isNaN(value)) {
|
|
152
|
+
return prev + value;
|
|
153
|
+
}
|
|
154
|
+
return prev;
|
|
155
|
+
}, 0) / columnValues.length;
|
|
156
|
+
if (result % 1 !== 0) {
|
|
157
|
+
result = result.toFixed(1);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case 'max':
|
|
161
|
+
result = Math.max(...columnValues);
|
|
162
|
+
break;
|
|
163
|
+
case 'min':
|
|
164
|
+
result = Math.min(...columnValues);
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
result = getConvertValue(column, result);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
const getSummaryRenderer = (column) => {
|
|
175
|
+
const str = column.summaryRenderer;
|
|
176
|
+
const summaryData = column.summaryData ? column.summaryData : [];
|
|
177
|
+
const fields = [column.field, ...summaryData];
|
|
178
|
+
let result = str;
|
|
179
|
+
fields.forEach((name, idx) => {
|
|
180
|
+
const columnIndex = getColumnIndex(name);
|
|
181
|
+
if (columnIndex >= 0) {
|
|
182
|
+
const value = getSummaryValue(
|
|
183
|
+
stores.value.orderedColumns[columnIndex],
|
|
184
|
+
column.summaryType,
|
|
185
|
+
);
|
|
186
|
+
result = result.replace(`{${idx}}`, value);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
return result;
|
|
190
|
+
};
|
|
191
|
+
watch(
|
|
192
|
+
() => props.scrollLeft,
|
|
193
|
+
(val) => {
|
|
194
|
+
nextTick(() => {
|
|
195
|
+
summaryRef.value.scrollLeft = val;
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
return {
|
|
200
|
+
columns,
|
|
201
|
+
styleInfo,
|
|
202
|
+
showCheckbox,
|
|
203
|
+
summaryRef,
|
|
204
|
+
getSummaryValue,
|
|
205
|
+
getSummaryRenderer,
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<style lang="scss" scoped>
|
|
212
|
+
@import 'style/grid.scss';
|
|
213
|
+
.grid-summary {
|
|
214
|
+
width: 100%;
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
|
|
217
|
+
@include evThemify() {
|
|
218
|
+
border-bottom: 1px solid evThemed('disabled');
|
|
219
|
+
background-color: evThemed('background-lighten');
|
|
220
|
+
}
|
|
221
|
+
.non-border {
|
|
222
|
+
border-bottom: none !important;
|
|
223
|
+
}
|
|
224
|
+
span {
|
|
225
|
+
display: inline-block;
|
|
226
|
+
overflow: hidden;
|
|
227
|
+
text-overflow: ellipsis;
|
|
228
|
+
font-size: 14px;
|
|
229
|
+
> div {
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
text-overflow: ellipsis;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@include evThemify() {
|
|
236
|
+
color: evThemed('font-color-base');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
.column {
|
|
240
|
+
&.number,
|
|
241
|
+
&.float {
|
|
242
|
+
text-align: right;
|
|
243
|
+
}
|
|
244
|
+
&.string,
|
|
245
|
+
&.stringNumber {
|
|
246
|
+
text-align: left;
|
|
247
|
+
}
|
|
248
|
+
&.center {
|
|
249
|
+
text-align: center;
|
|
250
|
+
}
|
|
251
|
+
&.left {
|
|
252
|
+
text-align: left;
|
|
253
|
+
.wrap {
|
|
254
|
+
justify-content: flex-start;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
&.right {
|
|
258
|
+
text-align: right;
|
|
259
|
+
.wrap {
|
|
260
|
+
justify-content: flex-end;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
</style>
|