renusify 1.1.4 → 1.2.0

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 (84) hide show
  1. package/components/app/notify/notification.vue +2 -1
  2. package/components/app/toast/index.vue +7 -2
  3. package/components/app/toast/toast.vue +2 -0
  4. package/components/avatar/index.vue +29 -23
  5. package/components/bar/bottomNavigationCircle.vue +8 -3
  6. package/components/bar/scss/bottomNav.scss +1 -1
  7. package/components/bar/toolbar/laptop.vue +4 -4
  8. package/components/bar/toolbar/mixin.js +1 -2
  9. package/components/bar/toolbar/mobile.vue +5 -4
  10. package/components/breadcrumb/index.vue +1 -0
  11. package/components/button/buttonConfirm.vue +1 -1
  12. package/components/button/buttonGroup.vue +1 -0
  13. package/components/button/style.scss +1 -0
  14. package/components/calendar/index.vue +1 -0
  15. package/components/calendar/month.vue +1 -0
  16. package/components/calendar/year.vue +1 -0
  17. package/components/chat/chatInput.vue +1 -0
  18. package/components/chat/chatMsg.vue +1 -0
  19. package/components/chat/index.vue +1 -0
  20. package/components/chip/index.vue +1 -0
  21. package/components/codeEditor/index.vue +0 -2
  22. package/components/confirm/index.vue +1 -0
  23. package/components/countdown/index.vue +1 -0
  24. package/components/float/index.vue +1 -0
  25. package/components/form/address.vue +6 -2
  26. package/components/form/camInput.vue +10 -3
  27. package/components/form/check-input.vue +95 -94
  28. package/components/form/checkbox.vue +1 -1
  29. package/components/form/colorPicker/index.vue +1 -0
  30. package/components/form/colorPicker/picker.vue +1 -0
  31. package/components/form/datePicker/index.vue +349 -348
  32. package/components/form/datePicker/month.vue +1 -0
  33. package/components/form/datePicker/year.vue +1 -0
  34. package/components/form/fileUploader/file.js +21 -3
  35. package/components/form/fileUploader/index.vue +13 -2
  36. package/components/form/fileUploader/single.vue +4 -2
  37. package/components/form/form.vue +1 -0
  38. package/components/form/group-input.vue +42 -38
  39. package/components/form/input.vue +253 -1
  40. package/components/form/inputTel/index.vue +22 -12
  41. package/components/form/json/JsonView.vue +95 -94
  42. package/components/form/json/index.vue +2 -0
  43. package/components/form/mask-input.vue +1 -0
  44. package/components/form/number.vue +25 -12
  45. package/components/form/password.vue +121 -121
  46. package/components/form/radioInput.vue +1 -0
  47. package/components/form/range.vue +26 -1
  48. package/components/form/rating.vue +13 -1
  49. package/components/form/select.vue +67 -4
  50. package/components/form/switch.vue +64 -2
  51. package/components/form/text-area.vue +1 -1
  52. package/components/form/text-editor/index.vue +18 -11
  53. package/components/form/text-input.vue +1 -1
  54. package/components/form/timepicker/index.vue +2 -1
  55. package/components/form/timepicker/range.vue +2 -1
  56. package/components/form/timepicker/timepicker.vue +2 -1
  57. package/components/form/unique/index.vue +3 -1
  58. package/components/form/unit-input.vue +2 -1
  59. package/components/formCreator/index.vue +8 -6
  60. package/components/html2pdf/index.vue +1 -0
  61. package/components/img/index.vue +12 -2
  62. package/components/img/svgImg.vue +43 -0
  63. package/components/infinite/div.vue +2 -1
  64. package/components/infinite/page.vue +24 -23
  65. package/components/list/index.vue +35 -32
  66. package/components/map/index.vue +324 -306
  67. package/components/map/route.vue +1 -0
  68. package/components/map/select.vue +1 -0
  69. package/components/menu/index.vue +1 -0
  70. package/components/modal/index.vue +1 -0
  71. package/components/searchBox/index.vue +5 -3
  72. package/components/slider/index.vue +1 -0
  73. package/components/table/crud/footer.vue +1 -1
  74. package/components/table/crud/header.vue +10 -4
  75. package/components/table/crud/index.vue +463 -458
  76. package/components/tabs/index.vue +1 -0
  77. package/components/tree/index.vue +15 -13
  78. package/components/tree/tree-element.vue +8 -4
  79. package/package.json +1 -1
  80. package/style/colors.scss +1 -1
  81. package/components/form/scss/input.scss +0 -249
  82. package/components/form/scss/rating.scss +0 -9
  83. package/components/form/scss/select.scss +0 -55
  84. package/components/form/scss/switch.scss +0 -68
