vdesign-ui 0.1.22 → 0.1.24
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.
- package/dist/components/checkbox/index.vue +0 -26
- package/dist/components/dropdown/index.vue +36 -45
- package/dist/components/dropdown/style.less +23 -1
- package/dist/components/radio/index.vue +3 -7
- package/dist/components/radio/style.css +213 -0
- package/dist/components/radio/style.less +5 -0
- package/dist/components/selector/index.vue +40 -25
- package/dist/components/slider/index.vue +0 -6
- package/dist/components/title/index.vue +1 -1
- package/dist/components/upload/index.vue +67 -189
- package/dist/token.css +2 -2
- package/dist/vdesign-ui.common.js +414 -498
- package/dist/vdesign-ui.css +1 -1
- package/dist/vdesign-ui.umd.js +414 -498
- package/dist/vdesign-ui.umd.min.js +3 -3
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<div class="vd-title--right" v-if="guideText || arrow || $slots.right">
|
|
12
12
|
<slot name="right">
|
|
13
13
|
<span v-if="guideText" :class="textRightClasses">{{ guideText }}</span>
|
|
14
|
-
<vd-icon v-if="arrow" class="vd-title-arrow" name="
|
|
14
|
+
<vd-icon v-if="arrow" class="vd-title-arrow" name="icon_btn_next"></vd-icon>
|
|
15
15
|
</slot>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
@@ -1,220 +1,98 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="vd-upload" :class="{ 'vd-upload--block':
|
|
2
|
+
<div class="vd-upload" :class="{ 'vd-upload--block': block }">
|
|
3
3
|
<div class="vd-upload__wrapper">
|
|
4
4
|
<div class="vd-upload__uploader" :class="{ 'vd-upload__uploader--text': text }">
|
|
5
|
-
<vd-icon name="
|
|
5
|
+
<vd-icon :name="photo" class="vd-upload__icon"></vd-icon>
|
|
6
6
|
<p class="vd-upload__text" v-if="text">{{ text }}</p>
|
|
7
|
-
<input type="file" class="vd-upload__input" accept="
|
|
7
|
+
<input type="file" ref="input" class="vd-upload__input" :accept="accept" @change="onChange"
|
|
8
8
|
:disabled="disabled">
|
|
9
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
10
|
</div>
|
|
24
11
|
</div>
|
|
25
12
|
</template>
|
|
26
13
|
|
|
27
14
|
<script>
|
|
28
|
-
const prefixCls = 'vd-upload';
|
|
29
15
|
export default {
|
|
30
16
|
name: 'vd-upload',
|
|
31
|
-
|
|
32
|
-
prop: 'fileList'
|
|
33
|
-
},
|
|
17
|
+
inheritAttrs: false,
|
|
34
18
|
props: {
|
|
35
|
-
|
|
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: {
|
|
19
|
+
photo: {
|
|
48
20
|
type: String,
|
|
49
|
-
default: ''
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
21
|
+
default: 'icon_btn_photo'
|
|
22
|
+
},
|
|
23
|
+
text: String,
|
|
24
|
+
block: Boolean,
|
|
25
|
+
disabled: Boolean,
|
|
26
|
+
beforeRead: Function,
|
|
27
|
+
afterRead: Function,
|
|
28
|
+
accept: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'image/*'
|
|
87
31
|
},
|
|
88
32
|
maxSize: {
|
|
89
33
|
type: Number,
|
|
90
|
-
default:
|
|
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
|
|
34
|
+
default: Number.MAX_VALUE
|
|
113
35
|
}
|
|
114
36
|
},
|
|
37
|
+
|
|
115
38
|
methods: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return [];
|
|
39
|
+
onChange(event) {
|
|
40
|
+
let { files } = event.target;
|
|
41
|
+
if (this.disabled || !files.length) {
|
|
42
|
+
return;
|
|
121
43
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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)
|
|
44
|
+
|
|
45
|
+
files = files.length === 1 ? files[0] : [].slice.call(files, 0);
|
|
46
|
+
if (!files || (this.beforeRead && !this.beforeRead(files))) {
|
|
47
|
+
return;
|
|
149
48
|
}
|
|
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
49
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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)
|
|
50
|
+
if (Array.isArray(files)) {
|
|
51
|
+
Promise.all(files.map(this.readFile)).then(contents => {
|
|
52
|
+
let oversize = false;
|
|
53
|
+
const payload = files.map((file, index) => {
|
|
54
|
+
if (file.size > this.maxSize) {
|
|
55
|
+
oversize = true;
|
|
56
|
+
}
|
|
183
57
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
58
|
+
return {
|
|
59
|
+
file: files[index],
|
|
60
|
+
content: contents[index]
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.onAfterRead(payload, oversize);
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
this.readFile(files).then(content => {
|
|
68
|
+
this.onAfterRead(
|
|
69
|
+
{ file: files, content },
|
|
70
|
+
files.size > this.maxSize
|
|
71
|
+
);
|
|
72
|
+
});
|
|
213
73
|
}
|
|
214
74
|
},
|
|
215
|
-
|
|
216
|
-
|
|
75
|
+
|
|
76
|
+
readFile(file) {
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
const reader = new FileReader();
|
|
79
|
+
|
|
80
|
+
reader.onload = event => {
|
|
81
|
+
resolve(event.target.result);
|
|
82
|
+
};
|
|
83
|
+
reader.readAsDataURL(file);
|
|
84
|
+
|
|
85
|
+
});
|
|
217
86
|
},
|
|
87
|
+
|
|
88
|
+
onAfterRead(files, oversize) {
|
|
89
|
+
if (oversize) {
|
|
90
|
+
this.$emit('oversize', files);
|
|
91
|
+
} else {
|
|
92
|
+
this.afterRead && this.afterRead(files);
|
|
93
|
+
this.$refs.input && (this.$refs.input.value = '');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
218
96
|
}
|
|
219
97
|
}
|
|
220
98
|
</script>
|
package/dist/token.css
CHANGED
|
@@ -903,9 +903,9 @@ html{
|
|
|
903
903
|
}
|
|
904
904
|
|
|
905
905
|
html[theme="dark"]{
|
|
906
|
-
--divider-small:0.5;
|
|
907
906
|
--divider-medium:1;
|
|
908
907
|
--divider-large:3;
|
|
908
|
+
--divider-small:0.5;
|
|
909
909
|
--height-super-small:28;
|
|
910
910
|
--height-extra-small:32;
|
|
911
911
|
--height-small:36;
|
|
@@ -1382,9 +1382,9 @@ html[theme="dark"]{
|
|
|
1382
1382
|
--color-trade-account_head_card_ar-bg:#09825a;
|
|
1383
1383
|
}
|
|
1384
1384
|
html{
|
|
1385
|
-
--divider-small:0.5;
|
|
1386
1385
|
--divider-medium:1;
|
|
1387
1386
|
--divider-large:3;
|
|
1387
|
+
--divider-small:0.5;
|
|
1388
1388
|
--height-super-small:28;
|
|
1389
1389
|
--height-extra-small:32;
|
|
1390
1390
|
--height-small:36;
|