@kengic/uni 0.5.1 → 0.5.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,511 +1,518 @@
1
1
  <template>
2
- <view class="uni-filter-dropdown">
3
- <view class="dropdown-btn" @click="onDropdown">
4
- <view class="icon-select" :class="{active: canReset}" v-if="isSelect || isRange"></view>
5
- <view class="icon-search" :class="{active: canReset}" v-if="isSearch">
6
- <view class="icon-search-0"></view>
7
- <view class="icon-search-1"></view>
8
- </view>
9
- <view class="icon-calendar" :class="{active: canReset}" v-if="isDate">
10
- <view class="icon-calendar-0"></view>
11
- <view class="icon-calendar-1"></view>
12
- </view>
13
- </view>
14
- <view class="uni-dropdown-cover" v-if="isOpened" @click="handleClose"></view>
15
- <view class="dropdown-popup dropdown-popup-right" v-if="isOpened" @click.stop>
16
- <!-- select-->
17
- <view v-if="isSelect" class="list">
18
- <label class="flex-r a-i-c list-item" v-for="(item,index) in dataList" :key="index"
19
- @click="onItemClick($event, index)">
20
- <check-box class="check" :checked="item.checked" />
21
- <view class="checklist-content">
22
- <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text>
23
- </view>
24
- </label>
25
- </view>
26
- <view v-if="isSelect" class="flex-r opera-area">
27
- <view class="flex-f btn btn-default" :class="{disable: !canReset}" @click="handleSelectReset">
28
- {{resource.reset}}</view>
29
- <view class="flex-f btn btn-submit" @click="handleSelectSubmit">{{resource.submit}}</view>
30
- </view>
31
- <!-- search -->
32
- <view v-if="isSearch" class="search-area">
33
- <input class="search-input" v-model="filterValue" />
34
- </view>
35
- <view v-if="isSearch" class="flex-r opera-area">
36
- <view class="flex-f btn btn-submit" @click="handleSearchSubmit">{{resource.search}}</view>
37
- <view class="flex-f btn btn-default" :class="{disable: !canReset}" @click="handleSearchReset">
38
- {{resource.reset}}</view>
39
- </view>
40
- <!-- range -->
41
- <view v-if="isRange">
42
- <view class="input-label">{{resource.gt}}</view>
43
- <input class="input" v-model="gtValue" />
44
- <view class="input-label">{{resource.lt}}</view>
45
- <input class="input" v-model="ltValue" />
46
- </view>
47
- <view v-if="isRange" class="flex-r opera-area">
48
- <view class="flex-f btn btn-default" :class="{disable: !canReset}" @click="handleRangeReset">
49
- {{resource.reset}}</view>
50
- <view class="flex-f btn btn-submit" @click="handleRangeSubmit">{{resource.submit}}</view>
51
- </view>
52
- <!-- date -->
53
- <view v-if="isDate">
54
- <uni-datetime-picker ref="datetimepicker" :value="dateRange" type="datetimerange" return-type="timestamp" @change="datetimechange" @maskClick="timepickerclose">
55
- <view></view>
56
- </uni-datetime-picker>
57
- </view>
58
- </view>
59
- </view>
2
+ <view class="uni-filter-dropdown">
3
+ <view class="dropdown-btn" @click="onDropdown">
4
+ <view class="icon-select" :class="{ active: canReset }" v-if="isSelect || isRange"></view>
5
+ <view class="icon-search" :class="{ active: canReset }" v-if="isSearch">
6
+ <view class="icon-search-0"></view>
7
+ <view class="icon-search-1"></view>
8
+ </view>
9
+ <view class="icon-calendar" :class="{ active: canReset }" v-if="isDate">
10
+ <view class="icon-calendar-0"></view>
11
+ <view class="icon-calendar-1"></view>
12
+ </view>
13
+ </view>
14
+ <view class="uni-dropdown-cover" v-if="isOpened" @click="handleClose"></view>
15
+ <view class="dropdown-popup dropdown-popup-right" v-if="isOpened" @click.stop>
16
+ <!-- select-->
17
+ <view v-if="isSelect" class="list">
18
+ <label class="flex-r a-i-c list-item" v-for="(item, index) in dataList" :key="index" @click="onItemClick($event, index)">
19
+ <check-box class="check" :checked="item.checked" />
20
+ <view class="checklist-content">
21
+ <text class="checklist-text" :style="item.styleIconText">{{ item[map.text] }}</text>
22
+ </view>
23
+ </label>
24
+ </view>
25
+ <view v-if="isSelect" class="flex-r opera-area">
26
+ <view class="flex-f btn btn-default" :class="{ disable: !canReset }" @click="handleSelectReset"> {{ resource.reset }}</view>
27
+ <view class="flex-f btn btn-submit" @click="handleSelectSubmit">{{ resource.submit }}</view>
28
+ </view>
29
+ <!-- search -->
30
+ <view v-if="isSearch" class="search-area">
31
+ <input class="search-input" v-model="filterValue" />
32
+ </view>
33
+ <view v-if="isSearch" class="flex-r opera-area">
34
+ <view class="flex-f btn btn-submit" @click="handleSearchSubmit">{{ resource.search }}</view>
35
+ <view class="flex-f btn btn-default" :class="{ disable: !canReset }" @click="handleSearchReset"> {{ resource.reset }}</view>
36
+ </view>
37
+ <!-- range -->
38
+ <view v-if="isRange">
39
+ <view class="input-label">{{ resource.gt }}</view>
40
+ <input class="input" v-model="gtValue" />
41
+ <view class="input-label">{{ resource.lt }}</view>
42
+ <input class="input" v-model="ltValue" />
43
+ </view>
44
+ <view v-if="isRange" class="flex-r opera-area">
45
+ <view class="flex-f btn btn-default" :class="{ disable: !canReset }" @click="handleRangeReset"> {{ resource.reset }}</view>
46
+ <view class="flex-f btn btn-submit" @click="handleRangeSubmit">{{ resource.submit }}</view>
47
+ </view>
48
+ <!-- date -->
49
+ <view v-if="isDate">
50
+ <uni-datetime-picker
51
+ ref="datetimepicker"
52
+ :value="dateRange"
53
+ type="datetimerange"
54
+ return-type="timestamp"
55
+ @change="datetimechange"
56
+ @maskClick="timepickerclose"
57
+ >
58
+ <view></view>
59
+ </uni-datetime-picker>
60
+ </view>
61
+ </view>
62
+ </view>
60
63
  </template>