@@ -1,486 +1,491 @@
1
1
  <template>
2
- <r-card :class="`${$r.prefix}table-manage`">
3
- <r-modal bottom full-width v-model="showForm">
4
- <slot name="form" :autoSend="autoSend"
5
- :method="method"
6
- :options="table.option"
7
- :title="title"
8
- :url="url"
9
- :modelValue="editedItem"
10
- :ok="ok">
11
- <r-form-creator :autoSend="autoSend"
12
- :method="method"
13
- :options="table.option"
14
- :title="title"
15
- :url="url"
16
- :modelValue="editedItem"
17
- @ok="ok"
18
- ></r-form-creator>
19
- </slot>
20
- </r-modal>
21
- <r-modal v-model="showCopy" bottom full-width>
22
- <r-card class="pa-3">
23
- <div :key="key" class="mb-5"
24
- v-for="(item,key) in table.option">
25
- <template v-if="item['formInput']!==false">
2
+ <r-card :class="`${$r.prefix}table-manage`">
3
+ <r-modal bottom full-width v-model="showForm">
4
+ <slot name="form" :autoSend="autoSend"
5
+ :method="method"
6
+ :options="table.option"
7
+ :title="title"
8
+ :url="url"
9
+ :modelValue="editedItem"
10
+ :ok="ok">
11
+ <r-form-creator :autoSend="autoSend"
12
+ :method="method"
13
+ :options="table.option"
14
+ :title="title"
15
+ :url="url"
16
+ :modelValue="editedItem"
17
+ @ok="ok"
18
+ ></r-form-creator>
19
+ </slot>
20
+ </r-modal>
21
+ <r-modal v-model="showCopy" bottom full-width>
22
+ <r-card class="pa-3">
23
+ <div :key="key" class="mb-5"
24
+ v-for="(item,key) in table.option">
25
+ <template v-if="item['formInput']!==false">
26
26
 
27
- <r-json-input v-if="item['type']==='file-uploader'" baseArray :label="$t(key,'renusify')"
28
- v-model="copyItem['d'][key]"></r-json-input>
29
- <component
30
- v-else
31
- :is="'r-'+item['type']"
32
- :label="$t(key,'renusify')"
33
- v-model="copyItem['d'][key]"
34
- v-bind="getAttr(table.option[key],copyItem['t'])"
35
- ></component>
36
- </template>
37
- </div>
27
+ <r-json-input v-if="item['type']==='file-uploader'" baseArray :label="$t(key,'renusify')"
28
+ v-model="copyItem['d'][key]"></r-json-input>
29
+ <component
30
+ v-else
31
+ :is="'r-'+item['type']"
32
+ :label="$t(key,'renusify')"
33
+ v-model="copyItem['d'][key]"
34
+ v-bind="getAttr(table.option[key],copyItem['t'])"
35
+ ></component>
36
+ </template>
37
+ </div>
38
38
 
39
- <r-divider class="my-5"></r-divider>
40
- <div class="d-flex h-space-between v-baseline">
39
+ <r-divider class="my-5"></r-divider>
40
+ <div class="d-flex h-space-between v-baseline">
41
41
  <span>
42
42
  <r-number-input v-if="copyItem['t']==='copy'" :label="$t('count_copy','renusify')"
43
43
  v-model="copyItem['c']"></r-number-input>
44
44
  </span>
45
- <r-btn class="color-success" :loading="loading" @click="copyAll()">{{$t('send','renusify')}}</r-btn>
46
- </div>
47
- </r-card>
48
- </r-modal>
49
- <manage-header v-model="search" @update:modelValue="searching()"
50
- :header-table="table.headers"
51
- :mcud="showMCUD"
52
- :advance-search="advanceSearch" :disable-add="disableAdd" :new-item="newItem"
53
- :loading="loading"
54
- @delete="deleteAll()"
55
- @copy="copyHandle('copy')"
56
- @edit="copyHandle('edit')"
57
- @a-search="(a_search=$event),(searching())"></manage-header>
58
- <r-table :responsive="responsive" transition="table-row" :headers="headerTable" :items="table.data"
59
- key-item="_id">
60
- <template v-slot:header="{header}">
61
- <th :class="{
45
+ <r-btn class="color-success" :loading="loading" @click="copyAll()">{{ $t('send', 'renusify') }}</r-btn>
46
+ </div>
47
+ </r-card>
48
+ </r-modal>
49
+ <manage-header v-model="search" @update:modelValue="searching()"
50
+ :header-table="table.headers"
51
+ :mcud="showMCUD"
52
+ :advance-search="advanceSearch" :disable-add="disableAdd" :new-item="newItem"
53
+ :loading="loading"
54
+ @delete="deleteAll()"
55
+ @copy="copyHandle('copy')"
56
+ @edit="copyHandle('edit')"
57
+ @a-search="(a_search=$event),(searching())"></manage-header>
58
+ <r-table :responsive="responsive" transition="table-row" :headers="headerTable" :items="table.data"
59
+ key-item="_id">
60
+ <template v-slot:header="{header}">
61
+ <th :class="{
62
62
  'header-sortable':$helper.ifHas(item, true, 'option', 'sortable')
