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