renusify 1.4.3 → 1.4.7

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.
Files changed (53) hide show
  1. package/components/app/index.vue +1 -10
  2. package/components/chip/style.scss +0 -1
  3. package/components/codeEditor/highlightHtml.vue +8 -2
  4. package/components/codeEditor/index.vue +13 -55
  5. package/components/codeEditor/mixin.js +18 -4
  6. package/components/form/camInput.vue +6 -2
  7. package/components/form/input.vue +2 -2
  8. package/components/form/inputTel/assets/flags.png +0 -0
  9. package/components/form/inputTel/assets/flags@2x.png +0 -0
  10. package/components/form/mask-input.vue +2 -2
  11. package/components/form/select.vue +1 -1
  12. package/components/form/text-area.vue +1 -2
  13. package/components/form/text-editor/index.vue +0 -1
  14. package/components/form/timepicker/index.vue +18 -16
  15. package/components/form/unit-input.vue +1 -0
  16. package/components/formCreator/index.vue +7 -20
  17. package/components/index.js +1 -1
  18. package/components/infinite/index.vue +9 -6
  19. package/components/map/images/destination.png +0 -0
  20. package/components/map/images/layers.png +0 -0
  21. package/components/map/images/marker-icon.png +0 -0
  22. package/components/map/images/origin.png +0 -0
  23. package/components/map/images/point.png +0 -0
  24. package/components/map/index.vue +52 -20
  25. package/components/map/leaflet.css +511 -397
  26. package/components/map/route.vue +570 -560
  27. package/components/map/select.vue +64 -48
  28. package/components/message/index.vue +22 -21
  29. package/components/modal/index.vue +20 -7
  30. package/components/modal/style.scss +17 -14
  31. package/components/{app/notify → notify}/index.vue +21 -29
  32. package/components/{app/notify → notify}/notification.vue +10 -10
  33. package/components/notify/notify.js +27 -0
  34. package/components/searchBox/index.vue +30 -12
  35. package/components/slider/index.vue +1 -0
  36. package/components/table/crud/header.vue +55 -34
  37. package/components/table/crud/index.vue +4 -4
  38. package/components/table/index.vue +366 -367
  39. package/components/table/style.scss +1 -4
  40. package/components/tabs/index.vue +9 -23
  41. package/components/timeAgo/index.vue +4 -1
  42. package/components/tour/index.vue +237 -222
  43. package/components/tree/index.vue +135 -136
  44. package/components/tree/tree-element.vue +17 -3
  45. package/directive/index.js +1 -2
  46. package/directive/mask/index.js +1 -4
  47. package/directive/skeleton/index.js +27 -0
  48. package/directive/skeleton/style.scss +37 -0
  49. package/index.js +14 -9
  50. package/package.json +1 -1
  51. package/style/transitions.scss +6 -116
  52. package/tools/helper.js +20 -0
  53. package/components/app/notify/notify.js +0 -28
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <div
3
- :class="{
2
+ <div
3
+ :class="{
4
4
  [`${$r.prefix}table`]:true,
5
5
  'table-editable':editable,
6
6
  'table-bordered':borderd,
@@ -9,98 +9,98 @@
9
9
  'table-sortable':sortable,
10
10
  'table-stripped':stripped,
11
11
  'table-fixed-first-columns':fixedFirstColumn}">
12
- <div class="d-flex h-end v-end" v-if="editable">
13
- <svg class="table-svg" height="18" width="18">
14
- <path class="table-svg-path" d="M 0 0 l 0 18 l 18 0 q -18 0 -18 -18"/>
15
- </svg>
16
- <span class="color-info-text table-editable-icon px-2"
17
- @click.prevent="open_modal()">
18
- <r-icon v-html="$r.icons.setting" ></r-icon>
12
+ <div v-if="editable" class="d-flex h-end v-end">
13
+ <svg class="table-svg" height="18" width="18">
14
+ <path class="table-svg-path" d="M 0 0 l 0 18 l 18 0 q -18 0 -18 -18"/>
15
+ </svg>
16
+ <span class="color-info-text table-editable-icon px-2"
17
+ @click.prevent="open_modal()">
18
+ <r-icon v-html="$r.icons.setting"></r-icon>
19
19
  </span>
