vue-devui 1.0.0-beta.10 → 1.0.0-beta.11
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 +31 -36
- package/accordion/index.es.js +309 -38
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/button/index.es.js +203 -1
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/drawer/index.es.js +3 -4
- package/drawer/index.umd.js +1 -1
- package/editable-select/index.es.js +67 -3
- package/editable-select/index.umd.js +11 -11
- package/modal/index.es.js +198 -0
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/package.json +1 -1
- package/progress/index.es.js +8 -8
- package/progress/index.umd.js +3 -3
- package/radio/index.es.js +5 -5
- package/radio/index.umd.js +1 -1
- package/statistic/index.es.js +2 -2
- package/statistic/index.umd.js +1 -1
- package/statistic/style.css +1 -1
- package/style.css +1 -1
- package/table/index.es.js +207 -5
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/time-picker/index.es.js +203 -1
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.es.js +1 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/transfer/style.css +1 -1
- package/upload/index.es.js +158 -503
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +857 -869
- package/vue-devui.umd.js +18 -18
- package/nuxt/components/MultiUpload.js +0 -3
package/upload/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { defineComponent, createVNode, getCurrentInstance, ref, computed, watch, nextTick, onUnmounted, mergeProps, createApp, toRefs, withDirectives, resolveComponent,
|
|
24
|
+
import { defineComponent, createVNode, getCurrentInstance, ref, computed, watch, nextTick, onUnmounted, mergeProps, createApp, toRefs, withDirectives, resolveComponent, isVNode, resolveDirective } from "vue";
|
|
25
25
|
var toast = "";
|
|
26
26
|
const toastProps = {
|
|
27
27
|
value: {
|
|
@@ -149,7 +149,7 @@ var ToastImage = defineComponent({
|
|
|
149
149
|
"class": wrapperCls
|
|
150
150
|
}, [showIcon() ? createVNode(Icon, {
|
|
151
151
|
"name": severityIconMap[severity],
|
|
152
|
-
"size": "
|
|
152
|
+
"size": "16px"
|
|
153
153
|
}, null) : null]);
|
|
154
154
|
}
|
|
155
155
|
});
|
|
@@ -2060,13 +2060,20 @@ var UploadStatus;
|
|
|
2060
2060
|
UploadStatus2[UploadStatus2["failed"] = 3] = "failed";
|
|
2061
2061
|
})(UploadStatus || (UploadStatus = {}));
|
|
2062
2062
|
const uploadProps = {
|
|
2063
|
+
accept: {
|
|
2064
|
+
type: String
|
|
2065
|
+
},
|
|
2066
|
+
webkitdirectory: {
|
|
2067
|
+
type: Boolean,
|
|
2068
|
+
default: false
|
|
2069
|
+
},
|
|
2063
2070
|
uploadOptions: {
|
|
2064
2071
|
type: Object,
|
|
2065
2072
|
required: true
|
|
2066
2073
|
},
|
|
2067
|
-
|
|
2068
|
-
type:
|
|
2069
|
-
|
|
2074
|
+
multiple: {
|
|
2075
|
+
type: Boolean,
|
|
2076
|
+
default: false
|
|
2070
2077
|
},
|
|
2071
2078
|
autoUpload: {
|
|
2072
2079
|
type: Boolean,
|
|
@@ -2102,10 +2109,6 @@ const uploadProps = {
|
|
|
2102
2109
|
type: Boolean,
|
|
2103
2110
|
default: false
|
|
2104
2111
|
},
|
|
2105
|
-
showTip: {
|
|
2106
|
-
type: Boolean,
|
|
2107
|
-
default: false
|
|
2108
|
-
},
|
|
2109
2112
|
onChange: {
|
|
2110
2113
|
type: Function
|
|
2111
2114
|
},
|
|
@@ -2121,96 +2124,128 @@ const uploadProps = {
|
|
|
2121
2124
|
type: Function,
|
|
2122
2125
|
default: void 0
|
|
2123
2126
|
},
|
|
2124
|
-
|
|
2127
|
+
deleteUploadedFile: {
|
|
2125
2128
|
type: Function,
|
|
2126
2129
|
default: void 0
|
|
2127
2130
|
},
|
|
2128
|
-
|
|
2131
|
+
"on-error": {
|
|
2129
2132
|
type: Function,
|
|
2130
2133
|
default: void 0
|
|
2131
2134
|
},
|
|
2132
|
-
|
|
2135
|
+
"on-success": {
|
|
2133
2136
|
type: Function,
|
|
2134
2137
|
default: void 0
|
|
2135
|
-
}
|
|
2136
|
-
};
|
|
2137
|
-
const multiUploadProps = {
|
|
2138
|
-
uploadOptions: {
|
|
2139
|
-
type: Object,
|
|
2140
|
-
required: true
|
|
2141
|
-
},
|
|
2142
|
-
fileOptions: {
|
|
2143
|
-
type: Object,
|
|
2144
|
-
required: true
|
|
2145
|
-
},
|
|
2146
|
-
autoUpload: {
|
|
2147
|
-
type: Boolean,
|
|
2148
|
-
default: false
|
|
2149
|
-
},
|
|
2150
|
-
withoutBtn: {
|
|
2151
|
-
type: Boolean,
|
|
2152
|
-
default: false
|
|
2153
|
-
},
|
|
2154
|
-
showTip: {
|
|
2155
|
-
type: Boolean,
|
|
2156
|
-
default: false
|
|
2157
|
-
},
|
|
2158
|
-
uploadedFiles: {
|
|
2159
|
-
type: Array,
|
|
2160
|
-
default: () => []
|
|
2161
|
-
},
|
|
2162
|
-
enableDrop: {
|
|
2163
|
-
type: Boolean,
|
|
2164
|
-
default: false
|
|
2165
|
-
},
|
|
2166
|
-
placeholderText: {
|
|
2167
|
-
type: String,
|
|
2168
|
-
default: "\u9009\u62E9\u6587\u4EF6"
|
|
2169
|
-
},
|
|
2170
|
-
uploadText: {
|
|
2171
|
-
type: String,
|
|
2172
|
-
default: "\u4E0A\u4F20"
|
|
2173
2138
|
},
|
|
2174
2139
|
oneTimeUpload: {
|
|
2175
2140
|
type: Boolean,
|
|
2176
2141
|
default: false
|
|
2177
|
-
},
|
|
2178
|
-
disabled: {
|
|
2179
|
-
type: Boolean,
|
|
2180
|
-
default: false
|
|
2181
|
-
},
|
|
2182
|
-
beforeUpload: {
|
|
2183
|
-
type: Function
|
|
2184
|
-
},
|
|
2185
|
-
fileDrop: {
|
|
2186
|
-
type: Function,
|
|
2187
|
-
default: void 0
|
|
2188
|
-
},
|
|
2189
|
-
fileOver: {
|
|
2190
|
-
type: Function,
|
|
2191
|
-
default: void 0
|
|
2192
|
-
},
|
|
2193
|
-
fileSelect: {
|
|
2194
|
-
type: Function,
|
|
2195
|
-
default: void 0
|
|
2196
|
-
},
|
|
2197
|
-
errorEvent: {
|
|
2198
|
-
type: Function,
|
|
2199
|
-
default: void 0
|
|
2200
|
-
},
|
|
2201
|
-
successEvent: {
|
|
2202
|
-
type: Function,
|
|
2203
|
-
default: void 0
|
|
2204
|
-
},
|
|
2205
|
-
deleteUploadedFileEvent: {
|
|
2206
|
-
type: Function,
|
|
2207
|
-
default: void 0
|
|
2208
|
-
},
|
|
2209
|
-
setCustomUploadOptions: {
|
|
2210
|
-
type: Function,
|
|
2211
|
-
default: void 0
|
|
2212
2142
|
}
|
|
2213
2143
|
};
|
|
2144
|
+
const getFailedFilesCount = (failedCount) => `${failedCount}\u4E2A\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF01`;
|
|
2145
|
+
const getUploadingFilesCount = (uploadingCount, filesCount) => `${uploadingCount}/${filesCount}\u6B63\u5728\u4E0A\u4F20`;
|
|
2146
|
+
const getSelectedFilesCount = (filesCount) => `\u5DF2\u6DFB\u52A0${filesCount}\u4E2A\u6587\u4EF6`;
|
|
2147
|
+
const getAllFilesBeyondMaximalFileSizeMsg = (maximalSize) => `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2148
|
+
const getBeyondMaximalFileSizeMsg = (filename, maximalSize) => {
|
|
2149
|
+
return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2150
|
+
};
|
|
2151
|
+
const getNotAllowedFileTypeMsg = (filename, scope) => {
|
|
2152
|
+
return `\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${scope}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2153
|
+
};
|
|
2154
|
+
const getExistSameNameFilesMsg = (sameNames) => {
|
|
2155
|
+
return `\u60A8\u4E0A\u4F20\u7684 "${sameNames}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2156
|
+
};
|
|
2157
|
+
const useSelectFiles = () => {
|
|
2158
|
+
const BEYOND_MAXIMAL_FILE_SIZE_MSG = ref("");
|
|
2159
|
+
const simulateClickEvent = (input) => {
|
|
2160
|
+
const evt = document.createEvent("MouseEvents");
|
|
2161
|
+
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
2162
|
+
input.dispatchEvent(evt);
|
|
2163
|
+
};
|
|
2164
|
+
const selectFiles = ({ multiple, accept, webkitdirectory }) => {
|
|
2165
|
+
return new Promise((resolve) => {
|
|
2166
|
+
const tempNode = document.getElementById("d-upload-temp");
|
|
2167
|
+
if (tempNode) {
|
|
2168
|
+
document.body.removeChild(tempNode);
|
|
2169
|
+
}
|
|
2170
|
+
const input = document.createElement("input");
|
|
2171
|
+
input.style.position = "fixed";
|
|
2172
|
+
input.style.left = "-2000px";
|
|
2173
|
+
input.style.top = "-2000px";
|
|
2174
|
+
input.setAttribute("id", "d-upload-temp");
|
|
2175
|
+
input.setAttribute("type", "file");
|
|
2176
|
+
if (multiple) {
|
|
2177
|
+
input.setAttribute("multiple", "");
|
|
2178
|
+
}
|
|
2179
|
+
if (accept) {
|
|
2180
|
+
input.setAttribute("accept", accept);
|
|
2181
|
+
}
|
|
2182
|
+
if (webkitdirectory) {
|
|
2183
|
+
input.setAttribute("webkitdirectory", "");
|
|
2184
|
+
}
|
|
2185
|
+
input.addEventListener("change", (event) => {
|
|
2186
|
+
resolve(Array.prototype.slice.call(event.target.files));
|
|
2187
|
+
});
|
|
2188
|
+
document.body.appendChild(input);
|
|
2189
|
+
simulateClickEvent(input);
|
|
2190
|
+
});
|
|
2191
|
+
};
|
|
2192
|
+
const isAllowedFileType = (accept, file) => {
|
|
2193
|
+
if (accept) {
|
|
2194
|
+
const acceptArr = accept.split(",");
|
|
2195
|
+
const baseMimeType = file.type.replace(/\/.*$/, "");
|
|
2196
|
+
return acceptArr.some((type) => {
|
|
2197
|
+
const validType = type.trim();
|
|
2198
|
+
if (validType.startsWith(".")) {
|
|
2199
|
+
return file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.toLowerCase().length - validType.toLowerCase().length) > -1;
|
|
2200
|
+
} else if (/\/\*$/.test(validType)) {
|
|
2201
|
+
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
2202
|
+
}
|
|
2203
|
+
return file.type === validType;
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
return true;
|
|
2207
|
+
};
|
|
2208
|
+
const beyondMaximalSize = (fileSize, maximumSize) => {
|
|
2209
|
+
if (maximumSize) {
|
|
2210
|
+
return fileSize > 1024 * 1024 * maximumSize;
|
|
2211
|
+
}
|
|
2212
|
+
return false;
|
|
2213
|
+
};
|
|
2214
|
+
const _validateFiles = (file, accept, uploadOptions) => {
|
|
2215
|
+
if (!isAllowedFileType(accept, file)) {
|
|
2216
|
+
return {
|
|
2217
|
+
checkError: true,
|
|
2218
|
+
errorMsg: getNotAllowedFileTypeMsg(file.name, accept)
|
|
2219
|
+
};
|
|
2220
|
+
}
|
|
2221
|
+
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
2222
|
+
return {
|
|
2223
|
+
checkError: true,
|
|
2224
|
+
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
return { checkError: false, errorMsg: void 0 };
|
|
2228
|
+
};
|
|
2229
|
+
const triggerSelectFiles = (fileOptions) => {
|
|
2230
|
+
const { multiple, accept, webkitdirectory } = fileOptions;
|
|
2231
|
+
return selectFiles({ multiple, accept, webkitdirectory });
|
|
2232
|
+
};
|
|
2233
|
+
const triggerDropFiles = (files) => {
|
|
2234
|
+
return Promise.resolve(files);
|
|
2235
|
+
};
|
|
2236
|
+
const checkAllFilesSize = (fileSize, maximumSize) => {
|
|
2237
|
+
if (beyondMaximalSize(fileSize, maximumSize)) {
|
|
2238
|
+
BEYOND_MAXIMAL_FILE_SIZE_MSG.value = getAllFilesBeyondMaximalFileSizeMsg(maximumSize);
|
|
2239
|
+
return { checkError: true, errorMsg: BEYOND_MAXIMAL_FILE_SIZE_MSG.value };
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
return {
|
|
2243
|
+
triggerSelectFiles,
|
|
2244
|
+
_validateFiles,
|
|
2245
|
+
triggerDropFiles,
|
|
2246
|
+
checkAllFilesSize
|
|
2247
|
+
};
|
|
2248
|
+
};
|
|
2214
2249
|
class FileUploader {
|
|
2215
2250
|
constructor(file, uploadOptions) {
|
|
2216
2251
|
__publicField(this, "xhr");
|
|
@@ -2412,402 +2447,17 @@ const useUpload = () => {
|
|
|
2412
2447
|
_oneTimeUpload
|
|
2413
2448
|
};
|
|
2414
2449
|
};
|
|
2415
|
-
const i18nText = {
|
|
2416
|
-
warning: "\u63D0\u9192",
|
|
2417
|
-
upload: "\u4E0A\u4F20",
|
|
2418
|
-
chooseFile: "\u9009\u62E9\u6587\u4EF6",
|
|
2419
|
-
chooseFiles: "\u9009\u62E9\u591A\u4E2A\u6587\u4EF6",
|
|
2420
|
-
preload: "\u9884\u52A0\u8F7D",
|
|
2421
|
-
uploading: "\u4E0A\u4F20\u4E2D...",
|
|
2422
|
-
uploaded: "\u5DF2\u4E0A\u4F20",
|
|
2423
|
-
uploadFailed: "\u4E0A\u4F20\u5931\u8D25",
|
|
2424
|
-
uploadSuccess: "\u4E0A\u4F20\u6210\u529F!",
|
|
2425
|
-
delete: "\u5220\u9664",
|
|
2426
|
-
reUpload: "\u91CD\u65B0\u4E0A\u4F20",
|
|
2427
|
-
cancelUpload: "\u53D6\u6D88\u4E0A\u4F20"
|
|
2428
|
-
};
|
|
2429
|
-
const getFailedFilesCount = (failedCount) => `${failedCount}\u4E2A\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF01`;
|
|
2430
|
-
const getUploadingFilesCount = (uploadingCount, filesCount) => `${uploadingCount}/${filesCount}\u6B63\u5728\u4E0A\u4F20`;
|
|
2431
|
-
const getSelectedFilesCount = (filesCount) => `\u5DF2\u6DFB\u52A0${filesCount}\u4E2A\u6587\u4EF6`;
|
|
2432
|
-
const getAllFilesBeyondMaximalFileSizeMsg = (maximalSize) => `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u672C\u6B21\u4E0A\u4F20\u7684\u6240\u6709\u6587\u4EF6\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2433
|
-
const getBeyondMaximalFileSizeMsg = (filename, maximalSize) => {
|
|
2434
|
-
return `\u6700\u5927\u652F\u6301\u4E0A\u4F20${maximalSize}MB\u7684\u6587\u4EF6, \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u8D85\u8FC7\u53EF\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F`;
|
|
2435
|
-
};
|
|
2436
|
-
const getNotAllowedFileTypeMsg = (filename, scope) => {
|
|
2437
|
-
return `\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B: "${scope}", \u60A8\u4E0A\u4F20\u7684\u6587\u4EF6"${filename}"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2438
|
-
};
|
|
2439
|
-
const getExistSameNameFilesMsg = (sameNames) => {
|
|
2440
|
-
return `\u60A8\u4E0A\u4F20\u7684 "${sameNames}" \u5B58\u5728\u91CD\u540D\u6587\u4EF6, \u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6`;
|
|
2441
|
-
};
|
|
2442
|
-
const useSelectFiles = () => {
|
|
2443
|
-
const BEYOND_MAXIMAL_FILE_SIZE_MSG = ref("");
|
|
2444
|
-
const simulateClickEvent = (input) => {
|
|
2445
|
-
const evt = document.createEvent("MouseEvents");
|
|
2446
|
-
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
2447
|
-
input.dispatchEvent(evt);
|
|
2448
|
-
};
|
|
2449
|
-
const selectFiles = ({
|
|
2450
|
-
multiple,
|
|
2451
|
-
accept,
|
|
2452
|
-
webkitdirectory
|
|
2453
|
-
}) => {
|
|
2454
|
-
return new Promise((resolve) => {
|
|
2455
|
-
const tempNode = document.getElementById("d-upload-temp");
|
|
2456
|
-
if (tempNode) {
|
|
2457
|
-
document.body.removeChild(tempNode);
|
|
2458
|
-
}
|
|
2459
|
-
const input = document.createElement("input");
|
|
2460
|
-
input.style.position = "fixed";
|
|
2461
|
-
input.style.left = "-2000px";
|
|
2462
|
-
input.style.top = "-2000px";
|
|
2463
|
-
input.setAttribute("id", "d-upload-temp");
|
|
2464
|
-
input.setAttribute("type", "file");
|
|
2465
|
-
if (multiple) {
|
|
2466
|
-
input.setAttribute("multiple", "");
|
|
2467
|
-
}
|
|
2468
|
-
if (accept) {
|
|
2469
|
-
input.setAttribute("accept", accept);
|
|
2470
|
-
}
|
|
2471
|
-
if (webkitdirectory) {
|
|
2472
|
-
input.setAttribute("webkitdirectory", "");
|
|
2473
|
-
}
|
|
2474
|
-
input.addEventListener("change", (event) => {
|
|
2475
|
-
resolve(Array.prototype.slice.call(event.target.files));
|
|
2476
|
-
});
|
|
2477
|
-
document.body.appendChild(input);
|
|
2478
|
-
simulateClickEvent(input);
|
|
2479
|
-
});
|
|
2480
|
-
};
|
|
2481
|
-
const isAllowedFileType = (accept, file) => {
|
|
2482
|
-
if (accept) {
|
|
2483
|
-
const acceptArr = accept.split(",");
|
|
2484
|
-
const baseMimeType = file.type.replace(/\/.*$/, "");
|
|
2485
|
-
return acceptArr.some((type) => {
|
|
2486
|
-
const validType = type.trim();
|
|
2487
|
-
if (validType.startsWith(".")) {
|
|
2488
|
-
return file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.toLowerCase().length - validType.toLowerCase().length) > -1;
|
|
2489
|
-
} else if (/\/\*$/.test(validType)) {
|
|
2490
|
-
return baseMimeType === validType.replace(/\/.*$/, "");
|
|
2491
|
-
}
|
|
2492
|
-
return file.type === validType;
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
return true;
|
|
2496
|
-
};
|
|
2497
|
-
const beyondMaximalSize = (fileSize, maximumSize) => {
|
|
2498
|
-
if (maximumSize) {
|
|
2499
|
-
return fileSize > 1024 * 1024 * maximumSize;
|
|
2500
|
-
}
|
|
2501
|
-
return false;
|
|
2502
|
-
};
|
|
2503
|
-
const _validateFiles = (file, accept, uploadOptions) => {
|
|
2504
|
-
if (!isAllowedFileType(accept, file)) {
|
|
2505
|
-
return {
|
|
2506
|
-
checkError: true,
|
|
2507
|
-
errorMsg: getNotAllowedFileTypeMsg(file.name, accept)
|
|
2508
|
-
};
|
|
2509
|
-
}
|
|
2510
|
-
if (uploadOptions && beyondMaximalSize(file.size, uploadOptions.maximumSize)) {
|
|
2511
|
-
return {
|
|
2512
|
-
checkError: true,
|
|
2513
|
-
errorMsg: getBeyondMaximalFileSizeMsg(file.name, uploadOptions.maximumSize)
|
|
2514
|
-
};
|
|
2515
|
-
}
|
|
2516
|
-
return { checkError: false, errorMsg: void 0 };
|
|
2517
|
-
};
|
|
2518
|
-
const triggerSelectFiles = (fileOptions) => {
|
|
2519
|
-
const { multiple, accept, webkitdirectory } = fileOptions;
|
|
2520
|
-
return selectFiles({ multiple, accept, webkitdirectory });
|
|
2521
|
-
};
|
|
2522
|
-
const triggerDropFiles = (files) => {
|
|
2523
|
-
return Promise.resolve(files);
|
|
2524
|
-
};
|
|
2525
|
-
const checkAllFilesSize = (fileSize, maximumSize) => {
|
|
2526
|
-
if (beyondMaximalSize(fileSize, maximumSize)) {
|
|
2527
|
-
BEYOND_MAXIMAL_FILE_SIZE_MSG.value = getAllFilesBeyondMaximalFileSizeMsg(maximumSize);
|
|
2528
|
-
return { checkError: true, errorMsg: BEYOND_MAXIMAL_FILE_SIZE_MSG.value };
|
|
2529
|
-
}
|
|
2530
|
-
};
|
|
2531
|
-
return {
|
|
2532
|
-
triggerSelectFiles,
|
|
2533
|
-
_validateFiles,
|
|
2534
|
-
triggerDropFiles,
|
|
2535
|
-
checkAllFilesSize
|
|
2536
|
-
};
|
|
2537
|
-
};
|
|
2538
2450
|
var upload = "";
|
|
2539
|
-
var Upload = defineComponent({
|
|
2540
|
-
name: "DSingleUpload",
|
|
2541
|
-
props: uploadProps,
|
|
2542
|
-
emits: ["fileDrop", "fileOver", "fileSelect", "successEvent", "errorEvent", "deleteUploadedFileEvent", "update:uploadedFiles"],
|
|
2543
|
-
setup(props, ctx) {
|
|
2544
|
-
const {
|
|
2545
|
-
uploadOptions,
|
|
2546
|
-
fileOptions,
|
|
2547
|
-
placeholderText,
|
|
2548
|
-
autoUpload,
|
|
2549
|
-
withoutBtn,
|
|
2550
|
-
uploadText,
|
|
2551
|
-
disabled,
|
|
2552
|
-
beforeUpload,
|
|
2553
|
-
enableDrop,
|
|
2554
|
-
showTip,
|
|
2555
|
-
uploadedFiles
|
|
2556
|
-
} = toRefs(props);
|
|
2557
|
-
const isDropOVer = ref(false);
|
|
2558
|
-
const {
|
|
2559
|
-
getFiles,
|
|
2560
|
-
fileUploaders,
|
|
2561
|
-
addFile,
|
|
2562
|
-
getFullFiles,
|
|
2563
|
-
deleteFile,
|
|
2564
|
-
upload: upload2,
|
|
2565
|
-
removeFiles
|
|
2566
|
-
} = useUpload();
|
|
2567
|
-
const {
|
|
2568
|
-
triggerSelectFiles,
|
|
2569
|
-
_validateFiles,
|
|
2570
|
-
triggerDropFiles
|
|
2571
|
-
} = useSelectFiles();
|
|
2572
|
-
const filename = computed(() => (getFiles()[0] || {}).name || "");
|
|
2573
|
-
const alertMsg = (errorMsg) => {
|
|
2574
|
-
ToastService.open({
|
|
2575
|
-
value: [{
|
|
2576
|
-
severity: "warn",
|
|
2577
|
-
content: errorMsg
|
|
2578
|
-
}]
|
|
2579
|
-
});
|
|
2580
|
-
};
|
|
2581
|
-
const canUpload = () => {
|
|
2582
|
-
let uploadResult = Promise.resolve(true);
|
|
2583
|
-
if (beforeUpload.value) {
|
|
2584
|
-
const result = beforeUpload.value(getFullFiles()[0] || {});
|
|
2585
|
-
if (typeof result !== "undefined") {
|
|
2586
|
-
if (result.then) {
|
|
2587
|
-
uploadResult = result;
|
|
2588
|
-
} else {
|
|
2589
|
-
uploadResult = Promise.resolve(result);
|
|
2590
|
-
}
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
return uploadResult;
|
|
2594
|
-
};
|
|
2595
|
-
const fileUpload = () => {
|
|
2596
|
-
canUpload().then((canUpload2) => {
|
|
2597
|
-
if (!canUpload2) {
|
|
2598
|
-
return;
|
|
2599
|
-
}
|
|
2600
|
-
upload2().then((results) => {
|
|
2601
|
-
ctx.emit("successEvent", results);
|
|
2602
|
-
const newFiles = results.map((result) => result.file);
|
|
2603
|
-
const newUploadedFiles = [...newFiles, ...uploadedFiles.value];
|
|
2604
|
-
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2605
|
-
}).catch((error) => {
|
|
2606
|
-
console.error(error);
|
|
2607
|
-
if (fileUploaders.value[0]) {
|
|
2608
|
-
fileUploaders.value[0].percentage = 0;
|
|
2609
|
-
}
|
|
2610
|
-
ctx.emit("errorEvent", error);
|
|
2611
|
-
});
|
|
2612
|
-
});
|
|
2613
|
-
};
|
|
2614
|
-
const checkValid = () => {
|
|
2615
|
-
fileUploaders.value.forEach((fileUploader) => {
|
|
2616
|
-
const checkResult = _validateFiles(fileUploader.file, fileOptions.value.accept, fileUploader.uploadOptions);
|
|
2617
|
-
if (checkResult.checkError) {
|
|
2618
|
-
deleteFile(fileUploader.file);
|
|
2619
|
-
alertMsg(checkResult.errorMsg);
|
|
2620
|
-
}
|
|
2621
|
-
});
|
|
2622
|
-
};
|
|
2623
|
-
const _dealFiles = (promise) => {
|
|
2624
|
-
promise.then((files) => {
|
|
2625
|
-
var _a;
|
|
2626
|
-
files.forEach((file2) => {
|
|
2627
|
-
removeFiles();
|
|
2628
|
-
addFile(file2, uploadOptions.value);
|
|
2629
|
-
});
|
|
2630
|
-
checkValid();
|
|
2631
|
-
const file = (_a = fileUploaders.value[0]) == null ? void 0 : _a.file;
|
|
2632
|
-
if (props.onChange) {
|
|
2633
|
-
props.onChange(file);
|
|
2634
|
-
}
|
|
2635
|
-
if (file) {
|
|
2636
|
-
ctx.emit("fileSelect", file);
|
|
2637
|
-
}
|
|
2638
|
-
if (autoUpload.value) {
|
|
2639
|
-
fileUpload();
|
|
2640
|
-
}
|
|
2641
|
-
}).catch((error) => {
|
|
2642
|
-
alertMsg(error.message);
|
|
2643
|
-
});
|
|
2644
|
-
};
|
|
2645
|
-
const handleClick = () => {
|
|
2646
|
-
var _a;
|
|
2647
|
-
if (disabled.value || fileUploaders.value[0] && ((_a = fileUploaders.value[0]) == null ? void 0 : _a.status) === UploadStatus.uploading) {
|
|
2648
|
-
return;
|
|
2649
|
-
}
|
|
2650
|
-
_dealFiles(triggerSelectFiles(fileOptions.value));
|
|
2651
|
-
};
|
|
2652
|
-
const onDeleteFile = (event) => {
|
|
2653
|
-
event.stopPropagation();
|
|
2654
|
-
const files = getFiles();
|
|
2655
|
-
deleteFile(files[0]);
|
|
2656
|
-
};
|
|
2657
|
-
const deleteUploadedFile = (file) => {
|
|
2658
|
-
const newUploadedFiles = uploadedFiles.value.filter((uploadedFile) => {
|
|
2659
|
-
return uploadedFile.name !== file.name;
|
|
2660
|
-
});
|
|
2661
|
-
ctx.emit("deleteUploadedFileEvent", file);
|
|
2662
|
-
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2663
|
-
};
|
|
2664
|
-
const onFileDrop = (files) => {
|
|
2665
|
-
isDropOVer.value = false;
|
|
2666
|
-
_dealFiles(triggerDropFiles(files));
|
|
2667
|
-
ctx.emit("fileDrop", files[0]);
|
|
2668
|
-
};
|
|
2669
|
-
const onFileOver = (event) => {
|
|
2670
|
-
isDropOVer.value = event;
|
|
2671
|
-
ctx.emit("fileOver", event);
|
|
2672
|
-
};
|
|
2673
|
-
return {
|
|
2674
|
-
placeholderText,
|
|
2675
|
-
filename,
|
|
2676
|
-
autoUpload,
|
|
2677
|
-
withoutBtn,
|
|
2678
|
-
fileUploaders,
|
|
2679
|
-
uploadText,
|
|
2680
|
-
handleClick,
|
|
2681
|
-
onDeleteFile,
|
|
2682
|
-
fileUpload,
|
|
2683
|
-
enableDrop,
|
|
2684
|
-
onFileDrop,
|
|
2685
|
-
onFileOver,
|
|
2686
|
-
isDropOVer,
|
|
2687
|
-
showTip,
|
|
2688
|
-
uploadedFiles,
|
|
2689
|
-
deleteUploadedFile
|
|
2690
|
-
};
|
|
2691
|
-
},
|
|
2692
|
-
render() {
|
|
2693
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2694
|
-
const {
|
|
2695
|
-
placeholderText,
|
|
2696
|
-
filename,
|
|
2697
|
-
autoUpload,
|
|
2698
|
-
withoutBtn,
|
|
2699
|
-
fileUploaders,
|
|
2700
|
-
uploadText,
|
|
2701
|
-
handleClick,
|
|
2702
|
-
onDeleteFile,
|
|
2703
|
-
fileUpload,
|
|
2704
|
-
enableDrop,
|
|
2705
|
-
onFileDrop,
|
|
2706
|
-
onFileOver,
|
|
2707
|
-
isDropOVer,
|
|
2708
|
-
disabled,
|
|
2709
|
-
showTip,
|
|
2710
|
-
uploadedFiles,
|
|
2711
|
-
deleteUploadedFile
|
|
2712
|
-
} = this;
|
|
2713
|
-
return createVNode("div", null, [withDirectives(createVNode("div", {
|
|
2714
|
-
"class": "devui-upload",
|
|
2715
|
-
"style": `border: ${isDropOVer ? "1px solid #15bf15" : "0"}`
|
|
2716
|
-
}, [((_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)) ? createVNode("div", {
|
|
2717
|
-
"onClick": handleClick
|
|
2718
|
-
}, [this.$slots.default()]) : createVNode("div", {
|
|
2719
|
-
"class": `devui-input-group ${disabled || ((_c = fileUploaders[0]) == null ? void 0 : _c.status) === UploadStatus.uploading ? "disabled" : ""}`,
|
|
2720
|
-
"onClick": handleClick
|
|
2721
|
-
}, [createVNode("div", {
|
|
2722
|
-
"class": "devui-form-control devui-files-list"
|
|
2723
|
-
}, [!filename && createVNode("div", {
|
|
2724
|
-
"class": "devui-file-item devui-upload-placeholder"
|
|
2725
|
-
}, [placeholderText]), !!filename && createVNode("div", {
|
|
2726
|
-
"class": "devui-file-tag devui-file-item",
|
|
2727
|
-
"title": filename,
|
|
2728
|
-
"style": "display: inline-block; margin: 0 2px 2px 0"
|
|
2729
|
-
}, [createVNode("span", {
|
|
2730
|
-
"class": `devui-filename ${((_d = fileUploaders[0]) == null ? void 0 : _d.status) === UploadStatus.failed ? "devui-failed-color" : ""}`
|
|
2731
|
-
}, [filename]), createVNode(resolveComponent("d-icon"), {
|
|
2732
|
-
"name": "close",
|
|
2733
|
-
"class": `${((_e = fileUploaders[0]) == null ? void 0 : _e.status) === UploadStatus.failed ? "devui-upload-delete-file-button" : ""} ${((_f = fileUploaders[0]) == null ? void 0 : _f.status) === UploadStatus.uploading || ((_g = fileUploaders[0]) == null ? void 0 : _g.status) === UploadStatus.uploaded ? "devui-uploading-delete" : ""}`,
|
|
2734
|
-
"onClick": (event) => onDeleteFile(event)
|
|
2735
|
-
}, null), ((_h = fileUploaders[0]) == null ? void 0 : _h.status) === UploadStatus.uploading && createVNode("div", {
|
|
2736
|
-
"class": "icon devui-upload-progress"
|
|
2737
|
-
}, [createVNode(resolveComponent("d-progress"), {
|
|
2738
|
-
"isCircle": true,
|
|
2739
|
-
"percentage": fileUploaders[0].percentage,
|
|
2740
|
-
"barbgcolor": "#50D4AB",
|
|
2741
|
-
"strokeWidth": 8,
|
|
2742
|
-
"showContent": false
|
|
2743
|
-
}, null)]), fileUploaders[0].status === UploadStatus.failed && createVNode(resolveComponent("d-icon"), {
|
|
2744
|
-
"name": "running",
|
|
2745
|
-
"onClick": fileUpload
|
|
2746
|
-
}, null), fileUploaders[0].status === UploadStatus.uploaded && createVNode(resolveComponent("d-icon"), {
|
|
2747
|
-
"name": "right",
|
|
2748
|
-
"color": "#50d4ab"
|
|
2749
|
-
}, null)])]), createVNode("span", {
|
|
2750
|
-
"class": "devui-input-group-addon"
|
|
2751
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2752
|
-
"name": "more-operate",
|
|
2753
|
-
"color": "#252b3a"
|
|
2754
|
-
}, null)])]), !autoUpload && !withoutBtn && createVNode(resolveComponent("d-button"), {
|
|
2755
|
-
"style": "marginLeft: 8px",
|
|
2756
|
-
"bsStyle": "common",
|
|
2757
|
-
"onClick": fileUpload,
|
|
2758
|
-
"disabled": disabled || ((_i = fileUploaders[0]) == null ? void 0 : _i.status) === UploadStatus.uploading
|
|
2759
|
-
}, {
|
|
2760
|
-
default: () => {
|
|
2761
|
-
var _a2, _b2, _c2, _d2;
|
|
2762
|
-
return [(!fileUploaders[0] || !((_a2 = fileUploaders[0]) == null ? void 0 : _a2.status)) && createVNode("span", null, [uploadText]), ((_b2 = fileUploaders[0]) == null ? void 0 : _b2.status) === UploadStatus.uploading && createVNode("span", null, [createTextVNode("\u4E0A\u4F20\u4E2D...")]), ((_c2 = fileUploaders[0]) == null ? void 0 : _c2.status) === UploadStatus.uploaded && createVNode("span", null, [createTextVNode("\u5DF2\u4E0A\u4F20")]), ((_d2 = fileUploaders[0]) == null ? void 0 : _d2.status) === UploadStatus.failed && createVNode("span", null, [createTextVNode("\u4E0A\u4F20\u5931\u8D25")])];
|
|
2763
|
-
}
|
|
2764
|
-
})]), [[resolveDirective("file-drop"), {
|
|
2765
|
-
enableDrop,
|
|
2766
|
-
isSingle: true,
|
|
2767
|
-
onFileDrop,
|
|
2768
|
-
onFileOver
|
|
2769
|
-
}]]), showTip && createVNode("div", {
|
|
2770
|
-
"class": "devui-upload-tip"
|
|
2771
|
-
}, [((_j = fileUploaders[0]) == null ? void 0 : _j.status) === UploadStatus.uploading && createVNode("span", {
|
|
2772
|
-
"class": "devui-loading"
|
|
2773
|
-
}, [i18nText.uploading]), ((_k = fileUploaders[0]) == null ? void 0 : _k.status) === UploadStatus.uploaded && createVNode("div", {
|
|
2774
|
-
"class": "devui-loaded"
|
|
2775
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2776
|
-
"name": "right-o",
|
|
2777
|
-
"color": "#50d4ab"
|
|
2778
|
-
}, null), createVNode("span", {
|
|
2779
|
-
"style": "vertical-align: middle"
|
|
2780
|
-
}, [i18nText.uploadSuccess])]), ((_l = fileUploaders[0]) == null ? void 0 : _l.status) === UploadStatus.failed && createVNode("div", {
|
|
2781
|
-
"class": "devui-upload-failed"
|
|
2782
|
-
}, [createVNode(resolveComponent("d-icon"), {
|
|
2783
|
-
"name": "info-o",
|
|
2784
|
-
"color": "#f66f6a"
|
|
2785
|
-
}, null), createVNode("span", {
|
|
2786
|
-
"style": "vertical-align: middle"
|
|
2787
|
-
}, [createVNode("span", {
|
|
2788
|
-
"style": "margin-right: 8px"
|
|
2789
|
-
}, [i18nText.uploadFailed]), createVNode("a", {
|
|
2790
|
-
"onClick": fileUpload
|
|
2791
|
-
}, [i18nText.reUpload])])])]), createVNode("div", null, [(_n = (_m = this.$slots).preloadFiles) == null ? void 0 : _n.call(_m, {
|
|
2792
|
-
fileUploaders,
|
|
2793
|
-
deleteFile: onDeleteFile
|
|
2794
|
-
})]), createVNode("div", null, [(_p = (_o = this.$slots).uploadedFiles) == null ? void 0 : _p.call(_o, {
|
|
2795
|
-
uploadedFiles,
|
|
2796
|
-
deleteFile: deleteUploadedFile
|
|
2797
|
-
})])]);
|
|
2798
|
-
}
|
|
2799
|
-
});
|
|
2800
2451
|
function _isSlot(s) {
|
|
2801
2452
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
2802
2453
|
}
|
|
2803
|
-
var
|
|
2804
|
-
name: "
|
|
2805
|
-
props:
|
|
2806
|
-
emits: ["fileDrop", "fileOver", "fileSelect", "
|
|
2454
|
+
var Upload = defineComponent({
|
|
2455
|
+
name: "DUpload",
|
|
2456
|
+
props: uploadProps,
|
|
2457
|
+
emits: ["fileDrop", "fileOver", "fileSelect", "deleteUploadedFile", "update:uploadedFiles"],
|
|
2807
2458
|
setup(props, ctx) {
|
|
2808
2459
|
const {
|
|
2809
2460
|
uploadOptions,
|
|
2810
|
-
fileOptions,
|
|
2811
2461
|
placeholderText,
|
|
2812
2462
|
autoUpload,
|
|
2813
2463
|
withoutBtn,
|
|
@@ -2816,8 +2466,10 @@ var MultiUpload = defineComponent({
|
|
|
2816
2466
|
beforeUpload,
|
|
2817
2467
|
enableDrop,
|
|
2818
2468
|
oneTimeUpload,
|
|
2819
|
-
|
|
2820
|
-
|
|
2469
|
+
uploadedFiles,
|
|
2470
|
+
multiple,
|
|
2471
|
+
accept,
|
|
2472
|
+
webkitdirectory
|
|
2821
2473
|
} = toRefs(props);
|
|
2822
2474
|
const {
|
|
2823
2475
|
triggerSelectFiles,
|
|
@@ -2826,7 +2478,6 @@ var MultiUpload = defineComponent({
|
|
|
2826
2478
|
checkAllFilesSize
|
|
2827
2479
|
} = useSelectFiles();
|
|
2828
2480
|
const {
|
|
2829
|
-
getFiles,
|
|
2830
2481
|
fileUploaders,
|
|
2831
2482
|
addFile,
|
|
2832
2483
|
getFullFiles,
|
|
@@ -2851,7 +2502,7 @@ var MultiUpload = defineComponent({
|
|
|
2851
2502
|
let totalFileSize = 0;
|
|
2852
2503
|
fileUploaders.value.forEach((fileUploader) => {
|
|
2853
2504
|
totalFileSize += fileUploader.file.size;
|
|
2854
|
-
const checkResult = _validateFiles(fileUploader.file,
|
|
2505
|
+
const checkResult = _validateFiles(fileUploader.file, accept.value, fileUploader.uploadOptions);
|
|
2855
2506
|
if (checkResult && checkResult.checkError) {
|
|
2856
2507
|
deleteFile(fileUploader.file);
|
|
2857
2508
|
alertMsg(checkResult.errorMsg);
|
|
@@ -2870,6 +2521,9 @@ var MultiUpload = defineComponent({
|
|
|
2870
2521
|
resetSameNameFiles();
|
|
2871
2522
|
promise.then((files) => {
|
|
2872
2523
|
files.forEach((file) => {
|
|
2524
|
+
if (!multiple.value) {
|
|
2525
|
+
removeFiles();
|
|
2526
|
+
}
|
|
2873
2527
|
addFile(file, uploadOptions.value);
|
|
2874
2528
|
});
|
|
2875
2529
|
checkValid();
|
|
@@ -2880,7 +2534,7 @@ var MultiUpload = defineComponent({
|
|
|
2880
2534
|
const selectedFiles = fileUploaders.value.filter((fileUploader) => fileUploader.status === UploadStatus.preLoad).map((fileUploader) => fileUploader.file);
|
|
2881
2535
|
ctx.emit("fileSelect", selectedFiles);
|
|
2882
2536
|
if (autoUpload.value) {
|
|
2883
|
-
|
|
2537
|
+
fileUpload();
|
|
2884
2538
|
}
|
|
2885
2539
|
}).catch((error) => {
|
|
2886
2540
|
alertMsg(error.message);
|
|
@@ -2890,7 +2544,11 @@ var MultiUpload = defineComponent({
|
|
|
2890
2544
|
if (disabled.value) {
|
|
2891
2545
|
return;
|
|
2892
2546
|
}
|
|
2893
|
-
_dealFiles(triggerSelectFiles(
|
|
2547
|
+
_dealFiles(triggerSelectFiles({
|
|
2548
|
+
accept: accept.value,
|
|
2549
|
+
multiple: multiple.value,
|
|
2550
|
+
webkitdirectory: webkitdirectory.value
|
|
2551
|
+
}));
|
|
2894
2552
|
};
|
|
2895
2553
|
const onFileDrop = (files) => {
|
|
2896
2554
|
isDropOVer.value = false;
|
|
@@ -2901,17 +2559,20 @@ var MultiUpload = defineComponent({
|
|
|
2901
2559
|
isDropOVer.value = event;
|
|
2902
2560
|
ctx.emit("fileOver", event);
|
|
2903
2561
|
};
|
|
2904
|
-
const onDeleteFile = (event, file) => {
|
|
2905
|
-
event.stopPropagation();
|
|
2906
|
-
deleteFile(file);
|
|
2907
|
-
};
|
|
2908
2562
|
const deleteUploadedFile = (file) => {
|
|
2909
2563
|
const newUploadedFiles = uploadedFiles.value.filter((uploadedFile) => {
|
|
2910
2564
|
return uploadedFile.name !== file.name;
|
|
2911
2565
|
});
|
|
2912
|
-
ctx.emit("
|
|
2566
|
+
ctx.emit("deleteUploadedFile", file);
|
|
2913
2567
|
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2914
2568
|
};
|
|
2569
|
+
const onDeleteFile = (event, file, status) => {
|
|
2570
|
+
event.stopPropagation();
|
|
2571
|
+
if (status === UploadStatus.uploaded) {
|
|
2572
|
+
deleteUploadedFile(file);
|
|
2573
|
+
}
|
|
2574
|
+
deleteFile(file);
|
|
2575
|
+
};
|
|
2915
2576
|
const canUpload = () => {
|
|
2916
2577
|
let uploadResult = Promise.resolve(true);
|
|
2917
2578
|
if (beforeUpload.value) {
|
|
@@ -2937,12 +2598,12 @@ var MultiUpload = defineComponent({
|
|
|
2937
2598
|
}
|
|
2938
2599
|
const uploadObservable = oneTimeUpload.value ? _oneTimeUpload() : upload2(fileUploader);
|
|
2939
2600
|
uploadObservable.then((results) => {
|
|
2940
|
-
|
|
2601
|
+
props["on-success"] && props["on-success"](results);
|
|
2941
2602
|
const newFiles = results.map((result) => result.file);
|
|
2942
2603
|
const newUploadedFiles = [...newFiles, ...uploadedFiles.value];
|
|
2943
2604
|
ctx.emit("update:uploadedFiles", newUploadedFiles);
|
|
2944
2605
|
}).catch((error) => {
|
|
2945
|
-
|
|
2606
|
+
props["on-error"] && props["on-error"](error);
|
|
2946
2607
|
});
|
|
2947
2608
|
});
|
|
2948
2609
|
};
|
|
@@ -2987,7 +2648,6 @@ var MultiUpload = defineComponent({
|
|
|
2987
2648
|
};
|
|
2988
2649
|
return {
|
|
2989
2650
|
uploadOptions,
|
|
2990
|
-
fileOptions,
|
|
2991
2651
|
placeholderText,
|
|
2992
2652
|
autoUpload,
|
|
2993
2653
|
withoutBtn,
|
|
@@ -3002,11 +2662,11 @@ var MultiUpload = defineComponent({
|
|
|
3002
2662
|
fileUploaders,
|
|
3003
2663
|
onDeleteFile,
|
|
3004
2664
|
fileUpload,
|
|
3005
|
-
showTip,
|
|
3006
2665
|
getStatus,
|
|
3007
2666
|
uploadTips,
|
|
3008
2667
|
cancelUpload,
|
|
3009
|
-
deleteUploadedFile
|
|
2668
|
+
deleteUploadedFile,
|
|
2669
|
+
multiple
|
|
3010
2670
|
};
|
|
3011
2671
|
},
|
|
3012
2672
|
render() {
|
|
@@ -3017,7 +2677,6 @@ var MultiUpload = defineComponent({
|
|
|
3017
2677
|
withoutBtn,
|
|
3018
2678
|
uploadText,
|
|
3019
2679
|
disabled,
|
|
3020
|
-
beforeUpload,
|
|
3021
2680
|
enableDrop,
|
|
3022
2681
|
isDropOVer,
|
|
3023
2682
|
onFileDrop,
|
|
@@ -3026,14 +2685,11 @@ var MultiUpload = defineComponent({
|
|
|
3026
2685
|
fileUploaders,
|
|
3027
2686
|
onDeleteFile,
|
|
3028
2687
|
fileUpload,
|
|
3029
|
-
showTip,
|
|
3030
|
-
getStatus,
|
|
3031
|
-
uploadTips,
|
|
3032
|
-
cancelUpload,
|
|
3033
2688
|
uploadedFiles,
|
|
3034
|
-
deleteUploadedFile
|
|
2689
|
+
deleteUploadedFile,
|
|
2690
|
+
multiple
|
|
3035
2691
|
} = this;
|
|
3036
|
-
return createVNode(
|
|
2692
|
+
return createVNode("div", null, [withDirectives(createVNode("div", {
|
|
3037
2693
|
"class": "devui-upload",
|
|
3038
2694
|
"style": `border: ${isDropOVer ? "1px solid #15bf15" : "0"}`
|
|
3039
2695
|
}, [((_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)) ? createVNode("div", {
|
|
@@ -3055,7 +2711,7 @@ var MultiUpload = defineComponent({
|
|
|
3055
2711
|
}, [fileUploader.file.name]), createVNode(resolveComponent("d-icon"), {
|
|
3056
2712
|
"name": "close",
|
|
3057
2713
|
"class": `${(fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.failed ? "devui-upload-delete-file-button" : ""} ${(fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.uploading || (fileUploader == null ? void 0 : fileUploader.status) === UploadStatus.uploaded ? "devui-uploading-delete" : ""}`,
|
|
3058
|
-
"onClick": (event) => onDeleteFile(event, fileUploader.file)
|
|
2714
|
+
"onClick": (event) => onDeleteFile(event, fileUploader.file, fileUploader.status)
|
|
3059
2715
|
}, null), fileUploader.status === UploadStatus.uploading && createVNode("div", {
|
|
3060
2716
|
"class": "icon devui-upload-progress"
|
|
3061
2717
|
}, [createVNode(resolveComponent("d-progress"), {
|
|
@@ -3077,14 +2733,14 @@ var MultiUpload = defineComponent({
|
|
|
3077
2733
|
"color": "#252b3a"
|
|
3078
2734
|
}, null)])]), !autoUpload && !withoutBtn && createVNode(resolveComponent("d-button"), {
|
|
3079
2735
|
"style": "marginLeft: 8px",
|
|
3080
|
-
"
|
|
2736
|
+
"btnStyle": "common",
|
|
3081
2737
|
"disabled": disabled,
|
|
3082
2738
|
"onClick": fileUpload
|
|
3083
2739
|
}, _isSlot(uploadText) ? uploadText : {
|
|
3084
2740
|
default: () => [uploadText]
|
|
3085
2741
|
})]), [[resolveDirective("file-drop"), {
|
|
3086
2742
|
enableDrop,
|
|
3087
|
-
isSingle:
|
|
2743
|
+
isSingle: !multiple,
|
|
3088
2744
|
onFileDrop,
|
|
3089
2745
|
onFileOver
|
|
3090
2746
|
}]]), createVNode("div", null, [(_d = (_c = this.$slots).preloadFiles) == null ? void 0 : _d.call(_c, {
|
|
@@ -3148,7 +2804,7 @@ const onDrop = (el, binding) => {
|
|
|
3148
2804
|
if (isSingle) {
|
|
3149
2805
|
onFileDrop && onFileDrop([transfer.files[0]]);
|
|
3150
2806
|
} else {
|
|
3151
|
-
onFileDrop && onFileDrop(transfer.files);
|
|
2807
|
+
onFileDrop && onFileDrop(Array.from(transfer.files));
|
|
3152
2808
|
}
|
|
3153
2809
|
});
|
|
3154
2810
|
};
|
|
@@ -3166,7 +2822,6 @@ const fileDropDirective = {
|
|
|
3166
2822
|
Upload.install = function(app) {
|
|
3167
2823
|
app.directive("file-drop", fileDropDirective);
|
|
3168
2824
|
app.component(Upload.name, Upload);
|
|
3169
|
-
app.component(MultiUpload.name, MultiUpload);
|
|
3170
2825
|
};
|
|
3171
2826
|
var index = {
|
|
3172
2827
|
title: "Upload \u4E0A\u4F20",
|
|
@@ -3176,4 +2831,4 @@ var index = {
|
|
|
3176
2831
|
app.use(Upload);
|
|
3177
2832
|
}
|
|
3178
2833
|
};
|
|
3179
|
-
export {
|
|
2834
|
+
export { Upload, index as default };
|