iov-design 2.15.60 → 2.15.61
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/README.md +148 -148
- package/lib/alert.js +24 -105
- package/lib/aside.js +24 -34
- package/lib/autocomplete.js +36 -240
- package/lib/avatar.js +21 -20
- package/lib/backtop.js +27 -52
- package/lib/badge.js +30 -58
- package/lib/breadcrumb-item.js +24 -53
- package/lib/breadcrumb.js +24 -37
- package/lib/button-group.js +24 -29
- package/lib/button.js +38 -60
- package/lib/calendar.js +29 -146
- package/lib/card.js +24 -51
- package/lib/carousel-item.js +30 -68
- package/lib/carousel.js +27 -159
- package/lib/cascader-panel.js +41 -64
- package/lib/cascader.js +37 -470
- package/lib/checkbox-button.js +28 -164
- package/lib/checkbox-group.js +24 -37
- package/lib/checkbox.js +35 -189
- package/lib/col.js +1 -0
- package/lib/collapse-item.js +27 -125
- package/lib/collapse.js +24 -37
- package/lib/color-picker.js +104 -424
- package/lib/container.js +24 -34
- package/lib/date-picker.js +126 -1981
- package/lib/descriptions-item.js +1 -0
- package/lib/descriptions.js +1 -0
- package/lib/dialog.js +24 -137
- package/lib/divider.js +29 -64
- package/lib/drawer.js +24 -139
- package/lib/dropdown-item.js +27 -45
- package/lib/dropdown-menu.js +24 -51
- package/lib/dropdown.js +21 -20
- package/lib/empty.js +24 -61
- package/lib/footer.js +24 -34
- package/lib/form-item.js +42 -128
- package/lib/form.js +27 -40
- package/lib/header.js +24 -34
- package/lib/icon.js +24 -29
- package/lib/image.js +36 -220
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +1 -0
- package/lib/input-number.js +30 -163
- package/lib/input.js +42 -274
- package/lib/iov-design.common.js +1635 -11132
- package/lib/link.js +31 -56
- package/lib/loading.js +24 -77
- package/lib/locale/format.js +10 -10
- package/lib/main.js +24 -29
- package/lib/menu-item-group.js +24 -40
- package/lib/menu-item.js +27 -83
- package/lib/menu.js +21 -20
- package/lib/message-box.js +24 -321
- package/lib/message.js +30 -82
- package/lib/mixins/migrating.js +20 -20
- package/lib/notification.js +24 -109
- package/lib/option-group.js +24 -50
- package/lib/option.js +27 -76
- package/lib/page-header.js +24 -56
- package/lib/pagination.js +24 -97
- package/lib/popconfirm.js +24 -97
- package/lib/popover.js +24 -89
- package/lib/progress.js +30 -133
- package/lib/radio-button.js +29 -111
- package/lib/radio-group.js +24 -39
- package/lib/radio.js +36 -152
- package/lib/rate.js +24 -94
- package/lib/result.js +72 -187
- package/lib/row.js +1 -0
- package/lib/scrollbar.js +1 -0
- package/lib/select.js +48 -637
- package/lib/skeleton-item.js +36 -68
- package/lib/skeleton.js +28 -70
- package/lib/slider.js +36 -267
- package/lib/spinner.js +24 -51
- package/lib/statistic.js +24 -76
- package/lib/step.js +29 -118
- package/lib/steps.js +27 -40
- package/lib/submenu.js +21 -20
- package/lib/switch.js +24 -130
- package/lib/tab-pane.js +24 -52
- package/lib/table-column.js +1 -0
- package/lib/table.js +93 -633
- package/lib/tabs.js +34 -49
- package/lib/tag.js +21 -20
- package/lib/theme-chalk/button.css +1 -1
- package/lib/theme-chalk/calendar.css +1 -1
- package/lib/theme-chalk/dropdown.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/link.css +1 -1
- package/lib/theme-chalk/message-box.css +1 -1
- package/lib/theme-chalk/transfer.css +1 -1
- package/lib/time-picker.js +58 -820
- package/lib/time-select.js +42 -303
- package/lib/timeline-item.js +29 -75
- package/lib/timeline.js +21 -20
- package/lib/tooltip.js +1 -0
- package/lib/transfer.js +36 -299
- package/lib/tree.js +54 -243
- package/lib/upload.js +86 -654
- package/lib/utils/clickoutside.js +7 -7
- package/lib/utils/vue-popper.js +7 -7
- package/package.json +154 -154
- package/packages/autocomplete/src/autocomplete-suggestions.vue +76 -76
- package/packages/autocomplete/src/autocomplete.vue +285 -285
- package/packages/button/src/button.vue +90 -90
- package/packages/calendar/src/date-table.vue +200 -200
- package/packages/calendar/src/main.vue +280 -280
- package/packages/carousel/src/item.vue +138 -138
- package/packages/carousel/src/main.vue +315 -315
- package/packages/cascader/src/cascader.vue +776 -776
- package/packages/cascader-panel/src/cascader-menu.vue +138 -138
- package/packages/cascader-panel/src/cascader-node.vue +246 -246
- package/packages/cascader-panel/src/cascader-panel.vue +391 -391
- package/packages/cascader-panel/src/node.js +166 -166
- package/packages/cascader-panel/src/store.js +58 -58
- package/packages/checkbox/src/checkbox-button.vue +199 -199
- package/packages/checkbox/src/checkbox-group.vue +49 -49
- package/packages/checkbox/src/checkbox.vue +225 -225
- package/packages/collapse/src/collapse-item.vue +114 -114
- package/packages/color-picker/src/components/picker-dropdown.vue +121 -121
- package/packages/color-picker/src/main.vue +188 -188
- package/packages/date-picker/src/basic/date-table.vue +441 -441
- package/packages/date-picker/src/basic/month-table.vue +269 -269
- package/packages/date-picker/src/basic/time-spinner.vue +304 -304
- package/packages/date-picker/src/basic/year-table.vue +111 -111
- package/packages/date-picker/src/panel/date-range.vue +680 -680
- package/packages/date-picker/src/panel/date.vue +609 -609
- package/packages/date-picker/src/panel/month-range.vue +289 -289
- package/packages/date-picker/src/panel/time-range.vue +248 -248
- package/packages/date-picker/src/panel/time-select.vue +178 -178
- package/packages/date-picker/src/panel/time.vue +186 -186
- package/packages/date-picker/src/picker.vue +967 -967
- package/packages/descriptions/src/index.js +180 -180
- package/packages/dialog/src/component.vue +262 -262
- package/packages/drawer/src/main.vue +205 -205
- package/packages/dropdown/src/dropdown-item.vue +37 -37
- package/packages/dropdown/src/dropdown-menu.vue +63 -63
- package/packages/dropdown/src/dropdown.vue +293 -293
- package/packages/empty/src/index.vue +70 -70
- package/packages/form/src/form-item.vue +324 -324
- package/packages/form/src/form.vue +182 -182
- package/packages/image/src/image-viewer.vue +330 -330
- package/packages/image/src/main.vue +249 -249
- package/packages/infinite-scroll/src/main.js +150 -150
- package/packages/input/src/input.vue +477 -477
- package/packages/input-number/src/input-number.vue +283 -283
- package/packages/loading/src/directive.js +133 -133
- package/packages/loading/src/index.js +106 -106
- package/packages/menu/src/menu-item.vue +112 -112
- package/packages/menu/src/menu.vue +325 -325
- package/packages/menu/src/submenu.vue +349 -349
- package/packages/message/src/main.js +91 -91
- package/packages/message-box/src/main.js +216 -216
- package/packages/message-box/src/main.vue +333 -333
- package/packages/notification/src/main.js +94 -94
- package/packages/page-header/src/main.vue +30 -30
- package/packages/pagination/src/pagination.js +390 -390
- package/packages/popconfirm/src/main.vue +104 -104
- package/packages/popover/src/main.vue +239 -239
- package/packages/radio/src/radio-button.vue +115 -115
- package/packages/radio/src/radio-group.vue +115 -115
- package/packages/radio/src/radio.vue +148 -148
- package/packages/rate/src/main.vue +348 -348
- package/packages/scrollbar/src/bar.js +92 -92
- package/packages/scrollbar/src/main.js +130 -130
- package/packages/select/src/option-group.vue +60 -60
- package/packages/select/src/option.vue +171 -171
- package/packages/select/src/select-dropdown.vue +74 -74
- package/packages/select/src/select.vue +979 -979
- package/packages/slider/src/button.vue +238 -238
- package/packages/slider/src/main.vue +427 -427
- package/packages/statistic/src/main.vue +204 -204
- package/packages/steps/src/steps.vue +68 -68
- package/packages/switch/src/component.vue +182 -182
- package/packages/table/src/config.js +153 -153
- package/packages/table/src/filter-panel.vue +194 -194
- package/packages/table/src/store/current.js +76 -76
- package/packages/table/src/store/helper.js +41 -41
- package/packages/table/src/store/index.js +147 -147
- package/packages/table/src/store/watcher.js +502 -502
- package/packages/table/src/table-body.js +469 -469
- package/packages/table/src/table-column.js +328 -328
- package/packages/table/src/table-header.js +571 -571
- package/packages/table/src/table-layout.js +249 -249
- package/packages/table/src/table-row.js +101 -101
- package/packages/table/src/table.vue +740 -740
- package/packages/table/src/util.js +273 -273
- package/packages/tabs/src/tab-bar.vue +57 -57
- package/packages/tabs/src/tab-nav.vue +294 -294
- package/packages/tabs/src/tabs.vue +201 -201
- package/packages/theme-chalk/src/button.scss +416 -416
- package/packages/theme-chalk/src/cascader.scss +252 -252
- package/packages/theme-chalk/src/checkbox.scss +419 -419
- package/packages/theme-chalk/src/common/var.scss +795 -795
- package/packages/theme-chalk/src/form.scss +201 -201
- package/packages/theme-chalk/src/input.scss +591 -591
- package/packages/theme-chalk/src/iovfont.scss +803 -803
- package/packages/theme-chalk/src/link.scss +8 -8
- package/packages/theme-chalk/src/message-box.scss +207 -207
- package/packages/theme-chalk/src/mixins/_button.scss +136 -136
- package/packages/theme-chalk/src/mixins/mixins.scss +190 -190
- package/packages/theme-chalk/src/radio-button.scss +115 -115
- package/packages/theme-chalk/src/select.scss +270 -270
- package/packages/theme-chalk/src/tabs.scss +755 -755
- package/packages/theme-chalk/src/upload.scss +568 -568
- package/packages/tooltip/src/main.js +242 -242
- package/packages/transfer/src/main.vue +231 -231
- package/packages/transfer/src/transfer-panel.vue +251 -251
- package/packages/tree/src/model/node.js +484 -484
- package/packages/tree/src/tree-node.vue +279 -279
- package/packages/tree/src/tree.vue +496 -496
- package/packages/upload/src/index.vue +420 -420
- package/packages/upload/src/upload-file.vue +98 -98
- package/packages/upload/src/upload-list.vue +115 -115
- package/packages/upload/src/upload-picture.vue +98 -98
- package/packages/upload/src/upload.vue +231 -231
- package/packages/upload/src/utils.js +31 -31
- package/src/directives/repeat-click.js +26 -26
- package/src/index.js +259 -259
- package/src/locale/format.js +46 -46
- package/src/locale/index.js +48 -48
- package/src/locale/lang/lo-LA.js +126 -126
- package/src/mixins/locale.js +9 -9
- package/src/mixins/migrating.js +54 -54
- package/src/transitions/collapse-transition.js +77 -77
- package/src/utils/clickoutside.js +76 -76
- package/src/utils/date-util.js +282 -282
- package/src/utils/popup/index.js +218 -218
- package/src/utils/popup/popup-manager.js +194 -194
- package/src/utils/util.js +245 -245
- package/src/utils/vdom.js +5 -5
- package/src/utils/vue-popper.js +198 -198
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import ajax from './ajax';
|
|
3
|
-
import UploadDragger from './upload-dragger.vue';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
inject: ['uploader'],
|
|
7
|
-
components: {
|
|
8
|
-
UploadDragger
|
|
9
|
-
},
|
|
10
|
-
props: {
|
|
11
|
-
type: String,
|
|
12
|
-
action: {
|
|
13
|
-
type: String,
|
|
14
|
-
required: true
|
|
15
|
-
},
|
|
16
|
-
name: {
|
|
17
|
-
type: String,
|
|
18
|
-
default: 'file'
|
|
19
|
-
},
|
|
20
|
-
data: Object,
|
|
21
|
-
headers: Object,
|
|
22
|
-
withCredentials: Boolean,
|
|
23
|
-
multiple: Boolean,
|
|
24
|
-
accept: String,
|
|
25
|
-
onStart: Function,
|
|
26
|
-
onProgress: Function,
|
|
27
|
-
onSuccess: Function,
|
|
28
|
-
onError: Function,
|
|
29
|
-
beforeUpload: Function,
|
|
30
|
-
drag: Boolean,
|
|
31
|
-
size: String,
|
|
32
|
-
onPreview: {
|
|
33
|
-
type: Function,
|
|
34
|
-
default: function() {}
|
|
35
|
-
},
|
|
36
|
-
onRemove: {
|
|
37
|
-
type: Function,
|
|
38
|
-
default: function() {}
|
|
39
|
-
},
|
|
40
|
-
fileList: Array,
|
|
41
|
-
autoUpload: Boolean,
|
|
42
|
-
listType: String,
|
|
43
|
-
httpRequest: {
|
|
44
|
-
type: Function,
|
|
45
|
-
default: ajax
|
|
46
|
-
},
|
|
47
|
-
disabled: Boolean,
|
|
48
|
-
limit: Number,
|
|
49
|
-
onExceed: Function
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
data() {
|
|
53
|
-
return {
|
|
54
|
-
mouseover: false,
|
|
55
|
-
reqs: {}
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
computed: {
|
|
60
|
-
hideUploadInput() {
|
|
61
|
-
return !this.showFileList &&
|
|
62
|
-
this.listType === 'picture-card' &&
|
|
63
|
-
this.limit === 1 &&
|
|
64
|
-
this.fileList.length === 1;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
methods: {
|
|
69
|
-
isImage(str) {
|
|
70
|
-
return str.indexOf('image') !== -1;
|
|
71
|
-
},
|
|
72
|
-
handleChange(ev) {
|
|
73
|
-
const files = ev.target.files;
|
|
74
|
-
|
|
75
|
-
if (!files) return;
|
|
76
|
-
|
|
77
|
-
if (this.drag && this.limit === 1 || this.hideUploadInput) {
|
|
78
|
-
this.fileList.length = [];
|
|
79
|
-
}
|
|
80
|
-
this.uploadFiles(files);
|
|
81
|
-
},
|
|
82
|
-
uploadFiles(files) {
|
|
83
|
-
if (this.limit && this.fileList.length + files.length > this.limit) {
|
|
84
|
-
this.onExceed && this.onExceed(files, this.fileList);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let postFiles = Array.prototype.slice.call(files);
|
|
89
|
-
if (!this.multiple) { postFiles = postFiles.slice(0, 1); }
|
|
90
|
-
|
|
91
|
-
if (postFiles.length === 0) { return; }
|
|
92
|
-
|
|
93
|
-
postFiles.forEach(rawFile => {
|
|
94
|
-
this.onStart(rawFile);
|
|
95
|
-
if (this.autoUpload) this.upload(rawFile);
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
upload(rawFile) {
|
|
99
|
-
this.$refs.input.value = null;
|
|
100
|
-
|
|
101
|
-
if (!this.beforeUpload) {
|
|
102
|
-
return this.post(rawFile);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const before = this.beforeUpload(rawFile);
|
|
106
|
-
if (before && before.then) {
|
|
107
|
-
before.then(processedFile => {
|
|
108
|
-
const fileType = Object.prototype.toString.call(processedFile);
|
|
109
|
-
|
|
110
|
-
if (fileType === '[object File]' || fileType === '[object Blob]') {
|
|
111
|
-
if (fileType === '[object Blob]') {
|
|
112
|
-
processedFile = new File([processedFile], rawFile.name, {
|
|
113
|
-
type: rawFile.type
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
for (const p in rawFile) {
|
|
117
|
-
if (rawFile.hasOwnProperty(p)) {
|
|
118
|
-
processedFile[p] = rawFile[p];
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
this.post(processedFile);
|
|
122
|
-
} else {
|
|
123
|
-
this.post(rawFile);
|
|
124
|
-
}
|
|
125
|
-
}, () => {
|
|
126
|
-
this.onRemove(null, rawFile);
|
|
127
|
-
});
|
|
128
|
-
} else if (before !== false) {
|
|
129
|
-
this.post(rawFile);
|
|
130
|
-
} else {
|
|
131
|
-
this.onRemove(null, rawFile);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
abort(file) {
|
|
135
|
-
const { reqs } = this;
|
|
136
|
-
if (file) {
|
|
137
|
-
let uid = file;
|
|
138
|
-
if (file.uid) uid = file.uid;
|
|
139
|
-
if (reqs[uid]) {
|
|
140
|
-
reqs[uid].abort();
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
Object.keys(reqs).forEach((uid) => {
|
|
144
|
-
if (reqs[uid]) reqs[uid].abort();
|
|
145
|
-
delete reqs[uid];
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
post(rawFile) {
|
|
150
|
-
const { uid } = rawFile;
|
|
151
|
-
const options = {
|
|
152
|
-
headers: this.headers,
|
|
153
|
-
withCredentials: this.withCredentials,
|
|
154
|
-
file: rawFile,
|
|
155
|
-
data: this.data,
|
|
156
|
-
filename: this.name,
|
|
157
|
-
action: this.action,
|
|
158
|
-
onProgress: e => {
|
|
159
|
-
this.onProgress(e, rawFile);
|
|
160
|
-
},
|
|
161
|
-
onSuccess: res => {
|
|
162
|
-
this.onSuccess(res, rawFile);
|
|
163
|
-
delete this.reqs[uid];
|
|
164
|
-
},
|
|
165
|
-
onError: err => {
|
|
166
|
-
this.onError(err, rawFile);
|
|
167
|
-
delete this.reqs[uid];
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const req = this.httpRequest(options);
|
|
171
|
-
this.reqs[uid] = req;
|
|
172
|
-
if (req && req.then) {
|
|
173
|
-
req.then(options.onSuccess, options.onError);
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
handleClick() {
|
|
177
|
-
if (!this.disabled) {
|
|
178
|
-
this.$refs.input.value = null;
|
|
179
|
-
this.$refs.input.click();
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
handleKeydown(e) {
|
|
183
|
-
if (e.target !== e.currentTarget) return;
|
|
184
|
-
if (e.keyCode === 13 || e.keyCode === 32) {
|
|
185
|
-
this.handleClick();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
render(h) {
|
|
191
|
-
let {
|
|
192
|
-
handleClick,
|
|
193
|
-
drag,
|
|
194
|
-
name,
|
|
195
|
-
handleChange,
|
|
196
|
-
multiple,
|
|
197
|
-
accept,
|
|
198
|
-
listType,
|
|
199
|
-
uploadFiles,
|
|
200
|
-
disabled,
|
|
201
|
-
handleKeydown,
|
|
202
|
-
size
|
|
203
|
-
} = this;
|
|
204
|
-
const data = {
|
|
205
|
-
class: {
|
|
206
|
-
'el-upload': true,
|
|
207
|
-
'el-upload--drag': drag,
|
|
208
|
-
[`el-upload--drag__${size}`]: drag,
|
|
209
|
-
[`el-upload--${size}`]: !drag,
|
|
210
|
-
'el-upload--picture-card': listType === 'picture-card',
|
|
211
|
-
'el-upload--picture-card__no-border': this.hideUploadInput
|
|
212
|
-
},
|
|
213
|
-
on: {
|
|
214
|
-
click: handleClick,
|
|
215
|
-
keydown: handleKeydown
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
data.class[`el-upload--${listType}`] = true;
|
|
219
|
-
return (
|
|
220
|
-
<div {...data} tabindex="0" >
|
|
221
|
-
{
|
|
222
|
-
drag
|
|
223
|
-
? <upload-dragger disabled={disabled} on-file={uploadFiles}>{this.$slots.default}{this.$slots.tip}</upload-dragger>
|
|
224
|
-
: this.$slots.default
|
|
225
|
-
}
|
|
226
|
-
<input class="el-upload__input" type="file" ref="input" name={name} on-change={handleChange} multiple={multiple} accept={accept}></input>
|
|
227
|
-
</div>
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
</script>
|
|
1
|
+
<script>
|
|
2
|
+
import ajax from './ajax';
|
|
3
|
+
import UploadDragger from './upload-dragger.vue';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
inject: ['uploader'],
|
|
7
|
+
components: {
|
|
8
|
+
UploadDragger
|
|
9
|
+
},
|
|
10
|
+
props: {
|
|
11
|
+
type: String,
|
|
12
|
+
action: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
name: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'file'
|
|
19
|
+
},
|
|
20
|
+
data: Object,
|
|
21
|
+
headers: Object,
|
|
22
|
+
withCredentials: Boolean,
|
|
23
|
+
multiple: Boolean,
|
|
24
|
+
accept: String,
|
|
25
|
+
onStart: Function,
|
|
26
|
+
onProgress: Function,
|
|
27
|
+
onSuccess: Function,
|
|
28
|
+
onError: Function,
|
|
29
|
+
beforeUpload: Function,
|
|
30
|
+
drag: Boolean,
|
|
31
|
+
size: String,
|
|
32
|
+
onPreview: {
|
|
33
|
+
type: Function,
|
|
34
|
+
default: function() {}
|
|
35
|
+
},
|
|
36
|
+
onRemove: {
|
|
37
|
+
type: Function,
|
|
38
|
+
default: function() {}
|
|
39
|
+
},
|
|
40
|
+
fileList: Array,
|
|
41
|
+
autoUpload: Boolean,
|
|
42
|
+
listType: String,
|
|
43
|
+
httpRequest: {
|
|
44
|
+
type: Function,
|
|
45
|
+
default: ajax
|
|
46
|
+
},
|
|
47
|
+
disabled: Boolean,
|
|
48
|
+
limit: Number,
|
|
49
|
+
onExceed: Function
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
data() {
|
|
53
|
+
return {
|
|
54
|
+
mouseover: false,
|
|
55
|
+
reqs: {}
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
computed: {
|
|
60
|
+
hideUploadInput() {
|
|
61
|
+
return !this.showFileList &&
|
|
62
|
+
this.listType === 'picture-card' &&
|
|
63
|
+
this.limit === 1 &&
|
|
64
|
+
this.fileList.length === 1;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
methods: {
|
|
69
|
+
isImage(str) {
|
|
70
|
+
return str.indexOf('image') !== -1;
|
|
71
|
+
},
|
|
72
|
+
handleChange(ev) {
|
|
73
|
+
const files = ev.target.files;
|
|
74
|
+
|
|
75
|
+
if (!files) return;
|
|
76
|
+
|
|
77
|
+
if (this.drag && this.limit === 1 || this.hideUploadInput) {
|
|
78
|
+
this.fileList.length = [];
|
|
79
|
+
}
|
|
80
|
+
this.uploadFiles(files);
|
|
81
|
+
},
|
|
82
|
+
uploadFiles(files) {
|
|
83
|
+
if (this.limit && this.fileList.length + files.length > this.limit) {
|
|
84
|
+
this.onExceed && this.onExceed(files, this.fileList);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let postFiles = Array.prototype.slice.call(files);
|
|
89
|
+
if (!this.multiple) { postFiles = postFiles.slice(0, 1); }
|
|
90
|
+
|
|
91
|
+
if (postFiles.length === 0) { return; }
|
|
92
|
+
|
|
93
|
+
postFiles.forEach(rawFile => {
|
|
94
|
+
this.onStart(rawFile);
|
|
95
|
+
if (this.autoUpload) this.upload(rawFile);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
upload(rawFile) {
|
|
99
|
+
this.$refs.input.value = null;
|
|
100
|
+
|
|
101
|
+
if (!this.beforeUpload) {
|
|
102
|
+
return this.post(rawFile);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const before = this.beforeUpload(rawFile);
|
|
106
|
+
if (before && before.then) {
|
|
107
|
+
before.then(processedFile => {
|
|
108
|
+
const fileType = Object.prototype.toString.call(processedFile);
|
|
109
|
+
|
|
110
|
+
if (fileType === '[object File]' || fileType === '[object Blob]') {
|
|
111
|
+
if (fileType === '[object Blob]') {
|
|
112
|
+
processedFile = new File([processedFile], rawFile.name, {
|
|
113
|
+
type: rawFile.type
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
for (const p in rawFile) {
|
|
117
|
+
if (rawFile.hasOwnProperty(p)) {
|
|
118
|
+
processedFile[p] = rawFile[p];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.post(processedFile);
|
|
122
|
+
} else {
|
|
123
|
+
this.post(rawFile);
|
|
124
|
+
}
|
|
125
|
+
}, () => {
|
|
126
|
+
this.onRemove(null, rawFile);
|
|
127
|
+
});
|
|
128
|
+
} else if (before !== false) {
|
|
129
|
+
this.post(rawFile);
|
|
130
|
+
} else {
|
|
131
|
+
this.onRemove(null, rawFile);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
abort(file) {
|
|
135
|
+
const { reqs } = this;
|
|
136
|
+
if (file) {
|
|
137
|
+
let uid = file;
|
|
138
|
+
if (file.uid) uid = file.uid;
|
|
139
|
+
if (reqs[uid]) {
|
|
140
|
+
reqs[uid].abort();
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
Object.keys(reqs).forEach((uid) => {
|
|
144
|
+
if (reqs[uid]) reqs[uid].abort();
|
|
145
|
+
delete reqs[uid];
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
post(rawFile) {
|
|
150
|
+
const { uid } = rawFile;
|
|
151
|
+
const options = {
|
|
152
|
+
headers: this.headers,
|
|
153
|
+
withCredentials: this.withCredentials,
|
|
154
|
+
file: rawFile,
|
|
155
|
+
data: this.data,
|
|
156
|
+
filename: this.name,
|
|
157
|
+
action: this.action,
|
|
158
|
+
onProgress: e => {
|
|
159
|
+
this.onProgress(e, rawFile);
|
|
160
|
+
},
|
|
161
|
+
onSuccess: res => {
|
|
162
|
+
this.onSuccess(res, rawFile);
|
|
163
|
+
delete this.reqs[uid];
|
|
164
|
+
},
|
|
165
|
+
onError: err => {
|
|
166
|
+
this.onError(err, rawFile);
|
|
167
|
+
delete this.reqs[uid];
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const req = this.httpRequest(options);
|
|
171
|
+
this.reqs[uid] = req;
|
|
172
|
+
if (req && req.then) {
|
|
173
|
+
req.then(options.onSuccess, options.onError);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
handleClick() {
|
|
177
|
+
if (!this.disabled) {
|
|
178
|
+
this.$refs.input.value = null;
|
|
179
|
+
this.$refs.input.click();
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
handleKeydown(e) {
|
|
183
|
+
if (e.target !== e.currentTarget) return;
|
|
184
|
+
if (e.keyCode === 13 || e.keyCode === 32) {
|
|
185
|
+
this.handleClick();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
render(h) {
|
|
191
|
+
let {
|
|
192
|
+
handleClick,
|
|
193
|
+
drag,
|
|
194
|
+
name,
|
|
195
|
+
handleChange,
|
|
196
|
+
multiple,
|
|
197
|
+
accept,
|
|
198
|
+
listType,
|
|
199
|
+
uploadFiles,
|
|
200
|
+
disabled,
|
|
201
|
+
handleKeydown,
|
|
202
|
+
size
|
|
203
|
+
} = this;
|
|
204
|
+
const data = {
|
|
205
|
+
class: {
|
|
206
|
+
'el-upload': true,
|
|
207
|
+
'el-upload--drag': drag,
|
|
208
|
+
[`el-upload--drag__${size}`]: drag,
|
|
209
|
+
[`el-upload--${size}`]: !drag,
|
|
210
|
+
'el-upload--picture-card': listType === 'picture-card',
|
|
211
|
+
'el-upload--picture-card__no-border': this.hideUploadInput
|
|
212
|
+
},
|
|
213
|
+
on: {
|
|
214
|
+
click: handleClick,
|
|
215
|
+
keydown: handleKeydown
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
data.class[`el-upload--${listType}`] = true;
|
|
219
|
+
return (
|
|
220
|
+
<div {...data} tabindex="0" >
|
|
221
|
+
{
|
|
222
|
+
drag
|
|
223
|
+
? <upload-dragger disabled={disabled} on-file={uploadFiles}>{this.$slots.default}{this.$slots.tip}</upload-dragger>
|
|
224
|
+
: this.$slots.default
|
|
225
|
+
}
|
|
226
|
+
<input class="el-upload__input" type="file" ref="input" name={name} on-change={handleChange} multiple={multiple} accept={accept}></input>
|
|
227
|
+
</div>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
</script>
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const ICON_MAP = {
|
|
2
|
-
img: '//obs-helf.cucloud.cn/prod-common-public/iov-design/img.png', // require('./assets/img.png'),
|
|
3
|
-
pdf: '//obs-helf.cucloud.cn/prod-common-public/iov-design/pdf.png', // require('./assets/pdf.png'),
|
|
4
|
-
excel: '//obs-helf.cucloud.cn/prod-common-public/iov-design/excel.png', // require('./assets/excel.png'),
|
|
5
|
-
zip: '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
6
|
-
rar: '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
7
|
-
'7z': '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
8
|
-
ppt: '//obs-helf.cucloud.cn/prod-common-public/iov-design/ppt.png', // require('./assets/ppt.png'),
|
|
9
|
-
word: '//obs-helf.cucloud.cn/prod-common-public/iov-design/word.png', // require('./assets/word.png'),
|
|
10
|
-
default: '//obs-helf.cucloud.cn/prod-common-public/iov-design/file.png' // require('./assets/file.png')
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function iconStyle(fileName) {
|
|
14
|
-
if (!fileName) return;
|
|
15
|
-
const suffixMap = {
|
|
16
|
-
img: ['png', 'jpg', 'jpeg'],
|
|
17
|
-
word: ['doc', 'docx'],
|
|
18
|
-
excel: ['xls', 'xlsx'],
|
|
19
|
-
ppt: ['ppt', 'pptx']
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const ext = fileName.split('.').pop().toLowerCase();
|
|
23
|
-
|
|
24
|
-
for (const [key, list] of Object.entries(suffixMap)) {
|
|
25
|
-
if (list.includes(ext)) {
|
|
26
|
-
return { 'background-image': `url(${ICON_MAP[key]})` };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return { 'background-image': `url(${ICON_MAP[ext] || ICON_MAP.default})` };
|
|
31
|
-
}
|
|
1
|
+
const ICON_MAP = {
|
|
2
|
+
img: '//obs-helf.cucloud.cn/prod-common-public/iov-design/img.png', // require('./assets/img.png'),
|
|
3
|
+
pdf: '//obs-helf.cucloud.cn/prod-common-public/iov-design/pdf.png', // require('./assets/pdf.png'),
|
|
4
|
+
excel: '//obs-helf.cucloud.cn/prod-common-public/iov-design/excel.png', // require('./assets/excel.png'),
|
|
5
|
+
zip: '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
6
|
+
rar: '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
7
|
+
'7z': '//obs-helf.cucloud.cn/prod-common-public/iov-design/zip.png', // require('./assets/zip.png'),
|
|
8
|
+
ppt: '//obs-helf.cucloud.cn/prod-common-public/iov-design/ppt.png', // require('./assets/ppt.png'),
|
|
9
|
+
word: '//obs-helf.cucloud.cn/prod-common-public/iov-design/word.png', // require('./assets/word.png'),
|
|
10
|
+
default: '//obs-helf.cucloud.cn/prod-common-public/iov-design/file.png' // require('./assets/file.png')
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function iconStyle(fileName) {
|
|
14
|
+
if (!fileName) return;
|
|
15
|
+
const suffixMap = {
|
|
16
|
+
img: ['png', 'jpg', 'jpeg'],
|
|
17
|
+
word: ['doc', 'docx'],
|
|
18
|
+
excel: ['xls', 'xlsx'],
|
|
19
|
+
ppt: ['ppt', 'pptx']
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ext = fileName.split('.').pop().toLowerCase();
|
|
23
|
+
|
|
24
|
+
for (const [key, list] of Object.entries(suffixMap)) {
|
|
25
|
+
if (list.includes(ext)) {
|
|
26
|
+
return { 'background-image': `url(${ICON_MAP[key]})` };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return { 'background-image': `url(${ICON_MAP[ext] || ICON_MAP.default})` };
|
|
31
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { once, on } from 'iov-design/src/utils/dom';
|
|
2
|
-
import { isMac } from 'iov-design/src/utils/util';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
bind(el, binding, vnode) {
|
|
6
|
-
let interval = null;
|
|
7
|
-
let startTime;
|
|
8
|
-
const maxIntervals = isMac() ? 100 : 200;
|
|
9
|
-
const handler = () => vnode.context[binding.expression].apply();
|
|
10
|
-
const clear = () => {
|
|
11
|
-
if (Date.now() - startTime < maxIntervals) {
|
|
12
|
-
handler();
|
|
13
|
-
}
|
|
14
|
-
clearInterval(interval);
|
|
15
|
-
interval = null;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
on(el, 'mousedown', (e) => {
|
|
19
|
-
if (e.button !== 0) return;
|
|
20
|
-
startTime = Date.now();
|
|
21
|
-
once(document, 'mouseup', clear);
|
|
22
|
-
clearInterval(interval);
|
|
23
|
-
interval = setInterval(handler, maxIntervals);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
1
|
+
import { once, on } from 'iov-design/src/utils/dom';
|
|
2
|
+
import { isMac } from 'iov-design/src/utils/util';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
bind(el, binding, vnode) {
|
|
6
|
+
let interval = null;
|
|
7
|
+
let startTime;
|
|
8
|
+
const maxIntervals = isMac() ? 100 : 200;
|
|
9
|
+
const handler = () => vnode.context[binding.expression].apply();
|
|
10
|
+
const clear = () => {
|
|
11
|
+
if (Date.now() - startTime < maxIntervals) {
|
|
12
|
+
handler();
|
|
13
|
+
}
|
|
14
|
+
clearInterval(interval);
|
|
15
|
+
interval = null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
on(el, 'mousedown', (e) => {
|
|
19
|
+
if (e.button !== 0) return;
|
|
20
|
+
startTime = Date.now();
|
|
21
|
+
once(document, 'mouseup', clear);
|
|
22
|
+
clearInterval(interval);
|
|
23
|
+
interval = setInterval(handler, maxIntervals);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|