20
- </div>
21
- <div class="table-wrapper">
22
- <div class="table-container" ref="table">
23
- <r-progress-line v-if="loading" color="color-two"></r-progress-line>
24
- <table>
25
- <thead>
26
- <tr>
27
- <slot name="header" v-bind:header="th">
28
- <th :key="key" class="text-start text-no-wrap"
29
- :class="{'color-info-text':sortKey===item.value}"
30
- v-for="(item,key) in th"
31
- @click.prevent="sorting(item.value)">
32
- {{translate?$t(item.text,'renusify'):item.text}}
33
- <r-icon v-if="sortKey===item.value" :class="{'sort-desc':!sortAsc}" v-html="$r.icons.arrow_up" ></r-icon>
34
- </th>
35
- </slot>
36
- </tr>
37
- </thead>
38
- <transition-group :name="transition" tag="tbody">
39
- <template v-for="(item,key) in lists" :key="gen_key(item)||key">
40
- <template v-if="true">
41
- <tr :key="`${gen_key(item)||key}- f`">
42
- <slot name="row" :item="item" :th="th" :key="key" :opened="opened" :open="open"
43
- :show="show">
44
- <td :key="`${key}- ${k}`" v-for="(value,k) in th">
45
- <div>
46
- <r-btn @click.prevent="open(key)"
47
- icon text v-if="show(k)">
48
- <r-icon v-if="opened!==key" v-html="$r.icons.plus" ></r-icon>
49
- <r-icon v-else v-html="$r.icons.minus" ></r-icon>
50
- </r-btn>
51
- {{item[value.value]}}
52
- </div>
53
- </td>
54
- </slot>
55
- </tr>
56
- <tr v-if="opened===key" class="tr-hidden"
57
- :key="`${gen_key(item)||key}- l`">
58
- <td :colspan="($helper.size(th)||th.length)">
59
- <div class="pa-2" v-for="(v,h) in hidden" :key="key+h">
60
- <span class="title">{{getText(h)}}: </span>
61
- <span>{{item[h]}}</span>
62
- </div>
63
- </td>
64
- </tr>
65
- </template>
66
- </template>
67
- </transition-group>
68
- </table>
69
- </div>
70
- </div>
71
20
  </div>
72
- <r-modal v-model="showModal" v-if="editable">
73
- <r-card>
74
- <r-container
75
- v-sortable="{
21
+ <div class="table-wrapper">
22
+ <div ref="table" class="table-container">
23
+ <r-progress-line v-if="loading" color="color-two"></r-progress-line>
24
+ <table>
25
+ <thead>
26
+ <tr>
27
+ <slot name="header" v-bind:header="th">
28
+ <th v-for="(item,key) in th" :key="key"
29
+ :class="{'color-info-text':sortKey===item.value}"
30
+ class="text-start text-no-wrap"
31
+ @click.prevent="sorting(item.value)">
32
+ {{ translate ? $t(item.text, 'renusify') : item.text }}
33
+ <r-icon v-if="sortKey===item.value" :class="{'sort-desc':!sortAsc}" v-html="$r.icons.arrow_up"></r-icon>
34
+ </th>
35
+ </slot>
36
+ </tr>
37
+ </thead>
38
+ <transition-group :name="transition" tag="tbody">
39
+ <template v-for="(item,key) in lists" :key="gen_key(item)||key">
40
+ <template v-if="true">
41
+ <tr :key="`${gen_key(item)||key}- f`">
42
+ <slot :key="key" :item="item" :open="open" :opened="opened" :show="show" :th="th"
43
+ name="row">
44
+ <td v-for="(value,k) in th" :key="`${key}- ${k}`">
45
+ <div>
46
+ <r-btn v-if="show(k)"
47
+ icon text @click.prevent="open(key)">
48
+ <r-icon v-if="opened!==key" v-html="$r.icons.plus"></r-icon>
49
+ <r-icon v-else v-html="$r.icons.minus"></r-icon>
50
+ </r-btn>
51
+ {{ item[value.value] }}
52
+ </div>
53
+ </td>
54
+ </slot>
55
+ </tr>
56
+ <tr v-if="opened===key" :key="`${gen_key(item)||key}- l`"
57
+ class="tr-hidden">
58
+ <td :colspan="($helper.size(th)||th.length)">
59
+ <div v-for="(v,h) in hidden" :key="key+h" class="pa-2">
60
+ <span class="title">{{ getText(h) }}: </span>
61
+ <span>{{ item[h] }}</span>
62
+ </div>
63
+ </td>
64
+ </tr>
65
+ </template>
66
+ </template>
67
+ </transition-group>
68
+ </table>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ <r-modal v-if="editable" v-model="showModal">
73
+ <r-card>
74
+ <r-container
75
+ v-sortable="{
76
76
  items: cols,
