lew-ui 2.5.9 → 2.5.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.
|
@@ -7,6 +7,11 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
7
7
|
default: string;
|
|
8
8
|
description: string;
|
|
9
9
|
};
|
|
10
|
+
immediate: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
10
15
|
multiple: {
|
|
11
16
|
type: BooleanConstructor;
|
|
12
17
|
default: boolean;
|
|
@@ -66,6 +71,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
66
71
|
};
|
|
67
72
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
68
73
|
change: (...args: any[]) => void;
|
|
74
|
+
delete: (...args: any[]) => void;
|
|
69
75
|
}, string, import('vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
70
76
|
modelValue: import('vue').PropType<UploadFileItem[]>;
|
|
71
77
|
accept: {
|
|
@@ -73,6 +79,11 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
73
79
|
default: string;
|
|
74
80
|
description: string;
|
|
75
81
|
};
|
|
82
|
+
immediate: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
default: boolean;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
76
87
|
multiple: {
|
|
77
88
|
type: BooleanConstructor;
|
|
78
89
|
default: boolean;
|
|
@@ -132,6 +143,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
132
143
|
};
|
|
133
144
|
}>> & Readonly<{
|
|
134
145
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
146
|
+
onDelete?: ((...args: any[]) => any) | undefined;
|
|
135
147
|
}>, {
|
|
136
148
|
size: import('../../..').LewSize;
|
|
137
149
|
tips: string;
|
|
@@ -139,6 +151,7 @@ declare const _default: import('vue').DefineComponent<globalThis.ExtractPropType
|
|
|
139
151
|
readonly: boolean;
|
|
140
152
|
multiple: boolean;
|
|
141
153
|
accept: string;
|
|
154
|
+
immediate: boolean;
|
|
142
155
|
limit: number;
|
|
143
156
|
maxFileSize: number;
|
|
144
157
|
uploadHelper: Function;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ExtractPropTypes } from 'vue';
|
|
2
2
|
import { LewSize } from '../../..';
|
|
3
3
|
|
|
4
|
-
export type UploadStatus = 'success' | 'fail' | 'uploading' | '
|
|
4
|
+
export type UploadStatus = 'success' | 'fail' | 'uploading' | 'complete' | 'wrong_type' | 'wrong_size' | 'pending';
|
|
5
5
|
export type UploadFileItem = {
|
|
6
|
-
|
|
6
|
+
key: string;
|
|
7
7
|
name?: string;
|
|
8
8
|
url?: string;
|
|
9
9
|
status?: UploadStatus;
|
|
@@ -11,7 +11,7 @@ export type UploadFileItem = {
|
|
|
11
11
|
file?: File;
|
|
12
12
|
size?: number;
|
|
13
13
|
type?: string;
|
|
14
|
-
lastModifiedDate?:
|
|
14
|
+
lastModifiedDate?: string;
|
|
15
15
|
lastModified?: number;
|
|
16
16
|
};
|
|
17
17
|
export declare const uploadProps: {
|
|
@@ -20,6 +20,11 @@ export declare const uploadProps: {
|
|
|
20
20
|
default: string;
|
|
21
21
|
description: string;
|
|
22
22
|
};
|
|
23
|
+
immediate: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: boolean;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
23
28
|
multiple: {
|
|
24
29
|
type: BooleanConstructor;
|
|
25
30
|
default: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -19314,6 +19314,11 @@ const uploadProps = {
|
|
|
19314
19314
|
default: "",
|
|
19315
19315
|
description: "允许上传的文件类型"
|
|
19316
19316
|
},
|
|
19317
|
+
immediate: {
|
|
19318
|
+
type: Boolean,
|
|
19319
|
+
default: true,
|
|
19320
|
+
description: "是否在选择文件后立即上传,为false时仅保存文件信息不上传"
|
|
19321
|
+
},
|
|
19317
19322
|
multiple: {
|
|
19318
19323
|
type: Boolean,
|
|
19319
19324
|
default: false,
|
|
@@ -19437,19 +19442,19 @@ const uploadByCardProps = {
|
|
|
19437
19442
|
}
|
|
19438
19443
|
};
|
|
19439
19444
|
const statusMap = {
|
|
19445
|
+
pending: "待上传",
|
|
19440
19446
|
success: "上传成功",
|
|
19441
19447
|
fail: "上传失败",
|
|
19442
19448
|
uploading: "上传中",
|
|
19443
|
-
wrong_config: "未配置上传服务",
|
|
19444
19449
|
complete: "已上传",
|
|
19445
19450
|
wrong_type: "非法格式",
|
|
19446
19451
|
wrong_size: "文件大小超出限制"
|
|
19447
19452
|
};
|
|
19448
19453
|
const statusColorMap = {
|
|
19454
|
+
pending: "gray",
|
|
19449
19455
|
success: "green",
|
|
19450
19456
|
fail: "red",
|
|
19451
19457
|
uploading: "blue",
|
|
19452
|
-
wrong_config: "warning",
|
|
19453
19458
|
complete: "gray",
|
|
19454
19459
|
wrong_type: "red",
|
|
19455
19460
|
wrong_size: "red"
|
|
@@ -19525,7 +19530,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19525
19530
|
default: withCtx(() => [
|
|
19526
19531
|
(openBlock(true), createElementBlock(Fragment, null, renderList(modelValue2.value, (item) => {
|
|
19527
19532
|
return openBlock(), createBlock(unref(LewFlex), {
|
|
19528
|
-
key: item.
|
|
19533
|
+
key: item.key || item.url,
|
|
19529
19534
|
class: "lew-upload-file-item",
|
|
19530
19535
|
mode: "between",
|
|
19531
19536
|
gap: "8",
|
|
@@ -19564,7 +19569,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19564
19569
|
default: withCtx(() => [
|
|
19565
19570
|
item.status === "fail" ? (openBlock(), createBlock(unref(LewFlex), {
|
|
19566
19571
|
key: 0,
|
|
19567
|
-
onClick: withModifiers(($event) => emit2("reUpload", item.
|
|
19572
|
+
onClick: withModifiers(($event) => emit2("reUpload", item.key), ["stop"]),
|
|
19568
19573
|
x: "center",
|
|
19569
19574
|
y: "center",
|
|
19570
19575
|
style: normalizeStyle({
|
|
@@ -19583,7 +19588,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19583
19588
|
_: 2
|
|
19584
19589
|
}, 1032, ["onClick", "style"])) : createCommentVNode("", true),
|
|
19585
19590
|
createVNode(unref(LewFlex), {
|
|
19586
|
-
onClick: withModifiers(($event) => emit2("deleteFile", item.
|
|
19591
|
+
onClick: withModifiers(($event) => emit2("deleteFile", item.key), ["stop"]),
|
|
19587
19592
|
x: "center",
|
|
19588
19593
|
y: "center",
|
|
19589
19594
|
style: normalizeStyle({
|
|
@@ -19616,7 +19621,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19616
19621
|
createVNode(unref(LewTextTrim), {
|
|
19617
19622
|
text: unref(getFileName)(item),
|
|
19618
19623
|
style: normalizeStyle({
|
|
19619
|
-
width: `calc(100% -
|
|
19624
|
+
width: `calc(100% - 30px)`,
|
|
19620
19625
|
fontSize: `${unref(any2px)(fileNameFontSizeMap[_ctx.size])}`
|
|
19621
19626
|
}),
|
|
19622
19627
|
class: "lew-upload-file-name"
|
|
@@ -19672,7 +19677,8 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19672
19677
|
x: "end"
|
|
19673
19678
|
}, {
|
|
19674
19679
|
default: withCtx(() => [
|
|
19675
|
-
|
|
19680
|
+
item.status && item.status !== "pending" ? (openBlock(), createBlock(unref(_sfc_main$Z), {
|
|
19681
|
+
key: 0,
|
|
19676
19682
|
type: "light",
|
|
19677
19683
|
size: "small",
|
|
19678
19684
|
color: unref(statusColorMap)[item.status || "complete"]
|
|
@@ -19689,7 +19695,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19689
19695
|
createTextVNode(" " + toDisplayString(unref(statusMap)[item.status || "complete"]), 1)
|
|
19690
19696
|
]),
|
|
19691
19697
|
_: 2
|
|
19692
|
-
}, 1032, ["color"])
|
|
19698
|
+
}, 1032, ["color"])) : createCommentVNode("", true)
|
|
19693
19699
|
]),
|
|
19694
19700
|
_: 2
|
|
19695
19701
|
}, 1024)
|
|
@@ -19714,7 +19720,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
19714
19720
|
};
|
|
19715
19721
|
}
|
|
19716
19722
|
});
|
|
19717
|
-
const LewUploadByList = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-
|
|
19723
|
+
const LewUploadByList = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-684e2049"]]);
|
|
19718
19724
|
const _hoisted_1$e = ["src"];
|
|
19719
19725
|
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
19720
19726
|
__name: "LewUploadByCard",
|
|
@@ -19769,7 +19775,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19769
19775
|
default: withCtx(() => [
|
|
19770
19776
|
(openBlock(true), createElementBlock(Fragment, null, renderList(modelValue2.value, (item) => {
|
|
19771
19777
|
return openBlock(), createBlock(unref(LewFlex), {
|
|
19772
|
-
key: item.
|
|
19778
|
+
key: item.key || item.url,
|
|
19773
19779
|
class: "lew-upload-file-item",
|
|
19774
19780
|
mode: "between",
|
|
19775
19781
|
gap: "8",
|
|
@@ -19781,7 +19787,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19781
19787
|
default: withCtx(() => [
|
|
19782
19788
|
item.status === "fail" ? (openBlock(), createBlock(unref(LewFlex), {
|
|
19783
19789
|
key: 0,
|
|
19784
|
-
onClick: withModifiers(($event) => emit2("reUpload", item.
|
|
19790
|
+
onClick: withModifiers(($event) => emit2("reUpload", item.key), ["stop"]),
|
|
19785
19791
|
x: "center",
|
|
19786
19792
|
y: "center",
|
|
19787
19793
|
style: normalizeStyle({
|
|
@@ -19798,7 +19804,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19798
19804
|
}, null, 8, ["size"])
|
|
19799
19805
|
]),
|
|
19800
19806
|
_: 2
|
|
19801
|
-
}, 1032, ["onClick", "style"])) : item.status && !["complete", "success"].includes(item.status) ? withDirectives((openBlock(), createBlock(unref(LewFlex), {
|
|
19807
|
+
}, 1032, ["onClick", "style"])) : item.status && !["complete", "success", "none", "uploading"].includes(item.status) ? withDirectives((openBlock(), createBlock(unref(LewFlex), {
|
|
19802
19808
|
key: 1,
|
|
19803
19809
|
x: "center",
|
|
19804
19810
|
y: "center",
|
|
@@ -19824,7 +19830,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19824
19830
|
}]
|
|
19825
19831
|
]) : createCommentVNode("", true),
|
|
19826
19832
|
createVNode(unref(LewFlex), {
|
|
19827
|
-
onClick: withModifiers(($event) => emit2("deleteFile", item.
|
|
19833
|
+
onClick: withModifiers(($event) => emit2("deleteFile", item.key), ["stop"]),
|
|
19828
19834
|
x: "center",
|
|
19829
19835
|
y: "center",
|
|
19830
19836
|
style: normalizeStyle({
|
|
@@ -19909,7 +19915,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19909
19915
|
};
|
|
19910
19916
|
}
|
|
19911
19917
|
});
|
|
19912
|
-
const LewUploadByCard = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-
|
|
19918
|
+
const LewUploadByCard = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-7d6c26c0"]]);
|
|
19913
19919
|
const _hoisted_1$d = ["multiple", "accept"];
|
|
19914
19920
|
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
19915
19921
|
__name: "LewUpload",
|
|
@@ -19917,7 +19923,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19917
19923
|
"modelValue": {},
|
|
19918
19924
|
"modelModifiers": {}
|
|
19919
19925
|
}),
|
|
19920
|
-
emits: /* @__PURE__ */ mergeModels(["change"], ["update:modelValue"]),
|
|
19926
|
+
emits: /* @__PURE__ */ mergeModels(["change", "delete"], ["update:modelValue"]),
|
|
19921
19927
|
setup(__props2, { emit: __emit2 }) {
|
|
19922
19928
|
var _a;
|
|
19923
19929
|
const props2 = __props2;
|
|
@@ -19976,7 +19982,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19976
19982
|
if ((files || []).length > 0) {
|
|
19977
19983
|
const item = files.pop();
|
|
19978
19984
|
const { size, type, name, lastModifiedDate, lastModified } = item;
|
|
19979
|
-
let status = "
|
|
19985
|
+
let status = "pending";
|
|
19980
19986
|
if (!checkFileAccept({ ...item, file: item })) {
|
|
19981
19987
|
status = "wrong_type";
|
|
19982
19988
|
}
|
|
@@ -19984,7 +19990,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19984
19990
|
status = "wrong_size";
|
|
19985
19991
|
}
|
|
19986
19992
|
const fileItem = {
|
|
19987
|
-
|
|
19993
|
+
key: getUniqueId(),
|
|
19988
19994
|
status,
|
|
19989
19995
|
size,
|
|
19990
19996
|
type,
|
|
@@ -19996,8 +20002,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19996
20002
|
modelValue2.value = [fileItem, ...cloneDeep(modelValue2.value || [])];
|
|
19997
20003
|
emit2("change", modelValue2.value);
|
|
19998
20004
|
nextTick(() => {
|
|
19999
|
-
if (
|
|
20000
|
-
|
|
20005
|
+
if (status === "pending" && isFunction(_uploadHelper.value)) {
|
|
20006
|
+
setFileItem({ key: fileItem.key, status: "uploading", percent: 0 });
|
|
20007
|
+
_uploadHelper.value({ fileItem: cloneDeep(fileItem), setFileItem });
|
|
20001
20008
|
}
|
|
20002
20009
|
setTimeout(() => {
|
|
20003
20010
|
if ((modelValue2.value || []).length < props2.limit) {
|
|
@@ -20007,12 +20014,12 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
20007
20014
|
});
|
|
20008
20015
|
}
|
|
20009
20016
|
};
|
|
20010
|
-
const deleteFile = (
|
|
20017
|
+
const deleteFile = (key) => {
|
|
20011
20018
|
let fileList = cloneDeep(modelValue2.value) || [];
|
|
20012
|
-
const index2 = (fileList || []).findIndex((e) => e.
|
|
20019
|
+
const index2 = (fileList || []).findIndex((e) => e.key === key);
|
|
20013
20020
|
if (index2 >= 0) {
|
|
20014
20021
|
const { status } = fileList[index2];
|
|
20015
|
-
if (["wrong_type", "wrong_size", "
|
|
20022
|
+
if (["wrong_type", "wrong_size", "pending"].includes(status || "")) {
|
|
20016
20023
|
fileList.splice(index2, 1);
|
|
20017
20024
|
modelValue2.value = fileList;
|
|
20018
20025
|
} else {
|
|
@@ -20025,18 +20032,21 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
20025
20032
|
ok: () => {
|
|
20026
20033
|
fileList.splice(index2, 1);
|
|
20027
20034
|
modelValue2.value = fileList;
|
|
20035
|
+
emit2("delete", key);
|
|
20028
20036
|
return true;
|
|
20029
20037
|
}
|
|
20030
20038
|
});
|
|
20031
20039
|
}
|
|
20032
20040
|
}
|
|
20033
20041
|
};
|
|
20034
|
-
const reUpload = (
|
|
20035
|
-
const index2 = (modelValue2.value || []).findIndex((e) => e.
|
|
20042
|
+
const reUpload = (key) => {
|
|
20043
|
+
const index2 = (modelValue2.value || []).findIndex((e) => e.key === key);
|
|
20036
20044
|
if (index2 >= 0) {
|
|
20037
20045
|
const item = (modelValue2.value || [])[index2];
|
|
20038
|
-
|
|
20039
|
-
|
|
20046
|
+
if (isFunction(_uploadHelper.value)) {
|
|
20047
|
+
setFileItem({ key, percent: 0, status: "uploading" });
|
|
20048
|
+
_uploadHelper.value({ fileItem: cloneDeep(item), setFileItem });
|
|
20049
|
+
}
|
|
20040
20050
|
} else {
|
|
20041
20051
|
LewMessage.error("文件不存在");
|
|
20042
20052
|
}
|
|
@@ -20108,9 +20118,9 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
20108
20118
|
});
|
|
20109
20119
|
});
|
|
20110
20120
|
const setFileItem = (item) => {
|
|
20111
|
-
const {
|
|
20121
|
+
const { key, percent } = item;
|
|
20112
20122
|
let fileList = cloneDeep(modelValue2.value) || [];
|
|
20113
|
-
const index2 = (fileList || []).findIndex((e) => e.
|
|
20123
|
+
const index2 = (fileList || []).findIndex((e) => e.key === key);
|
|
20114
20124
|
let _percent = percent || 0;
|
|
20115
20125
|
if (index2 >= 0) {
|
|
20116
20126
|
if (percent) {
|
|
@@ -20250,7 +20260,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
20250
20260
|
};
|
|
20251
20261
|
}
|
|
20252
20262
|
});
|
|
20253
|
-
const LewUpload = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-
|
|
20263
|
+
const LewUpload = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-9a9115eb"]]);
|
|
20254
20264
|
const tableModel = {
|
|
20255
20265
|
selectedKeys: {
|
|
20256
20266
|
type: [Array, String, Number, void 0],
|