@kengic/uni 0.3.2-beta.10

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 (166) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +1 -0
  3. package/dist/kengic-uni.js +5 -0
  4. package/dist/src/consts/i18n/en.d.ts +45 -0
  5. package/dist/src/consts/i18n/index.d.ts +90 -0
  6. package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
  7. package/dist/src/consts/index.d.ts +1 -0
  8. package/dist/src/index.d.ts +2 -0
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/kg.util.d.ts +5 -0
  11. package/dist/uni-ui/index.ts +11 -0
  12. package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
  13. package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
  14. package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
  15. package/dist/uni-ui/uni-calendar/calendar.js +546 -0
  16. package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
  17. package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
  18. package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
  19. package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
  20. package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
  21. package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
  22. package/dist/uni-ui/uni-calendar/util.js +360 -0
  23. package/dist/uni-ui/uni-card/uni-card.vue +281 -0
  24. package/dist/uni-ui/uni-col/uni-col.vue +317 -0
  25. package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
  26. package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
  27. package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
  28. package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
  29. package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
  30. package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
  31. package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
  32. package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
  33. package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
  34. package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
  35. package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
  36. package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
  37. package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
  38. package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
  39. package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
  40. package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
  41. package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
  42. package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
  43. package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
  44. package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
  45. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  46. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  47. package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
  48. package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
  49. package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
  50. package/dist/uni-ui/uni-drawer/keypress.js +45 -0
  51. package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
  52. package/dist/uni-ui/uni-easyinput/common.js +56 -0
  53. package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
  54. package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
  55. package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
  56. package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
  57. package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
  58. package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
  59. package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
  60. package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
  61. package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
  62. package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
  63. package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
  64. package/dist/uni-ui/uni-file-picker/utils.js +109 -0
  65. package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
  66. package/dist/uni-ui/uni-forms/utils.js +293 -0
  67. package/dist/uni-ui/uni-forms/validate.js +486 -0
  68. package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
  69. package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
  70. package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
  71. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
  72. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
  73. package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
  74. package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
  75. package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
  76. package/dist/uni-ui/uni-group/uni-group.vue +134 -0
  77. package/dist/uni-ui/uni-icons/icons.js +1169 -0
  78. package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
  79. package/dist/uni-ui/uni-icons/uniicons.css +663 -0
  80. package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
  81. package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
  82. package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
  83. package/dist/uni-ui/uni-link/uni-link.vue +128 -0
  84. package/dist/uni-ui/uni-list/uni-list.vue +123 -0
  85. package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
  86. package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
  87. package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
  88. package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
  89. package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
  90. package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
  91. package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
  92. package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
  93. package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
  94. package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
  95. package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
  96. package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
  97. package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
  98. package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
  99. package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
  100. package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
  101. package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
  102. package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
  103. package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
  104. package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
  105. package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
  106. package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
  107. package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
  108. package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
  109. package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
  110. package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
  111. package/dist/uni-ui/uni-popup/keypress.js +45 -0
  112. package/dist/uni-ui/uni-popup/popup.js +23 -0
  113. package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
  114. package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
  115. package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
  116. package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
  117. package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
  118. package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
  119. package/dist/uni-ui/uni-row/uni-row.vue +190 -0
  120. package/dist/uni-ui/uni-scss/changelog.md +8 -0
  121. package/dist/uni-ui/uni-scss/index.scss +1 -0
  122. package/dist/uni-ui/uni-scss/package.json +82 -0
  123. package/dist/uni-ui/uni-scss/readme.md +4 -0
  124. package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
  125. package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
  126. package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
  127. package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
  128. package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
  129. package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
  130. package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
  131. package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
  132. package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
  133. package/dist/uni-ui/uni-scss/theme.scss +31 -0
  134. package/dist/uni-ui/uni-scss/variables.scss +62 -0
  135. package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
  136. package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
  137. package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
  138. package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
  139. package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
  140. package/dist/uni-ui/uni-section/uni-section.vue +167 -0
  141. package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
  142. package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
  143. package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
  144. package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
  145. package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
  146. package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
  147. package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
  148. package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
  149. package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
  150. package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
  151. package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
  152. package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
  153. package/dist/uni-ui/uni-table/uni-table.vue +455 -0
  154. package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
  155. package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
  156. package/dist/uni-ui/uni-td/uni-td.vue +90 -0
  157. package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
  158. package/dist/uni-ui/uni-th/uni-th.vue +285 -0
  159. package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
  160. package/dist/uni-ui/uni-title/uni-title.vue +171 -0
  161. package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
  162. package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
  163. package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
  164. package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
  165. package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
  166. package/package.json +90 -0