63
63
  }"
64
- :key="`th-${key}`"
65
- @click.stop="sortSetup(item)"
66
- v-for="(item,key) in header">
67
- <div v-if="item.option.type==='mcud'">
68
- <input
69
- class="table-checkbox"
70
- v-model="check_all"
71
- type="checkbox">
72
- </div>
73
- <div v-else class="d-flex v-end">
74
- <div class="w-90"><span>{{item.text}}</span></div>
75
- <div class="w-10 icon-holder" :class="{
64
+ :key="`th-${key}`"
65
+ @click.stop="sortSetup(item)"
66
+ v-for="(item,key) in header">
67
+ <div v-if="item.option.type==='mcud'">
68
+ <input
69
+ class="table-checkbox"
70
+ v-model="check_all"
71
+ type="checkbox">
72
+ </div>
73
+ <div v-else class="d-flex v-end">
74
+ <div class="w-90"><span>{{ item.text }}</span></div>
75
+ <div class="w-10 icon-holder" :class="{
76
76
  'icon-hidden': !(sortBy === item.value && sortType !== 0)
77
77
  }"
78
- >
79
- <r-icon v-if="(sortType === 2 && sortBy === item.value)"
80
- v-html="this.$r.icons.arrow_down"></r-icon>
81
- <r-icon v-if="(sortType !== 2 || sortBy !== item.value)"
82
- v-html="this.$r.icons.arrow_up"></r-icon>
78
+ >
79
+ <r-icon v-if="(sortType === 2 && sortBy === item.value)"
80
+ v-html="this.$r.icons.arrow_down"></r-icon>
81
+ <r-icon v-if="(sortType !== 2 || sortBy !== item.value)"
82
+ v-html="this.$r.icons.arrow_up"></r-icon>
83
83
 
84
- </div>
84
+ </div>
85
85
 
86
- </div>
87
- </th>
88
- </template>
86
+ </div>
87
+ </th>
88
+ </template>
89
89
 