77
77
  end: store_db,
78
78
  grab: '.drag-btn'
79
79
  }"
80
- >
81
- <r-row
82
- v-for="(col, i) in cols"
83
- :key="col.value+i"
84
- class="no-gutters"
85
- >
86
- <r-col>
87
- <r-card tile class="pa-4 ma-1 d-flex h-space-between">
80
+ >
81
+ <r-row
82
+ v-for="(col, i) in cols"
83
+ :key="col.value+i"
84
+ class="no-gutters"
85
+ >
86
+ <r-col>
87
+ <r-card class="pa-4 ma-1 d-flex h-space-between" tile>
88
88
  <span class="title">
89
89
  <r-btn class="drag-btn" icon text>
90
90
  <r-icon v-html="$r.icons.drag"></r-icon>
91
91
  </r-btn>
92
92
  {{ col.text }}
93
93
  </span>
94
- <span>
94
+ <span>
95
95
  <r-switch-input :label="$t('show','renusify')" v-model="col.show"
96
96
  @update:model-value="store_db(cols)"></r-switch-input>
97
97
  </span>
98
- </r-card>
99
- </r-col>
100
- </r-row>
101
- </r-container>
102
- </r-card>
103
- </r-modal>
98
+ </r-card>
99
+ </r-col>
100
+ </r-row>
101
+ </r-container>
102
+ </r-card>
103
+ </r-modal>
104
104
  </template>
105
105
 
106
106
  <script>
