@10yun/cv-mobile-ui 0.4.2 → 0.4.3

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/package.json +1 -1
  2. package/ui-uni/amap-wx/js/util.js +166 -158
  3. package/ui-uni/page-foot/page-foot.vue +38 -0
  4. package/ui-uni/page-head/page-head.vue +16 -0
  5. package/ui-uni/product.vue +52 -52
  6. package/ui-uni/u-charts/u-charts.js +743 -1092
  7. package/ui-uni/u-link/u-link.vue +59 -0
  8. package/ui-uni/uni-badge/uni-badge.vue +250 -0
  9. package/ui-uni/uni-calendar/calendar.js +546 -0
  10. package/ui-uni/uni-calendar/uni-calendar-item.vue +171 -0
  11. package/ui-uni/uni-calendar/uni-calendar.vue +504 -0
  12. package/{ui-cv/cv-calendar → ui-uni/uni-calendar}/util.js +0 -0
  13. package/ui-uni/uni-card/uni-card.vue +420 -0
  14. package/ui-uni/uni-col/uni-col.vue +2968 -0
  15. package/ui-uni/uni-collapse/uni-collapse.vue +146 -0
  16. package/ui-uni/uni-collapse-item/uni-collapse-item.vue +378 -0
  17. package/ui-uni/uni-combox/uni-combox.vue +237 -0
  18. package/ui-uni/uni-countdown/uni-countdown.vue +234 -0
  19. package/ui-uni/uni-data-checkbox/uni-data-checkbox.vue +792 -0
  20. package/{ui-cv/cv-data-indexed-list → ui-uni/uni-data-indexed-list}/clientdb.js +0 -0
  21. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list-item.vue +142 -0
  22. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list.vue +364 -0
  23. package/{ui-cv/cv-data-picker → ui-uni/uni-data-picker}/keypress.js +0 -0
  24. package/ui-uni/uni-data-picker/uni-data-picker.vue +468 -0
  25. package/{ui-cv/cv-data-pickerview/cv-data-picker.js → ui-uni/uni-data-pickerview/uni-data-picker.js} +0 -0
  26. package/ui-uni/uni-data-pickerview/uni-data-pickerview.vue +298 -0
  27. package/{ui-cv/cv-dateformat → ui-uni/uni-dateformat}/date-format.js +0 -0
  28. package/ui-uni/uni-dateformat/uni-dateformat.vue +88 -0
  29. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar-item.vue +0 -0
  30. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar.js +0 -0
  31. package/ui-uni/uni-datetime-picker/calendar.vue +747 -0
  32. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/keypress.js +0 -0
  33. package/ui-uni/uni-datetime-picker/time-picker.vue +899 -0
  34. package/ui-uni/uni-datetime-picker/uni-datetime-picker.vue +874 -0
  35. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/util.js +0 -0
  36. package/ui-uni/uni-drawer/keypress.js +45 -0
  37. package/ui-uni/uni-drawer/uni-drawer.vue +178 -0
  38. package/{ui-cv/cv-easyinput → ui-uni/uni-easyinput}/common.js +0 -0
  39. package/ui-uni/uni-easyinput/uni-easyinput.vue +438 -0
  40. package/ui-uni/uni-fab/uni-fab.vue +443 -0
  41. package/{ui-cv/cv-fab/cv-fab.vue.bak → ui-uni/uni-fab/uni-fab.vue.bak} +2 -2
  42. package/ui-uni/uni-fav/uni-fav.vue +136 -0
  43. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/choose-and-upload-file.js +0 -0
  44. package/ui-uni/uni-file-picker/uni-file-picker.vue +614 -0
  45. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-file.vue +0 -0
  46. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-image.vue +0 -0
  47. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/utils.js +0 -0
  48. package/ui-uni/uni-forms/uni-forms.vue +467 -0
  49. package/ui-uni/uni-forms/validate.js +486 -0
  50. package/ui-uni/uni-forms-item/uni-forms-item.vue +500 -0
  51. package/{ui-cv/cv-goods-nav/cv-goods-nav.vue → ui-uni/uni-goods-nav/uni-goods-nav.vue} +1 -1
  52. package/ui-uni/uni-grid/uni-grid.vue +141 -0
  53. package/ui-uni/uni-grid-item/uni-grid-item.vue +123 -0
  54. package/ui-uni/uni-group/uni-group.vue +123 -0
  55. package/ui-uni/uni-icons/icons.js +132 -0
  56. package/ui-uni/uni-icons/uni-icons.vue +72 -0
  57. package/{ui-cv/cv-icon2 → ui-uni/uni-icons}/uni.ttf +0 -0
  58. package/ui-uni/uni-indexed-list/uni-indexed-list-item.vue +142 -0
  59. package/ui-uni/uni-indexed-list/uni-indexed-list.vue +357 -0
  60. package/ui-uni/uni-link/uni-link.vue +117 -0
  61. package/ui-uni/uni-list/uni-list.vue +107 -0
  62. package/ui-uni/uni-list/uni-refresh.vue +65 -0
  63. package/{ui-cv/cv-list → ui-uni/uni-list}/uni-refresh.wxs +0 -0
  64. package/ui-uni/uni-list-ad/uni-list-ad.vue +106 -0
  65. package/{ui-cv/cv-list-chat/cv-list-chat.scss → ui-uni/uni-list-chat/uni-list-chat.scss} +0 -0
  66. package/{ui-cv/cv-list-chat/cv-list-chat.vue → ui-uni/uni-list-chat/uni-list-chat.vue} +0 -0
  67. package/ui-uni/uni-list-item/uni-list-item.vue +428 -0
  68. package/ui-uni/uni-load-more/uni-load-more.vue +366 -0
  69. package/ui-uni/uni-nav-bar/uni-nav-bar.vue +244 -0
  70. package/{ui-cv/cv-nav-bar/cv-status-bar.vue → ui-uni/uni-nav-bar/uni-status-bar.vue} +0 -0
  71. package/ui-uni/uni-notice-bar/uni-notice-bar.vue +394 -0
  72. package/ui-uni/uni-number-box/uni-number-box.vue +224 -0
  73. package/ui-uni/uni-pagination/uni-pagination.vue +376 -0
  74. package/{ui-cv/cv-popup → ui-uni/uni-popup}/keypress.js +0 -0
  75. package/{ui-cv/cv-popup → ui-uni/uni-popup}/popup.js +0 -0
  76. package/ui-uni/uni-popup/uni-popup.vue +412 -0
  77. package/{ui-cv/cv-popup-dialog → ui-uni/uni-popup-dialog}/keypress.js +0 -0
  78. package/{ui-cv/cv-popup-dialog/cv-popup-dialog.vue → ui-uni/uni-popup-dialog/uni-popup-dialog.vue} +0 -0
  79. package/ui-uni/uni-popup-message/uni-popup-message.vue +143 -0
  80. package/{ui-cv/cv-popup-share/cv-popup-share.vue → ui-uni/uni-popup-share/uni-popup-share.vue} +0 -0
  81. package/ui-uni/uni-rate/uni-rate.vue +357 -0
  82. package/ui-uni/uni-row/uni-row.vue +155 -0
  83. package/ui-uni/uni-search-bar/uni-search-bar.vue +262 -0
  84. package/{ui-cv/cv-section/cv-section.vue → ui-uni/uni-section/uni-section.vue} +0 -0
  85. package/{ui-cv/cv-segmented-control/cv-segmented-control.vue → ui-uni/uni-segmented-control/uni-segmented-control.vue} +0 -0
  86. package/{ui-cv/cv-status-bar/cv-status-bar.vue → ui-uni/uni-status-bar/uni-status-bar.vue} +0 -0
  87. package/ui-uni/uni-steps/uni-steps.vue +250 -0
  88. package/{ui-cv/cv-swipe-action/cv-swipe-action.vue → ui-uni/uni-swipe-action/uni-swipe-action.vue} +0 -0
  89. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/bindingx.js +0 -0
  90. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/index.wxs +0 -0
  91. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/isPC.js +0 -0
  92. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpalipay.js +0 -0
  93. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpother.js +0 -0
  94. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpwxs.js +0 -0
  95. package/{ui-cv/cv-swipe-action-item/cv-swipe-action-item.vue → ui-uni/uni-swipe-action-item/uni-swipe-action-item.vue} +0 -0
  96. package/ui-uni/uni-swiper-dot/uni-swiper-dot.vue +205 -0
  97. package/ui-uni/uni-table/uni-table.vue +455 -0
  98. package/ui-uni/uni-tag/uni-tag.vue +283 -0
  99. package/ui-uni/uni-tbody/uni-tbody.vue +30 -0
  100. package/ui-uni/uni-td/uni-td.vue +88 -0
  101. package/{ui-cv/cv-test/cv-test.vue → ui-uni/uni-test/uni-test.vue} +0 -0
  102. package/{ui-cv/cv-th → ui-uni/uni-th}/filter-dropdown.vue +0 -0
  103. package/ui-uni/uni-th/uni-th.vue +259 -0
  104. package/ui-uni/uni-thead/uni-thead.vue +114 -0
  105. package/ui-uni/uni-title/uni-title.vue +171 -0
  106. package/{ui-cv/cv-tr → ui-uni/uni-tr}/table-checkbox.vue +0 -0
  107. package/ui-uni/uni-tr/uni-tr.vue +156 -0
  108. package/{ui-cv/cv-transition → ui-uni/uni-transition}/createAnimation.js +0 -0
  109. package/ui-uni/uni-transition/uni-transition.vue +287 -0
  110. package/ui-cv/cv-badge/cv-badge.vue +0 -249
  111. package/ui-cv/cv-calendar/calendar.js +0 -963
  112. package/ui-cv/cv-calendar/cv-calendar-item.vue +0 -198
  113. package/ui-cv/cv-calendar/cv-calendar.vue +0 -508
  114. package/ui-cv/cv-card/cv-card.vue +0 -427
  115. package/ui-cv/cv-col/cv-col.vue +0 -2965
  116. package/ui-cv/cv-collapse/cv-collapse.vue +0 -146
  117. package/ui-cv/cv-collapse-item/cv-collapse-item.vue +0 -395
  118. package/ui-cv/cv-combox/cv-combox.vue +0 -250
  119. package/ui-cv/cv-countdown/cv-countdown.vue +0 -245
  120. package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +0 -841
  121. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +0 -154
  122. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +0 -376
  123. package/ui-cv/cv-data-picker/cv-data-picker.vue +0 -486
  124. package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +0 -304
  125. package/ui-cv/cv-dateformat/cv-dateformat.vue +0 -86
  126. package/ui-cv/cv-datetime-picker/calendar.vue +0 -761
  127. package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +0 -958
  128. package/ui-cv/cv-datetime-picker/time-picker.vue +0 -907
  129. package/ui-cv/cv-drawer/cv-drawer.vue +0 -185
  130. package/ui-cv/cv-drawer/keypress.js +0 -45
  131. package/ui-cv/cv-easyinput/cv-easyinput.vue +0 -514
  132. package/ui-cv/cv-fab/cv-fab.vue +0 -465
  133. package/ui-cv/cv-fav/cv-fav.vue +0 -150
  134. package/ui-cv/cv-file-picker/cv-file-picker.vue +0 -619
  135. package/ui-cv/cv-form-base/cv-form-base.vue +0 -470
  136. package/ui-cv/cv-form-base/validate.js +0 -477
  137. package/ui-cv/cv-grid-group/cv-grid-group.vue +0 -148
  138. package/ui-cv/cv-grid-item/cv-grid-item.vue +0 -132
  139. package/ui-cv/cv-icon2/cv-icon2.vue +0 -78
  140. package/ui-cv/cv-icon2/icons.js +0 -132
  141. package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +0 -154
  142. package/ui-cv/cv-indexed-list/cv-indexed-list.vue +0 -371
  143. package/ui-cv/cv-link2/cv-link2.vue +0 -130
  144. package/ui-cv/cv-list/cv-list.vue +0 -107
  145. package/ui-cv/cv-list/cv-refresh.vue +0 -65
  146. package/ui-cv/cv-list-ad/cv-list-ad.vue +0 -113
  147. package/ui-cv/cv-list-item/cv-list-item.vue +0 -449
  148. package/ui-cv/cv-nav-bar/cv-nav-bar.vue +0 -256
  149. package/ui-cv/cv-notice-bar/cv-notice-bar.vue +0 -453
  150. package/ui-cv/cv-number-box/cv-number-box.vue +0 -223
  151. package/ui-cv/cv-pagination/cv-pagination.vue +0 -397
  152. package/ui-cv/cv-popup/cv-popup.vue +0 -429
  153. package/ui-cv/cv-popup-message/cv-popup-message.vue +0 -143
  154. package/ui-cv/cv-row/cv-row.vue +0 -157
  155. package/ui-cv/cv-search-bar/cv-search-bar.vue +0 -280
  156. package/ui-cv/cv-steps/cv-steps.vue +0 -293
  157. package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +0 -255
  158. package/ui-cv/cv-table/cv-table.vue +0 -460
  159. package/ui-cv/cv-tag/cv-tag.vue +0 -276
  160. package/ui-cv/cv-tbody/cv-tbody.vue +0 -28
  161. package/ui-cv/cv-td/cv-td.vue +0 -93
  162. package/ui-cv/cv-th/cv-th.vue +0 -270
  163. package/ui-cv/cv-thead/cv-thead.vue +0 -114
  164. package/ui-cv/cv-title/cv-title.vue +0 -168
  165. package/ui-cv/cv-tr/cv-tr.vue +0 -166
  166. package/ui-cv/cv-transition/cv-transition.vue +0 -279