@@ -0,0 +1,821 @@
1
+ <template>
2
+ <view class="uni-data-checklist" :style="{'margin-top':isTop+'px'}">
3
+ <template v-if="!isLocal">
4
+ <view class="uni-data-loading">
5
+ <uni-load-more v-if="!mixinDatacomErrorMessage" status="loading" iconType="snow" :iconSize="18" :content-text="contentText"></uni-load-more>
6
+ <text v-else>{{mixinDatacomErrorMessage}}</text>
7
+ </view>
8
+ </template>
9
+ <template v-else>
10
+ <checkbox-group v-if="multiple" class="checklist-group" :class="{'is-list':mode==='list' || wrap}" @change="chagne">
11
+ <label class="checklist-box" :class="['is--'+mode,item.selected?'is-checked':'',(disabled || !!item.disabled)?'is-disable':'',index!==0&&mode==='list'?'is-list-border':'']"
12
+ :style="item.styleBackgroud" v-for="(item,index) in dataList" :key="index">
13
+ <checkbox class="hidden" hidden :disabled="disabled || !!item.disabled" :value="item[map.value]+''" :checked="item.selected" />
14
+ <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="checkbox__inner" :style="item.styleIcon">
15
+ <view class="checkbox__inner-icon"></view>
16
+ </view>
17
+ <view class="checklist-content" :class="{'list-content':mode === 'list' && icon ==='left'}">
18
+ <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text>
19
+ <view v-if="mode === 'list' && icon === 'right'" class="checkobx__list" :style="item.styleBackgroud"></view>
20
+ </view>
21
+ </label>
22
+ </checkbox-group>
23
+ <radio-group v-else class="checklist-group" :class="{'is-list':mode==='list','is-wrap':wrap}" @change="chagne">
24
+ <!-- -->
25
+ <label class="checklist-box" :class="['is--'+mode,item.selected?'is-checked':'',(disabled || !!item.disabled)?'is-disable':'',index!==0&&mode==='list'?'is-list-border':'']"
26
+ :style="item.styleBackgroud" v-for="(item,index) in dataList" :key="index">
27
+ <radio class="hidden" hidden :disabled="disabled || item.disabled" :value="item[map.value]+''" :checked="item.selected" />
28
+ <view v-if="(mode !=='tag' && mode !== 'list') || ( mode === 'list' && icon === 'left')" class="radio__inner"
29
+ :style="item.styleBackgroud">
30
+ <view class="radio__inner-icon" :style="item.styleIcon"></view>
31
+ </view>
32
+ <view class="checklist-content" :class="{'list-content':mode === 'list' && icon ==='left'}">
33
+ <text class="checklist-text" :style="item.styleIconText">{{item[map.text]}}</text>
34
+ <view v-if="mode === 'list' && icon === 'right'" :style="item.styleRightIcon" class="checkobx__list"></view>
35
+ </view>
36
+ </label>
37
+ </radio-group>
38
+ </template>
39
+ </view>
40
+ </template>
41
+
42
+ <script>
43
+ /**
44
+ * DataChecklist 数据选择器
45
+ * @description 通过数据渲染 checkbox 和 radio
46
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
47
+ * @property {String} mode = [default| list | button | tag] 显示模式
48
+ * @value default 默认横排模式
49
+ * @value list 列表模式
50
+ * @value button 按钮模式
51
+ * @value tag 标签模式
52
+ * @property {Boolean} multiple = [true|false] 是否多选
53
+ * @property {Array|String|Number} value 默认值
54
+ * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
55
+ * @property {Number|String} min 最小选择个数 ,multiple为true时生效
56
+ * @property {Number|String} max 最大选择个数 ,multiple为true时生效
57
+ * @property {Boolean} wrap 是否换行显示
58
+ * @property {String} icon = [left|right] list 列表模式下icon显示位置
59
+ * @property {Boolean} selectedColor 选中颜色
60
+ * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
61
+ * @property {Boolean} selectedTextColor 选中文本颜色,如不填写则自动显示
62
+ * @property {Object} map 字段映射, 默认 map={text:'text',value:'value'}
63
+ * @value left 左侧显示
64
+ * @value right 右侧显示
65
+ * @event {Function} change 选中发生变化触发
66
+ */
67
+
68
+ export default {
69
+ name: 'uniDataChecklist',
70
+ mixins: [uniCloud.mixinDatacom || {}],
71
+ emits:['input','update:modelValue','change'],
72
+ props: {
73
+ mode: {
74
+ type: String,
75
+ default: 'default'
76
+ },
77
+
78
+ multiple: {
79
+ type: Boolean,
80
+ default: false
81
+ },
82
+ value: {
83
+ type: [Array, String, Number],
84
+ default () {
85
+ return ''
86
+ }
87
+ },
88
+ // TODO vue3
89
+ modelValue: {
90
+ type: [Array, String, Number],
91
+ default() {
92
+ return '';
93
+ }
94
+ },
95
+ localdata: {
96
+ type: Array,
97
+ default () {
98
+ return []
99
+ }
100
+ },
101
+ min: {
102
+ type: [Number, String],
103
+ default: ''
104
+ },
105
+ max: {
106
+ type: [Number, String],
107
+ default: ''
108
+ },
109
+ wrap: {
110
+ type: Boolean,
111
+ default: false
112
+ },
113
+ icon: {
114
+ type: String,
115
+ default: 'left'
116
+ },
117
+ selectedColor: {
118
+ type: String,
119
+ default: ''
120
+ },
121
+ selectedTextColor: {
122
+ type: String,
123
+ default: ''
124
+ },
125
+ emptyText:{
126
+ type: String,
127
+ default: '暂无数据'
128
+ },
129
+ disabled:{
130
+ type: Boolean,
131
+ default: false
132
+ },
133
+ map:{
134
+ type: Object,
135
+ default(){
136
+ return {
137
+ text:'text',
138
+ value:'value'
139
+ }
140
+ }
141
+ }
142
+ },
143
+ watch: {
144
+ localdata: {
145
+ handler(newVal) {
146
+ this.range = newVal
147
+ this.dataList = this.getDataList(this.getSelectedValue(newVal))
148
+ },
149
+ deep: true
150
+ },
151
+ mixinDatacomResData(newVal) {
152
+ this.range = newVal
153
+ this.dataList = this.getDataList(this.getSelectedValue(newVal))
154
+ },
155
+ value(newVal) {
156
+ this.dataList = this.getDataList(newVal)
157
+ // fix by mehaotian is_reset 在 uni-forms 中定义
158
+ // if(!this.is_reset){
159
+ // this.is_reset = false
160
+ // this.formItem && this.formItem.setValue(newVal)
161
+ // }
162
+ },
163
+ modelValue(newVal) {
164
+ this.dataList = this.getDataList(newVal);
165
+ // if(!this.is_reset){
166
+ // this.is_reset = false
167
+ // this.formItem && this.formItem.setValue(newVal)
168
+ // }
169
+ }
170
+ },
171
+ data() {
172
+ return {
173
+ dataList: [],
174
+ range: [],
175
+ contentText: {
176
+ contentdown: '查看更多',
177
+ contentrefresh: '加载中',
178
+ contentnomore: '没有更多'
179
+ },
180
+ isLocal:true,
181
+ styles: {
182
+ selectedColor: '#2979ff',
183
+ selectedTextColor: '#666',
184
+ },
185
+ isTop:0
186
+ };
187
+ },
188
+ computed:{
189
+ dataValue(){
190
+ if(this.value === '')return this.modelValue
191
+ if(this.modelValue === '') return this.value
192
+ return this.value
193
+ }
194
+ },
195
+ created() {
196
+ // this.form = this.getForm('uniForms')
197
+ // this.formItem = this.getForm('uniFormsItem')
198
+ // this.formItem && this.formItem.setValue(this.value)
199
+
200
+ // if (this.formItem) {
201
+ // this.isTop = 6
202
+ // if (this.formItem.name) {
203
+ // // 如果存在name添加默认值,否则formData 中不存在这个字段不校验
204
+ // if(!this.is_reset){
205
+ // this.is_reset = false
206
+ // this.formItem.setValue(this.dataValue)
207
+ // }
208
+ // this.rename = this.formItem.name
209
+ // this.form.inputChildrens.push(this)
210
+ // }
211
+ // }
212
+
213
+ if (this.localdata && this.localdata.length !== 0) {
214
+ this.isLocal = true
215
+ this.range = this.localdata
216
+ this.dataList = this.getDataList(this.getSelectedValue(this.range))
217
+ } else {
218
+ if (this.collection) {
219
+ this.isLocal = false
220
+ this.loadData()
221
+ }
222
+ }
223
+ },
224
+ methods: {
225
+ loadData() {
226
+ this.mixinDatacomGet().then(res=>{
227
+ this.mixinDatacomResData = res.result.data
228
+ if(this.mixinDatacomResData.length === 0){
229
+ this.isLocal = false
230
+ this.mixinDatacomErrorMessage = this.emptyText
231
+ }else{
232
+ this.isLocal = true
233
+ }
234
+ }).catch(err=>{
235
+ this.mixinDatacomErrorMessage = err.message
236
+ })
237
+ },
238
+ /**
239
+ * 获取父元素实例
240
+ */
241
+ getForm(name = 'uniForms') {
242
+ let parent = this.$parent;
243
+ let parentName = parent.$options.name;
244
+ while (parentName !== name) {
245
+ parent = parent.$parent;
246
+ if (!parent) return false
247
+ parentName = parent.$options.name;
248
+ }
249
+ return parent;
250
+ },
251
+ chagne(e) {
252
+ const values = e.detail.value
253
+
254
+ let detail = {
255
+ value: [],
256
+ data: []
257
+ }
258
+
259
+ if (this.multiple) {
260
+ this.range.forEach(item => {
261
+
262
+ if (values.includes(item[this.map.value] + '')) {
263
+ detail.value.push(item[this.map.value])
264
+ detail.data.push(item)
265
+ }
266
+ })
267
+ } else {
268
+ const range = this.range.find(item => (item[this.map.value] + '') === values)
269
+ if (range) {
270
+ detail = {
271
+ value: range[this.map.value],
272
+ data: range
273
+ }
274
+ }
275
+ }
276
+ // this.formItem && this.formItem.setValue(detail.value)
277
+ // TODO 兼容 vue2
278
+ this.$emit('input', detail.value);
279
+ // // TOTO 兼容 vue3
280
+ this.$emit('update:modelValue', detail.value);
281
+ this.$emit('change', {
282
+ detail
283
+ })
284
+ if (this.multiple) {
285
+ // 如果 v-model 没有绑定 ,则走内部逻辑
286
+ // if (this.value.length === 0) {
287
+ this.dataList = this.getDataList(detail.value, true)
288
+ // }
289
+ } else {
290
+ this.dataList = this.getDataList(detail.value)
291
+ }
292
+ },
293
+
294
+ /**
295
+ * 获取渲染的新数组
296
+ * @param {Object} value 选中内容
297
+ */
298
+ getDataList(value) {
299
+ // 解除引用关系,破坏原引用关系,避免污染源数据
300
+ let dataList = JSON.parse(JSON.stringify(this.range))
301
+ let list = []
302
+ if (this.multiple) {
303
+ if (!Array.isArray(value)) {
304
+ value = []
305
+ }
306
+ }
307
+ dataList.forEach((item, index) => {
308
+ item.disabled = item.disable || item.disabled || false
309
+ if (this.multiple) {
310
+ if (value.length > 0) {
311
+ let have = value.find(val => val === item[this.map.value])
312
+ item.selected = have !== undefined
313
+ } else {
314
+ item.selected = false
315
+ }
316
+ } else {
317
+ item.selected = value === item[this.map.value]
318
+ }
319
+
320
+ list.push(item)
321
+ })
322
+ return this.setRange(list)
323
+ },
324
+ /**
325
+ * 处理最大最小值
326
+ * @param {Object} list
327
+ */
328
+ setRange(list) {
329
+ let selectList = list.filter(item => item.selected)
330
+ let min = Number(this.min) || 0
331
+ let max = Number(this.max) || ''
332
+ list.forEach((item, index) => {
333
+ if (this.multiple) {
334
+ if (selectList.length <= min) {
335
+ let have = selectList.find(val => val[this.map.value] === item[this.map.value])
336
+ if (have !== undefined) {
337
+ item.disabled = true
338
+ }
339
+ }
340
+
341
+ if (selectList.length >= max && max !== '') {
342
+ let have = selectList.find(val => val[this.map.value] === item[this.map.value])
343
+ if (have === undefined) {
344
+ item.disabled = true
345
+ }
346
+ }
347
+ }
348
+ this.setStyles(item, index)
349
+ list[index] = item
350
+ })
351
+ return list
352
+ },
353
+ /**
354
+ * 设置 class
355
+ * @param {Object} item
356
+ * @param {Object} index
357
+ */
358
+ setStyles(item, index) {
359
+ // 设置自定义样式
360
+ item.styleBackgroud = this.setStyleBackgroud(item)
361
+ item.styleIcon = this.setStyleIcon(item)
362
+ item.styleIconText = this.setStyleIconText(item)
363
+ item.styleRightIcon = this.setStyleRightIcon(item)
364
+ },
365
+
366
+ /**
367
+ * 获取选中值
368
+ * @param {Object} range
369
+ */
370
+ getSelectedValue(range) {
371
+ if (!this.multiple) return this.dataValue
372
+ let selectedArr = []
373
+ range.forEach((item) => {
374
+ if (item.selected) {
375
+ selectedArr.push(item[this.map.value])
376
+ }
377
+ })
378
+ return this.dataValue.length > 0 ? this.dataValue : selectedArr
379
+ },
380
+
381
+ /**
382
+ * 设置背景样式
383
+ */
384
+ setStyleBackgroud(item) {
385
+ let styles = {}
386
+ let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
387
+ if (this.selectedColor) {
388
+ if (this.mode !== 'list') {
389
+ styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
390
+ }
391
+ if (this.mode === 'tag') {
392
+ styles['background-color'] = item.selected? selectedColor:'#f5f5f5'
393
+ }
394
+ }
395
+ let classles = ''
396
+ for (let i in styles) {
397
+ classles += `${i}:${styles[i]};`
398
+ }
399
+ return classles
400
+ },
401
+ setStyleIcon(item) {
402
+ let styles = {}
403
+ let classles = ''
404
+ if (this.selectedColor) {
405
+ let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
406
+ styles['background-color'] = item.selected?selectedColor:'#fff'
407
+ styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
408
+
409
+ if(!item.selected && item.disabled){
410
+ styles['background-color'] = '#F2F6FC'
411
+ styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
412
+ }
413
+ }
414
+ for (let i in styles) {
415
+ classles += `${i}:${styles[i]};`
416
+ }
417
+ return classles
418
+ },
419
+ setStyleIconText(item) {
420
+ let styles = {}
421
+ let classles = ''
422
+ if (this.selectedColor) {
423
+ let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
424
+ if (this.mode === 'tag') {
425
+ styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666'
426
+ } else {
427
+ styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:selectedColor):'#666'
428
+ }
429
+ if(!item.selected && item.disabled){
430
+ styles.color = '#999'
431
+ }
432
+ }
433
+ for (let i in styles) {
434
+ classles += `${i}:${styles[i]};`
435
+ }
436
+ return classles
437
+ },
438
+ setStyleRightIcon(item) {
439
+ let styles = {}
440
+ let classles = ''
441
+ if (this.mode === 'list') {
442
+ styles['border-color'] = item.selected?this.styles.selectedColor:'#DCDFE6'
443
+ }
444
+ for (let i in styles) {
445
+ classles += `${i}:${styles[i]};`
446
+ }
447
+
448
+ return classles
449
+ }
450
+ }
451
+ }
452
+ </script>
453
+
454
+ <style lang="scss">
455
+ $uni-primary: #2979ff !default;
456
+ $border-color: #DCDFE6;
457
+ $disable:0.4;
458
+
459
+ @mixin flex {
460
+ /* #ifndef APP-NVUE */
461
+ display: flex;
462
+ /* #endif */
463
+ }
464
+
465
+ .uni-data-loading {
466
+ @include flex;
467
+ flex-direction: row;
468
+ justify-content: center;
469
+ align-items: center;
470
+ height: 36px;
471
+ padding-left: 10px;
472
+ color: #999;
473
+ }
474
+
475
+ .uni-data-checklist {
476
+ position: relative;
477
+ z-index: 0;
478
+ flex: 1;
479
+ // 多选样式
480
+ .checklist-group {
481
+ @include flex;
482
+ flex-direction: row;
483
+ flex-wrap: wrap;
484
+
485
+ &.is-list {
486
+ flex-direction: column;
487
+ }
488
+
489
+ .checklist-box {
490
+ @include flex;
491
+ flex-direction: row;
492
+ align-items: center;
493
+ position: relative;
494
+ margin: 5px 0;
495
+ margin-right: 25px;
496
+
497
+ .hidden {
498
+ position: absolute;
499
+ opacity: 0;
500
+ }
501
+
502
+ // 文字样式
503
+ .checklist-content {
504
+ @include flex;
505
+ flex: 1;
506
+ flex-direction: row;
507
+ align-items: center;
508
+ justify-content: space-between;
509
+ .checklist-text {
510
+ font-size: 14px;
511
+ color: #666;
512
+ margin-left: 5px;
513
+ line-height: 14px;
514
+ }
515
+
516
+ .checkobx__list {
517
+ border-right-width: 1px;
518
+ border-right-color: #007aff;
519
+ border-right-style: solid;
520
+ border-bottom-width:1px;
521
+ border-bottom-color: #007aff;
522
+ border-bottom-style: solid;
523
+ height: 12px;
524
+ width: 6px;
525
+ left: -5px;
526
+ transform-origin: center;
527
+ transform: rotate(45deg);
528
+ opacity: 0;
529
+ }
530
+ }
531
+
532
+ // 多选样式
533
+ .checkbox__inner {
534
+ /* #ifndef APP-NVUE */
535
+ flex-shrink: 0;
536
+ box-sizing: border-box;
537
+ /* #endif */
538
+ position: relative;
539
+ width: 16px;
540
+ height: 16px;
541
+ border: 1px solid $border-color;
542
+ border-radius: 4px;
543
+ background-color: #fff;
544
+ z-index: 1;
545
+ .checkbox__inner-icon {
546
+ position: absolute;
547
+ /* #ifdef APP-NVUE */
548
+ top: 2px;
549
+ /* #endif */
550
+ /* #ifndef APP-NVUE */
551
+ top: 1px;
552
+ /* #endif */
553
+ left: 5px;
554
+ height: 8px;
555
+ width: 4px;
556
+ border-right-width: 1px;
557
+ border-right-color: #fff;
558
+ border-right-style: solid;
559
+ border-bottom-width:1px ;
560
+ border-bottom-color: #fff;
561
+ border-bottom-style: solid;
562
+ opacity: 0;
563
+ transform-origin: center;
564
+ transform: rotate(40deg);
565
+ }
566
+ }
567
+
568
+ // 单选样式
569
+ .radio__inner {
570
+ @include flex;
571
+ /* #ifndef APP-NVUE */
572
+ flex-shrink: 0;
573
+ box-sizing: border-box;
574
+ /* #endif */
575
+ justify-content: center;
576
+ align-items: center;
577
+ position: relative;
578
+ width: 16px;
579
+ height: 16px;
580
+ border: 1px solid $border-color;
581
+ border-radius: 16px;
582
+ background-color: #fff;
583
+ z-index: 1;
584
+
585
+ .radio__inner-icon {
586
+ width: 8px;
587
+ height: 8px;
588
+ border-radius: 10px;
589
+ opacity: 0;
590
+ }
591
+ }
592
+
593
+ // 默认样式
594
+ &.is--default {
595
+
596
+ // 禁用
597
+ &.is-disable {
598
+ /* #ifdef H5 */
599
+ cursor: not-allowed;
600
+ /* #endif */
601
+ .checkbox__inner {
602
+ background-color: #F2F6FC;
603
+ border-color: $border-color;
604
+ /* #ifdef H5 */
605
+ cursor: not-allowed;
606
+ /* #endif */
607
+ }
608
+
609
+ .radio__inner {
610
+ background-color: #F2F6FC;
611
+ border-color: $border-color;
612
+ }
613
+ .checklist-text {
614
+ color: #999;
615
+ }
616
+ }
617
+
618
+ // 选中
619
+ &.is-checked {
620
+ .checkbox__inner {
621
+ border-color: $uni-primary;
622
+ background-color: $uni-primary;
623
+
624
+ .checkbox__inner-icon {
625
+ opacity: 1;
626
+ transform: rotate(45deg);
627
+ }
628
+ }
629
+ .radio__inner {
630
+ border-color: $uni-primary;
631
+ .radio__inner-icon {
632
+ opacity: 1;
633
+ background-color: $uni-primary;
634
+ }
635
+ }
636
+ .checklist-text {
637
+ color: $uni-primary;
638
+ }
639
+ // 选中禁用
640
+ &.is-disable {
641
+ .checkbox__inner {
642
+ opacity: $disable;
643
+ }
644
+
645
+ .checklist-text {
646
+ opacity: $disable;
647
+ }
648
+ .radio__inner {
649
+ opacity: $disable;
650
+ }
651
+ }
652
+ }
653
+ }
654
+
655
+ // 按钮样式
656
+ &.is--button {
657
+ margin-right: 10px;
658
+ padding: 5px 10px;
659
+ border: 1px $border-color solid;
660
+ border-radius: 3px;
661
+ transition: border-color 0.2s;
662
+
663
+ // 禁用
664
+ &.is-disable {
665
+ /* #ifdef H5 */
666
+ cursor: not-allowed;
667
+ /* #endif */
668
+ border: 1px #eee solid;
669
+ opacity: $disable;
670
+ .checkbox__inner {
671
+ background-color: #F2F6FC;
672
+ border-color: $border-color;
673
+ /* #ifdef H5 */
674
+ cursor: not-allowed;
675
+ /* #endif */
676
+ }
677
+ .radio__inner {
678
+ background-color: #F2F6FC;
679
+ border-color: $border-color;
680
+ /* #ifdef H5 */
681
+ cursor: not-allowed;
682
+ /* #endif */
683
+ }
684
+ .checklist-text {
685
+ color: #999;
686
+ }
687
+ }
688
+
689
+ &.is-checked {
690
+ border-color: $uni-primary;
691
+ .checkbox__inner {
692
+ border-color: $uni-primary;
693
+ background-color: $uni-primary;
694
+ .checkbox__inner-icon {
695
+ opacity: 1;
696
+ transform: rotate(45deg);
697
+ }
698
+ }
699
+
700
+ .radio__inner {
701
+ border-color: $uni-primary;
702
+
703
+ .radio__inner-icon {
704
+ opacity: 1;
705
+ background-color: $uni-primary;
706
+ }
707
+ }
708
+
709
+ .checklist-text {
710
+ color: $uni-primary;
711
+ }
712
+
713
+ // 选中禁用
714
+ &.is-disable {
715
+ opacity: $disable;
716
+ }
717
+ }
718
+ }
719
+
720
+ // 标签样式
721
+ &.is--tag {
722
+ margin-right: 10px;
723
+ padding: 5px 10px;
724
+ border: 1px $border-color solid;
725
+ border-radius: 3px;
726
+ background-color: #f5f5f5;
727
+
728
+ .checklist-text {
729
+ margin: 0;
730
+ color: #666;
731
+ }
732
+
733
+ // 禁用
734
+ &.is-disable {
735
+ /* #ifdef H5 */
736
+ cursor: not-allowed;
737
+ /* #endif */
738
+ opacity: $disable;
739
+ }
740
+
741
+ &.is-checked {
742
+ background-color: $uni-primary;
743
+ border-color: $uni-primary;
744
+
745
+ .checklist-text {
746
+ color: #fff;
747
+ }
748
+ }
749
+ }
750
+ // 列表样式
751
+ &.is--list {
752
+ /* #ifndef APP-NVUE */
753
+ display: flex;
754
+ /* #endif */
755
+ padding: 10px 15px;
756
+ padding-left: 0;
757
+ margin: 0;
758
+
759
+ &.is-list-border {
760
+ border-top: 1px #eee solid;
761
+ }
762
+
763
+ // 禁用
764
+ &.is-disable {
765
+ /* #ifdef H5 */
766
+ cursor: not-allowed;
767
+ /* #endif */
768
+ .checkbox__inner {
769
+ background-color: #F2F6FC;
770
+ border-color: $border-color;
771
+ /* #ifdef H5 */
772
+ cursor: not-allowed;
773
+ /* #endif */
774
+ }
775
+ .checklist-text {
776
+ color: #999;
777
+ }
778
+ }
779
+
780
+ &.is-checked {
781
+ .checkbox__inner {
782
+ border-color: $uni-primary;
783
+ background-color: $uni-primary;
784
+
785
+ .checkbox__inner-icon {
786
+ opacity: 1;
787
+ transform: rotate(45deg);
788
+ }
789
+ }
790
+ .radio__inner {
791
+ .radio__inner-icon {
792
+ opacity: 1;
793
+ }
794
+ }
795
+ .checklist-text {
796
+ color: $uni-primary;
797
+ }
798
+
799
+ .checklist-content {
800
+ .checkobx__list {
801
+ opacity: 1;
802
+ border-color: $uni-primary;
803
+ }
804
+ }
805
+
806
+ // 选中禁用
807
+ &.is-disable {
808
+ .checkbox__inner {
809
+ opacity: $disable;
810
+ }
811
+
812
+ .checklist-text {
813
+ opacity: $disable;
814
+ }
815
+ }
816
+ }
817
+ }
818
+ }
819
+ }
820
+ }
821
+ </style>