61
64
 
62
65
  <script>
63
- import checkBox from '../uni-tr/table-checkbox.vue'
64
-
65
- const resource = {
66
- "reset": "重置",
67
- "search": "搜索",
68
- "submit": "确定",
69
- "filter": "筛选",
70
- "gt": "大于等于",
71
- "lt": "小于等于",
72
- "date": "日期范围"
73
- }
74
-
75
- const DropdownType = {
76
- Select: "select",
77
- Search: "search",
78
- Range: "range",
79
- Date: "date",
80
- Timestamp: "timestamp"
81
- }
82
-
83
- export default {
84
- name: 'FilterDropdown',
85
- emits:['change'],
86
- components: {
87
- checkBox
88
- },
89
- options: {
90
- virtualHost: true
91
- },
92
- props: {
93
- filterType: {
94
- type: String,
95
- default: DropdownType.Select
96
- },
97
- filterData: {
98
- type: Array,
99
- default () {
100
- return []
101
- }
102
- },
103
- mode: {
104
- type: String,
105
- default: 'default'
106
- },
107
- map: {
108
- type: Object,
109
- default () {
110
- return {
111
- text: 'text',
112
- value: 'value'
113
- }
114
- }
115
- },
116
- filterDefaultValue: {
117
- type: [Array,String],
118
- default () {
119
- return ""
120
- }
121
- }
122
- },
123
- computed: {
124
- canReset() {
125
- if (this.isSearch) {
126
- return this.filterValue.length > 0
127
- }
128
- if (this.isSelect) {
129
- return this.checkedValues.length > 0
130
- }
131
- if (this.isRange) {
132
- return (this.gtValue.length > 0 && this.ltValue.length > 0)
133
- }
134
- if (this.isDate) {
135
- return this.dateSelect.length > 0
136
- }
137
- return false
138
- },
139
- isSelect() {
140
- return this.filterType === DropdownType.Select
141
- },
142
- isSearch() {
143
- return this.filterType === DropdownType.Search
144
- },
145
- isRange() {
146
- return this.filterType === DropdownType.Range
147
- },
148
- isDate() {
149
- return (this.filterType === DropdownType.Date || this.filterType === DropdownType.Timestamp)
150
- }
151
- },
152
- watch: {
153
- filterData(newVal) {
154
- this._copyFilters()
155
- },
156
- indeterminate(newVal) {
157
- this.isIndeterminate = newVal
158
- }
159
- },
160
- data() {
161
- return {
162
- resource,
163
- enabled: true,
164
- isOpened: false,
165
- dataList: [],
166
- filterValue: this.filterDefaultValue,
167
- checkedValues: [],
168
- gtValue: '',
169
- ltValue: '',
170
- dateRange: [],
171
- dateSelect: []
172
- };
173
- },
174
- created() {
175
- this._copyFilters()
176
- },
177
- methods: {
178
- _copyFilters() {
179
- let dl = JSON.parse(JSON.stringify(this.filterData))
180
- for (let i = 0; i < dl.length; i++) {
181
- if (dl[i].checked === undefined) {
182
- dl[i].checked = false
183
- }
184
- }
185
- this.dataList = dl
186
- },
187
- openPopup() {
188
- this.isOpened = true
189
- if (this.isDate) {
190
- this.$nextTick(() => {
191
- if (!this.dateRange.length) {
192
- this.resetDate()
193
- }
194
- this.$refs.datetimepicker.show()
195
- })
196
- }
197
- },
198
- closePopup() {
199
- this.isOpened = false
200
- },
201
- handleClose(e) {
202
- this.closePopup()
203
- },
204
- resetDate() {
205
- let date = new Date()
206
- let dateText = date.toISOString().split('T')[0]
207
- this.dateRange = [dateText + ' 0:00:00', dateText + ' 23:59:59']
208
- },
209
- onDropdown(e) {
210
- this.openPopup()
211
- },
212
- onItemClick(e, index) {
213
- let items = this.dataList
214
- let listItem = items[index]
215
- if (listItem.checked === undefined) {
216
- items[index].checked = true
217
- } else {
218
- items[index].checked = !listItem.checked
219
- }
220
-
221
- let checkvalues = []
222
- for (let i = 0; i < items.length; i++) {
223
- const item = items[i]
224
- if (item.checked) {
225
- checkvalues.push(item.value)
226
- }
227
- }
228
- this.checkedValues = checkvalues
229
- },
230
- datetimechange(e) {
231
- this.closePopup()
232
- this.dateRange = e
233
- this.dateSelect = e
234
- this.$emit('change', {
235
- filterType: this.filterType,
236
- filter: e
237
- })
238
- },
239
- timepickerclose(e) {
240
- this.closePopup()
241
- },
242
- handleSelectSubmit() {
243
- this.closePopup()
244
- this.$emit('change', {
245
- filterType: this.filterType,
246
- filter: this.checkedValues
247
- })
248
- },
249
- handleSelectReset() {
250
- if (!this.canReset) {
251
- return;
252
- }
253
- var items = this.dataList
254
- for (let i = 0; i < items.length; i++) {
255
- let item = items[i]
256
- this.$set(item, 'checked', false)
257
- }
258
- this.checkedValues = []
259
- this.handleSelectSubmit()
260
- },
261
- handleSearchSubmit() {
262
- this.closePopup()
263
- this.$emit('change', {
264
- filterType: this.filterType,
265
- filter: this.filterValue
266
- })
267
- },
268
- handleSearchReset() {
269
- if (!this.canReset) {
270
- return;
271
- }
272
- this.filterValue = ''
273
- this.handleSearchSubmit()
274
- },
275
- handleRangeSubmit(isReset) {
276
- this.closePopup()
277
- this.$emit('change', {
278
- filterType: this.filterType,
279
- filter: isReset === true ? [] : [parseInt(this.gtValue), parseInt(this.ltValue)]
280
- })
281
- },
282
- handleRangeReset() {
283
- if (!this.canReset) {
284
- return;
285
- }
286
- this.gtValue = ''
287
- this.ltValue = ''
288
- this.handleRangeSubmit(true)
289
- }
290
- }
291
- }
66
+ import checkBox from '../uni-tr/table-checkbox.vue';
67
+
68
+ const resource = {
69
+ reset: '重置',
70
+ search: '搜索',
71
+ submit: '确定',
72
+ filter: '筛选',
73
+ gt: '大于等于',
74
+ lt: '小于等于',
75
+ date: '日期范围',
76
+ };
77
+
78
+ const DropdownType = {
79
+ Select: 'select',
80
+ Search: 'search',
81
+ Range: 'range',
82
+ Date: 'date',
83
+ Timestamp: 'timestamp',
84
+ };
85
+
86
+ export default {
87
+ name: 'FilterDropdown',
88
+ emits: ['change'],
89
+ components: {
90
+ checkBox,
91
+ },
92
+ options: {
93
+ virtualHost: true,
94
+ },
95
+ props: {
96
+ filterType: {
97
+ type: String,
98
+ default: DropdownType.Select,
99
+ },
100
+ filterData: {
101
+ type: Array,
102
+ default() {
103
+ return [];
104
+ },
105
+ },
106
+ mode: {
107
+ type: String,
108
+ default: 'default',
109
+ },
110
+ map: {
111
+ type: Object,
112
+ default() {
113
+ return {
114
+ text: 'text',
115
+ value: 'value',
116
+ };
117
+ },
118
+ },
119
+ filterDefaultValue: {
120
+ type: [Array, String],
121
+ default() {
122
+ return '';
123
+ },
124
+ },
125
+ },
126
+ computed: {
127
+ canReset() {
128
+ if (this.isSearch) {
129
+ return this.filterValue.length > 0;
130
+ }
131
+ if (this.isSelect) {
132
+ return this.checkedValues.length > 0;
133
+ }
134
+ if (this.isRange) {
135
+ return this.gtValue.length > 0 && this.ltValue.length > 0;
136
+ }
137
+ if (this.isDate) {
138
+ return this.dateSelect.length > 0;
139
+ }
140
+ return false;
141
+ },
142
+ isSelect() {
143
+ return this.filterType === DropdownType.Select;
144
+ },
145
+ isSearch() {
146
+ return this.filterType === DropdownType.Search;
147
+ },
148
+ isRange() {
149
+ return this.filterType === DropdownType.Range;
150
+ },
151
+ isDate() {
152
+ return this.filterType === DropdownType.Date || this.filterType === DropdownType.Timestamp;
153
+ },
154
+ },
155
+ watch: {
156
+ filterData(newVal) {
157
+ this._copyFilters();
158
+ },
159
+ indeterminate(newVal) {
160
+ this.isIndeterminate = newVal;
161
+ },
162
+ },
163
+ data() {
164
+ return {
165
+ resource,
166
+ enabled: true,
167
+ isOpened: false,
168
+ dataList: [],
169
+ filterValue: this.filterDefaultValue,
170
+ checkedValues: [],
171
+ gtValue: '',
172
+ ltValue: '',
173
+ dateRange: [],
174
+ dateSelect: [],
175
+ };
176
+ },
177
+ created() {
178
+ this._copyFilters();
179
+ },
180
+ methods: {
181
+ _copyFilters() {
182
+ let dl = JSON.parse(JSON.stringify(this.filterData));
183
+ for (let i = 0; i < dl.length; i++) {
184
+ if (dl[i].checked === undefined) {
185
+ dl[i].checked = false;
186
+ }
187
+ }
188
+ this.dataList = dl;
189
+ },
190
+ openPopup() {
191
+ this.isOpened = true;
192
+ if (this.isDate) {
193
+ this.$nextTick(() => {
194
+ if (!this.dateRange.length) {
195
+ this.resetDate();
196
+ }
197
+ this.$refs.datetimepicker.show();
198
+ });
199
+ }
200
+ },
201
+ closePopup() {
202
+ this.isOpened = false;
203
+ },
204
+ handleClose(e) {
205
+ this.closePopup();
206
+ },
207
+ resetDate() {
208
+ let date = new Date();
209
+ let dateText = date.toISOString().split('T')[0];
210
+ this.dateRange = [dateText + ' 0:00:00', dateText + ' 23:59:59'];
211
+ },
212
+ onDropdown(e) {
213
+ this.openPopup();
214
+ },
215
+ onItemClick(e, index) {
216
+ let items = this.dataList;
217
+ let listItem = items[index];
218
+ if (listItem.checked === undefined) {
219
+ items[index].checked = true;
220
+ } else {
221
+ items[index].checked = !listItem.checked;
222
+ }
223
+
224
+ let checkvalues = [];
225
+ for (let i = 0; i < items.length; i++) {
226
+ const item = items[i];
227
+ if (item.checked) {
228
+ checkvalues.push(item.value);
229
+ }
230
+ }
231
+ this.checkedValues = checkvalues;
232
+ },
233
+ datetimechange(e) {
234
+ this.closePopup();
235
+ this.dateRange = e;
236
+ this.dateSelect = e;
237
+ this.$emit('change', {
238
+ filterType: this.filterType,
239
+ filter: e,
240
+ });
241
+ },
242
+ timepickerclose(e) {
243
+ this.closePopup();
244
+ },
245
+ handleSelectSubmit() {
246
+ this.closePopup();
247
+ this.$emit('change', {
248
+ filterType: this.filterType,
249
+ filter: this.checkedValues,
250
+ });
251
+ },
252
+ handleSelectReset() {
253
+ if (!this.canReset) {
254
+ return;
255
+ }
256
+ var items = this.dataList;
257
+ for (let i = 0; i < items.length; i++) {
258
+ let item = items[i];
259
+ this.$set(item, 'checked', false);
260
+ }
261
+ this.checkedValues = [];
262
+ this.handleSelectSubmit();
263
+ },
264
+ handleSearchSubmit() {
265
+ this.closePopup();
266
+ this.$emit('change', {
267
+ filterType: this.filterType,
268
+ filter: this.filterValue,
269
+ });
270
+ },
271
+ handleSearchReset() {
272
+ if (!this.canReset) {
273
+ return;
274
+ }
275
+ this.filterValue = '';
276
+ this.handleSearchSubmit();
277
+ },
278
+ handleRangeSubmit(isReset) {
279
+ this.closePopup();
280
+ this.$emit('change', {
281
+ filterType: this.filterType,
282
+ filter: isReset === true ? [] : [parseInt(this.gtValue), parseInt(this.ltValue)],
283
+ });
284
+ },
285
+ handleRangeReset() {
286
+ if (!this.canReset) {
287
+ return;
288
+ }
289
+ this.gtValue = '';
290
+ this.ltValue = '';
291
+ this.handleRangeSubmit(true);
292
+ },
293
+ },
294
+ };
292
295
  </script>
