kouxiangtang 0.0.27-beta.3 → 0.0.27-beta.5
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/AttachmentUploader-DAXdnRlz.js +209 -0
- package/dist/AttachmentUploader-DAXdnRlz.js.map +1 -0
- package/dist/ImageUploader-L6e5K-M0.js +96 -0
- package/dist/ImageUploader-L6e5K-M0.js.map +1 -0
- package/dist/RichTextEditor-DuUZfMzR.js +1777 -0
- package/dist/RichTextEditor-DuUZfMzR.js.map +1 -0
- package/dist/index-BATiLmeA.js +6850 -0
- package/dist/index-BATiLmeA.js.map +1 -0
- package/dist/kouxiangtang.js +25 -0
- package/dist/kouxiangtang.js.map +1 -0
- package/dist/kouxiangtang.umd.cjs +20 -0
- package/dist/kouxiangtang.umd.cjs.map +1 -0
- package/dist/style.css +6 -0
- package/dist/vite.svg +1 -0
- package/package.json +6 -9
- package/src/demo/App.vue +0 -10
- package/src/demo/Layout.vue +0 -9
- package/src/demo/assets/logo.svg +0 -15
- package/src/demo/config.js +0 -26
- package/src/demo/domains/config.js +0 -8
- package/src/demo/domains/platform/post/config.js +0 -10
- package/src/demo/domains/platform/post/fields.js +0 -16
- package/src/demo/domains/platform/post/rest.js +0 -43
- package/src/demo/domains/platform/user/config.js +0 -11
- package/src/demo/domains/platform/user/fields.js +0 -59
- package/src/demo/domains/platform/user/rest.js +0 -52
- package/src/demo/main.js +0 -10
- package/src/demo/page/platform/Home.vue +0 -12
- package/src/demo/page/user/Home.vue +0 -3
- package/src/demo/route/rest-routes.js +0 -24
- package/src/demo/route/routes.js +0 -30
- package/src/demo/side-menus.js +0 -25
- package/src/framework/DataDetailHeader.vue +0 -111
- package/src/framework/DataDetailPage.vue +0 -153
- package/src/framework/DataGrid.vue +0 -237
- package/src/framework/DataList.vue +0 -152
- package/src/framework/DataTable.vue +0 -49
- package/src/framework/DataTableHeader.vue +0 -121
- package/src/framework/DataTablePage.vue +0 -221
- package/src/framework/DomainDescription.vue +0 -166
- package/src/framework/DomainEdit.vue +0 -140
- package/src/framework/DomainNew.vue +0 -86
- package/src/framework/FieldsWrapper.js +0 -91
- package/src/framework/PageActions.vue +0 -63
- package/src/framework/Pagination.vue +0 -100
- package/src/framework/RowActionFormEditor.vue +0 -75
- package/src/framework/RowActions.vue +0 -70
- package/src/framework/TooltipText.vue +0 -50
- package/src/framework/component/EmptyTip.vue +0 -24
- package/src/framework/config-loader.js +0 -52
- package/src/framework/dashboard/DashboardPage.vue +0 -7
- package/src/framework/dashboard/DashboardRow.vue +0 -21
- package/src/framework/define-domain.js +0 -5
- package/src/framework/domain-config.js +0 -148
- package/src/framework/field/attachment/AttachmentUploader.vue +0 -259
- package/src/framework/field/attachment/FieldDisplay.vue +0 -102
- package/src/framework/field/attachment/FieldEditor.vue +0 -78
- package/src/framework/field/attachment/config.js +0 -14
- package/src/framework/field/base-field-config.js +0 -142
- package/src/framework/field/belongs-to/FieldDisplay.vue +0 -117
- package/src/framework/field/belongs-to/FieldEditor.vue +0 -77
- package/src/framework/field/belongs-to/config.js +0 -38
- package/src/framework/field/boolean/FieldDisplay.vue +0 -38
- package/src/framework/field/boolean/FieldEditor.vue +0 -34
- package/src/framework/field/boolean/config.js +0 -14
- package/src/framework/field/cascader/FieldDisplay.vue +0 -37
- package/src/framework/field/cascader/FieldEditor.vue +0 -36
- package/src/framework/field/cascader/config.js +0 -18
- package/src/framework/field/component/config.js +0 -12
- package/src/framework/field/datetime/FieldDisplay.vue +0 -34
- package/src/framework/field/datetime/FieldEditor.vue +0 -37
- package/src/framework/field/datetime/config.js +0 -22
- package/src/framework/field/editor/FieldDisplay.vue +0 -25
- package/src/framework/field/editor/FieldEditor.vue +0 -30
- package/src/framework/field/editor/RichTextEditor.vue +0 -307
- package/src/framework/field/editor/config.js +0 -13
- package/src/framework/field/image/FieldDisplay.vue +0 -87
- package/src/framework/field/image/FieldEditor.vue +0 -31
- package/src/framework/field/image/ImageUploader.vue +0 -143
- package/src/framework/field/image/config.js +0 -13
- package/src/framework/field/images/FieldDisplay.vue +0 -83
- package/src/framework/field/images/FieldEditor.vue +0 -68
- package/src/framework/field/images/ImagesUploader.vue +0 -163
- package/src/framework/field/images/config.js +0 -15
- package/src/framework/field/json/FieldDisplay.vue +0 -53
- package/src/framework/field/json/FieldEditor.vue +0 -40
- package/src/framework/field/json/config.js +0 -13
- package/src/framework/field/row-id/FieldDisplay.vue +0 -53
- package/src/framework/field/row-id/config.js +0 -16
- package/src/framework/field/select/FieldDisplay.vue +0 -91
- package/src/framework/field/select/FieldEditor.vue +0 -69
- package/src/framework/field/select/config.js +0 -18
- package/src/framework/field/string/FieldDisplay.vue +0 -32
- package/src/framework/field/string/FieldEditor.vue +0 -37
- package/src/framework/field/string/config.js +0 -13
- package/src/framework/field/switch/FieldDisplay.vue +0 -38
- package/src/framework/field/switch/FieldEditor.vue +0 -34
- package/src/framework/field/switch/config.js +0 -14
- package/src/framework/field/text/FieldDisplay.vue +0 -34
- package/src/framework/field/text/FieldEditor.vue +0 -38
- package/src/framework/field/text/config.js +0 -13
- package/src/framework/field/tree-select/FieldDisplay.vue +0 -90
- package/src/framework/field/tree-select/FieldEditor.vue +0 -69
- package/src/framework/field/tree-select/config.js +0 -18
- package/src/framework/filters/FiltersEditor.vue +0 -328
- package/src/framework/filters/FiltersRange.vue +0 -120
- package/src/framework/filters/FiltersSorters.vue +0 -152
- package/src/framework/form/FormEditor.vue +0 -82
- package/src/framework/form/PureForm.vue +0 -218
- package/src/framework/index.js +0 -24
- package/src/framework/layout/BaseLayout.vue +0 -75
- package/src/framework/layout/HeaderMenu.vue +0 -314
- package/src/framework/layout/SideBar.vue +0 -49
- package/src/framework/layout/SideBarItem.vue +0 -75
- package/src/framework/page/Detail.vue +0 -59
- package/src/framework/page/DetailTab.vue +0 -54
- package/src/framework/page/List.vue +0 -27
- package/src/framework/rest-client.js +0 -121
- package/src/framework/statistic/Statistic.vue +0 -73
- package/src/framework/statistic/StatisticCard.vue +0 -63
- package/src/framework/statistic/Widget.vue +0 -33
- package/src/framework/store/data-table-store.js +0 -28
- package/src/framework/store/route-history-store.js +0 -52
- package/src/framework/store/table-filter-store.js +0 -81
- package/src/framework/style/main.css +0 -25
- package/src/framework/utils/alert.js +0 -13
- package/src/framework/utils/color.js +0 -36
- package/src/framework/utils/http.js +0 -82
- package/src/framework/utils/route-query.js +0 -16
- package/src/framework/utils/str.js +0 -5
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { computed as $, ref as x, resolveComponent as c, openBlock as d, createElementBlock as T, Fragment as I, createVNode as s, unref as f, normalizeClass as L, withModifiers as S, withCtx as r, createBlock as g, createTextVNode as j, createElementVNode as B, renderList as q, toDisplayString as O, createCommentVNode as W } from "vue";
|
|
2
|
+
import { _ as G, b as H, p as J, e as K, f as Q, a as X } from "./index-BATiLmeA.js";
|
|
3
|
+
import { ElMessage as m, ElLoading as C } from "element-plus";
|
|
4
|
+
const Y = ["src"], Z = { class: "file-type" }, ee = {
|
|
5
|
+
__name: "AttachmentUploader",
|
|
6
|
+
props: {
|
|
7
|
+
pics: {
|
|
8
|
+
type: Array,
|
|
9
|
+
default() {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
limit: { type: Number },
|
|
14
|
+
props: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default() {
|
|
17
|
+
return {
|
|
18
|
+
listType: "picture-card",
|
|
19
|
+
//'text' | 'picture' | 'picture-card'
|
|
20
|
+
limit: 5,
|
|
21
|
+
//最多上传几个文件
|
|
22
|
+
accept: "image/*"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
emits: ["on-success", "on-remove", "on-change"],
|
|
28
|
+
setup(E, { emit: N }) {
|
|
29
|
+
const _ = N, a = E, y = $(() => a.pics.map((e) => {
|
|
30
|
+
const t = e.url.substring(e.url.lastIndexOf(".") + 1);
|
|
31
|
+
if (typeof e.name !== void 0)
|
|
32
|
+
return e.fileType = t, e;
|
|
33
|
+
if (e.url) {
|
|
34
|
+
const o = e.url.split("/");
|
|
35
|
+
return {
|
|
36
|
+
...e,
|
|
37
|
+
name: o[o.length - 1],
|
|
38
|
+
fileType: t
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { ...e, name: e.id, fileType: t };
|
|
42
|
+
})), k = x(""), h = x(!1);
|
|
43
|
+
x(a);
|
|
44
|
+
const U = H().fileUploadUrl;
|
|
45
|
+
`${localStorage.getItem("token")}`;
|
|
46
|
+
const z = (e) => {
|
|
47
|
+
const t = new FileReader();
|
|
48
|
+
return t.readAsDataURL(e), new Promise(function(o, p) {
|
|
49
|
+
return e.type.startsWith("image/") ? (t.onload = async (u) => {
|
|
50
|
+
const i = new Image();
|
|
51
|
+
i.src = u.target.result, i.onload = () => {
|
|
52
|
+
const l = document.createElement("canvas"), v = l.getContext("2d");
|
|
53
|
+
l.width = i.width, l.height = i.height, v.drawImage(i, 0, 0, l.width, l.height), l.toBlob(
|
|
54
|
+
(w) => {
|
|
55
|
+
const n = new File([w], e.name, {
|
|
56
|
+
type: e.type,
|
|
57
|
+
lastModified: Date.now()
|
|
58
|
+
});
|
|
59
|
+
o(n);
|
|
60
|
+
},
|
|
61
|
+
e.type,
|
|
62
|
+
0.5
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
}, !1) : (o(e), !1);
|
|
66
|
+
});
|
|
67
|
+
}, V = (e) => {
|
|
68
|
+
_("on-remove", e);
|
|
69
|
+
}, A = () => {
|
|
70
|
+
m({
|
|
71
|
+
message: `最多只能上传 ${a.props.limit} 个文件!`,
|
|
72
|
+
type: "warning"
|
|
73
|
+
});
|
|
74
|
+
}, D = (e) => {
|
|
75
|
+
k.value = e.url, h.value = !0;
|
|
76
|
+
}, F = (e) => {
|
|
77
|
+
z(e).then((t) => t.size / 1024 / 1024 < 5 ? (M(t), !1) : (m({
|
|
78
|
+
message: "上传大小不能超过 5MB!",
|
|
79
|
+
type: "warning"
|
|
80
|
+
}), !1));
|
|
81
|
+
};
|
|
82
|
+
function P(e, t) {
|
|
83
|
+
if (!e.name) {
|
|
84
|
+
m({
|
|
85
|
+
message: "附件名称不能为空!",
|
|
86
|
+
type: "warning"
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
_("on-change", e);
|
|
91
|
+
}
|
|
92
|
+
function M(e) {
|
|
93
|
+
return C.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((t, o) => {
|
|
94
|
+
const p = new FormData();
|
|
95
|
+
p.append("file", e), X.post(U, p, {}).then((u) => (C.service().close(), m({
|
|
96
|
+
message: "上传成功",
|
|
97
|
+
type: "success"
|
|
98
|
+
}), _("on-success", u.data.data), t(u.data), !1)).catch(() => {
|
|
99
|
+
C.service().close(), m({
|
|
100
|
+
message: "上传失败",
|
|
101
|
+
type: "warning"
|
|
102
|
+
}), o("Upload failed");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return (e, t) => {
|
|
107
|
+
const o = c("el-icon"), p = c("el-button"), u = c("el-upload"), i = c("el-dialog"), l = c("el-input"), v = c("el-form-item"), w = c("el-form");
|
|
108
|
+
return d(), T(I, null, [
|
|
109
|
+
s(u, {
|
|
110
|
+
"file-list": y.value,
|
|
111
|
+
action: f(U),
|
|
112
|
+
limit: a.props.limit,
|
|
113
|
+
accept: a.props.accept,
|
|
114
|
+
"list-type": a.props.listType,
|
|
115
|
+
"on-remove": V,
|
|
116
|
+
"before-upload": F,
|
|
117
|
+
"on-exceed": A,
|
|
118
|
+
"on-preview": D,
|
|
119
|
+
multiple: !0,
|
|
120
|
+
"http-request": () => !1,
|
|
121
|
+
"show-file-list": a.props.listType !== "text",
|
|
122
|
+
class: L([
|
|
123
|
+
"upload-main",
|
|
124
|
+
{ "disable-upload": y.value.length >= a.props.limit }
|
|
125
|
+
]),
|
|
126
|
+
onClick: t[0] || (t[0] = S(() => {
|
|
127
|
+
}, ["prevent"]))
|
|
128
|
+
}, {
|
|
129
|
+
default: r(() => [
|
|
130
|
+
a.props.listType !== "text" ? (d(), g(o, {
|
|
131
|
+
key: 0,
|
|
132
|
+
disabled: !0
|
|
133
|
+
}, {
|
|
134
|
+
default: r(() => [
|
|
135
|
+
s(f(J))
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
})) : (d(), g(p, {
|
|
139
|
+
key: 1,
|
|
140
|
+
class: "upload-button",
|
|
141
|
+
type: "primary"
|
|
142
|
+
}, {
|
|
143
|
+
default: r(() => [
|
|
144
|
+
j("上传附件")
|
|
145
|
+
]),
|
|
146
|
+
_: 1
|
|
147
|
+
}))
|
|
148
|
+
]),
|
|
149
|
+
_: 1
|
|
150
|
+
}, 8, ["file-list", "action", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
151
|
+
s(i, {
|
|
152
|
+
modelValue: h.value,
|
|
153
|
+
"onUpdate:modelValue": t[1] || (t[1] = (n) => h.value = n)
|
|
154
|
+
}, {
|
|
155
|
+
default: r(() => [
|
|
156
|
+
B("img", {
|
|
157
|
+
"w-full": "",
|
|
158
|
+
src: k.value,
|
|
159
|
+
alt: "Preview Image"
|
|
160
|
+
}, null, 8, Y)
|
|
161
|
+
]),
|
|
162
|
+
_: 1
|
|
163
|
+
}, 8, ["modelValue"]),
|
|
164
|
+
a.props.listType == "text" ? (d(), g(w, { key: 0 }, {
|
|
165
|
+
default: r(() => [
|
|
166
|
+
(d(!0), T(I, null, q(y.value, (n, R) => (d(), g(v, {
|
|
167
|
+
key: R,
|
|
168
|
+
class: "file-list"
|
|
169
|
+
}, {
|
|
170
|
+
default: r(() => [
|
|
171
|
+
s(o, {
|
|
172
|
+
color: "#73767a",
|
|
173
|
+
size: 14
|
|
174
|
+
}, {
|
|
175
|
+
default: r(() => [
|
|
176
|
+
s(f(K))
|
|
177
|
+
]),
|
|
178
|
+
_: 1
|
|
179
|
+
}),
|
|
180
|
+
s(l, {
|
|
181
|
+
modelValue: n.name,
|
|
182
|
+
"onUpdate:modelValue": (b) => n.name = b,
|
|
183
|
+
onChange: (b) => P(n)
|
|
184
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"]),
|
|
185
|
+
B("span", Z, "." + O(n.fileType), 1),
|
|
186
|
+
s(o, {
|
|
187
|
+
color: "#73767a",
|
|
188
|
+
size: 12,
|
|
189
|
+
onClick: (b) => V(n)
|
|
190
|
+
}, {
|
|
191
|
+
default: r(() => [
|
|
192
|
+
s(f(Q))
|
|
193
|
+
]),
|
|
194
|
+
_: 2
|
|
195
|
+
}, 1032, ["onClick"])
|
|
196
|
+
]),
|
|
197
|
+
_: 2
|
|
198
|
+
}, 1024))), 128))
|
|
199
|
+
]),
|
|
200
|
+
_: 1
|
|
201
|
+
})) : W("", !0)
|
|
202
|
+
], 64);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}, ne = /* @__PURE__ */ G(ee, [["__scopeId", "data-v-7fb06abf"]]);
|
|
206
|
+
export {
|
|
207
|
+
ne as default
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=AttachmentUploader-DAXdnRlz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentUploader-DAXdnRlz.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\nimport axios from \"axios\";\nimport { getConfig } from \"../../config-loader\";\nimport { ref, computed } from \"vue\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Document, Close } from \"@element-plus/icons-vue\";\n\nconst emit = defineEmits([\"on-success\", \"on-remove\", \"on-change\"]);\nconst props = defineProps({\n pics: {\n type: Array,\n default() {\n return [];\n },\n },\n limit: { type: Number },\n props: {\n type: Object,\n default() {\n return {\n listType: \"picture-card\", //'text' | 'picture' | 'picture-card'\n limit: 5, //最多上传几个文件\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.pics.map((item) => {\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n if (typeof item.name !== undefined) {\n item.fileType = fileType;\n return item;\n }\n\n if (item.url) {\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType: fileType,\n };\n return namedItem;\n }\n\n return { ...item, name: item.id, fileType: fileType };\n });\n});\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst imageUrl = ref(props);\nconst uploadUrl = getConfig().fileUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst compressImg = (file) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n\n return new Promise(function (resolve, reject) {\n if (!file.type.startsWith(\"image/\")) {\n resolve(file);\n return false;\n }\n reader.onload = async (e) => {\n const img = new Image();\n img.src = e.target.result;\n img.onload = () => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n canvas.width = img.width;\n canvas.height = img.height;\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n canvas.toBlob(\n (blob) => {\n const newFile = new File([blob], file.name, {\n type: file.type,\n lastModified: Date.now(),\n });\n resolve(newFile);\n },\n file.type,\n 0.5,\n );\n };\n };\n return false;\n });\n};\nconst handleRemoveSuccess = (uploadFile) => {\n emit(\"on-remove\", uploadFile);\n};\nconst handleExceed = () => {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n};\nconst handlePictureCardPreview = (uploadFile) => {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n};\nconst handleBeforeUpload = (file) => {\n compressImg(file).then((newFile) => {\n if (newFile.size / 1024 / 1024 < 5) {\n uploadRequest(newFile);\n return false;\n } else {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n });\n};\n\nfunction handleFileNameChange(file, index) {\n if (!file.name) {\n ElMessage({\n message: \"附件名称不能为空!\",\n type: \"warning\",\n });\n return;\n }\n emit(\"on-change\", file);\n}\n\nfunction uploadRequest(file) {\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(\"file\", file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n emit(\"on-success\", res.data.data);\n resolve(res.data);\n return false;\n })\n .catch(() => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传失败\",\n type: \"warning\",\n });\n reject(\"Upload failed\");\n });\n });\n}\n</script>\n\n<template>\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\n <el-upload\n :file-list=\"files\"\n :action=\"uploadUrl\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"handleRemoveSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :on-exceed=\"handleExceed\"\n :on-preview=\"handlePictureCardPreview\"\n :multiple=\"true\"\n :http-request=\"\n () => {\n return false;\n }\n \"\n :show-file-list=\"props.props.listType !== 'text'\"\n :class=\"[\n 'upload-main',\n { 'disable-upload': files.length >= props.props.limit },\n ]\"\n @click.prevent\n >\n <template v-if=\"props.props.listType !== 'text'\">\n <el-icon :disabled=\"true\">\n <Plus />\n </el-icon>\n </template>\n <template v-else>\n <el-button class=\"upload-button\" type=\"primary\">上传附件</el-button>\n </template>\n </el-upload>\n <el-dialog v-model=\"dialogVisible\">\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\n </el-dialog>\n <el-form v-if=\"props.props.listType == 'text'\">\n <el-form-item v-for=\"(file, index) in files\" :key=\"index\" class=\"file-list\">\n <el-icon color=\"#73767a\" :size=\"14\">\n <Document />\n </el-icon>\n <el-input\n v-model=\"file.name\"\n @change=\"handleFileNameChange(file, index)\"\n />\n <span class=\"file-type\">.{{ file.fileType }}</span>\n <el-icon color=\"#73767a\" :size=\"12\" @click=\"handleRemoveSuccess(file)\">\n <Close />\n </el-icon>\n </el-form-item>\n </el-form>\n</template>\n<style scoped lang=\"scss\">\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n\n.disable-upload {\n :deep(.el-upload--picture-card) {\n display: none !important;\n }\n\n :deep(.el-upload--text) {\n display: none !important;\n }\n\n :deep(.el-upload--picture) {\n display: none !important;\n }\n}\n.upload-main {\n flex-basis: 100%;\n}\n.file-list {\n display: flex;\n align-items: center;\n margin-top: 10px;\n .file-type {\n height: 22px;\n line-height: 22px;\n margin-right: 5px;\n background: #eeeeee;\n border-radius: 4px;\n font-size: 12px;\n padding: 0 4px;\n }\n :deep(.el-form-item__content) {\n display: contents;\n }\n :deep(.el-input__wrapper) {\n margin: 0 5px;\n }\n :deep(.el-input__inner) {\n height: 20px;\n line-height: 20px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","files","computed","item","fileType","parts","dialogImageUrl","ref","dialogVisible","uploadUrl","getConfig","compressImg","file","reader","resolve","reject","e","img","canvas","ctx","blob","newFile","handleRemoveSuccess","uploadFile","handleExceed","ElMessage","handlePictureCardPreview","handleBeforeUpload","uploadRequest","handleFileNameChange","index","ElLoading","formData","axios","res"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAQC,GAoBRC,IAAQC,EAAS,MACdH,EAAM,KAAK,IAAI,CAACI,MAAS;AAC9B,YAAMC,IAAWD,EAAK,IAAI,UAAUA,EAAK,IAAI,YAAY,GAAG,IAAI,CAAC;AACjE,UAAI,OAAOA,EAAK,SAAS;AACvB,eAAAA,EAAK,WAAWC,GACTD;AAGT,UAAIA,EAAK,KAAK;AACZ,cAAME,IAAQF,EAAK,IAAI,MAAM,GAAG;AAMhC,eALkB;AAAA,UAChB,GAAGA;AAAA,UACH,MAAME,EAAMA,EAAM,SAAS,CAAC;AAAA,UAC5B,UAAUD;AAAA,QAClB;AAAA,MAEK;AAED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"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { openBlock as t, createBlock as o, unref as e, withCtx as s, renderSlot as I, createElementVNode as b, createVNode as l, withModifiers as v, createCommentVNode as E } from "vue";
|
|
2
|
+
import { ElUpload as x, ElImage as B, ElIcon as n, ElMessage as i, ElLoading as d } from "element-plus";
|
|
3
|
+
import { _ as M, b as C, l as S, p as L, d as N, a as V } from "./index-BATiLmeA.js";
|
|
4
|
+
const q = { class: "image-slot" }, z = {
|
|
5
|
+
__name: "ImageUploader",
|
|
6
|
+
props: {
|
|
7
|
+
imageUrl: { type: String }
|
|
8
|
+
},
|
|
9
|
+
emits: ["on-success"],
|
|
10
|
+
setup(f, { emit: g }) {
|
|
11
|
+
const m = g, r = f, p = C().imageUploadUrl;
|
|
12
|
+
`${localStorage.getItem("token")}`;
|
|
13
|
+
const _ = (a) => {
|
|
14
|
+
if (!(a.size / 1024 / 1024 < 5))
|
|
15
|
+
return i({
|
|
16
|
+
message: "上传大小不能超过 5MB!",
|
|
17
|
+
type: "warning"
|
|
18
|
+
}), !1;
|
|
19
|
+
}, U = (a) => {
|
|
20
|
+
m("on-success", a.data.imageUrl);
|
|
21
|
+
};
|
|
22
|
+
function h() {
|
|
23
|
+
m("on-success", "");
|
|
24
|
+
}
|
|
25
|
+
function k(a) {
|
|
26
|
+
return d.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((c, w) => {
|
|
27
|
+
const u = new FormData();
|
|
28
|
+
u.append("image", a.file), V.post(p, u, {}).then((y) => {
|
|
29
|
+
d.service().close(), i({
|
|
30
|
+
message: "上传成功",
|
|
31
|
+
type: "success"
|
|
32
|
+
}), c(y.data);
|
|
33
|
+
}).catch(() => {
|
|
34
|
+
d.service().close(), i({
|
|
35
|
+
message: "上传失败",
|
|
36
|
+
type: "warning"
|
|
37
|
+
}), w("Upload failed");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return (a, c) => (t(), o(e(x), {
|
|
42
|
+
class: "image-uploader",
|
|
43
|
+
action: e(p),
|
|
44
|
+
name: "image",
|
|
45
|
+
"show-file-list": !1,
|
|
46
|
+
"on-success": U,
|
|
47
|
+
"before-upload": _,
|
|
48
|
+
"http-request": k
|
|
49
|
+
}, {
|
|
50
|
+
default: s(() => [
|
|
51
|
+
I(a.$slots, "default", {}, void 0, !0),
|
|
52
|
+
r.imageUrl ? (t(), o(e(B), {
|
|
53
|
+
key: 0,
|
|
54
|
+
class: "image",
|
|
55
|
+
src: r.imageUrl,
|
|
56
|
+
fit: "scale-down"
|
|
57
|
+
}, {
|
|
58
|
+
placeholder: s(() => [
|
|
59
|
+
b("div", q, [
|
|
60
|
+
l(e(n), { class: "placeholder-icon" }, {
|
|
61
|
+
default: s(() => [
|
|
62
|
+
l(e(S))
|
|
63
|
+
]),
|
|
64
|
+
_: 1
|
|
65
|
+
})
|
|
66
|
+
])
|
|
67
|
+
]),
|
|
68
|
+
_: 1
|
|
69
|
+
}, 8, ["src"])) : (t(), o(e(n), {
|
|
70
|
+
key: 1,
|
|
71
|
+
class: "uploader-icon"
|
|
72
|
+
}, {
|
|
73
|
+
default: s(() => [
|
|
74
|
+
l(e(L))
|
|
75
|
+
]),
|
|
76
|
+
_: 1
|
|
77
|
+
})),
|
|
78
|
+
r.imageUrl ? (t(), o(e(n), {
|
|
79
|
+
key: 2,
|
|
80
|
+
class: "delete-icon",
|
|
81
|
+
onClick: v(h, ["stop", "prevent"])
|
|
82
|
+
}, {
|
|
83
|
+
default: s(() => [
|
|
84
|
+
l(e(N))
|
|
85
|
+
]),
|
|
86
|
+
_: 1
|
|
87
|
+
})) : E("", !0)
|
|
88
|
+
]),
|
|
89
|
+
_: 3
|
|
90
|
+
}, 8, ["action"]));
|
|
91
|
+
}
|
|
92
|
+
}, F = /* @__PURE__ */ M(z, [["__scopeId", "data-v-ae965bb4"]]);
|
|
93
|
+
export {
|
|
94
|
+
F as default
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=ImageUploader-L6e5K-M0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageUploader-L6e5K-M0.js","sources":["../src/framework/field/image/ImageUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElImage, ElIcon } from \"element-plus\";\nimport axios from \"axios\";\nimport { getConfig } from \"../../config-loader\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Delete, Loading } from \"@element-plus/icons-vue\";\n\nconst emit = defineEmits([\"on-success\"]);\nconst props = defineProps({\n imageUrl: { type: String },\n});\nconst uploadUrl = getConfig().imageUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst handleBeforeUpload = (uploadFile) => {\n const isLt2M = uploadFile.size / 1024 / 1024 < 5;\n if (!isLt2M) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n};\nconst handleSuccess = (response) => {\n emit(\"on-success\", response.data.imageUrl);\n};\n\nfunction deleteImageUrl() {\n emit(\"on-success\", \"\");\n}\n\nfunction uploadRequest(file) {\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(\"image\", file.file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n resolve(res.data);\n })\n .catch(() => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传失败\",\n type: \"warning\",\n });\n reject(\"Upload failed\");\n });\n });\n}\n</script>\n\n<template>\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\n <el-upload\n class=\"image-uploader\"\n :action=\"uploadUrl\"\n name=\"image\"\n :show-file-list=\"false\"\n :on-success=\"handleSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :http-request=\"uploadRequest\"\n >\n <slot />\n <el-image\n v-if=\"props.imageUrl\"\n class=\"image\"\n :src=\"props.imageUrl\"\n fit=\"scale-down\"\n >\n <template #placeholder>\n <div class=\"image-slot\">\n <el-icon class=\"placeholder-icon\">\n <Loading />\n </el-icon>\n </div>\n </template>\n </el-image>\n <el-icon v-else class=\"uploader-icon\">\n <Plus />\n </el-icon>\n <el-icon\n v-if=\"props.imageUrl\"\n class=\"delete-icon\"\n @click.stop.prevent=\"deleteImageUrl\"\n >\n <Delete />\n </el-icon>\n </el-upload>\n</template>\n\n<style scoped lang=\"scss\">\n.image-uploader {\n :deep(.el-upload) {\n border: 1px dashed var(--el-border-color);\n border-radius: 6px;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n transition: var(--el-transition-duration-fast);\n\n &:hover {\n border-color: var(--el-color-primary);\n }\n }\n\n .image {\n width: 146px;\n height: 146px;\n\n .placeholder-icon {\n width: 146px;\n height: 146px;\n font-size: 30px;\n color: #a7a7a7;\n }\n }\n\n .uploader-icon {\n font-size: 28px;\n color: #8c939d;\n width: 146px;\n height: 146px;\n text-align: center;\n }\n\n .delete-icon {\n font-size: 20px;\n color: #b7b4b4;\n position: absolute;\n top: 10px;\n right: 10px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","uploadUrl","getConfig","handleBeforeUpload","uploadFile","ElMessage","handleSuccess","response","deleteImageUrl","uploadRequest","file","ElLoading","resolve","reject","formData","axios","res"],"mappings":";;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAQC,GAGRC,IAAYC,EAAW,EAAC;AACf,IACY,gBAAa,QAAQ,OAAO;AAEvD,UAAMC,IAAqB,CAACC,MAAe;AAEzC,UAAI,EADWA,EAAW,OAAO,OAAO,OAAO;AAE7C,eAAAC,EAAU;AAAA,UACR,SAAS;AAAA,UACT,MAAM;AAAA,QACZ,CAAK,GACM;AAAA,IAEX,GACMC,IAAgB,CAACC,MAAa;AAClC,MAAAV,EAAK,cAAcU,EAAS,KAAK,QAAQ;AAAA,IAC3C;AAEA,aAASC,IAAiB;AACxB,MAAAX,EAAK,cAAc,EAAE;AAAA,IACvB;AAEA,aAASY,EAAcC,GAAM;AAC3B,aAAAC,EAAU,QAAQ,EAAE,MAAM,WAAW,YAAY,kBAAiB,CAAE,GAC7D,IAAI,QAAQ,CAACC,GAASC,MAAW;AACtC,cAAMC,IAAW,IAAI;AACrB,QAAAA,EAAS,OAAO,SAASJ,EAAK,IAAI,GAClCK,EACG,KAAKd,GAAWa,GAAU,EAAE,EAC5B,KAAK,CAACE,MAAQ;AACb,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDO,EAAQI,EAAI,IAAI;AAAA,QACxB,CAAO,EACA,MAAM,MAAM;AACX,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDQ,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|