renusify 1.1.3 → 1.1.5

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