vdesign-ui 0.1.19 → 0.1.20

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 (193) hide show
  1. package/dist/components/actionbar/actionbar-cell/index.vue +34 -0
  2. package/dist/components/actionbar/index.js +8 -0
  3. package/dist/components/actionbar/index.vue +39 -0
  4. package/dist/components/actionbar/style.less +48 -0
  5. package/dist/components/actions-cell/actions/index.js +7 -0
  6. package/dist/components/actions-cell/actions/index.vue +76 -0
  7. package/dist/components/actions-cell/actions/style.less +112 -0
  8. package/dist/components/actions-cell/index.js +7 -0
  9. package/dist/components/actions-cell/index.vue +94 -0
  10. package/dist/components/actions-cell/style.less +39 -0
  11. package/dist/components/activityviews/index.js +8 -0
  12. package/dist/components/activityviews/index.vue +140 -0
  13. package/dist/components/activityviews/style.less +138 -0
  14. package/dist/components/badge/index.js +8 -0
  15. package/dist/components/badge/index.vue +49 -0
  16. package/dist/components/badge/style.less +66 -0
  17. package/dist/components/button/index.js +8 -0
  18. package/dist/components/button/index.vue +89 -0
  19. package/dist/components/button/style.less +563 -0
  20. package/dist/components/calendar/end.png +0 -0
  21. package/dist/components/calendar/index-element.vue +84 -0
  22. package/dist/components/calendar/index.js +8 -0
  23. package/dist/components/calendar/index.vue +52 -0
  24. package/dist/components/calendar/start.png +0 -0
  25. package/dist/components/calendar/style.less +167 -0
  26. package/dist/components/checkbox/assist.js +34 -0
  27. package/dist/components/checkbox/checkbox-group/index.js +8 -0
  28. package/dist/components/checkbox/checkbox-group/index.vue +69 -0
  29. package/dist/components/checkbox/index.js +8 -0
  30. package/dist/components/checkbox/index.vue +184 -0
  31. package/dist/components/checkbox/style.less +291 -0
  32. package/dist/components/common/state/index.vue +80 -0
  33. package/dist/components/data-list/index.js +10 -0
  34. package/dist/components/data-list/index.vue +19 -0
  35. package/dist/components/data-list/style.less +624 -0
  36. package/dist/components/datetime-picker/index.js +8 -0
  37. package/dist/components/datetime-picker/index.vue +37 -0
  38. package/dist/components/datetime-picker/style.less +24 -0
  39. package/dist/components/dialog/index.js +8 -0
  40. package/dist/components/dialog/index.vue +162 -0
  41. package/dist/components/dialog/overlay-manager.js +18 -0
  42. package/dist/components/dialog/style.less +132 -0
  43. package/dist/components/divider/index.js +8 -0
  44. package/dist/components/divider/index.vue +54 -0
  45. package/dist/components/divider/style.less +92 -0
  46. package/dist/components/dropdown/index.js +8 -0
  47. package/dist/components/dropdown/index.vue +210 -0
  48. package/dist/components/dropdown/style.less +418 -0
  49. package/dist/components/empty/404-dark.png +0 -0
  50. package/dist/components/empty/404.png +0 -0
  51. package/dist/components/empty/index.js +8 -0
  52. package/dist/components/empty/index.vue +95 -0
  53. package/dist/components/empty/network-dark.png +0 -0
  54. package/dist/components/empty/network.png +0 -0
  55. package/dist/components/empty/nodata-dark.png +0 -0
  56. package/dist/components/empty/nodata.png +0 -0
  57. package/dist/components/empty/style.less +60 -0
  58. package/dist/components/footer/index.js +7 -0
  59. package/dist/components/footer/index.vue +29 -0
  60. package/dist/components/footer/style.less +22 -0
  61. package/dist/components/footnav/footnav-item/index.js +7 -0
  62. package/dist/components/footnav/footnav-item/index.vue +75 -0
  63. package/dist/components/footnav/footnav-item/style.less +39 -0
  64. package/dist/components/footnav/index.js +7 -0
  65. package/dist/components/footnav/index.vue +97 -0
  66. package/dist/components/footnav/style.less +23 -0
  67. package/dist/components/form/index.js +7 -0
  68. package/dist/components/form/index.vue +12 -0
  69. package/dist/components/headnav/index.js +7 -0
  70. package/dist/components/headnav/index.vue +163 -0
  71. package/dist/components/headnav/style.less +245 -0
  72. package/dist/components/icon/font/iconfont.css +1050 -0
  73. package/dist/components/icon/font/iconfont.js +2 -0
  74. package/dist/components/icon/index.js +9 -0
  75. package/dist/components/icon/index.vue +46 -0
  76. package/dist/components/icon/style.less +44 -0
  77. package/dist/components/input/calcTextareaHeight.js +266 -0
  78. package/dist/components/input/index.js +8 -0
  79. package/dist/components/input/index.vue +343 -0
  80. package/dist/components/input/password/index.js +8 -0
  81. package/dist/components/input/password/index.vue +60 -0
  82. package/dist/components/input/search/index.js +8 -0
  83. package/dist/components/input/search/index.vue +66 -0
  84. package/dist/components/input/stepper/index.js +8 -0
  85. package/dist/components/input/stepper/index.vue +136 -0
  86. package/dist/components/input/style.less +497 -0
  87. package/dist/components/list/index.js +8 -0
  88. package/dist/components/list/index.vue +159 -0
  89. package/dist/components/list/style.less +292 -0
  90. package/dist/components/loading/index.js +7 -0
  91. package/dist/components/loading/index.vue +53 -0
  92. package/dist/components/loading/loading.png +0 -0
  93. package/dist/components/loading/refresh.png +0 -0
  94. package/dist/components/loading/style.less +48 -0
  95. package/dist/components/mixins/clickoutside.js +81 -0
  96. package/dist/components/mixins/dom.js +41 -0
  97. package/dist/components/mixins/languageMixin.js +38 -0
  98. package/dist/components/mixins/outlineConfigPlugin.js +40 -0
  99. package/dist/components/mixins/router-link.js +23 -0
  100. package/dist/components/mixins/themeMixin.js +29 -0
  101. package/dist/components/noticebar/index.js +8 -0
  102. package/dist/components/noticebar/index.vue +247 -0
  103. package/dist/components/noticebar/style.less +332 -0
  104. package/dist/components/overlay/index.js +8 -0
  105. package/dist/components/overlay/index.vue +161 -0
  106. package/dist/components/overlay/style.less +23 -0
  107. package/dist/components/pagebreak/index.js +7 -0
  108. package/dist/components/pagebreak/index.vue +60 -0
  109. package/dist/components/pagebreak/style.less +43 -0
  110. package/dist/components/popover/index.js +8 -0
  111. package/dist/components/popover/index.vue +99 -0
  112. package/dist/components/popover/style.less +346 -0
  113. package/dist/components/popover/vue-popover.vue +314 -0
  114. package/dist/components/radio/assist.js +34 -0
  115. package/dist/components/radio/index.js +8 -0
  116. package/dist/components/radio/index.vue +159 -0
  117. package/dist/components/radio/radio-group/index.vue +70 -0
  118. package/dist/components/radio/style.less +297 -0
  119. package/dist/components/result/completed-dark.png +0 -0
  120. package/dist/components/result/completed.png +0 -0
  121. package/dist/components/result/error-dark.png +0 -0
  122. package/dist/components/result/error.png +0 -0
  123. package/dist/components/result/index.js +8 -0
  124. package/dist/components/result/index.vue +75 -0
  125. package/dist/components/result/style.less +42 -0
  126. package/dist/components/result/wait-dark.png +0 -0
  127. package/dist/components/result/wait.png +0 -0
  128. package/dist/components/selector/index.js +8 -0
  129. package/dist/components/selector/index.vue +124 -0
  130. package/dist/components/selector/style.less +474 -0
  131. package/dist/components/skeleton/index.js +7 -0
  132. package/dist/components/skeleton/index.vue +142 -0
  133. package/dist/components/skeleton/style.less +192 -0
  134. package/dist/components/slider/draggable.js +49 -0
  135. package/dist/components/slider/index.js +7 -0
  136. package/dist/components/slider/index.vue +173 -0
  137. package/dist/components/slider/style.less +96 -0
  138. package/dist/components/slider/utils.js +60 -0
  139. package/dist/components/step/index.js +7 -0
  140. package/dist/components/step/index.vue +48 -0
  141. package/dist/components/step/style.less +59 -0
  142. package/dist/components/step-item/index.js +7 -0
  143. package/dist/components/step-item/index.vue +117 -0
  144. package/dist/components/step-item/style.less +361 -0
  145. package/dist/components/style/index.vue +42 -0
  146. package/dist/components/switch/index.js +8 -0
  147. package/dist/components/switch/index.vue +72 -0
  148. package/dist/components/switch/style.less +56 -0
  149. package/dist/components/tabs/index.js +8 -0
  150. package/dist/components/tabs/index.vue +145 -0
  151. package/dist/components/tabs/style.less +385 -0
  152. package/dist/components/tabs/tab/index.vue +56 -0
  153. package/dist/components/tag/index.js +7 -0
  154. package/dist/components/tag/index.vue +50 -0
  155. package/dist/components/tag/style.less +211 -0
  156. package/dist/components/title/index.js +8 -0
  157. package/dist/components/title/index.vue +92 -0
  158. package/dist/components/title/style.less +188 -0
  159. package/dist/components/toast/index.js +80 -0
  160. package/dist/components/toast/index.vue +44 -0
  161. package/dist/components/toast/style.less +55 -0
  162. package/dist/components/transition/index.js +8 -0
  163. package/dist/components/transition/index.vue +13 -0
  164. package/dist/components/transition/style.less +208 -0
  165. package/dist/components/upload/index.js +7 -0
  166. package/dist/components/upload/index.vue +224 -0
  167. package/dist/components/upload/style.less +156 -0
  168. package/dist/demo.html +10 -0
  169. package/dist/locale/ar.js +98 -0
  170. package/dist/locale/en.js +98 -0
  171. package/dist/locale/zh.js +98 -0
  172. package/dist/token.css +2982 -0
  173. package/dist/vdesign-ui.common.js +27204 -0
  174. package/dist/vdesign-ui.css +1 -0
  175. package/dist/vdesign-ui.umd.js +27214 -0
  176. package/dist/vdesign-ui.umd.min.js +32 -0
  177. package/package.json +1 -1
  178. package/dist/css/chunk-1952c402.04c2303e.css +0 -1
  179. package/dist/css/chunk-6a5c6104.38021b56.css +0 -1
  180. package/dist/css/chunk-vendors.4ecfba63.css +0 -1
  181. package/dist/css/sites.395ce21f.css +0 -1
  182. package/dist/img/bg_mobile.5909f667.png +0 -0
  183. package/dist/img/icon.a67073c3.svg +0 -7
  184. package/dist/img/iphoneX.38c8778e.png +0 -0
  185. package/dist/img/logo-white.fad4f907.png +0 -0
  186. package/dist/img/logo.1eda11d6.png +0 -0
  187. package/dist/img/qrcode2.0a9d9044.png +0 -0
  188. package/dist/index.html +0 -1
  189. package/dist/js/chunk-1952c402.c58ecfb5.js +0 -1
  190. package/dist/js/chunk-2d2183be.2a64419d.js +0 -1
  191. package/dist/js/chunk-6a5c6104.c8fa5635.js +0 -1
  192. package/dist/js/chunk-vendors.490b7673.js +0 -37
  193. package/dist/js/sites.5a217467.js +0 -1
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <!-- 消息提示 -->
3
+ <div :class="['vd-toast', { 'vd-toast-show': isShow }, { 'vd-toast-icon': !!icon }, customClass]"
4
+ :style="`background:${bgColor};`">
5
+ <i v-if="!!icon" class="vd-iconfont" :class="`vd-icon-${icon}`"></i>
6
+ <div>{{ message }}</div>
7
+ </div>
8
+ </template>
9
+ <script>
10
+ export default {
11
+ name: 'vd-toast',
12
+ data() {
13
+ return {
14
+ message: '', // 提示语
15
+ isShow: false, // 是否显示
16
+ bgColor: '', // 背景颜色
17
+ icon: '', // 图标
18
+ duration: 1500, // 延迟时间
19
+ position: 'middle' // default:middle, value: top, bottom
20
+ }
21
+ },
22
+ computed: {
23
+ customClass() {
24
+ var classes = [];
25
+ switch (this.position) {
26
+ case 'top':
27
+ classes.push('vd-toast__top');
28
+ break;
29
+ case 'bottom':
30
+ classes.push('vd-toast__bottom');
31
+ break;
32
+ default:
33
+ classes.push('vd-toast__middle');
34
+ }
35
+ classes.push(this.className);
36
+
37
+ return classes.join(' ');
38
+ }
39
+ }
40
+ }
41
+ </script>
42
+ <style lang="less">
43
+ @import './style.less';
44
+ </style>
@@ -0,0 +1,55 @@
1
+ @prefix: ~"vd-toast";
2
+
3
+ .@{prefix} {
4
+ display: inline-block;
5
+ width: max-content;
6
+ position: fixed;
7
+ top: 50%;
8
+ left: 50%;
9
+ transform: translate(-50%, -50%);
10
+ box-sizing: border-box;
11
+ text-align: center;
12
+ z-index: 1000;
13
+ transition: opacity .3s linear;
14
+ opacity: 0;
15
+ // token
16
+ min-width: calc(var(--width-toast-small)* 1px);
17
+ max-width: calc(var(--width-toast-large)* 1px);
18
+ padding: calc(var(--spacing-toast-padding_x) * 1px) calc(var(--spacing-toast-padding_y) * 1px);
19
+ background-color: var(--color-toast-bg);
20
+ border-radius: calc(var(--radius-toast-content) * 1px);
21
+ color: var(--color-toast-text);
22
+ font-size: calc(var(--en-single-f-c-r-fontSize) * 1px);
23
+ font-weight: var(--en-single-f-c-r-fontWeight);
24
+
25
+ &.vd-toast-show {
26
+ opacity: 1;
27
+ }
28
+
29
+ &-icon {
30
+ min-height: calc(var(--height-toast-small) * 1px);
31
+
32
+ .vd-iconfont {
33
+ font-size: calc(var(--icon-toast-size) * 1px);
34
+ margin-bottom: calc(var(--spacing-toast-icon-margin_bottom) * 1px);
35
+ }
36
+ }
37
+
38
+ &__top {
39
+ top: 50px;
40
+ left: 50%;
41
+ transform: translate(-50%, 0);
42
+ }
43
+
44
+ &__middle {
45
+ left: 50%;
46
+ top: 50%;
47
+ transform: translate(-50%, -50%);
48
+ }
49
+
50
+ &__bottom {
51
+ bottom: 50px;
52
+ left: 50%;
53
+ transform: translate(-50%, 0);
54
+ }
55
+ }
@@ -0,0 +1,8 @@
1
+ import Transition from './index.vue';
2
+ import './style.less';
3
+
4
+ Transition.install = function (Vue) {
5
+ Vue.component(Transition.name, Transition);
6
+ };
7
+
8
+ export default Transition;
@@ -0,0 +1,13 @@
1
+ <script>
2
+ export default {
3
+ name: 'transition',
4
+ functional: true,
5
+ render(h, context) {
6
+ return h('transition', context.data, context.children)
7
+ },
8
+ }
9
+ </script>
10
+
11
+ <style lang="less">
12
+ @import"./style.less";
13
+ </style>
@@ -0,0 +1,208 @@
1
+ .bounce-enter-active {
2
+ animation: bounce-in 300ms linear;
3
+ }
4
+
5
+ .bounce-leave-active {
6
+ animation: zoom-out 250ms linear;
7
+ }
8
+
9
+ .zoom-enter,
10
+ .zoom-leave-to {
11
+ opacity: 0.01;
12
+ transform: scale(0.75);
13
+ }
14
+
15
+ .zoom-enter-active {
16
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
17
+ }
18
+
19
+ .zoom-leave-active {
20
+ transition: all 250ms linear;
21
+ }
22
+
23
+ .punch-enter,
24
+ .punch-leave-to {
25
+ opacity: 0.01;
26
+ transform: scale(1.35);
27
+ }
28
+
29
+ .punch-enter-active {
30
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
31
+ }
32
+
33
+ .punch-leave-active {
34
+ transition: all 250ms linear;
35
+ }
36
+
37
+ .slide-up-enter,
38
+ .slide-up-leave-to {
39
+ transform: translate3d(0, 100%, 0);
40
+ }
41
+
42
+ .slide-up-enter-active {
43
+ transition: transform 300ms cubic-bezier(0.165, 0.84, 0.44, 1);
44
+ }
45
+
46
+ .slide-up-leave-active {
47
+ transition: transform 250ms cubic-bezier(0.165, 0.84, 0.44, 1);
48
+ }
49
+
50
+ .slide-right-enter,
51
+ .slide-right-leave-to {
52
+ transform: translate3d(-100%, 0, 0);
53
+ }
54
+
55
+ .slide-right-enter-active {
56
+ transition: transform 300ms cubic-bezier(0.165, 0.84, 0.44, 1);
57
+ }
58
+
59
+ .slide-right-leave-active {
60
+ transition: transform 250ms cubic-bezier(0.165, 0.84, 0.44, 1);
61
+ }
62
+
63
+ .slide-left-enter,
64
+ .slide-left-leave-to {
65
+ transform: translate3d(100%, 0, 0);
66
+ }
67
+
68
+ .slide-left-enter-active {
69
+ transition: transform 300ms cubic-bezier(0.165, 0.84, 0.44, 1);
70
+ }
71
+
72
+ .slide-left-leave-active {
73
+ transition: transform 250ms cubic-bezier(0.165, 0.84, 0.44, 1);
74
+ }
75
+
76
+ .slide-down-enter,
77
+ .slide-down-leave-to {
78
+ transform: translate3d(0, -100%, 0);
79
+ }
80
+
81
+ .slide-down-enter-active {
82
+ transition: transform 300ms cubic-bezier(0.165, 0.84, 0.44, 1);
83
+ }
84
+
85
+ .slide-down-leave-active {
86
+ transition: transform 250ms cubic-bezier(0.165, 0.84, 0.44, 1);
87
+ }
88
+
89
+ .fade-enter,
90
+ .fade-leave-to {
91
+ opacity: 0.01;
92
+ }
93
+
94
+ .fade-enter-active {
95
+ transition: opacity 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
96
+ }
97
+
98
+ .fade-leave-active {
99
+ transition: opacity 250ms linear;
100
+ }
101
+
102
+ .fade-up-enter,
103
+ .fade-up-leave-to {
104
+ opacity: 0.01;
105
+ transform: translate3d(0, 20%, 0);
106
+ }
107
+
108
+ .fade-up-enter-active {
109
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
110
+ }
111
+
112
+ .fade-up-leave-active {
113
+ transition: all 250ms linear;
114
+ }
115
+
116
+ .fade-down-enter,
117
+ .fade-down-leave-to {
118
+ opacity: 0.01;
119
+ transform: translate3d(0, -20%, 0);
120
+ }
121
+
122
+ .fade-down-enter-active {
123
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
124
+ }
125
+
126
+ .fade-down-leave-active {
127
+ transition: all 250ms linear;
128
+ }
129
+
130
+ .fade-right-enter,
131
+ .fade-right-leave-to {
132
+ opacity: 0.01;
133
+ transform: translate3d(-20%, 0, 0);
134
+ }
135
+
136
+ .fade-right-enter-active {
137
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
138
+ }
139
+
140
+ .fade-right-leave-active {
141
+ transition: all 250ms linear;
142
+ }
143
+
144
+ .fade-left-enter,
145
+ .fade-left-leave-to {
146
+ opacity: 0.01;
147
+ transform: translate3d(20%, 0, 0);
148
+ }
149
+
150
+ .fade-left-enter-active {
151
+ transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
152
+ }
153
+
154
+ .fade-left-leave-active {
155
+ transition: all 250ms linear;
156
+ }
157
+
158
+ .fly-enter-active {
159
+ animation: fly-in 600ms;
160
+ animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
161
+ }
162
+
163
+ .fly-leave-active {
164
+ animation: zoom-out 250ms;
165
+ }
166
+
167
+
168
+ @keyframes fly-in {
169
+ 0% {
170
+ opacity: 0.5;
171
+ transform: scale(0.5) translate3d(0, 50px, 0);
172
+ }
173
+
174
+ 45% {
175
+ opacity: 1;
176
+ transform: scale(1.05) translate3d(0, -50px, 0);
177
+ }
178
+
179
+ 100% {
180
+ transform: scale(1) translate3d(0, 0, 0);
181
+ }
182
+ }
183
+
184
+
185
+ @keyframes bounce-in {
186
+ 0% {
187
+ transform: scale(0.5);
188
+ }
189
+
190
+ 45% {
191
+ transform: scale(1.05);
192
+ }
193
+
194
+ 80% {
195
+ transform: scale(0.95);
196
+ }
197
+
198
+ 100% {
199
+ transform: scale(1);
200
+ }
201
+ }
202
+
203
+ @keyframes zoom-out {
204
+ to {
205
+ opacity: 0.01;
206
+ transform: scale(0.75);
207
+ }
208
+ }
@@ -0,0 +1,7 @@
1
+ import Upload from './index.vue';
2
+ import './style.less';
3
+ Upload.install = function(Vue) {
4
+ Vue.component(Upload.name, Upload)
5
+ }
6
+
7
+ export default Upload;
@@ -0,0 +1,224 @@
1
+ <template>
2
+ <div class="vd-upload" :class="{ 'vd-upload--block': (block && listData.length === 0) }">
3
+ <div class="vd-upload__wrapper">
4
+ <div class="vd-upload__uploader" :class="{ 'vd-upload__uploader--text': text }">
5
+ <vd-icon name="icon_btn_photo" class="vd-upload__icon"></vd-icon>
6
+ <p class="vd-upload__text" v-if="text">{{ text }}</p>
7
+ <input type="file" class="vd-upload__input" accept="image/*,.pdf" :multiple="multiple" @change="onChange"
8
+ :disabled="disabled">
9
+ </div>
10
+ <div class="vd-upload__preview" v-for="item in listData" :key="item.id" :class="fileCls(item.type)">
11
+ <div class="vd-upload__preview-img" v-if="item.type.startsWith('image')" @click="onPreview(item)">
12
+ <img :src="item.url" />
13
+ </div>
14
+ <div class="vd-upload__preview-word" v-if="item.type === 'application/pdf'">PDF</div>
15
+ <div class="vd-upload__preview-delete" @click="onDelete($event, item)" v-if="deletable">
16
+ <vd-icon name="icon_btn_close" class="vd-upload__preview-delete-icon"></vd-icon>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <div class="vd-image-preview" v-if="isPreview" @click="closePreview">
21
+ <div class="vd-image-preview__item" v-for="item in listData" :key="item.id" v-show="curNum === item.id"><img
22
+ :src="item.url" /></div>
23
+ </div>
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ const prefixCls = 'vd-upload';
29
+ export default {
30
+ name: 'vd-upload',
31
+ model: {
32
+ prop: 'fileList'
33
+ },
34
+ props: {
35
+ uploaded: {
36
+ type: Boolean,
37
+ default: false
38
+ },
39
+ preview: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ block: {
44
+ type: Boolean,
45
+ default: false
46
+ },
47
+ text: {
48
+ type: String,
49
+ default: ''
50
+ },
51
+ fileList: {
52
+ type: Array,
53
+ default: () => []
54
+ },
55
+ deletable: {
56
+ type: Boolean,
57
+ default: true
58
+ },
59
+ disabled: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ /**
64
+ * 文件读取前钩子函数
65
+ */
66
+ beforeRead: {
67
+ type: Function,
68
+ default: () => () => true
69
+ },
70
+ /**
71
+ * 文件读取完钩子函数
72
+ */
73
+ afterRead: {
74
+ type: Function,
75
+ default: () => () => true
76
+ },
77
+ /**
78
+ * 文件删除前钩子函数
79
+ */
80
+ beforeDelete: {
81
+ type: Function,
82
+ default: () => () => true
83
+ },
84
+ maxCount: {
85
+ type: Number,
86
+ default: 1000
87
+ },
88
+ maxSize: {
89
+ type: Number,
90
+ default: 6 * 1024 * 1024
91
+ },
92
+ multiple: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ },
97
+ data() {
98
+ return {
99
+ listData: this.fileList,
100
+ curNum: 1,
101
+ isPreview: false
102
+ }
103
+ },
104
+ watch: {
105
+ /**
106
+ * 监听列表数据
107
+ */
108
+ fileList: {
109
+ handler(value) {
110
+ this.listData = value
111
+ },
112
+ deep: true
113
+ }
114
+ },
115
+ methods: {
116
+ fileCls(file) {
117
+ if (file === 'application/pdf') {
118
+ return [`${prefixCls}__preview--pdf`];
119
+ } else {
120
+ return [];
121
+ }
122
+ },
123
+ onDelete(e, item) {
124
+ e.stopPropagation()
125
+ const { disabled, beforeDelete, listData } = this
126
+ /**
127
+ * 判断是否允许删除文件
128
+ */
129
+ if (!disabled && beforeDelete(item) !== false) {
130
+ /**
131
+ * 索引
132
+ */
133
+ let i = 0
134
+ /**
135
+ * 循环遍历数组定位下标位置
136
+ */
137
+ for (; i < listData.length; i++) {
138
+ /**
139
+ * 判断 id 是否相等
140
+ */
141
+ if (listData[i].id === item.id) break
142
+ }
143
+ /**
144
+ * 删除
145
+ */
146
+ listData.splice(i, 1)
147
+ this.$emit('input', listData)
148
+ this.$emit('on-change', listData)
149
+ }
150
+ },
151
+ onChange(e) {
152
+ const { beforeRead, afterRead, maxSize, maxCount, listData } = this
153
+ /**
154
+ * 获取不超过 maxCount 文件
155
+ */
156
+ const files = Object.values(e.target.files).slice(0, maxCount)
157
+
158
+ /**
159
+ * 判断是否允许读取文件
160
+ */
161
+ if (beforeRead(files) !== false) {
162
+ /**
163
+ * 循环遍历添加数据
164
+ */
165
+ const arr = []
166
+ files.forEach(elem => {
167
+ /**
168
+ * 判断大小是否小于或等于 maxSize
169
+ */
170
+ if (elem.size <= maxSize) {
171
+ /**
172
+ * 数组长度
173
+ */
174
+ const len = listData.length
175
+ /**
176
+ * 获取 id
177
+ */
178
+ const id = len === 0 ? 1 : listData[len - 1].id + 1
179
+ /**
180
+ * 创建 blob 预览图片地址
181
+ */
182
+ const url = window.URL.createObjectURL(elem)
183
+
184
+ const type = e.target.files[0].type;
185
+ /**
186
+ * 添加进数组
187
+ */
188
+ listData.push({ id, url, type })
189
+ arr.push(elem)
190
+ }
191
+ })
192
+ /**
193
+ * 符合规则的图片数组
194
+ */
195
+ if (arr.length > 0) {
196
+ afterRead(arr)
197
+ this.$emit('change', listData)
198
+ this.$emit('num-changed', this.curNum);
199
+ }
200
+ }
201
+ },
202
+ onPreview({ id }) {
203
+ const { disabled, preview } = this
204
+ /**
205
+ * 判断是否允许预览
206
+ */
207
+ if (!disabled && preview) {
208
+ this.curNum = id
209
+ /**
210
+ * 打开图片预览
211
+ */
212
+ this.isPreview = true
213
+ }
214
+ },
215
+ closePreview() {
216
+ this.isPreview = false
217
+ },
218
+ }
219
+ }
220
+ </script>
221
+
222
+ <style lang="less">
223
+ @import './style.less';
224
+ </style>
@@ -0,0 +1,156 @@
1
+
2
+ @upload-prefix-cls: vd-upload;
3
+
4
+ .@{upload-prefix-cls}{
5
+ position: relative;
6
+ display: inline-flex;
7
+ width: 100%;
8
+ overflow-x: auto;
9
+
10
+ &--block{
11
+ display: flex;
12
+ width: 100%;
13
+ .@{upload-prefix-cls}{
14
+ &__wrapper{
15
+ width: 100%;
16
+ }
17
+ &__uploader{
18
+ width: 100%;
19
+ }
20
+ }
21
+
22
+ }
23
+
24
+ &__wrapper{
25
+ display: flex;
26
+ gap: 12px;
27
+ }
28
+
29
+ &__uploader{
30
+ position: relative;
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ justify-content: center;
35
+ height: calc(var(--height-upload-bg) * 1px);
36
+ min-width: calc(var(--width-upload-small) * 1px);
37
+ background-color: var(--color-upload-bg);
38
+ border-radius: calc( var(--radius-upload-content) * 1px);
39
+
40
+ &--text{
41
+ padding-block-start: calc(var(--spacing-upload-padding_top) * 1px);
42
+ padding-block-end: calc(var(--spacing-upload-padding_bottom) * 1px);
43
+ }
44
+
45
+ }
46
+
47
+ &__preview{
48
+ position: relative;
49
+ display: flex;
50
+ align-items: center;
51
+ justify-content: center;
52
+ width: calc(var(--width-upload-small) * 1px);
53
+ border-radius: calc( var(--radius-upload-content) * 1px);
54
+
55
+ &--pdf{
56
+ background-color: var(--color-upload-pdf-bg);
57
+ }
58
+
59
+ &-delete{
60
+ position: absolute;
61
+ top: 0;
62
+ right: 0;
63
+ width: 24px;
64
+ height: 24px;
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: center;
68
+ border-radius: 0 calc(var(--radius-upload-content) * 1px);
69
+ background-color: var(--color-upload-close_bg);
70
+ &-icon{
71
+ font-size: calc(var(--icon-upload-close) * 1px);
72
+ color: #ffffff;
73
+ }
74
+ }
75
+ &-word{
76
+ color: var(--color-upload-pdf-text);
77
+ font-size: calc(var(--en-single-f-f-b-fontSize) * 1px);
78
+ font-weight: var(--en-single-f-f-b-fontWeight);
79
+ }
80
+
81
+ &-img{
82
+
83
+ img{
84
+ object-fit: cover;
85
+ width: calc(var(--height-upload-bg) * 1px);
86
+ height: calc(var(--height-upload-bg) * 1px);
87
+ border-radius: calc( var(--radius-upload-content) * 1px);
88
+ }
89
+ }
90
+ }
91
+
92
+
93
+
94
+ &__icon{
95
+ font-size: calc(var(--icon-upload-size) * 1px);
96
+ color: var(--color-upload-icon);
97
+ }
98
+
99
+ &__text{
100
+ margin-block-start: calc(var(--spacing-upload-text-margin_top) * 1px);
101
+ color: var(--color-upload-text);
102
+ font-size: calc(var(--en-single-f-c-r-fontSize) * 1px);
103
+ font-weight: var(--en-single-f-c-r-fontWeight);
104
+ }
105
+
106
+ &__input{
107
+ position: absolute;
108
+ top: 0;
109
+ left: 0;
110
+ width: 100%;
111
+ height: 100%;
112
+ overflow: hidden;
113
+ cursor: pointer;
114
+ opacity: 0;
115
+ }
116
+ }
117
+
118
+ .vd-image-preview{
119
+ display: flex;
120
+ flex-direction: column;
121
+ position: fixed;
122
+ top: 0;
123
+ left: 0;
124
+ z-index: 2001;
125
+ width: 100%;
126
+ height: 100%;
127
+ background-color: var(--color-dialog-mask_bg);
128
+ background: rgba(0,0,0,.8);
129
+
130
+ &__item{
131
+ flex-grow: 1;
132
+ position: relative;
133
+ display: flex;
134
+ justify-content: center;
135
+ align-items: center;
136
+ img{
137
+ display: block;
138
+ object-fit: contain;
139
+ }
140
+ }
141
+ }
142
+
143
+
144
+
145
+ [lang='ar'] {
146
+ .@{upload-prefix-cls}{
147
+ &__preview{
148
+ &-delete{
149
+ left: 0;
150
+ right: auto;
151
+ border-radius: calc(var(--radius-upload-content) * 1px) 0;
152
+
153
+ }
154
+ }
155
+ }
156
+ }