renusify 2.5.2 → 3.0.1
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/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +207 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +139 -80
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +93 -49
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +71 -39
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +332 -168
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +82 -55
- package/components/form/timeInput/range.vue +115 -94
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +250 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +3 -3
- package/components/infinite/index.vue +290 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +206 -94
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +382 -156
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +319 -156
- package/components/swiper/index.vue +237 -108
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +629 -399
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +106 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +272 -24
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +11 -19
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +155 -178
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +7 -2
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -705
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<r-container ref="
|
|
2
|
+
<r-container ref="treeRef" :class="classes" full-width>
|
|
3
3
|
<r-row v-if="searchLink">
|
|
4
4
|
<r-col>
|
|
5
5
|
<r-select-input
|
|
@@ -13,18 +13,20 @@
|
|
|
13
13
|
<r-float v-if="show" :minZoom="0.01" :zoom="0.7" bordered>
|
|
14
14
|
<template v-slot="{move,ease,transform}">
|
|
15
15
|
<div :class="{
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
'tree-rotate':rotate
|
|
17
|
+
}">
|
|
18
18
|
<r-tree-element :expand="expand"
|
|
19
19
|
:link="link"
|
|
20
20
|
:model-value="node"
|
|
21
|
-
:openAll="openAll"
|
|
22
21
|
:sortBy="sortBy"
|
|
23
22
|
@expand="handleExpand(ease,move,transform,$event)"
|
|
24
23
|
@select="handleSelect"
|
|
25
24
|
@update:model-value="$emit('update:modelValue',$event)"
|
|
26
25
|
>
|
|
27
26
|
<template v-slot="{ item,nodeKey }">
|
|
27
|
+
<!-- Default slot for custom tree node content
|
|
28
|
+
@binding {Object} item - The tree node item
|
|
29
|
+
@binding {String} nodeKey - The key identifier for the node -->
|
|
28
30
|
<slot :item="item" :nodeKey="nodeKey">{{ item }}</slot>
|
|
29
31
|
</template>
|
|
30
32
|
</r-tree-element>
|
|
@@ -32,110 +34,254 @@
|
|
|
32
34
|
</template>
|
|
33
35
|
</r-float>
|
|
34
36
|
</r-container>
|
|
35
|
-
|
|
36
37
|
</template>
|
|
37
|
-
<script>
|
|
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
|
-
|
|
38
|
+
<script setup>
|
|
39
|
+
import {ref, computed, watch, inject} from 'vue'
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @example // Tree usage
|
|
43
|
+
* <template>
|
|
44
|
+
* <r-tree style="height:600px" v-model="treeData" :link="link" :searchLink="searchLink" :gen="gen" :selected="selected" :rotate="rotate" :childsName="childsName" :openAll="openAll" :headers="headers" @update:model-Value="log(`update:modelValue`,$event)" @select-node="log(`select-node`,$event)">
|
|
45
|
+
* <template v-slot="{nodeKey,item}">
|
|
46
|
+
* <r-card class="pa-5 title-1 mx-1">{{nodeKey}}:{{item.name}}</r-card>
|
|
47
|
+
* </template>
|
|
48
|
+
* </r-tree>
|
|
49
|
+
* </template>
|
|
50
|
+
* <script>
|
|
51
|
+
* import { ref } from 'vue'
|
|
52
|
+
*
|
|
53
|
+
* const treeData = ref({
|
|
54
|
+
* "0": {
|
|
55
|
+
* "name": "Root",
|
|
56
|
+
* "childs": {
|
|
57
|
+
* "1": {
|
|
58
|
+
* "name": "Child 1",
|
|
59
|
+
* "childs": {
|
|
60
|
+
* "3": {
|
|
61
|
+
* "name": "Grandchild 1",
|
|
62
|
+
* "childs": {
|
|
63
|
+
* "4": {
|
|
64
|
+
* "name": "Great Grandchild 1",
|
|
65
|
+
* "childs": {
|
|
66
|
+
* "6": {
|
|
67
|
+
* "name": "Level 5 Node 1",
|
|
68
|
+
* "childs": {
|
|
69
|
+
* "7": {
|
|
70
|
+
* "name": "Level 6 Node 1",
|
|
71
|
+
* "childs": {},
|
|
72
|
+
* },
|
|
73
|
+
* "8": {
|
|
74
|
+
* "name": "Level 6 Node 2",
|
|
75
|
+
* "childs": {},
|
|
76
|
+
* }
|
|
77
|
+
* },
|
|
78
|
+
* }
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* "5": {
|
|
82
|
+
* "name": "Great Grandchild 2",
|
|
83
|
+
* "childs": {},
|
|
84
|
+
* }
|
|
85
|
+
* },
|
|
86
|
+
* }
|
|
87
|
+
* },
|
|
88
|
+
* },
|
|
89
|
+
* "2": {
|
|
90
|
+
* "name": "Child 2",
|
|
91
|
+
* "childs": {},
|
|
92
|
+
* }
|
|
93
|
+
* },
|
|
94
|
+
* }
|
|
95
|
+
* })
|
|
96
|
+
*
|
|
97
|
+
* const link = ref(null)
|
|
98
|
+
* const searchLink = ref(null)
|
|
99
|
+
* const gen = ref("0") // Root node ID
|
|
100
|
+
* const selected = ref(null)
|
|
101
|
+
* const rotate = ref(false)
|
|
102
|
+
* const childsName = ref("childs") // Property name for children
|
|
103
|
+
* const openAll = ref(false)
|
|
104
|
+
* const headers = ref({})
|
|
105
|
+
*
|
|
106
|
+
* const log = (name, event) => {
|
|
107
|
+
* console.log(name, event)
|
|
108
|
+
* }
|
|
109
|
+
* <//script>
|
|
110
|
+
* */
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
const props = defineProps({
|
|
114
|
+
/**
|
|
115
|
+
* Tree data model
|
|
116
|
+
* @type {Object}
|
|
117
|
+
*/
|
|
118
|
+
modelValue: Object,
|
|
119
|
+
/**
|
|
120
|
+
* API endpoint URL for fetching tree data
|
|
121
|
+
* @type {String}
|
|
122
|
+
*/
|
|
123
|
+
link: String,
|
|
124
|
+
/**
|
|
125
|
+
* API endpoint URL for search functionality
|
|
126
|
+
* @type {String}
|
|
127
|
+
*/
|
|
128
|
+
searchLink: String,
|
|
129
|
+
/**
|
|
130
|
+
* Property name to sort tree nodes by
|
|
131
|
+
* @type {String}
|
|
132
|
+
* @default 'gen'
|
|
133
|
+
*/
|
|
134
|
+
sortBy: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: 'gen'
|
|
78
137
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Initial node identifier to load
|
|
140
|
+
* @type {String}
|
|
141
|
+
*/
|
|
142
|
+
gen: String,
|
|
143
|
+
/**
|
|
144
|
+
* Currently selected node identifier
|
|
145
|
+
* @type {String}
|
|
146
|
+
*/
|
|
147
|
+
selected: String,
|
|
148
|
+
/**
|
|
149
|
+
* Rotates the tree layout
|
|
150
|
+
* @type {Boolean}
|
|
151
|
+
*/
|
|
152
|
+
rotate: Boolean,
|
|
153
|
+
/**
|
|
154
|
+
* Expands all tree nodes by default
|
|
155
|
+
* @type {Boolean}
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
expand: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: false
|
|
83
161
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Property name for child nodes in tree data
|
|
164
|
+
* @type {String}
|
|
165
|
+
* @default 'childs'
|
|
166
|
+
*/
|
|
167
|
+
childsName: {
|
|
168
|
+
type: String,
|
|
169
|
+
default: 'childs'
|
|
90
170
|
},
|
|
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
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Additional headers for API requests
|
|
173
|
+
* @type {Object}
|
|
174
|
+
*/
|
|
175
|
+
headers: Object
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
const emit = defineEmits([
|
|
179
|
+
/**
|
|
180
|
+
* Emitted when tree data changes
|
|
181
|
+
* @param {Object} data - Updated tree data
|
|
182
|
+
*/
|
|
183
|
+
'update:modelValue',
|
|
184
|
+
/**
|
|
185
|
+
* Emitted when a tree node is selected
|
|
186
|
+
* @param {Object} node - Selected node data
|
|
187
|
+
*/
|
|
188
|
+
'select-node'
|
|
189
|
+
])
|
|
190
|
+
|
|
191
|
+
const {$r} = inject('renusify')
|
|
192
|
+
const $axios = inject('axios')
|
|
193
|
+
|
|
194
|
+
const show = ref(false)
|
|
195
|
+
const search = ref(null)
|
|
196
|
+
const nodeParent = ref(props.gen)
|
|
197
|
+
const node = ref(props.modelValue)
|
|
198
|
+
|
|
199
|
+
const treeRef = ref(null)
|
|
200
|
+
|
|
201
|
+
const classes = computed(() => {
|
|
202
|
+
const a = {'tree-searchable': props.searchLink}
|
|
203
|
+
a[`${$r.prefix}tree`] = true
|
|
204
|
+
return a
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Handles search selection changes
|
|
209
|
+
* @param {Object} e - Selected search item with value property
|
|
210
|
+
*/
|
|
211
|
+
const change = (e) => {
|
|
212
|
+
if (e && "value" in e) {
|
|
213
|
+
nodeParent.value = e.value
|
|
214
|
+
show.value = false
|
|
215
|
+
get()
|
|
120
216
|
}
|
|
121
217
|
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Fetches tree data from the API endpoint
|
|
221
|
+
*/
|
|
222
|
+
const get = () => {
|
|
223
|
+
$axios.get(props.link + nodeParent.value, {headers: props.headers})
|
|
224
|
+
.then(({data}) => {
|
|
225
|
+
node.value = data
|
|
226
|
+
show.value = true
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Handles tree node expansion with animation
|
|
232
|
+
* @param {Function} ease - Animation easing function
|
|
233
|
+
* @param {Function} move - Move function for positioning
|
|
234
|
+
* @param {Function} transform - Transform function
|
|
235
|
+
* @param {Array} $event - Event data containing node information
|
|
236
|
+
*/
|
|
237
|
+
const handleExpand = (ease, move, transform, $event) => {
|
|
238
|
+
const el = $event[1].getBoundingClientRect()
|
|
239
|
+
ease()
|
|
240
|
+
const node_info = $event[1].querySelector('.node-info').getBoundingClientRect()
|
|
241
|
+
const card_h = node_info.height
|
|
242
|
+
const card_w = node_info.width
|
|
243
|
+
const parent = treeRef.value.$el
|
|
244
|
+
const bb = treeRef.value.$el.getBoundingClientRect()
|
|
245
|
+
move(parent.offsetWidth / 2 - (el.left - bb.left + ($event[0] ? el.width / 2 : el.width - card_w / 2)),
|
|
246
|
+
parent.offsetHeight / 2 - (el.top - bb.top + (props.rotate ? el.height - card_h : card_h / 2)))
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Handles tree node selection
|
|
251
|
+
* @param {Object} e - Selected node data
|
|
252
|
+
*/
|
|
253
|
+
const handleSelect = (e) => {
|
|
254
|
+
emit('select-node', e)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (props.modelValue) {
|
|
258
|
+
show.value = true
|
|
259
|
+
} else if (props.link) {
|
|
260
|
+
get()
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Watchers
|
|
264
|
+
watch(() => props.modelValue, (newVal) => {
|
|
265
|
+
node.value = newVal
|
|
266
|
+
})
|
|
267
|
+
|
|
122
268
|
</script>
|
|
123
269
|
<style lang="scss">
|
|
124
|
-
@use "../../style
|
|
270
|
+
@use "../../style" as *;
|
|
125
271
|
|
|
126
272
|
$distance: 20px;
|
|
127
|
-
.#{
|
|
273
|
+
.#{$prefix}tree {
|
|
128
274
|
position: relative;
|
|
129
275
|
width: 100%;
|
|
130
276
|
height: 100%;
|
|
131
277
|
|
|
132
278
|
&.tree-searchable {
|
|
133
|
-
.#{
|
|
279
|
+
.#{$prefix}float {
|
|
134
280
|
height: calc(100% - 70px)
|
|
135
281
|
}
|
|
136
282
|
}
|
|
137
283
|
|
|
138
|
-
.#{
|
|
284
|
+
.#{$prefix}float {
|
|
139
285
|
direction: ltr;
|
|
140
286
|
}
|
|
141
287
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<r-container v-if="show"
|
|
2
|
+
<r-container v-if="show" ref="treeRef" :class="`${$r.prefix}tree-element px-0`" full-width>
|
|
3
3
|
<r-row class="h-center flex-nowrap no-gutters">
|
|
4
4
|
<r-col class="text-center">
|
|
5
5
|
<div class="d-flex h-center mb-1 node-info" @click.prevent="$emit('select',{key:nodeKey,item:node[nodeKey]})">
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
:model-value="{[child['gen']]:child}"
|
|
29
29
|
@expand="handleExpand"
|
|
30
30
|
:expand="expand"
|
|
31
|
-
:openAll="openAll"
|
|
32
31
|
:sort-by="sortBy"
|
|
33
32
|
@select="$emit('select',$event)"
|
|
34
33
|
>
|
|
@@ -40,11 +39,10 @@
|
|
|
40
39
|
</r-row>
|
|
41
40
|
</r-container>
|
|
42
41
|
</template>
|
|
43
|
-
<script>
|
|
42
|
+
<script setup>
|
|
43
|
+
import {ref, computed, inject} from 'vue'
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
name: 'r-tree-element',
|
|
47
|
-
props: {
|
|
45
|
+
const props = defineProps({
|
|
48
46
|
modelValue: Object,
|
|
49
47
|
link: String,
|
|
50
48
|
parentNode: String,
|
|
@@ -60,120 +58,122 @@ export default {
|
|
|
60
58
|
type: String,
|
|
61
59
|
default: 'childs'
|
|
62
60
|
},
|
|
63
|
-
openAll: Boolean,
|
|
64
61
|
headers: Object
|
|
65
|
-
|
|
66
|
-
emits:['update:modelValue','fire','select','expand'],
|
|
67
|
-
data() {
|
|
68
|
-
return {
|
|
69
|
-
back: false,
|
|
70
|
-
show: false,
|
|
71
|
-
loading: false,
|
|
72
|
-
open: this.expand,
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
mounted() {
|
|
76
|
-
if (this.modelValue) {
|
|
77
|
-
this.show = true
|
|
78
|
-
}
|
|
79
|
-
if (this.openAll && this.childs.length > 0) {
|
|
80
|
-
this.open = true;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
computed: {
|
|
84
|
-
node() {
|
|
85
|
-
return this.modelValue
|
|
86
|
-
},
|
|
87
|
-
size() {
|
|
88
|
-
return this.childs.length
|
|
89
|
-
},
|
|
90
|
-
childs() {
|
|
91
|
-
let res = []
|
|
92
|
-
if (!this.node || !(this.nodeKey in this.node) || !(this.childsName in this.node[this.nodeKey])) {
|
|
93
|
-
return res
|
|
94
|
-
}
|
|
95
|
-
const childs = this.node[this.nodeKey][this.childsName]
|
|
62
|
+
})
|
|
96
63
|
|
|
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
|
-
return res
|
|
128
|
-
},
|
|
129
|
-
nodeKey() {
|
|
130
|
-
const keys = Object.keys(this.node)
|
|
131
|
-
if (keys) {
|
|
132
|
-
return keys[0]
|
|
64
|
+
const emit = defineEmits(['update:modelValue', 'fire', 'select', 'expand'])
|
|
65
|
+
|
|
66
|
+
const {$helper} = inject('renusify')
|
|
67
|
+
const $axios = inject('axios')
|
|
68
|
+
|
|
69
|
+
const show = ref(false)
|
|
70
|
+
const loading = ref(false)
|
|
71
|
+
const open = ref(props.expand)
|
|
72
|
+
|
|
73
|
+
const treeRef = ref(null)
|
|
74
|
+
|
|
75
|
+
const node = computed(() => props.modelValue)
|
|
76
|
+
|
|
77
|
+
const size = computed(() => childs.value.length)
|
|
78
|
+
|
|
79
|
+
const childs = computed(() => {
|
|
80
|
+
const res = []
|
|
81
|
+
const nodeKeyValue = nodeKey.value
|
|
82
|
+
|
|
83
|
+
if (!node.value || !nodeKeyValue || !(nodeKeyValue in node.value) || !(props.childsName in node.value[nodeKeyValue])) {
|
|
84
|
+
return res
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const childs = node.value[nodeKeyValue][props.childsName]
|
|
88
|
+
const s = []
|
|
89
|
+
|
|
90
|
+
for (const key in childs) {
|
|
91
|
+
if ($helper.hasKey(childs, key)) {
|
|
92
|
+
if (childs[key]['gen'] === undefined) {
|
|
93
|
+
childs[key]['gen'] = key
|
|
133
94
|
}
|
|
134
|
-
|
|
95
|
+
s.push({
|
|
96
|
+
'key': key,
|
|
97
|
+
'value': childs[key]
|
|
98
|
+
})
|
|
135
99
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (current) {
|
|
145
|
-
if (this.link && this.size === 0) {
|
|
146
|
-
this.loading = true
|
|
147
|
-
this.$axios.get(this.link + e, {headers: this.headers})
|
|
148
|
-
.then(({data}) => {
|
|
149
|
-
this.$emit('update:modelValue', data)
|
|
150
|
-
this.open = !this.open
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
this.$emit('expand', [this.open, this.$refs.tree.$el])
|
|
153
|
-
}, 220)
|
|
154
|
-
this.loading = false
|
|
155
|
-
}, () => {
|
|
156
|
-
this.loading = false
|
|
157
|
-
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const sortBy = props.sortBy
|
|
103
|
+
s.sort(function (a, b) {
|
|
104
|
+
if (a['value'][sortBy] !== undefined) {
|
|
105
|
+
if (b['value'][sortBy] !== undefined) {
|
|
106
|
+
if (typeof a['value'][sortBy] === 'number' && typeof b['value'][sortBy] === 'number') {
|
|
107
|
+
return a['value'][sortBy] - b['value'][sortBy]
|
|
158
108
|
} else {
|
|
159
|
-
|
|
160
|
-
setTimeout(() => {
|
|
161
|
-
this.$emit('expand', [this.open, this.$refs.tree.$el])
|
|
162
|
-
}, 250)
|
|
109
|
+
return String(a['value'][sortBy]).localeCompare(String(b['value'][sortBy]))
|
|
163
110
|
}
|
|
164
|
-
|
|
165
|
-
} else {
|
|
166
|
-
this.$emit('expand', e)
|
|
167
111
|
}
|
|
112
|
+
return -1
|
|
113
|
+
}
|
|
114
|
+
return b['value'][sortBy] !== undefined ? 1 : 0
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const lng = s.length
|
|
118
|
+
for (let i = 0; i < lng; i++) {
|
|
119
|
+
res.push(s[i]['value'])
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return res
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const nodeKey = computed(() => {
|
|
126
|
+
if (!node.value) return false
|
|
127
|
+
|
|
128
|
+
const keys = Object.keys(node.value)
|
|
129
|
+
if (keys.length > 0) {
|
|
130
|
+
return keys[0]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return false
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const updateNode = (e, key) => {
|
|
137
|
+
const res = {...props.modelValue}
|
|
138
|
+
res[nodeKey.value][props.childsName][key] = e[key]
|
|
139
|
+
emit('update:modelValue', props.modelValue)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const handleExpand = (e, current) => {
|
|
143
|
+
if (current) {
|
|
144
|
+
if (props.link && size.value === 0) {
|
|
145
|
+
loading.value = true
|
|
146
|
+
$axios.get(props.link + e, {headers: props.headers})
|
|
147
|
+
.then(({data}) => {
|
|
148
|
+
emit('update:modelValue', data)
|
|
149
|
+
open.value = !open.value
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
emit('expand', [open.value, treeRef.value.$el])
|
|
152
|
+
}, 220)
|
|
153
|
+
loading.value = false
|
|
154
|
+
})
|
|
155
|
+
.catch(() => {
|
|
156
|
+
loading.value = false
|
|
157
|
+
})
|
|
158
|
+
} else {
|
|
159
|
+
open.value = !open.value
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
emit('expand', [open.value, treeRef.value.$el])
|
|
162
|
+
}, 250)
|
|
168
163
|
}
|
|
164
|
+
} else {
|
|
165
|
+
emit('expand', e)
|
|
169
166
|
}
|
|
170
167
|
}
|
|
168
|
+
if (props.modelValue) {
|
|
169
|
+
show.value = true
|
|
170
|
+
}
|
|
171
171
|
</script>
|
|
172
172
|
<style lang="scss">
|
|
173
|
-
@use "../../style
|
|
173
|
+
@use "../../style" as *;
|
|
174
174
|
|
|
175
175
|
$distance: 20px;
|
|
176
|
-
.#{
|
|
176
|
+
.#{$prefix}tree-element {
|
|
177
177
|
direction: ltr;
|
|
178
178
|
position: relative;
|
|
179
179
|
display: table;
|