90
- <template v-slot:row="props">
91
- <slot name="row" :table="props" :editItem="editItem" :deleteItem="deleteItem">
92
- <td :key="`td-${key2}`"
93
- v-for="(value,key2) in props.th">
94
- <input v-if="value['option']['type']==='mcud'"
95
- class="table-checkbox"
96
- v-model="checked[props.item['_id']]"
97
- @update:model-value="$event===false?check_all=false:''"
98
- :checked="check_all"
99
- type="checkbox">
100
- <r-btn @click.prevent="props.open(props.key)"
101
- icon text v-if="props.show(key2)">
102
- <r-icon v-html="props.opened!==props.key?$r.icons.plus:$r.icons.minus"></r-icon>
103
- </r-btn>
104
- <slot name="cell" :value="value" :item="props.item" :editItem="editItem">
105
- <div v-if="value['option']['type']==='date-input' && props.item[value['value']]!==undefined">
106
- {{ $d(new Date(props.item[value['value']]), value['option']['format'] || 'short') }}
107
- </div>
108
- <div
109
- v-else-if="value['option']['type']==='time-ago' && props.item[value['value']]!==undefined">
110
- <r-time-ago :time="props.item[value['value']]"></r-time-ago>
111
- </div>
112
- <div v-else-if="value['option']['type']==='switch-input'">
113
- <r-switch-input
114
- :readonly="value['option']['formInput']===false"
115
- :modelValue="props.item[value['value']]"
116
- @update:modelValue="value['option']['formInput']!==false?editItem(props.item,true,value['value']):''"
117
- class="mt-0"
118
- ></r-switch-input>
119
- </div>
120
- <div v-else-if="value['option']['type'] === 'number-input'">
121
- {{ $n(props.item[value["value"]]) }}
122
- </div>
123
- <div v-else-if="value['option']['type']!=='action'">
124
- {{value['value'] in cast?
125
- $helper.ifHas(props.item,'',value['value'],cast[value['value']])
126
- :props.item[value['value']]}}
127
- </div>
128
- </slot>
129
- <div v-if="value['option']['type']==='action'">
130
- <r-btn v-if="!disableUpdate" @click.prevent="editItem(props.item)"
131
- class="mx-0 color-success-text" icon text>
132
- <r-icon exact v-html="$r.icons.edit"></r-icon>
133
- </r-btn>
134
- <r-btn v-if="!disableDelete" @click.prevent="deleteItem(props.item)"
135
- class="mx-0 color-error-text" icon text>
136
- <r-icon v-html="$r.icons.delete"></r-icon>
137
- </r-btn>
138
- <r-btn :key="index" @click.prevent="$emit(val.name,props.item)" class="mx-0" icon text
139
- v-for="(val,index) in actions" :class="`color-${val.color}-text`">
140
- <r-icon exact v-html="val.icon"></r-icon>
141
- </r-btn>
142
- </div>
143
- </td>
144
- </slot>
145
- </template>
90
+ <template v-slot:row="props">
91
+ <slot name="row" :table="props" :editItem="editItem" :deleteItem="deleteItem">
92
+ <td :key="`td-${key2}`"
93
+ v-for="(value,key2) in props.th">
94
+ <input v-if="value['option']['type']==='mcud'"
95
+ class="table-checkbox"
96
+ v-model="checked[props.item['_id']]"
97
+ @update:model-value="$event===false?check_all=false:''"
98
+ :checked="check_all"
99
+ type="checkbox">
100
+ <r-btn @click.prevent="props.open(props.key)"
101
+ icon text v-if="props.show(key2)">
102
+ <r-icon v-html="props.opened!==props.key?$r.icons.plus:$r.icons.minus"></r-icon>
103
+ </r-btn>
104
+ <slot name="cell" :value="value" :item="props.item" :editItem="editItem">
105
+ <div v-if="value['option']['type']==='date-input' && props.item[value['value']]!==undefined">
106
+ {{ $d(new Date(props.item[value['value']]), value['option']['format'] || 'short') }}
107
+ </div>
108
+ <div
109
+ v-else-if="value['option']['type']==='time-ago' && props.item[value['value']]!==undefined">
110
+ <r-time-ago :time="props.item[value['value']]"></r-time-ago>
111
+ </div>
112
+ <div v-else-if="value['option']['type']==='switch-input'">
113
+ <r-switch-input
114
+ :readonly="value['option']['formInput']===false"
115
+ :modelValue="props.item[value['value']]"
116
+ @update:modelValue="value['option']['formInput']!==false?editItem(props.item,true,value['value']):''"
117
+ class="mt-0"
118
+ ></r-switch-input>
119
+ </div>
120
+ <div v-else-if="value['option']['type'] === 'number-input'">
121
+ {{ $n(props.item[value["value"]]) }}
122
+ </div>
123
+ <div v-else-if="value['option']['type']!=='action'">
124
+ {{
125
+ value['value'] in cast ?
126
+ $helper.ifHas(props.item, '', value['value'], cast[value['value']])
127
+ : props.item[value['value']]
128
+ }}
129
+ </div>
130
+ </slot>
131
+ <div v-if="value['option']['type']==='action'">
132
+ <r-btn v-if="!disableUpdate" @click.prevent="editItem(props.item)"
133
+ class="mx-0 color-success-text" icon text>
134
+ <r-icon exact v-html="$r.icons.edit"></r-icon>
135
+ </r-btn>
136
+ <r-btn v-if="!disableDelete" @click.prevent="deleteItem(props.item)"
137
+ class="mx-0 color-error-text" icon text>
138
+ <r-icon v-html="$r.icons.delete"></r-icon>
139
+ </r-btn>
140
+ <r-btn :key="index" @click.prevent="$emit(val.name,props.item)" class="mx-0" icon text
141
+ v-for="(val,index) in actions" :class="`color-${val.color}-text`">
142
+ <r-icon exact v-html="val.icon"></r-icon>
143
+ </r-btn>
144
+ </div>
145
+ </td>
146
+ </slot>
147
+ </template>
146
148
 
147
- </r-table>
148
- <manage-footer v-model:page="page" v-model:per-page="itemsPerPage" :total="table.total"></manage-footer>
149
- <r-confirm
150
- hard
151
- v-model="showConfirm"
152
- v-on:accept="accept"
153
- v-on:cancel="showConfirm = false"
154
- />
155
- </r-card>
149
+ </r-table>
150
+ <manage-footer v-model:page="page" v-model:per-page="itemsPerPage" :total="table.total"></manage-footer>
151
+ <r-confirm
152
+ hard
153
+ v-model="showConfirm"
154
+ v-on:accept="accept"
155
+ v-on:cancel="showConfirm = false"
156
+ />
157
+ </r-card>
156
158
  </template>
157
159
 
158
160
  <script>
159
- import ManageFooter from "./footer";
160
- import ManageHeader from "./header";
161
+ import ManageFooter from "./footer";
162
+ import ManageHeader from "./header";
161
163
 