@@ -0,0 +1,205 @@
1
+ <template>
2
+ <view class="uni-swiper__warp">
3
+ <slot />
4
+ <view v-if="mode === 'default'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='default'>
5
+ <view v-for="(item,index) in info" @click="clickItem(index)" :style="{
6
+ 'width': (index === current? dots.width*2:dots.width ) + 'px','height':dots.width/3 +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border-radius':'0px'}" :key="index" class="uni-swiper__dots-item uni-swiper__dots-bar" />
7
+ </view>
8
+ <view v-if="mode === 'dot'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='dot'>
9
+ <view v-for="(item,index) in info" @click="clickItem(index)" :style="{
10
+ 'width': dots.width + 'px','height':dots.height +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}" :key="index" class="uni-swiper__dots-item" />
11
+ </view>
12
+ <view v-if="mode === 'round'" :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box" key='round'>
13
+ <view v-for="(item,index) in info" @click="clickItem(index)" :class="[index === current&&'uni-swiper__dots-long']" :style="{
14
+ 'width':(index === current? dots.width*3:dots.width ) + 'px','height':dots.height +'px' ,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}" :key="index" class="uni-swiper__dots-item " />
15
+ </view>
16
+ <view v-if="mode === 'nav'" key='nav' :style="{'background-color':dotsStyles.backgroundColor,'bottom':'0'}" class="uni-swiper__dots-box uni-swiper__dots-nav">
17
+ <text :style="{'color':dotsStyles.color}" class="uni-swiper__dots-nav-item">{{ (current+1)+"/"+info.length +' ' +info[current][field] }}</text>
18
+ </view>
19
+ <view v-if="mode === 'indexes'" key='indexes' :style="{'bottom':dots.bottom + 'px'}" class="uni-swiper__dots-box">
20
+ <view v-for="(item,index) in info" @click="clickItem(index)" :style="{
21
+ 'width':dots.width + 'px','height':dots.height +'px' ,'color':index === current?dots.selectedColor:dots.color,'background-color':index !== current?dots.backgroundColor:dots.selectedBackgroundColor,'border':index !==current ? dots.border:dots.selectedBorder}" :key="index" class="uni-swiper__dots-item uni-swiper__dots-indexes"><text class="uni-swiper__dots-indexes-text">{{ index+1 }}</text></view>
22
+ </view>
23
+ </view>
24
+ </template>
25
+
26
+ <script>
27
+ /**
28
+ * SwiperDod 轮播图指示点
29
+ * @description 自定义轮播图指示点
30
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=284
31
+ * @property {Number} current 当前指示点索引,必须是通过 `swiper` 的 `change` 事件获取到的 `e.detail.current`
32
+ * @property {String} mode = [default|round|nav|indexes] 指示点的类型
33
+ * @value defualt 默认指示点
34
+ * @value round 圆形指示点
35
+ * @value nav 条形指示点
36
+ * @value indexes 索引指示点
37
+ * @property {String} field mode 为 nav 时,显示的内容字段(mode = nav 时必填)
38
+ * @property {String} info 轮播图的数据,通过数组长度决定指示点个数
39
+ * @property {Object} dotsStyles 指示点样式
40
+ * @event {Function} clickItem 组件触发点击事件时触发,e={currentIndex}
41
+ */
42
+
43
+ export default {
44
+ name: 'UniSwiperDot',
45
+ emits: ['clickItem'],
46
+ props: {
47
+ info: {
48
+ type: Array,
49
+ default () {
50
+ return []
51
+ }
52
+ },
53
+ current: {
54
+ type: Number,
55
+ default: 0
56
+ },
57
+ dotsStyles: {
58
+ type: Object,
59
+ default () {
60
+ return {}
61
+ }
62
+ },
63
+ // 类型 :default(默认) indexes long nav
64
+ mode: {
65
+ type: String,
66
+ default: 'default'
67
+ },
68
+ // 只在 nav 模式下生效,变量名称
69
+ field: {
70
+ type: String,
71
+ default: ''
72
+ }
73
+ },
74
+ data() {
75
+ return {
76
+ dots: {
77
+ width: 8,
78
+ height: 8,
79
+ bottom: 10,
80
+ color: '#fff',
81
+ backgroundColor: 'rgba(0, 0, 0, .3)',
82
+ border: '1px rgba(0, 0, 0, .3) solid',
83
+ selectedBackgroundColor: '#333',
84
+ selectedBorder: '1px rgba(0, 0, 0, .9) solid'
85
+ }
86
+ }
87
+ },
88
+ watch: {
89
+ dotsStyles(newVal) {
90
+ this.dots = Object.assign(this.dots, this.dotsStyles)
91
+ },
92
+ mode(newVal) {
93
+ if (newVal === 'indexes') {
94
+ this.dots.width = 20
95
+ this.dots.height = 20
96
+ } else {
97
+ this.dots.width = 8
98
+ this.dots.height = 8
99
+ }
100
+ }
101
+
102
+ },
103
+ created() {
104
+ if (this.mode === 'indexes') {
105
+ this.dots.width = 20
106
+ this.dots.height = 20
107
+ }
108
+ this.dots = Object.assign(this.dots, this.dotsStyles)
109
+ },
110
+ methods: {
111
+ clickItem(index) {
112
+ this.$emit('clickItem', index)
113
+ }
114
+ }
115
+ }
116
+ </script>
117
+
118
+ <style scoped>
119
+ .uni-swiper__warp {
120
+ /* #ifndef APP-NVUE */
121
+ display: flex;
122
+ /* #endif */
123
+ flex: 1;
124
+ flex-direction: column;
125
+ position: relative;
126
+ overflow: hidden;
127
+ }
128
+
129
+ .uni-swiper__dots-box {
130
+ position: absolute;
131
+ bottom: 10px;
132
+ left: 0;
133
+ right: 0;
134
+ /* #ifndef APP-NVUE */
135
+ display: flex;
136
+ /* #endif */
137
+ flex: 1;
138
+ flex-direction: row;
139
+ justify-content: center;
140
+ align-items: center;
141
+ }
142
+
143
+ .uni-swiper__dots-item {
144
+ width: 8px;
145
+ border-radius: 100px;
146
+ margin-left: 6px;
147
+ background-color: rgba(0, 0, 0, 0.4);
148
+ /* #ifndef APP-NVUE */
149
+ cursor: pointer;
150
+ /* #endif */
151
+ /* #ifdef H5 */
152
+ /* #endif */
153
+ }
154
+
155
+ .uni-swiper__dots-item:first-child {
156
+ margin: 0;
157
+ }
158
+
159
+ .uni-swiper__dots-default {
160
+ border-radius: 100px;
161
+ }
162
+
163
+ .uni-swiper__dots-long {
164
+ border-radius: 50px;
165
+ }
166
+
167
+ .uni-swiper__dots-bar {
168
+ border-radius: 50px;
169
+ }
170
+
171
+ .uni-swiper__dots-nav {
172
+ bottom: 0px;
173
+ height: 40px;
174
+ /* #ifndef APP-NVUE */
175
+ display: flex;
176
+ /* #endif */
177
+ flex: 1;
178
+ flex-direction: row;
179
+ justify-content: flex-start;
180
+ align-items: center;
181
+ background-color: rgba(0, 0, 0, 0.2);
182
+ }
183
+
184
+ .uni-swiper__dots-nav-item {
185
+ /* overflow: hidden;
186
+ text-overflow: ellipsis;
187
+ white-space: nowrap; */
188
+ font-size: 14px;
189
+ color: #fff;
190
+ margin: 0 15px;
191
+ }
192
+
193
+ .uni-swiper__dots-indexes {
194
+ /* #ifndef APP-NVUE */
195
+ display: flex;
196
+ /* #endif */
197
+ justify-content: center;
198
+ align-items: center;
199
+ }
200
+
201
+ .uni-swiper__dots-indexes-text {
202
+ color: #fff;
203
+ font-size: 12px;
204
+ }
205
+ </style>
@@ -0,0 +1,455 @@
1
+ <template>
2
+ <view class="uni-table-scroll" :class="{ 'table--border': border, 'border-none': !noData }">
3
+ <!-- #ifdef H5 -->
4
+ <table class="uni-table" border="0" cellpadding="0" cellspacing="0" :class="{ 'table--stripe': stripe }" :style="{ 'min-width': minWidth + 'px' }">
5
+ <slot></slot>
6
+ <view v-if="noData" class="uni-table-loading">
7
+ <view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view>
8
+ </view>
9
+ <view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }">
10
+ <div class="uni-table--loader"></div>
11
+ </view>
12
+ </table>
13
+ <!-- #endif -->
14
+ <!-- #ifndef H5 -->
15
+ <view class="uni-table" :style="{ 'min-width': minWidth + 'px' }" :class="{ 'table--stripe': stripe }">
16
+ <slot></slot>
17
+ <view v-if="noData" class="uni-table-loading">
18
+ <view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view>
19
+ </view>
20
+ <view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }">
21
+ <div class="uni-table--loader"></div>
22
+ </view>
23
+ </view>
24
+ <!-- #endif -->
25
+ </view>
26
+ </template>
27
+
28
+ <script>
29
+ /**
30
+ * Table 表格
31
+ * @description 用于展示多条结构类似的数据
32
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3270
33
+ * @property {Boolean} border 是否带有纵向边框
34
+ * @property {Boolean} stripe 是否显示斑马线
35
+ * @property {Boolean} type 是否开启多选
36
+ * @property {String} emptyText 空数据时显示的文本内容
37
+ * @property {Boolean} loading 显示加载中
38
+ * @event {Function} selection-change 开启多选时,当选择项发生变化时会触发该事件
39
+ */
40
+ export default {
41
+ name: 'uniTable',
42
+ options: {
43
+ virtualHost: true
44
+ },
45
+ emits: ['selection-change'],
46
+ props: {
47
+ data: {
48
+ type: Array,
49
+ default () {
50
+ return []
51
+ }
52
+ },
53
+ // 是否有竖线
54
+ border: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ // 是否显示斑马线
59
+ stripe: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ // 多选
64
+ type: {
65
+ type: String,
66
+ default: ''
67
+ },
68
+ // 没有更多数据
69
+ emptyText: {
70
+ type: String,
71
+ default: '没有更多数据'
72
+ },
73
+ loading: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ rowKey: {
78
+ type: String,
79
+ default: ''
80
+ }
81
+ },
82
+ data() {
83
+ return {
84
+ noData: true,
85
+ minWidth: 0,
86
+ multiTableHeads: []
87
+ }
88
+ },
89
+ watch: {
90
+ loading(val) {},
91
+ data(newVal) {
92
+ let theadChildren = this.theadChildren
93
+ let rowspan = 1
94
+ if (this.theadChildren) {
95
+ rowspan = this.theadChildren.rowspan
96
+ }
97
+
98
+ // this.trChildren.length - rowspan
99
+ this.noData = false
100
+ // this.noData = newVal.length === 0
101
+ }
102
+ },
103
+ created() {
104
+ // 定义tr的实例数组
105
+ this.trChildren = []
106
+ this.thChildren = []
107
+ this.theadChildren = null
108
+ this.backData = []
109
+ this.backIndexData = []
110
+ },
111
+
112
+ methods: {
113
+ isNodata() {
114
+ let theadChildren = this.theadChildren
115
+ let rowspan = 1
116
+ if (this.theadChildren) {
117
+ rowspan = this.theadChildren.rowspan
118
+ }
119
+ this.noData = this.trChildren.length - rowspan <= 0
120
+ },
121
+ /**
122
+ * 选中所有
123
+ */
124
+ selectionAll() {
125
+ let startIndex = 1
126
+ let theadChildren = this.theadChildren
127
+ if (!this.theadChildren) {
128
+ theadChildren = this.trChildren[0]
129
+ } else {
130
+ startIndex = theadChildren.rowspan - 1
131
+ }
132
+ let isHaveData = this.data && this.data.length.length > 0
133
+ theadChildren.checked = true
134
+ theadChildren.indeterminate = false
135
+ this.trChildren.forEach((item, index) => {
136
+ if (!item.disabled) {
137
+ item.checked = true
138
+ if (isHaveData && item.keyValue) {
139
+ const row = this.data.find(v => v[this.rowKey] === item.keyValue)
140
+ if (!this.backData.find(v => v[this.rowKey] === row[this.rowKey])) {
141
+ this.backData.push(row)
142
+ }
143
+ }
144
+ if (index > (startIndex - 1) && this.backIndexData.indexOf(index - startIndex) === -1) {
145
+ this.backIndexData.push(index - startIndex)
146
+ }
147
+ }
148
+ })
149
+ // this.backData = JSON.parse(JSON.stringify(this.data))
150
+ this.$emit('selection-change', {
151
+ detail: {
152
+ value: this.backData,
153
+ index: this.backIndexData
154
+ }
155
+ })
156
+ },
157
+ /**
158
+ * 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
159
+ */
160
+ toggleRowSelection(row, selected) {
161
+ // if (!this.theadChildren) return
162
+ row = [].concat(row)
163
+
164
+ this.trChildren.forEach((item, index) => {
165
+ // if (item.keyValue) {
166
+
167
+ const select = row.findIndex(v => {
168
+ //
169
+ if (typeof v === 'number') {
170
+ return v === index - 1
171
+ } else {
172
+ return v[this.rowKey] === item.keyValue
173
+ }
174
+ })
175
+ let ischeck = item.checked
176
+ if (select !== -1) {
177
+ if (typeof selected === 'boolean') {
178
+ item.checked = selected
179
+ } else {
180
+ item.checked = !item.checked
181
+ }
182
+ if (ischeck !== item.checked) {
183
+ this.check(item.rowData || item, item.checked, item.rowData ? item.keyValue : null, true)
184
+ }
185
+ }
186
+ // }
187
+ })
188
+ this.$emit('selection-change', {
189
+ detail: {
190
+ value: this.backData,
191
+ index: this.backIndexData
192
+ }
193
+ })
194
+ },
195
+
196
+ /**
197
+ * 用于多选表格,清空用户的选择
198
+ */
199
+ clearSelection() {
200
+ let theadChildren = this.theadChildren
201
+ if (!this.theadChildren) {
202
+ theadChildren = this.trChildren[0]
203
+ }
204
+ // if (!this.theadChildren) return
205
+ theadChildren.checked = false
206
+ theadChildren.indeterminate = false
207
+ this.trChildren.forEach(item => {
208
+ // if (item.keyValue) {
209
+ item.checked = false
210
+ // }
211
+ })
212
+ this.backData = []
213
+ this.backIndexData = []
214
+ this.$emit('selection-change', {
215
+ detail: {
216
+ value: [],
217
+ index: []
218
+ }
219
+ })
220
+ },
221
+ /**
222
+ * 用于多选表格,切换所有行的选中状态
223
+ */
224
+ toggleAllSelection() {
225
+ let list = []
226
+ let startIndex = 1
227
+ let theadChildren = this.theadChildren
228
+ if (!this.theadChildren) {
229
+ theadChildren = this.trChildren[0]
230
+ } else {
231
+ startIndex = theadChildren.rowspan - 1
232
+ }
233
+ this.trChildren.forEach((item, index) => {
234
+ if (!item.disabled) {
235
+ if (index > (startIndex - 1)) {
236
+ list.push(index - startIndex)
237
+ }
238
+ }
239
+ })
240
+ this.toggleRowSelection(list)
241
+ },
242
+
243
+ /**
244
+ * 选中\取消选中
245
+ * @param {Object} child
246
+ * @param {Object} check
247
+ * @param {Object} rowValue
248
+ */
249
+ check(child, check, keyValue, emit) {
250
+ let theadChildren = this.theadChildren
251
+ if (!this.theadChildren) {
252
+ theadChildren = this.trChildren[0]
253
+ }
254
+
255
+
256
+
257
+ let childDomIndex = this.trChildren.findIndex((item, index) => child === item)
258
+ if (childDomIndex < 0) {
259
+ childDomIndex = this.data.findIndex(v => v[this.rowKey] === keyValue) + 1
260
+ }
261
+ const dataLen = this.trChildren.filter(v => !v.disabled && v.keyValue).length
262
+ if (childDomIndex === 0) {
263
+ check ? this.selectionAll() : this.clearSelection()
264
+ return
265
+ }
266
+
267
+ if (check) {
268
+ if (keyValue) {
269
+ this.backData.push(child)
270
+ }
271
+ this.backIndexData.push(childDomIndex - 1)
272
+ } else {
273
+ const index = this.backData.findIndex(v => v[this.rowKey] === keyValue)
274
+ const idx = this.backIndexData.findIndex(item => item === childDomIndex - 1)
275
+ if (keyValue) {
276
+ this.backData.splice(index, 1)
277
+ }
278
+ this.backIndexData.splice(idx, 1)
279
+ }
280
+
281
+ const domCheckAll = this.trChildren.find((item, index) => index > 0 && !item.checked && !item.disabled)
282
+ if (!domCheckAll) {
283
+ theadChildren.indeterminate = false
284
+ theadChildren.checked = true
285
+ } else {
286
+ theadChildren.indeterminate = true
287
+ theadChildren.checked = false
288
+ }
289
+
290
+ if (this.backIndexData.length === 0) {
291
+ theadChildren.indeterminate = false
292
+ }
293
+
294
+ if (!emit) {
295
+ this.$emit('selection-change', {
296
+ detail: {
297
+ value: this.backData,
298
+ index: this.backIndexData
299
+ }
300
+ })
301
+ }
302
+ }
303
+ }
304
+ }
305
+ </script>
306
+
307
+ <style scoped>
308
+ @charset "UTF-8";
309
+
310
+ .uni-table-scroll {
311
+ width: 100%;
312
+ /* #ifndef APP-NVUE */
313
+ overflow-x: auto;
314
+ /* #endif */
315
+ }
316
+
317
+ .uni-table {
318
+ position: relative;
319
+ width: 100%;
320
+ border-radius: 5px;
321
+ background-color: #fff;
322
+ /* #ifndef APP-NVUE */
323
+ box-sizing: border-box;
324
+ display: table;
325
+ overflow-x: auto;
326
+ /* #endif */
327
+ }
328
+
329
+ .uni-table ::v-deep .uni-table-tr:nth-child(n+2):hover {
330
+ background-color: #f5f7fa;
331
+ }
332
+
333
+ .uni-table ::v-deep .uni-table-thead .uni-table-tr:hover {
334
+ background-color: #fafafa;
335
+ }
336
+
337
+ .table--border {
338
+ border: 1px #ebeef5 solid;
339
+ border-right: none;
340
+ }
341
+
342
+ .border-none {
343
+ /* #ifndef APP-NVUE */
344
+ border-bottom: none;
345
+ /* #endif */
346
+ }
347
+
348
+ .table--stripe {
349
+ /* #ifndef APP-NVUE */
350
+ /* #endif */
351
+ }
352
+
353
+ .table--stripe ::v-deep .uni-table-tr:nth-child(2n+3) {
354
+ background-color: #fafafa;
355
+ }
356
+
357
+ /* 表格加载、无数据样式 */
358
+ .uni-table-loading {
359
+ position: relative;
360
+ /* #ifndef APP-NVUE */
361
+ display: table-row;
362
+ /* #endif */
363
+ height: 50px;
364
+ line-height: 50px;
365
+ overflow: hidden;
366
+ box-sizing: border-box;
367
+ }
368
+
369
+ .empty-border {
370
+ border-right: 1px #ebeef5 solid;
371
+ }
372
+
373
+ .uni-table-text {
374
+ position: absolute;
375
+ right: 0;
376
+ left: 0;
377
+ text-align: center;
378
+ font-size: 14px;
379
+ color: #999;
380
+ }
381
+
382
+ .uni-table-mask {
383
+ position: absolute;
384
+ top: 0;
385
+ bottom: 0;
386
+ left: 0;
387
+ right: 0;
388
+ background-color: rgba(255, 255, 255, 0.8);
389
+ z-index: 99;
390
+ /* #ifndef APP-NVUE */
391
+ display: flex;
392
+ margin: auto;
393
+ transition: all 0.5s;
394
+ /* #endif */
395
+ justify-content: center;
396
+ align-items: center;
397
+ }
398
+
399
+ .uni-table--loader {
400
+ width: 30px;
401
+ height: 30px;
402
+ border: 2px solid #aaa;
403
+ border-radius: 50%;
404
+ /* #ifndef APP-NVUE */
405
+ animation: 2s uni-table--loader linear infinite;
406
+ /* #endif */
407
+ position: relative;
408
+ }
409
+
410
+ @keyframes uni-table--loader {
411
+ 0% {
412
+ transform: rotate(360deg);
413
+ }
414
+
415
+ 10% {
416
+ border-left-color: transparent;
417
+ }
418
+
419
+ 20% {
420
+ border-bottom-color: transparent;
421
+ }
422
+
423
+ 30% {
424
+ border-right-color: transparent;
425
+ }
426
+
427
+ 40% {
428
+ border-top-color: transparent;
429
+ }
430
+
431
+ 50% {
432
+ transform: rotate(0deg);
433
+ }
434
+
435
+ 60% {
436
+ border-top-color: transparent;
437
+ }
438
+
439
+ 70% {
440
+ border-left-color: transparent;
441
+ }
442
+
443
+ 80% {
444
+ border-bottom-color: transparent;
445
+ }
446
+
447
+ 90% {
448
+ border-right-color: transparent;
449
+ }
450
+
451
+ 100% {
452
+ transform: rotate(-360deg);
453
+ }
454
+ }
455
+ </style>