293
296
 
294
297
  <style lang="scss">
295
- $uni-primary: #1890ff !default;
296
-
297
- .flex-r {
298
- display: flex;
299
- flex-direction: row;
300
- }
301
-
302
- .flex-f {
303
- flex: 1;
304
- }
305
-
306
- .a-i-c {
307
- align-items: center;
308
- }
309
-
310
- .j-c-c {
311
- justify-content: center;
312
- }
313
-
314
- .icon-select {
315
- width: 14px;
316
- height: 16px;
317
- border: solid 6px transparent;
318
- border-top: solid 6px #ddd;
319
- border-bottom: none;
320
- background-color: #ddd;
321
- background-clip: content-box;
322
- box-sizing: border-box;
323
- }
324
-
325
- .icon-select.active {
326
- background-color: $uni-primary;
327
- border-top-color: $uni-primary;
328
- }
329
-
330
- .icon-search {
331
- width: 12px;
332
- height: 16px;
333
- position: relative;
334
- }
335
-
336
- .icon-search-0 {
337
- border: 2px solid #ddd;
338
- border-radius: 8px;
339
- width: 7px;
340
- height: 7px;
341
- }
342
-
343
- .icon-search-1 {
344
- position: absolute;
345
- top: 8px;
346
- right: 0;
347
- width: 1px;
348
- height: 7px;
349
- background-color: #ddd;
350
- transform: rotate(-45deg);
351
- }
352
-
353
- .icon-search.active .icon-search-0 {
354
- border-color: $uni-primary;
355
- }
356
-
357
- .icon-search.active .icon-search-1 {
358
- background-color: $uni-primary;
359
- }
360
-
361
- .icon-calendar {
362
- color: #ddd;
363
- width: 14px;
364
- height: 16px;
365
- }
366
-
367
- .icon-calendar-0 {
368
- height: 4px;
369
- margin-top: 3px;
370
- margin-bottom: 1px;
371
- background-color: #ddd;
372
- border-radius: 2px 2px 1px 1px;
373
- position: relative;
374
- }
375
- .icon-calendar-0:before, .icon-calendar-0:after {
376
- content: '';
377
- position: absolute;
378
- top: -3px;
379
- width: 4px;
380
- height: 3px;
381
- border-radius: 1px;
382
- background-color: #ddd;
383
- }
384
- .icon-calendar-0:before {
385
- left: 2px;
386
- }
387
- .icon-calendar-0:after {
388
- right: 2px;
389
- }
390
-
391
- .icon-calendar-1 {
392
- height: 9px;
393
- background-color: #ddd;
394
- border-radius: 1px 1px 2px 2px;
395
- }
396
-
397
- .icon-calendar.active {
398
- color: $uni-primary;
399
- }
400
-
401
- .icon-calendar.active .icon-calendar-0,
402
- .icon-calendar.active .icon-calendar-1,
403
- .icon-calendar.active .icon-calendar-0:before,
404
- .icon-calendar.active .icon-calendar-0:after {
405
- background-color: $uni-primary;
406
- }
407
-
408
- .uni-filter-dropdown {
409
- position: relative;
410
- font-weight: normal;
411
- }
412
-
413
- .dropdown-popup {
414
- position: absolute;
415
- top: 100%;
416
- background-color: #fff;
417
- box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d;
418
- min-width: 150px;
419
- z-index: 1000;
420
- }
421
-
422
- .dropdown-popup-left {
423
- left: 0;
424
- }
425
-
426
- .dropdown-popup-right {
427
- right: 0;
428
- }
429
-
430
- .uni-dropdown-cover {
431
- position: fixed;
432
- left: 0;
433
- top: 0;
434
- right: 0;
435
- bottom: 0;
436
- background-color: transparent;
437
- z-index: 100;
438
- }
439
-
440
- .list {
441
- margin-top: 5px;
442
- margin-bottom: 5px;
443
- }
444
-
445
- .list-item {
446
- padding: 5px 10px;
447
- text-align: left;
448
- }
449
-
450
- .list-item:hover {
451
- background-color: #f0f0f0;
452
- }
453
-
454
- .check {
455
- margin-right: 5px;
456
- }
457
-
458
- .search-area {
459
- padding: 10px;
460
- }
461
-
462
- .search-input {
463
- font-size: 12px;
464
- border: 1px solid #f0f0f0;
465
- border-radius: 3px;
466
- padding: 2px 5px;
467
- min-width: 150px;
468
- text-align: left;
469
- }
470
-
471
- .input-label {
472
- margin: 10px 10px 5px 10px;
473
- text-align: left;
474
- }
475
-
476
- .input {
477
- font-size: 12px;
478
- border: 1px solid #f0f0f0;
479
- border-radius: 3px;
480
- margin: 10px;
481
- padding: 2px 5px;
482
- min-width: 150px;
483
- text-align: left;
484
- }
485
-
486
- .opera-area {
487
- cursor: default;
488
- border-top: 1px solid #ddd;
489
- padding: 5px;
490
- }
491
-
492
- .opera-area .btn {
493
- font-size: 12px;
494
- border-radius: 3px;
495
- margin: 5px;
496
- padding: 4px 4px;
497
- }
498
-
499
- .btn-default {
500
- border: 1px solid #ddd;
501
- }
502
-
503
- .btn-default.disable {
504
- border-color: transparent;
505
- }
506
-
507
- .btn-submit {
508
- background-color: $uni-primary;
509
- color: #ffffff;
510
- }
298
+ $uni-primary: #1890ff !default;
299
+
300
+ .flex-r {
301
+ display: flex;
302
+ flex-direction: row;
303
+ }
304
+
305
+ .flex-f {
306
+ flex: 1;
307
+ }
308
+
309
+ .a-i-c {
310
+ align-items: center;
311
+ }
312
+
313
+ .j-c-c {
314
+ justify-content: center;
315
+ }
316
+
317
+ .icon-select {
318
+ width: 14px;
319
+ height: 16px;
320
+ border: solid 6px transparent;
321
+ border-top: solid 6px #ddd;
322
+ border-bottom: none;
323
+ background-color: #ddd;
324
+ background-clip: content-box;
325
+ box-sizing: border-box;
326
+ }
327
+
328
+ .icon-select.active {
329
+ background-color: $uni-primary;
330
+ border-top-color: $uni-primary;
331
+ }
332
+
333
+ .icon-search {
334
+ width: 12px;
335
+ height: 16px;
336
+ position: relative;
337
+ }
338
+
339
+ .icon-search-0 {
340
+ border: 2px solid #ddd;
341
+ border-radius: 8px;
342
+ width: 7px;
343
+ height: 7px;
344
+ }
345
+
346
+ .icon-search-1 {
347
+ position: absolute;
348
+ top: 8px;
349
+ right: 0;
350
+ width: 1px;
351
+ height: 7px;
352
+ background-color: #ddd;
353
+ transform: rotate(-45deg);
354
+ }
355
+
356
+ .icon-search.active .icon-search-0 {
357
+ border-color: $uni-primary;
358
+ }
359
+
360
+ .icon-search.active .icon-search-1 {
361
+ background-color: $uni-primary;
362
+ }
363
+
364
+ .icon-calendar {
365
+ color: #ddd;
366
+ width: 14px;
367
+ height: 16px;
368
+ }
369
+
370
+ .icon-calendar-0 {
371
+ height: 4px;
372
+ margin-top: 3px;
373
+ margin-bottom: 1px;
374
+ background-color: #ddd;
375
+ border-radius: 2px 2px 1px 1px;
376
+ position: relative;
377
+ }
378
+ .icon-calendar-0:before,
379
+ .icon-calendar-0:after {
380
+ content: '';
381
+ position: absolute;
382
+ top: -3px;
383
+ width: 4px;
384
+ height: 3px;
385
+ border-radius: 1px;
386
+ background-color: #ddd;
387
+ }
388
+ .icon-calendar-0:before {
389
+ left: 2px;
390
+ }
391
+ .icon-calendar-0:after {
392
+ right: 2px;
393
+ }
394
+
395
+ .icon-calendar-1 {
396
+ height: 9px;
397
+ background-color: #ddd;
398
+ border-radius: 1px 1px 2px 2px;
399
+ }
400
+
401
+ .icon-calendar.active {
402
+ color: $uni-primary;
403
+ }
404
+
405
+ .icon-calendar.active .icon-calendar-0,
406
+ .icon-calendar.active .icon-calendar-1,
407
+ .icon-calendar.active .icon-calendar-0:before,
408
+ .icon-calendar.active .icon-calendar-0:after {
409
+ background-color: $uni-primary;
410
+ }
411
+
412
+ .uni-filter-dropdown {
413
+ position: relative;
414
+ font-weight: normal;
415
+ }
416
+
417
+ .dropdown-popup {
418
+ position: absolute;
419
+ top: 100%;
420
+ background-color: #fff;
421
+ box-shadow:
422
+ 0 3px 6px -4px #0000001f,
423
+ 0 6px 16px #00000014,
424
+ 0 9px 28px 8px #0000000d;
425
+ min-width: 150px;
426
+ z-index: 1000;
427
+ }
428
+
429
+ .dropdown-popup-left {
430
+ left: 0;
431
+ }
432
+
433
+ .dropdown-popup-right {
434
+ right: 0;
435
+ }
436
+
437
+ .uni-dropdown-cover {
438
+ position: fixed;
439
+ left: 0;
440
+ top: 0;
441
+ right: 0;
442
+ bottom: 0;
443
+ background-color: transparent;
444
+ z-index: 100;
445
+ }
446
+
447
+ .list {
448
+ margin-top: 5px;
449
+ margin-bottom: 5px;
450
+ }
451
+
452
+ .list-item {
453
+ padding: 5px 10px;
454
+ text-align: left;
455
+ }
456
+
457
+ .list-item:hover {
458
+ background-color: #f0f0f0;
459
+ }
460
+
461
+ .check {
462
+ margin-right: 5px;
463
+ }
464
+
465
+ .search-area {
466
+ padding: 10px;
467
+ }
468
+
469
+ .search-input {
470
+ font-size: 12px;
471
+ border: 1px solid #f0f0f0;
472
+ border-radius: 3px;
473
+ padding: 2px 5px;
474
+ min-width: 150px;
475
+ text-align: left;
476
+ }
477
+
478
+ .input-label {
479
+ margin: 10px 10px 5px 10px;
480
+ text-align: left;
481
+ }
482
+
483
+ .input {
484
+ font-size: 12px;
485
+ border: 1px solid #f0f0f0;
486
+ border-radius: 3px;
487
+ margin: 10px;
488
+ padding: 2px 5px;
489
+ min-width: 150px;
490
+ text-align: left;
491
+ }
492
+
493
+ .opera-area {
494
+ cursor: default;
495
+ border-top: 1px solid #ddd;
496
+ padding: 5px;
497
+ }
498
+
499
+ .opera-area .btn {
500
+ font-size: 12px;
501
+ border-radius: 3px;
502
+ margin: 5px;
503
+ padding: 4px 4px;
504
+ }
505
+
506
+ .btn-default {
507
+ border: 1px solid #ddd;
508
+ }
509
+
510
+ .btn-default.disable {
511
+ border-color: transparent;
512
+ }
513
+
514
+ .btn-submit {
515
+ background-color: $uni-primary;
516
+ color: #ffffff;
517
+ }
511
518
  </style>