162
- export default {
163
- name: 'r-table-crud',
164
- components: {ManageHeader, ManageFooter},
165
- props: {
166
- link: {
167
- required: true,
168
- type: String
169
- },
170
- actions: {
171
- default: function () {
172
- return []
173
- },
174
- type: Array
175
- },
176
- cast: {
177
- default: function () {
178
- return {}
179
- },
180
- type: Object
181
- },
182
- perPage: {
183
- type: Object, default: () => {
184
- return {name: '10', value: 10}
185
- }
186
- },
187
- query: Object,
188
- responsive: {
189
- type: Boolean,
190
- default: true
191
- },
164
+ export default {
165
+ name: 'r-table-crud',
166
+ components: {ManageHeader, ManageFooter},
167
+ props: {
168
+ link: {
169
+ required: true,
170
+ type: String
171
+ },
172
+ actions: {
173
+ default: function () {
174
+ return []
175
+ },
176
+ type: Array
177
+ },
178
+ cast: {
179
+ default: function () {
180
+ return {}
181
+ },
182
+ type: Object
183
+ },
184
+ perPage: {
185
+ type: Object, default: () => {
186
+ return {name: '10', value: 10}
187
+ }
188
+ },
189
+ query: Object,
190
+ responsive: {
191
+ type: Boolean,
192
+ default: true
193
+ },
192
194
 
193
- disableAdd: Boolean,
194
- advanceSearch: {type: Boolean, default: true},
195
- disableDelete: Boolean,
196
- disableUpdate: Boolean,
197
- mcud: String
198
- },
199
- data() {
200
- return {
201
- time_out_id: null,
202
- loading: false,
203
- showForm: false,
204
- showCopy: false,
205
- showConfirm: false,
206
- search: '',
207
- a_search: {},
208
- copyItem: {'d': {}, 'c': 1},
209
- editedItem: {},
210
- deleted: '',
211
- url: '',
212
- method: 'post',
213
- title: '',
214
- autoSend: false,
215
- itemsPerPage: this.perPage,
216
- page: 1,
217
- sortBy: null,
218
- sortType: 0,
219
- table: {
220
- headers: [],
221
- option: {},
222
- data: [],
223
- startTime: false,
224
- total: 0
225
- },
226
- check_all: false,
227
- checked: {}
228
- }
229
- },
230
- created() {
231
- this.refresh()
232
- },
233
- watch: {
234
- page: function (n, o) {
235
- if (n > 0) {
236
- this.refresh()
237
- }
238
- },
239
- itemsPerPage: function () {
240
- this.refresh()
241
- }
242
- },
243
- computed: {
244
- showMCUD() {
245
- if (this.check_all) {
246
- return true
247
- }
248
- for (let k in this.checked) {
249
- if (this.checked[k] === true) {
250
- return true
251
- }
252
- }
253
- return false
254
- },
255
- headerTable() {
256
- const headers = this.table.headers
257
- const res = []
258
- const lng=headers.length
259
- for (let i = 0; i < lng; i++) {
260
- if (this.$helper.ifHas(headers[i], true, 'option', 'tableShow') !== false) {
261
- res.push(headers[i])
262
- }
263
- }
264
- return res
265
- }
266
- },
267
- methods: {
268
- getAttr(data, typ) {
269
- let res = {}
270
- let ls = ['formInput', 'sortable', 'type', 'tableShow', 'priority']
271
- if (typ === 'edit') {
272
- ls.push('rules')
273
- }
274
- for (let i in data) {
275
- if (this.$helper.hasKey(data, i) &&
276
- !ls.includes(i)) {
277
- res[i] = data[i]
278
- }
279
- }
280
- return res
281
- },
282
- copyAll() {
283
- this.loading = true
284
- this.$axios[this.copyItem['t'] === 'copy' ? 'post' : 'put'](this.mcud, this.copyItem).then(() => {
285
- this.loading = false
286
- this.showCopy = false
287
- this.refresh()
288
- }, () => {
289
- this.loading = false
290
- })
291
- },
292
- copyHandle(typ = 'copy') {
293
- this.copyItem = {'d': {}, 'c': 1, 't': typ}
294
- if (typ === 'edit') {
295
- this.copyItem['ids'] = this.get_ids()
296
- if (this.copyItem['ids'].length === 0) {
297
- return
298
- }
299
- }
300
- if(typ==='copy'){
301
- if (this.check_all) {
302
- this.copyItem['d'] = this.table.data[0]
303
- this.copyItem['c'] = 1
304
- }
305
- for (let k in this.checked) {
306
- if (this.checked[k] === true) {
307
- this.table.data.forEach((item) => {
308
- if (item._id === k) {
309
- this.copyItem['d'] = item
310
- this.copyItem['c'] = 1
311
- }
312
- })
313
- break
314
- }
315
- }
316
- }
317
- this.showCopy = true
318
- },
319
- get_ids() {
320
- let res = []
321
- if (this.check_all) {
322
- this.table.data.forEach((item) => {
323
- res.push(item._id)
324
- })
325
- }
326
- for (let k in this.checked) {
327
- if (this.checked[k] === true) {
328
- res.push(k)
329
- }
330
- }
331
- return res
332
- },
333
- deleteAll() {
334
- let res = this.get_ids()
335
- if (res.length > 0) {
336
- this.$axios.delete(this.mcud, {
337
- data: {
338
- ids: res
339
- }
340
- })
341
- .then(() => {
342
- this.refresh()
343
- })
344
- }
345
- },
346
- sortSetup(item) {
347
- if (!this.$helper.ifHas(item, true, 'option', 'sortable')) {
348
- return
349
- }
350
- if (this.sortBy !== item.value) {
351
- this.sortType = 0
352
- }
353
- this.sortBy = item.value
354
- if (this.sortType >= 2) {
355
- this.sortType = 0
356
- } else {
357
- this.sortType += 1
358
- }
359
- this.refresh()
360
- },
361
- ok() {
362
- this.refresh()
363
- this.autoSend = false
364
- this.showForm = false
365
- },
366
- refresh(e) {
367
- this.loading = true
368
- this.check_all = false
369
- this.checked = {}
370
- const perPage = e !== undefined ? e.value : this.itemsPerPage.value
371
- let params = this.query || {}
372
- params.page = this.page
373
- if (this.table.startTime !== false) {
374
- params.t = this.table.startTime
375
- }
376
- if (this.sortType !== 0) {
377
- const sort = (this.sortType === 2) ? 'desc' : 'asc'
378
- params[sort] = this.sortBy
379
- }
380
- params.per_page = perPage
381
- if (this.search.length >= 1) {
382
- params.search = this.search
383
- }
384
- if (this.$helper.size(this.a_search) > 0) {
385
- params.a_search = JSON.stringify(this.a_search)
195
+ disableAdd: Boolean,
196
+ advanceSearch: {type: Boolean, default: true},
197
+ disableDelete: Boolean,
198
+ disableUpdate: Boolean,
199
+ mcud: String,
200
+ headers: Object
201
+ },
202
+ emits:['actions'],
203
+ data() {
204
+ return {
205
+ time_out_id: null,
206
+ loading: false,
207
+ showForm: false,
208
+ showCopy: false,
209
+ showConfirm: false,
210
+ search: '',
211
+ a_search: {},
212
+ copyItem: {'d': {}, 'c': 1},
213
+ editedItem: {},
214
+ deleted: '',
215
+ url: '',
216
+ method: 'post',
217
+ title: '',
218
+ autoSend: false,
219
+ itemsPerPage: this.perPage,
220
+ page: 1,
221
+ sortBy: null,
222
+ sortType: 0,
223
+ table: {
224
+ headers: [],
225
+ option: {},
226
+ data: [],
227
+ startTime: false,
228
+ total: 0
229
+ },
230
+ check_all: false,
231
+ checked: {}
232
+ }
233
+ },
234
+ created() {
235
+ this.refresh()
236
+ },
237
+ watch: {
238
+ page: function (n, o) {
239
+ if (n > 0) {
240
+ this.refresh()
241
+ }
242
+ },
243
+ itemsPerPage: function () {
244
+ this.refresh()
245
+ }
246
+ },
247
+ computed: {
248
+ showMCUD() {
249
+ if (this.check_all) {
250
+ return true
251
+ }
252
+ for (let k in this.checked) {
253
+ if (this.checked[k] === true) {
254
+ return true
255
+ }
256
+ }
257
+ return false
258
+ },
259
+ headerTable() {
260
+ const headers = this.table.headers
261
+ const res = []
262
+ const lng = headers.length
263
+ for (let i = 0; i < lng; i++) {
264
+ if (this.$helper.ifHas(headers[i], true, 'option', 'tableShow') !== false) {
265
+ res.push(headers[i])
266
+ }
267
+ }
268
+ return res
269
+ }
270
+ },
271
+ methods: {
272
+ getAttr(data, typ) {
273
+ let res = {}
274
+ let ls = ['formInput', 'sortable', 'type', 'tableShow', 'priority']
275
+ if (typ === 'edit') {
276
+ ls.push('rules')
277
+ }
278
+ for (let i in data) {
279
+ if (this.$helper.hasKey(data, i) &&
280
+ !ls.includes(i)) {
281
+ res[i] = data[i]
282
+ }
283
+ }
284
+ return res
285
+ },
286
+ copyAll() {
287
+ this.loading = true
288
+ this.$axios[this.copyItem['t'] === 'copy' ? 'post' : 'put'](this.mcud, this.copyItem, {headers: this.headers}).then(() => {
289
+ this.loading = false
290
+ this.showCopy = false
291
+ this.refresh()
292
+ }, () => {
293
+ this.loading = false
294
+ })
295
+ },
296
+ copyHandle(typ = 'copy') {
297
+ this.copyItem = {'d': {}, 'c': 1, 't': typ}
298
+ if (typ === 'edit') {
299
+ this.copyItem['ids'] = this.get_ids()
300
+ if (this.copyItem['ids'].length === 0) {
301
+ return
302
+ }
303
+ }
304
+ if (typ === 'copy') {
305
+ if (this.check_all) {
306
+ this.copyItem['d'] = this.table.data[0]
307
+ this.copyItem['c'] = 1
308
+ }
309
+ for (let k in this.checked) {
310
+ if (this.checked[k] === true) {
311
+ this.table.data.forEach((item) => {
312
+ if (item._id === k) {
313
+ this.copyItem['d'] = item
314
+ this.copyItem['c'] = 1
386
315
  }
316
+ })
317
+ break
318
+ }
319
+ }
320
+ }
321
+ this.showCopy = true
322
+ },
323
+ get_ids() {
324
+ let res = []
325
+ if (this.check_all) {
326
+ this.table.data.forEach((item) => {
327
+ res.push(item._id)
328
+ })
329
+ }
330
+ for (let k in this.checked) {
331
+ if (this.checked[k] === true) {
332
+ res.push(k)
333
+ }
334
+ }
335
+ return res
336
+ },
337
+ deleteAll() {
338
+ let res = this.get_ids()
339
+ if (res.length > 0) {
340
+ this.$axios.delete(this.mcud, {
341
+ data: {
342
+ ids: res
343
+ },
344
+ headers: this.headers
345
+ })
346
+ .then(() => {
347
+ this.refresh()
348
+ })
349
+ }
350
+ },
351
+ sortSetup(item) {
352
+ if (!this.$helper.ifHas(item, true, 'option', 'sortable')) {
353
+ return
354
+ }
355
+ if (this.sortBy !== item.value) {
356
+ this.sortType = 0
357
+ }
358
+ this.sortBy = item.value
359
+ if (this.sortType >= 2) {
360
+ this.sortType = 0
361
+ } else {
362
+ this.sortType += 1
363
+ }
364
+ this.refresh()
365
+ },
366
+ ok() {
367
+ this.refresh()
368
+ this.autoSend = false
369
+ this.showForm = false
370
+ },
371
+ refresh(e) {
372
+ this.loading = true
373
+ this.check_all = false
374
+ this.checked = {}
375
+ const perPage = e !== undefined ? e.value : this.itemsPerPage.value
376
+ let params = this.query || {}
377
+ params.page = this.page
378
+ if (this.table.startTime !== false) {
379
+ params.t = this.table.startTime
380
+ }
381
+ if (this.sortType !== 0) {
382
+ const sort = (this.sortType === 2) ? 'desc' : 'asc'
383
+ params[sort] = this.sortBy
384
+ }
385
+ params.per_page = perPage
386
+ if (this.search.length >= 1) {
387
+ params.search = this.search
388
+ }
389
+ if (this.$helper.size(this.a_search) > 0) {
390
+ params.a_search = JSON.stringify(this.a_search)
391
+ }
387
392
 
388
- this.setup('/' + this.link, params)
389
- },
390
- searching() {
391
- clearTimeout(this.time_out_id)
392
- this.loading = true
393
- this.time_out_id = setTimeout(() => {
394
- this.page = 1
395
- this.refresh()
396
- }, 1000)
397
-
398
- },
399
- newItem() {
400
- this.title = this.$t('new', 'renusify')
401
- this.url = this.link
402
- const items = {}
403
- this.table.headers.map((item) => {
404
- if (item.option.formInput !== false) {
405
- if (item.option.type === 'boolean') {
406
- items[item.value] = false
407
- } else {
408
- items[item.value] = null
409
- }
410
- }
411
- })
412
- this.editedItem = items
413
- this.method = 'post'
414
- this.autoSend = false
415
- this.showForm = true
416
- },
417
- editItem(item, autoSend = false, key = null) {
418
- let sw
419
- this.title = this.$t('edit', 'renusify')
420
- this.url = this.link + '/' + item._id
421
- if (key) {
422
- sw = !item[key]
423
- }
424
- const items = {}
425
- this.table.headers.map((header) => {
426
- if (header.option.formInput !== false) {
427
- if (header.option.type === 'boolean') {
428
- items[header.value] = item[header.value] !== undefined ? item[header.value] : false
429
- } else {
430
- items[header.value] = item[header.value] !== undefined ? item[header.value] : null
431
- }
432
- }
433
- })
434
- this.editedItem = Object.assign({}, items)
393
+ this.setup('/' + this.link, params)
394
+ },
395
+ searching() {
396
+ clearTimeout(this.time_out_id)
397
+ this.loading = true
398
+ this.time_out_id = setTimeout(() => {
399
+ this.page = 1
400
+ this.refresh()
401
+ }, 1000)
435
402
 
436
- if (key) {
437
- this.editedItem[key] = sw
438
- }
439
- this.method = 'put'
440
- this.autoSend = autoSend
441
- this.showForm = true
442
- },
443
- deleteItem(item) {
444
- this.showConfirm = true
445
- this.deleted = item._id
446
- },
447
- delete(_id) {
448
- this.$axios.delete(this.link + '/' + _id)
449
- .then((res) => {
450
- this.refresh()
451
- })
452
- },
453
- accept() {
454
- this.showConfirm = false
455
- this.delete(this.deleted)
456
- this.deleted = ''
457
- this.refresh()
458
- },
459
- setup(url, params = null) {
460
- this.loading = true
403
+ },
404
+ newItem() {
405
+ this.title = this.$t('new', 'renusify')
406
+ this.url = this.link
407
+ const items = {}
408
+ this.table.headers.map((item) => {
409
+ if (item.option.formInput !== false) {
410
+ if (item.option.type === 'boolean') {
411
+ items[item.value] = false
412
+ } else {
413
+ items[item.value] = null
414
+ }
415
+ }
416
+ })
417
+ this.editedItem = items
418
+ this.method = 'post'
419
+ this.autoSend = false
420
+ this.showForm = true
421
+ },
422
+ editItem(item, autoSend = false, key = null) {
423
+ let sw
424
+ this.title = this.$t('edit', 'renusify')
425
+ this.url = this.link + '/' + item._id
426
+ if (key) {
427
+ sw = !item[key]
428
+ }
429
+ const items = {}
430
+ this.table.headers.map((header) => {
431
+ if (header.option.formInput !== false) {
432
+ if (header.option.type === 'boolean') {
433
+ items[header.value] = item[header.value] !== undefined ? item[header.value] : false
434
+ } else {
435
+ items[header.value] = item[header.value] !== undefined ? item[header.value] : null
436
+ }
437
+ }
438
+ })
439
+ this.editedItem = Object.assign({}, items)
461
440
 
462
- this.$axios.get(url, {params: params}).then(({data}) => {
463
- let all = []
464
- if (this.mcud) {
465
- all.push({
466
- option: {type: "mcud", sortable: false, formInput: false, priority: 10},
467
- text: "action",
468
- value: "action"
469
- })
470
- }
471
- all = all.concat(data.headers)
441
+ if (key) {
442
+ this.editedItem[key] = sw
443
+ }
444
+ this.method = 'put'
445
+ this.autoSend = autoSend
446
+ this.showForm = true
447
+ },
448
+ deleteItem(item) {
449
+ this.showConfirm = true
450
+ this.deleted = item._id
451
+ },
452
+ delete(_id) {
453
+ this.$axios.delete(this.link + '/' + _id, {headers: this.headers})
454
+ .then((res) => {
455
+ this.refresh()
456
+ })
457
+ },
458
+ accept() {
459
+ this.showConfirm = false
460
+ this.delete(this.deleted)
461
+ this.deleted = ''
462
+ this.refresh()
463
+ },
464
+ setup(url, params = null) {
465
+ this.loading = true
472
466
 
473
- this.table.headers = all.map((item) => {
474
- this.table.option[item.value] = item.option
475
- item.text = this.$t(item.value)
476
- return item
477
- })
478
- this.table.data = data.data
479
- this.table.total = data.total
480
- this.table.startTime = this.$helper.ifHas(data, false, 't')
481
- this.loading = false
482
- })
483
- }
467
+ this.$axios.get(url, {params: params, headers: this.headers}).then(({data}) => {
468
+ let all = []
469
+ if (this.mcud) {
470
+ all.push({
471
+ option: {type: "mcud", sortable: false, formInput: false, priority: 10},
472
+ text: "action",
473
+ value: "action"
474
+ })
484
475
  }
476
+ all = all.concat(data.headers)
477
+
478
+ this.table.headers = all.map((item) => {
479
+ this.table.option[item.value] = item.option
480
+ item.text = this.$t(item.value)
481
+ return item
482
+ })
483
+ this.table.data = data.data
484
+ this.table.total = data.total
485
+ this.table.startTime = this.$helper.ifHas(data, false, 't')
486
+ this.loading = false
487
+ })
485
488
  }
489
+ }
490
+ }
486
491
  </script>