@@ -117,304 +117,303 @@ export default {
117
117
  thin: Boolean,
118
118
  responsive: Boolean,
119
119
  translate: Boolean,
120
- editable: Boolean,
121
- stripped: Boolean,
122
- borderd: Boolean,
123
- sortable: Boolean,
124
- sortableKey: String,
125
- fixedHeader: Boolean,
126
- fixedFirstColumn: Boolean,
127
- headers: Array,
128
- items: Array
129
- },
130
- data() {
131
- return {
132
- showTable: true,
133
- opened: null,
134
- sortKey: null,
135
- sortAsc: true,
136
- showModal: false,
137
- loading: false,
138
- eventsHandler: null,
139
- hidden_col: {},
140
- hidden: {},
141
- cols: []
142
- }
143
- },
144
- created(){
145
- if(!this.$r.icons.setting){
146
- this.$r.icons.setting = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M19.14 12.94c.04-.3.06-.61.06-.94c0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6s3.6 1.62 3.6 3.6s-1.62 3.6-3.6 3.6z"/></svg>'
147
- }
148
- if(!this.$r.icons.drag){
149
- this.$r.icons.drag = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M7 19v-2h2v2H7m4 0v-2h2v2h-2m4 0v-2h2v2h-2m-8-4v-2h2v2H7m4 0v-2h2v2h-2m4 0v-2h2v2h-2m-8-4V9h2v2H7m4 0V9h2v2h-2m4 0V9h2v2h-2M7 7V5h2v2H7m4 0V5h2v2h-2m4 0V5h2v2h-2Z"/></svg>'
150
- }
151
- },
152
- watch: {
153
- items: {
154
- immediate: true,
155
- handler() {
156
- setTimeout(() => {
157
- this.setup()
158
- }, 100)
159
- },
160
- }
161
- },
162
- computed: {
163
- priority() {
164
- let res = {}
165
- this.th.forEach((item) => {
166
- if (this.$helper.ifHas(item, false, 'option', 'priority') !== false) {
167
- res[item.value] = item['option']['priority']
168
- } else {
169
- res[item.value] = 0
170
- }
171
- })
172
-
173
- return res
174
- },
175
- lists() {
176
- let res = this.items
120
+ editable: Boolean,
121
+ stripped: Boolean,
122
+ borderd: Boolean,
123
+ sortable: Object,
124
+ fixedHeader: Boolean,
125
+ fixedFirstColumn: Boolean,
126
+ headers: Array,
127
+ items: Array
128
+ },
129
+ data() {
130
+ return {
131
+ showTable: true,
132
+ opened: null,
133
+ sortKey: null,
134
+ sortAsc: true,
135
+ showModal: false,
136
+ loading: false,
137
+ eventsHandler: null,
138
+ hidden_col: {},
139
+ hidden: {},
140
+ cols: []
141
+ }
142
+ },
143
+ created() {
144
+ if (!this.$r.icons.setting) {
145
+ this.$r.icons.setting = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M19.14 12.94c.04-.3.06-.61.06-.94c0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6s3.6 1.62 3.6 3.6s-1.62 3.6-3.6 3.6z"/></svg>'
146
+ }
147
+ if (!this.$r.icons.drag) {
148
+ this.$r.icons.drag = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M7 19v-2h2v2H7m4 0v-2h2v2h-2m4 0v-2h2v2h-2m-8-4v-2h2v2H7m4 0v-2h2v2h-2m4 0v-2h2v2h-2m-8-4V9h2v2H7m4 0V9h2v2h-2m4 0V9h2v2h-2M7 7V5h2v2H7m4 0V5h2v2h-2m4 0V5h2v2h-2Z"/></svg>'
149
+ }
150
+ },
151
+ watch: {
152
+ items: {
153
+ immediate: true,
154
+ handler() {
155
+ setTimeout(() => {
156
+ this.setup()
157
+ }, 100)
158
+ },
159
+ }
160
+ },
161
+ computed: {
162
+ priority() {
163
+ let res = {}
164
+ this.th.forEach((item) => {
165
+ if (this.$helper.ifHas(item, false, 'option', 'priority') !== false) {
166
+ res[item.value] = item['option']['priority']
167
+ } else {
168
+ res[item.value] = 0
169
+ }
170
+ })
177
171
 
178
- if (res && this.sortKey !== null) {
179
- return res.sort(this.dynamicSort(this.sortKey, this.sortAsc, this.sortableKey))
180
- }
181
- return res
182
- },
183
- th() {
184
- let res = []
185
- let list = this.cols.length > 0 ? this.cols : this.th_all
186
- list.forEach((item) => {
187
- if (item && !(item.value in this.hidden) && !(item.value in this.hidden_col)) {
188
- res.push(item)
189
- }
190
- })
191
- return res
192
- },
193
- th_all() {
194
- let res = []
195
- if (this.headers) {
196
- this.headers.forEach((item) => {
197
- if (item) {
198
- res.push(item)
199
- }
200
- })
201
- } else {
202
- for (let name in this.items[0]) {
203
- if (this.$helper.hasKey(this.items[0], name)) {
204
- res.push({text: name, value: name})
205
- }
206
- }
207
- }
208
- return res
209
- },
210
- hash_key() {
211
- let r = ''
212
- this.th_all.forEach((item) => {
213
- if (item) {
214
- r += item.value
215
- }
216
- })
217
- return this.$helper.hash(r)
218
- }
219
- },
220
- methods: {
221
- check_hidden() {
222
- const d = this.$storage.get('table_' + this.hash_key)
223
- if (d) {
224
- let res = {}
225
- d.forEach((item) => {
226
- if (item && item.show === false) {
227
- res[item.value] = true
228
- }
229
- })
230
- this.hidden_col = res
231
- this.cols = d
232
- }
172
+ return res
173
+ },
174
+ lists() {
175
+ let res = this.items
233
176
 
234
- },
235
- store_db(data) {
236
- this.$storage.set('table_' + this.hash_key, data)
237
- this.check_hidden()
238
- if (this.responsive) {
239
- this.build()
240
- }
241
- },
242
- open_modal() {
243
- const d = this.$storage.get('table_' + this.hash_key)
244
- if (d) {
245
- this.cols = []
246
- d.forEach((item) => {
247
- if (item) {
248
- this.cols.push(item)
249
- }
250
- })
251
- } else {
252
- this.cols = []
253
- this.th_all.forEach((item) => {
254
- if (item) {
255
- this.cols.push({text: item.text, value: item.value, show: true})
256
- }
257
- })
258
- }
177
+ if (res && this.sortable && this.sortable[this.sortKey]) {
178
+ return res.sort(this.dynamicSort(this.sortKey, this.sortAsc, this.sortable[this.sortKey]))
179
+ }
180
+ return res
181
+ },
182
+ th() {
183
+ let res = []
184
+ let list = this.cols.length > 0 ? this.cols : this.th_all
185
+ list.forEach((item) => {
186
+ if (item && !(item.value in this.hidden) && !(item.value in this.hidden_col)) {
187
+ res.push(item)
188
+ }
189
+ })
190
+ return res
191
+ },
192
+ th_all() {
193
+ let res = []
194
+ if (this.headers) {
195
+ this.headers.forEach((item) => {
196
+ if (item) {
197
+ res.push(item)
198
+ }
199
+ })
200
+ } else {
201
+ for (let name in this.items[0]) {
202
+ if (this.$helper.hasKey(this.items[0], name)) {
203
+ res.push({text: name, value: name})
204
+ }
205
+ }
206
+ }
207
+ return res
208
+ },
209
+ hash_key() {
210
+ let r = ''
211
+ this.th_all.forEach((item) => {
212
+ if (item) {
213
+ r += item.value
214
+ }
215
+ })
216
+ return this.$helper.hash(r)
217
+ }
218
+ },
219
+ methods: {
220
+ check_hidden() {
221
+ const d = this.$storage.get('table_' + this.hash_key)
222
+ if (d) {
223
+ let res = {}
224
+ d.forEach((item) => {
225
+ if (item && item.show === false) {
226
+ res[item.value] = true
227
+ }
228
+ })
229
+ this.hidden_col = res
230
+ this.cols = d
231
+ }
259
232
 
260
- this.showModal = true
261
- },
262
- gen_key(item) {
263
- if (!this.keyItem) {
264
- return false
265
- }
266
- if (typeof this.keyItem === 'string') {
267
- return item[this.keyItem]
268
- }
269
- return this.keyItem(item)
270
- },
271
- open(key) {
272
- if (this.opened === key) {
273
- this.opened = null
274
- } else {
275
- this.opened = key
276
- }
277
- },
278
- show(k) {
279
- if (this.$helper.size(this.hidden) === 0) {
280
- return false
281
- }
282
- if (this.$helper.isArray(this.th) && k === 0) {
283
- return true
284
- }
285
- const l = Object.keys(this.th)
286
- return l[0] === k;
233
+ },
234
+ store_db(data) {
235
+ this.$storage.set('table_' + this.hash_key, data)
236
+ this.check_hidden()
237
+ if (this.responsive) {
238
+ this.build()
239
+ }
240
+ },
241
+ open_modal() {
242
+ const d = this.$storage.get('table_' + this.hash_key)
243
+ if (d) {
244
+ this.cols = []
245
+ d.forEach((item) => {
246
+ if (item) {
247
+ this.cols.push(item)
248
+ }
249
+ })
250
+ } else {
251
+ this.cols = []
252
+ this.th_all.forEach((item) => {
253
+ if (item) {
254
+ this.cols.push({text: item.text, value: item.value, show: true})
255
+ }
256
+ })
257
+ }
287
258
 
288
- },
289
- setup() {
290
- if (this.editable) {
291
- this.check_hidden()
292
- const s = this.$storage.get('table_sort')
293
- if (s && this.hash_key in s) {
294
- this.sortKey = s[this.hash_key][0]
295
- this.sortAsc = s[this.hash_key][1]
296
- }
297
- }
298
- if (this.responsive) {
299
- this.build()
300
- }
301
- },
302
- build() {
303
- let el = this.$refs.table
304
- if (!el) {
305
- return
306
- }
307
- this.opened = null
308
- this.hidden = {}
309
- setTimeout(() => {
310
- let table = el.querySelector('table')
311
- let all_th = table.querySelectorAll('th') || []
312
- let th_w = []
313
- all_th.forEach((th) => {
314
- if (th) {
315
- th_w.push(th.clientWidth)
316
- }
317
- })
318
- let thn_w = {}
319
- let i = 0
320
- for (let name in this.priority) {
321
- if (this.$helper.hasKey(this.priority, name)) {
322
- thn_w[name] = th_w[i]
323
- i++
324
- }
325
- }
326
- if (el.clientWidth < table.clientWidth) {
327
- const [show, hide] = this.extractor(el.clientWidth, table.clientWidth, thn_w, this.priority)
328
- this.hidden = hide
329
- }
330
- }, 10)
259
+ this.showModal = true
260
+ },
261
+ gen_key(item) {
262
+ if (!this.keyItem) {
263
+ return false
264
+ }
265
+ if (typeof this.keyItem === 'string') {
266
+ return item[this.keyItem]
267
+ }
268
+ return this.keyItem(item)
269
+ },
270
+ open(key) {
271
+ if (this.opened === key) {
272
+ this.opened = null
273
+ } else {
274
+ this.opened = key
275
+ }
276
+ },
277
+ show(k) {
278
+ if (this.$helper.size(this.hidden) === 0) {
279
+ return false
280
+ }
281
+ if (this.$helper.isArray(this.th) && k === 0) {
282
+ return true
283
+ }
284
+ const l = Object.keys(this.th)
285
+ return l[0] === k;
331
286
 
332
- },
333
- extractor(width, table_w, th, priority, removed = 0, hide = {}) {
287
+ },
288
+ setup() {
289
+ if (this.editable) {
290
+ this.check_hidden()
291
+ const s = this.$storage.get('table_sort')
292
+ if (s && this.hash_key in s) {
293
+ this.sortKey = s[this.hash_key][0]
294
+ this.sortAsc = s[this.hash_key][1]
295
+ }
296
+ }
297
+ if (this.responsive) {
298
+ this.build()
299
+ }
300
+ },
301
+ build() {
302
+ let el = this.$refs.table
303
+ if (!el) {
304
+ return
305
+ }
306
+ this.opened = null
307
+ this.hidden = {}
308
+ setTimeout(() => {
309
+ let table = el.querySelector('table')
310
+ let all_th = table.querySelectorAll('th') || []
311
+ let th_w = []
312
+ all_th.forEach((th) => {
313
+ if (th) {
314
+ th_w.push(th.clientWidth)
315
+ }
316
+ })
317
+ let thn_w = {}
318
+ let i = 0
319
+ for (let name in this.priority) {
320
+ if (this.$helper.hasKey(this.priority, name)) {
321
+ thn_w[name] = th_w[i]
322
+ i++
323
+ }
324
+ }
325
+ if (el.clientWidth < table.clientWidth) {
326
+ const [show, hide] = this.extractor(el.clientWidth, table.clientWidth, thn_w, this.priority)
327
+ this.hidden = hide
328
+ }
329
+ }, 10)
334
330
 
335
- if (table_w > width + removed) {
336
- const name = this.remove_one(priority)
337
- hide[name] = true
338
- delete priority[name]
339
- return this.extractor(width, table_w, th, priority, removed + th[name], hide)
340
- }
341
- return [priority, hide]
331
+ },
332
+ extractor(width, table_w, th, priority, removed = 0, hide = {}) {
342
333
 
343
- },
344
- remove_one(priority) {
345
- let res = []
346
- for (let name in priority) {
347
- if (this.$helper.hasKey(priority, name)) {
348
- res.push({'name': name, 'value': priority[name]})
349
- }
350
- }
351
- res = res.sort((a, b) => {
352
- return a['value'] - b['value']
353
- })
354
- return res[0]['name']
334
+ if (table_w > width + removed) {
335
+ const name = this.remove_one(priority)
336
+ hide[name] = true
337
+ delete priority[name]
338
+ return this.extractor(width, table_w, th, priority, removed + th[name], hide)
339
+ }
340
+ return [priority, hide]
355
341
 
356
- },
357
- getText(key) {
358
- if (this.$helper.isArray(this.headers)) {
359
- const lng=this.headers.length
360
- for (let i = 0; i < lng; i++) {
361
- const item = this.headers[i]
362
- if (item.value === key) {
363
- return item.text
364
- }
365
- }
342
+ },
343
+ remove_one(priority) {
344
+ let res = []
345
+ for (let name in priority) {
346
+ if (this.$helper.hasKey(priority, name)) {
347
+ res.push({'name': name, 'value': priority[name]})
348
+ }
349
+ }
350
+ res = res.sort((a, b) => {
351
+ return a['value'] - b['value']
352
+ })
353
+ return res[0]['name']
366
354
 
367
- } else {
368
- return key
369
- }
370
- },
371
- sorting(name) {
372
- if (this.sortable) {
373
- this.loading = true
374
- setTimeout(() => {
375
- this.loading = false
376
- }, 1000)
377
- if (this.sortKey === name) {
378
- this.sortAsc = !this.sortAsc
379
- } else {
380
- this.sortKey = name
381
- this.sortAsc = true
382
- }
383
- if (this.editable) {
384
- let t = this.$storage.get('table_sort')
385
- if (!t) {
386
- t = {}
387
- }
388
- t[this.hash_key] = [name, this.sortAsc]
389
- this.$storage.set('table_sort', t)
390
- }
391
- }
392
- },
393
- dynamicSort(property, sortAsc, sortable_key = undefined) {
394
- let sortOrder = 1
395
- if (!sortAsc) {
396
- sortOrder = -1
397
- }
398
- const that = this
399
- return function (a, b) {
400
- let result = -1
401
- if (a[property] !== undefined && b[property] !== undefined) {
402
- let av = a[property]
403
- let bv = b[property]
404
- if (sortable_key !== undefined && av[sortable_key] !== undefined && bv[sortable_key] !== undefined) {
405
- av = av[sortable_key]
406
- bv = bv[sortable_key]
407
- }
408
- result = (av < bv) ? -1 : (av > bv) ? 1 : 0
409
- } else if (a[property] === undefined && b[property] !== undefined) {
410
- result = -1
411
- } else if (a[property] !== undefined && b[property] === undefined) {
412
- result = 1
413
- }
355
+ },
356
+ getText(key) {
357
+ if (this.$helper.isArray(this.headers)) {
358
+ const lng = this.headers.length
359
+ for (let i = 0; i < lng; i++) {
360
+ const item = this.headers[i]
361
+ if (item.value === key) {
362
+ return item.text
363
+ }
364
+ }
414
365
 
415
- return result * sortOrder
416
- }
417
- }
366
+ } else {
367
+ return key
368
+ }
369
+ },
370
+ sorting(name) {
371
+ if (this.sortable && this.sortable[name]) {
372
+ this.loading = true
373
+ setTimeout(() => {
374
+ this.loading = false
375
+ }, 500)
376
+ if (this.sortKey === name) {
377
+ this.sortAsc = !this.sortAsc
378
+ } else {
379
+ this.sortKey = name
380
+ this.sortAsc = true
418
381
  }
382
+ if (this.editable) {
383
+ let t = this.$storage.get('table_sort')
384
+ if (!t) {
385
+ t = {}
386
+ }
387
+ t[this.hash_key] = [name, this.sortAsc]
388
+ this.$storage.set('table_sort', t)
389
+ }
390
+ }
391
+ },
392
+ dynamicSort(property, sortAsc, sortable_key = undefined) {
393
+ let sortOrder = 1
394
+ if (!sortAsc) {
395
+ sortOrder = -1
396
+ }
397
+ const that = this
398
+ return function (a, b) {
399
+ let result = -1
400
+ if (a[property] !== undefined && b[property] !== undefined) {
401
+ let av = a[property]
402
+ let bv = b[property]
403
+ if (av[sortable_key] !== undefined && bv[sortable_key] !== undefined) {
404
+ av = av[sortable_key]
405
+ bv = bv[sortable_key]
406
+ }
407
+ result = (av < bv) ? -1 : (av > bv) ? 1 : 0
408
+ } else if (a[property] === undefined && b[property] !== undefined) {
409
+ result = -1
410
+ } else if (a[property] !== undefined && b[property] === undefined) {
411
+ result = 1
412
+ }
413
+
414
+ return result * sortOrder
415
+ }
419
416
  }
417
+ }
418
+ }
420
419
  </script>