kouxiangtang 0.0.77 → 0.0.79
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 +48 -4
- package/dist/{AttachmentUploader-VeuPJ5r2.js → AttachmentUploader-CNRraZtx.js} +68 -56
- package/dist/AttachmentUploader-CNRraZtx.js.map +1 -0
- package/dist/{ImageUploader-KaQt6Hgh.js → ImageUploader-Bjfhrzw7.js} +4 -4
- package/dist/{ImageUploader-KaQt6Hgh.js.map → ImageUploader-Bjfhrzw7.js.map} +1 -1
- package/dist/{ImagesUploader-C0CS_P7-.js → ImagesUploader-DETYCvHu.js} +45 -34
- package/dist/ImagesUploader-DETYCvHu.js.map +1 -0
- package/dist/{RichTextEditor-0GJsHXVB.js → RichTextEditor-CnEVXr9n.js} +2 -2
- package/dist/{RichTextEditor-0GJsHXVB.js.map → RichTextEditor-CnEVXr9n.js.map} +1 -1
- package/dist/{config-DqTcnHXu.js → config-2_Cr-n4i.js} +2 -2
- package/dist/{config-DqTcnHXu.js.map → config-2_Cr-n4i.js.map} +1 -1
- package/dist/{config-BIHanElz.js → config-2s11rv4U.js} +3 -3
- package/dist/{config-BIHanElz.js.map → config-2s11rv4U.js.map} +1 -1
- package/dist/{config-BwmOXgir.js → config-B3rFCdb1.js} +2 -2
- package/dist/{config-BwmOXgir.js.map → config-B3rFCdb1.js.map} +1 -1
- package/dist/{config-BQCNJgQ7.js → config-B4U-qONS.js} +2 -2
- package/dist/{config-BQCNJgQ7.js.map → config-B4U-qONS.js.map} +1 -1
- package/dist/{config-B7U-ho3i.js → config-B91vghof.js} +3 -3
- package/dist/{config-B7U-ho3i.js.map → config-B91vghof.js.map} +1 -1
- package/dist/{config-BOD0Nhuj.js → config-BMGrKMpE.js} +2 -2
- package/dist/{config-BOD0Nhuj.js.map → config-BMGrKMpE.js.map} +1 -1
- package/dist/{config-0f5K4JqQ.js → config-BSN-cBcX.js} +2 -2
- package/dist/{config-0f5K4JqQ.js.map → config-BSN-cBcX.js.map} +1 -1
- package/dist/{config-C5c2fW5F.js → config-BV-dO9EP.js} +2 -2
- package/dist/{config-C5c2fW5F.js.map → config-BV-dO9EP.js.map} +1 -1
- package/dist/{config-aMhYhd0D.js → config-CNGnJM6F.js} +2 -2
- package/dist/{config-aMhYhd0D.js.map → config-CNGnJM6F.js.map} +1 -1
- package/dist/{config-Couk86DP.js → config-CYpYjgUQ.js} +2 -2
- package/dist/{config-Couk86DP.js.map → config-CYpYjgUQ.js.map} +1 -1
- package/dist/{config-Cma6O3K5.js → config-Cb_n8bE4.js} +2 -2
- package/dist/{config-Cma6O3K5.js.map → config-Cb_n8bE4.js.map} +1 -1
- package/dist/{config-jpna55zA.js → config-Cmc43iHq.js} +2 -2
- package/dist/{config-jpna55zA.js.map → config-Cmc43iHq.js.map} +1 -1
- package/dist/{config-CT-Llvpn.js → config-CxKo7dEe.js} +3 -3
- package/dist/{config-CT-Llvpn.js.map → config-CxKo7dEe.js.map} +1 -1
- package/dist/{config-BD29PMfM.js → config-DGVtv5rW.js} +2 -2
- package/dist/{config-BD29PMfM.js.map → config-DGVtv5rW.js.map} +1 -1
- package/dist/{config-DwedOToS.js → config-DIc7DMXS.js} +2 -2
- package/dist/{config-DwedOToS.js.map → config-DIc7DMXS.js.map} +1 -1
- package/dist/{config-ldk1g-bQ.js → config-DgHf3vtF.js} +2 -2
- package/dist/{config-ldk1g-bQ.js.map → config-DgHf3vtF.js.map} +1 -1
- package/dist/{config-DhXT6BVA.js → config-Dl3vDC54.js} +2 -2
- package/dist/{config-DhXT6BVA.js.map → config-Dl3vDC54.js.map} +1 -1
- package/dist/{config-D5pEVn4c.js → config-OKHueQCv.js} +2 -2
- package/dist/{config-D5pEVn4c.js.map → config-OKHueQCv.js.map} +1 -1
- package/dist/{config-CLBZfmse.js → config-nIyua4ul.js} +2 -2
- package/dist/{config-CLBZfmse.js.map → config-nIyua4ul.js.map} +1 -1
- package/dist/{index-CrXmXhG9.js → index-CL6D4EuF.js} +1820 -1788
- package/dist/index-CL6D4EuF.js.map +1 -0
- package/dist/kouxiangtang.js +1 -1
- package/dist/kouxiangtang.umd.cjs +8 -8
- package/dist/kouxiangtang.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/AttachmentUploader-VeuPJ5r2.js.map +0 -1
- package/dist/ImagesUploader-C0CS_P7-.js.map +0 -1
- package/dist/index-CrXmXhG9.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
## kouxiangtang
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### 介绍
|
|
4
|
+
`kouxiangtang` 通用的管理后台前端框架,此框架带有明确的后台数据管理目的。
|
|
4
5
|
|
|
5
|
-
## Recommended IDE Setup
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### 定义一个领域模型(`domain`)
|
|
8
|
+
本组件库为热血星球系列小程序使用,可能会随着业务非向下兼容改动,其他公司或下载使用请谨慎。
|
|
9
|
+
|
|
10
|
+
### 每个领域模型都有列表页
|
|
11
|
+
<img src="https://bloodcare-1251596343.cos.ap-shanghai.myqcloud.com/assets/qrcode/ui-lib-qrcode.jpg" width="240" height="240" style="margin: 20px auto;">
|
|
12
|
+
|
|
13
|
+
### 每个领域模型都有详情页
|
|
14
|
+
通过 `npm` 命令行安装
|
|
15
|
+
```
|
|
16
|
+
npm install bulade-ui -S
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 每个领域模型根据 `API` 接口情况提供标准的增删改查的操作
|
|
20
|
+
在微信小程序开发者工具组,点击“工具”菜单中的“构建 npm”,将其构建到 `miniprogram_npm` 目录下
|
|
21
|
+
|
|
22
|
+
### 列表页提供可配置的数据过滤方式
|
|
23
|
+
``` JSON
|
|
24
|
+
"usingComponents": {
|
|
25
|
+
"bld-button": "bulade-ui/button"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
``` HTML
|
|
29
|
+
<bld-button iclass="button" type="success" size="lg" >按钮</bld-button>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 提供针对列表页数据集的批量操作(`PageAction`)
|
|
33
|
+
```
|
|
34
|
+
# 安装项目依赖
|
|
35
|
+
npm install
|
|
36
|
+
|
|
37
|
+
# 执行组件编译
|
|
38
|
+
npm run dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 提供针对单条数据的操作(`RowAction`)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
npm run watch
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 提供针对数据关联的显示
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
npm run watch
|
|
51
|
+
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { ElUpload as q, ElIcon as
|
|
3
|
-
import { _ as Q,
|
|
1
|
+
import { computed as F, ref as y, openBlock as p, createElementBlock as k, Fragment as E, createVNode as r, unref as n, normalizeClass as M, withModifiers as R, withCtx as i, createBlock as f, createTextVNode as j, createElementVNode as U, renderList as L, toDisplayString as O, createCommentVNode as S } from "vue";
|
|
2
|
+
import { ElUpload as q, ElIcon as v, ElButton as W, ElDialog as G, ElForm as H, ElFormItem as J, ElInput as K, ElMessage as u, ElLoading as w } from "element-plus";
|
|
3
|
+
import { _ as Q, j as X, p as Y, d as Z, k as ee, h as te, m as ae } from "./index-CL6D4EuF.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
-
const
|
|
5
|
+
const se = ["src"], ne = { class: "file-type" }, le = {
|
|
6
6
|
__name: "AttachmentUploader",
|
|
7
7
|
props: {
|
|
8
8
|
pics: {
|
|
@@ -26,8 +26,8 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
emits: ["on-success", "on-remove", "on-change"],
|
|
29
|
-
setup(
|
|
30
|
-
const
|
|
29
|
+
setup(b, { emit: C }) {
|
|
30
|
+
const m = C, s = b, g = F(() => s.pics.map((e) => {
|
|
31
31
|
const t = e.url.substring(e.url.lastIndexOf(".") + 1);
|
|
32
32
|
if (typeof e.name !== void 0)
|
|
33
33
|
return e.fileType = t, e;
|
|
@@ -40,8 +40,8 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return { ...e, name: e.id, fileType: t };
|
|
43
|
-
})), _ =
|
|
44
|
-
|
|
43
|
+
})), _ = y(""), h = y(!1);
|
|
44
|
+
y(s);
|
|
45
45
|
const x = X().fileUploadUrl;
|
|
46
46
|
`${localStorage.getItem("token")}`;
|
|
47
47
|
const V = (e) => {
|
|
@@ -50,14 +50,14 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
50
50
|
return e.type.startsWith("image/") ? (t.onload = async (o) => {
|
|
51
51
|
const d = new Image();
|
|
52
52
|
d.src = o.target.result, d.onload = () => {
|
|
53
|
-
const c = document.createElement("canvas"),
|
|
54
|
-
c.width = d.width, c.height = d.height,
|
|
55
|
-
(
|
|
56
|
-
const
|
|
53
|
+
const c = document.createElement("canvas"), $ = c.getContext("2d");
|
|
54
|
+
c.width = d.width, c.height = d.height, $.drawImage(d, 0, 0, c.width, c.height), c.toBlob(
|
|
55
|
+
(z) => {
|
|
56
|
+
const A = new File([z], e.name, {
|
|
57
57
|
type: e.type,
|
|
58
58
|
lastModified: Date.now()
|
|
59
59
|
});
|
|
60
|
-
a(
|
|
60
|
+
a(A);
|
|
61
61
|
},
|
|
62
62
|
e.type,
|
|
63
63
|
0.5
|
|
@@ -66,81 +66,93 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
66
66
|
}, !1) : (a(e), !1);
|
|
67
67
|
});
|
|
68
68
|
}, I = (e) => {
|
|
69
|
-
|
|
69
|
+
var t, a;
|
|
70
|
+
if (e.status === "success")
|
|
71
|
+
if (s.props.deleteParams) {
|
|
72
|
+
const l = (t = s.props.deleteParams) != null && t.data ? (a = s.props.deleteParams) == null ? void 0 : a.data : {};
|
|
73
|
+
te.remove(
|
|
74
|
+
`${s.props.deleteParams.url}/${e.id}/attachment`,
|
|
75
|
+
l,
|
|
76
|
+
l
|
|
77
|
+
).then(() => {
|
|
78
|
+
m("on-remove", e);
|
|
79
|
+
});
|
|
80
|
+
} else
|
|
81
|
+
m("on-remove", e);
|
|
70
82
|
}, T = () => {
|
|
71
|
-
|
|
72
|
-
message: `最多只能上传 ${
|
|
83
|
+
u({
|
|
84
|
+
message: `最多只能上传 ${s.props.limit} 个文件!`,
|
|
73
85
|
type: "warning"
|
|
74
86
|
});
|
|
87
|
+
}, P = (e) => {
|
|
88
|
+
_.value = e.url, h.value = !0;
|
|
75
89
|
}, B = (e) => {
|
|
76
|
-
_.value = e.url, y.value = !0;
|
|
77
|
-
}, N = (e) => {
|
|
78
90
|
const t = e.name.substring(0, e.name.lastIndexOf("."));
|
|
79
91
|
if (!/^[\u4e00-\u9fa5\w-_]+$/.test(t))
|
|
80
|
-
return
|
|
92
|
+
return u({
|
|
81
93
|
message: "请勿输入特殊字符!",
|
|
82
94
|
type: "warning"
|
|
83
95
|
}), !1;
|
|
84
|
-
V(e).then((l) => l.size / 1024 / 1024 < 5 ? (
|
|
96
|
+
V(e).then((l) => l.size / 1024 / 1024 < 5 ? (N(l), !1) : (u({
|
|
85
97
|
message: "上传大小不能超过 5MB!",
|
|
86
98
|
type: "warning"
|
|
87
99
|
}), !1));
|
|
88
100
|
};
|
|
89
101
|
function D(e, t) {
|
|
90
102
|
if (!e.name) {
|
|
91
|
-
|
|
103
|
+
u({
|
|
92
104
|
message: "附件名称不能为空!",
|
|
93
105
|
type: "warning"
|
|
94
106
|
});
|
|
95
107
|
return;
|
|
96
108
|
}
|
|
97
|
-
|
|
109
|
+
m("on-change", e);
|
|
98
110
|
}
|
|
99
|
-
function
|
|
100
|
-
return
|
|
111
|
+
function N(e) {
|
|
112
|
+
return w.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((t, a) => {
|
|
101
113
|
const l = new FormData();
|
|
102
|
-
l.append("file", e),
|
|
114
|
+
l.append("file", e), ae.post(x, l, {}).then((o) => (w.service().close(), u({
|
|
103
115
|
message: "上传成功",
|
|
104
116
|
type: "success"
|
|
105
|
-
}),
|
|
106
|
-
|
|
117
|
+
}), m("on-success", o.data.data), t(o.data), !1)).catch(() => {
|
|
118
|
+
w.service().close(), u({
|
|
107
119
|
message: "上传失败",
|
|
108
120
|
type: "warning"
|
|
109
121
|
}), a("Upload failed");
|
|
110
122
|
});
|
|
111
123
|
});
|
|
112
124
|
}
|
|
113
|
-
return (e, t) => (
|
|
114
|
-
r(
|
|
125
|
+
return (e, t) => (p(), k(E, null, [
|
|
126
|
+
r(n(q), {
|
|
115
127
|
"file-list": g.value,
|
|
116
|
-
action:
|
|
117
|
-
limit:
|
|
118
|
-
accept:
|
|
119
|
-
"list-type":
|
|
128
|
+
action: n(x),
|
|
129
|
+
limit: s.props.limit,
|
|
130
|
+
accept: s.props.accept,
|
|
131
|
+
"list-type": s.props.listType,
|
|
120
132
|
"on-remove": I,
|
|
121
|
-
"before-upload":
|
|
133
|
+
"before-upload": B,
|
|
122
134
|
"on-exceed": T,
|
|
123
|
-
"on-preview":
|
|
135
|
+
"on-preview": P,
|
|
124
136
|
multiple: !0,
|
|
125
137
|
"http-request": () => !1,
|
|
126
|
-
"show-file-list":
|
|
138
|
+
"show-file-list": s.props.listType !== "text",
|
|
127
139
|
class: M([
|
|
128
140
|
"upload-main",
|
|
129
|
-
{ "disable-upload": g.value.length >=
|
|
141
|
+
{ "disable-upload": g.value.length >= s.props.limit }
|
|
130
142
|
]),
|
|
131
143
|
onClick: t[0] || (t[0] = R(() => {
|
|
132
144
|
}, ["prevent"]))
|
|
133
145
|
}, {
|
|
134
146
|
default: i(() => [
|
|
135
|
-
|
|
147
|
+
s.props.listType !== "text" ? (p(), f(n(v), {
|
|
136
148
|
key: 0,
|
|
137
149
|
disabled: !0
|
|
138
150
|
}, {
|
|
139
151
|
default: i(() => [
|
|
140
|
-
r(
|
|
152
|
+
r(n(Y))
|
|
141
153
|
]),
|
|
142
154
|
_: 1
|
|
143
|
-
})) : (
|
|
155
|
+
})) : (p(), f(n(W), {
|
|
144
156
|
key: 1,
|
|
145
157
|
class: "upload-button",
|
|
146
158
|
type: "primary"
|
|
@@ -153,48 +165,48 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
153
165
|
]),
|
|
154
166
|
_: 1
|
|
155
167
|
}, 8, ["file-list", "action", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
156
|
-
r(
|
|
157
|
-
modelValue:
|
|
158
|
-
"onUpdate:modelValue": t[1] || (t[1] = (a) =>
|
|
168
|
+
r(n(G), {
|
|
169
|
+
modelValue: h.value,
|
|
170
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => h.value = a)
|
|
159
171
|
}, {
|
|
160
172
|
default: i(() => [
|
|
161
|
-
|
|
173
|
+
U("img", {
|
|
162
174
|
"w-full": "",
|
|
163
175
|
src: _.value,
|
|
164
176
|
alt: "Preview Image"
|
|
165
|
-
}, null, 8,
|
|
177
|
+
}, null, 8, se)
|
|
166
178
|
]),
|
|
167
179
|
_: 1
|
|
168
180
|
}, 8, ["modelValue"]),
|
|
169
|
-
|
|
181
|
+
s.props.listType == "text" ? (p(), f(n(H), { key: 0 }, {
|
|
170
182
|
default: i(() => [
|
|
171
|
-
(
|
|
183
|
+
(p(!0), k(E, null, L(g.value, (a, l) => (p(), f(n(J), {
|
|
172
184
|
key: l,
|
|
173
185
|
class: "file-list"
|
|
174
186
|
}, {
|
|
175
187
|
default: i(() => [
|
|
176
|
-
r(
|
|
188
|
+
r(n(v), {
|
|
177
189
|
color: "#73767a",
|
|
178
190
|
size: 14
|
|
179
191
|
}, {
|
|
180
192
|
default: i(() => [
|
|
181
|
-
r(
|
|
193
|
+
r(n(Z))
|
|
182
194
|
]),
|
|
183
195
|
_: 1
|
|
184
196
|
}),
|
|
185
|
-
r(
|
|
197
|
+
r(n(K), {
|
|
186
198
|
modelValue: a.name,
|
|
187
199
|
"onUpdate:modelValue": (o) => a.name = o,
|
|
188
200
|
onChange: (o) => D(a)
|
|
189
201
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"]),
|
|
190
|
-
|
|
191
|
-
r(
|
|
202
|
+
U("span", ne, "." + O(a.fileType), 1),
|
|
203
|
+
r(n(v), {
|
|
192
204
|
color: "#73767a",
|
|
193
205
|
size: 12,
|
|
194
206
|
onClick: (o) => I(a)
|
|
195
207
|
}, {
|
|
196
208
|
default: i(() => [
|
|
197
|
-
r(
|
|
209
|
+
r(n(ee))
|
|
198
210
|
]),
|
|
199
211
|
_: 2
|
|
200
212
|
}, 1032, ["onClick"])
|
|
@@ -206,8 +218,8 @@ const ae = ["src"], se = { class: "file-type" }, ne = {
|
|
|
206
218
|
})) : S("", !0)
|
|
207
219
|
], 64));
|
|
208
220
|
}
|
|
209
|
-
},
|
|
221
|
+
}, pe = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-4c31cc76"]]);
|
|
210
222
|
export {
|
|
211
|
-
|
|
223
|
+
pe as default
|
|
212
224
|
};
|
|
213
|
-
//# sourceMappingURL=AttachmentUploader-
|
|
225
|
+
//# sourceMappingURL=AttachmentUploader-CNRraZtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentUploader-CNRraZtx.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\nimport {\n ElUpload,\n ElIcon,\n ElDialog,\n ElForm,\n ElFormItem,\n ElButton,\n ElInput,\n} from \"element-plus\";\nimport axios from \"axios\";\nimport http from \"../../utils/http\";\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 if (uploadFile.status === \"success\") {\n if (props.props.deleteParams) {\n const paramsData = props.props.deleteParams?.data\n ? props.props.deleteParams?.data\n : {};\n http\n .remove(\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\n paramsData,\n paramsData,\n )\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n }\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 const fileName = file.name.substring(0, file.name.lastIndexOf(\".\"));\n const regex = /^[\\u4e00-\\u9fa5\\w-_]+$/;\n if (!regex.test(fileName)) {\n ElMessage({\n message: \"请勿输入特殊字符!\",\n type: \"warning\",\n });\n return false;\n }\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","paramsData","_a","_b","http","handleExceed","ElMessage","handlePictureCardPreview","handleBeforeUpload","fileName","uploadRequest","handleFileNameChange","index","ElLoading","formData","axios","res"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { openBlock as t, createBlock as o, unref as e, withCtx as s, renderSlot as I, createElementVNode as v, createVNode as l, withModifiers as E, createCommentVNode as b } from "vue";
|
|
2
2
|
import { ElUpload as x, ElImage as B, ElIcon as n, ElMessage as i, ElLoading as d } from "element-plus";
|
|
3
|
-
import { _ as M,
|
|
3
|
+
import { _ as M, j as C, l as S, p as L, n as N, m as V } from "./index-CL6D4EuF.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
5
|
const q = { class: "image-slot" }, z = {
|
|
6
6
|
__name: "ImageUploader",
|
|
@@ -90,8 +90,8 @@ const q = { class: "image-slot" }, z = {
|
|
|
90
90
|
_: 3
|
|
91
91
|
}, 8, ["action"]));
|
|
92
92
|
}
|
|
93
|
-
},
|
|
93
|
+
}, F = /* @__PURE__ */ M(z, [["__scopeId", "data-v-ae965bb4"]]);
|
|
94
94
|
export {
|
|
95
|
-
|
|
95
|
+
F as default
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=ImageUploader-
|
|
97
|
+
//# sourceMappingURL=ImageUploader-Bjfhrzw7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploader-
|
|
1
|
+
{"version":3,"file":"ImageUploader-Bjfhrzw7.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { ElUpload as U, ElIcon as B, ElButton as z, ElDialog as
|
|
3
|
-
import { _ as
|
|
1
|
+
import { ref as c, computed as I, openBlock as i, createElementBlock as k, createVNode as u, unref as o, normalizeClass as E, withModifiers as T, withCtx as r, createBlock as f, createTextVNode as V, createElementVNode as P } from "vue";
|
|
2
|
+
import { ElUpload as U, ElIcon as B, ElButton as z, ElDialog as D, ElMessage as g } from "element-plus";
|
|
3
|
+
import { _ as N, p as C, h as M } from "./index-CL6D4EuF.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
-
const
|
|
5
|
+
const $ = ["src"], q = {
|
|
6
6
|
__name: "ImagesUploader",
|
|
7
7
|
props: {
|
|
8
8
|
images: {
|
|
@@ -24,8 +24,8 @@ const M = ["src"], q = {
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
emits: ["on-remove", "on-upload"],
|
|
27
|
-
setup(
|
|
28
|
-
const
|
|
27
|
+
setup(v, { emit: y }) {
|
|
28
|
+
const s = y, m = c(""), n = c(!1), l = v, d = I(() => l.images.map((e) => {
|
|
29
29
|
if (!(e != null && e.url))
|
|
30
30
|
return { ...e, name: "unknown", fileType: "unknown" };
|
|
31
31
|
const t = e.url.substring(e.url.lastIndexOf(".") + 1), a = e.url.split("/");
|
|
@@ -35,58 +35,69 @@ const M = ["src"], q = {
|
|
|
35
35
|
fileType: t
|
|
36
36
|
};
|
|
37
37
|
}));
|
|
38
|
-
function
|
|
39
|
-
|
|
38
|
+
function _(e) {
|
|
39
|
+
var t, a;
|
|
40
|
+
if (l.props.deleteParams) {
|
|
41
|
+
const p = (t = l.props.deleteParams) != null && t.data ? (a = l.props.deleteParams) == null ? void 0 : a.data : {};
|
|
42
|
+
M.remove(
|
|
43
|
+
`${l.props.deleteParams.url}/${e.id}/attachment`,
|
|
44
|
+
p,
|
|
45
|
+
p
|
|
46
|
+
).then(() => {
|
|
47
|
+
s("on-remove", e);
|
|
48
|
+
});
|
|
49
|
+
} else
|
|
50
|
+
s("on-remove", e);
|
|
40
51
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
52
|
+
function w() {
|
|
53
|
+
g({
|
|
43
54
|
message: `最多只能上传 ${l.props.limit} 个文件!`,
|
|
44
55
|
type: "warning"
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
|
-
function w(e) {
|
|
48
|
-
u.value = e.url, s.value = !0;
|
|
49
|
-
}
|
|
50
58
|
function b(e) {
|
|
51
|
-
|
|
59
|
+
m.value = e.url, n.value = !0;
|
|
60
|
+
}
|
|
61
|
+
function h(e) {
|
|
62
|
+
return e.size > 5242880 ? (g({
|
|
52
63
|
message: "上传大小不能超过 5MB!",
|
|
53
64
|
type: "warning"
|
|
54
65
|
}), !1) : !0;
|
|
55
66
|
}
|
|
56
67
|
function x(e) {
|
|
57
68
|
const t = new FormData();
|
|
58
|
-
t.append("file", e.file),
|
|
69
|
+
t.append("file", e.file), s("on-upload", t);
|
|
59
70
|
}
|
|
60
|
-
return (e, t) => (
|
|
61
|
-
|
|
62
|
-
"file-list":
|
|
71
|
+
return (e, t) => (i(), k("div", null, [
|
|
72
|
+
u(o(U), {
|
|
73
|
+
"file-list": d.value,
|
|
63
74
|
limit: l.props.limit,
|
|
64
75
|
accept: l.props.accept,
|
|
65
76
|
"list-type": l.props.listType,
|
|
66
|
-
"on-remove":
|
|
67
|
-
"on-exceed":
|
|
68
|
-
"on-preview":
|
|
77
|
+
"on-remove": _,
|
|
78
|
+
"on-exceed": w,
|
|
79
|
+
"on-preview": b,
|
|
69
80
|
multiple: !0,
|
|
70
|
-
"before-upload":
|
|
81
|
+
"before-upload": h,
|
|
71
82
|
"http-request": x,
|
|
72
83
|
"show-file-list": l.props.listType !== "text",
|
|
73
84
|
class: E([
|
|
74
85
|
"upload-main",
|
|
75
|
-
{ "disable-upload":
|
|
86
|
+
{ "disable-upload": d.value.length >= l.props.limit }
|
|
76
87
|
]),
|
|
77
88
|
onClick: t[0] || (t[0] = T(() => {
|
|
78
89
|
}, ["prevent"]))
|
|
79
90
|
}, {
|
|
80
91
|
default: r(() => [
|
|
81
|
-
l.props.listType !== "text" ? (
|
|
92
|
+
l.props.listType !== "text" ? (i(), f(o(B), {
|
|
82
93
|
key: 0,
|
|
83
94
|
disabled: !0
|
|
84
95
|
}, {
|
|
85
96
|
default: r(() => [
|
|
86
|
-
|
|
97
|
+
u(o(C))
|
|
87
98
|
]),
|
|
88
99
|
_: 1
|
|
89
|
-
})) : (
|
|
100
|
+
})) : (i(), f(o(z), {
|
|
90
101
|
key: 1,
|
|
91
102
|
class: "upload-button",
|
|
92
103
|
type: "primary"
|
|
@@ -99,23 +110,23 @@ const M = ["src"], q = {
|
|
|
99
110
|
]),
|
|
100
111
|
_: 1
|
|
101
112
|
}, 8, ["file-list", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
102
|
-
|
|
103
|
-
modelValue:
|
|
104
|
-
"onUpdate:modelValue": t[1] || (t[1] = (a) =>
|
|
113
|
+
u(o(D), {
|
|
114
|
+
modelValue: n.value,
|
|
115
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => n.value = a)
|
|
105
116
|
}, {
|
|
106
117
|
default: r(() => [
|
|
107
|
-
|
|
118
|
+
P("img", {
|
|
108
119
|
"w-full": "",
|
|
109
|
-
src:
|
|
120
|
+
src: m.value,
|
|
110
121
|
alt: "Preview Image"
|
|
111
|
-
}, null, 8,
|
|
122
|
+
}, null, 8, $)
|
|
112
123
|
]),
|
|
113
124
|
_: 1
|
|
114
125
|
}, 8, ["modelValue"])
|
|
115
126
|
]));
|
|
116
127
|
}
|
|
117
|
-
}, A = /* @__PURE__ */
|
|
128
|
+
}, A = /* @__PURE__ */ N(q, [["__scopeId", "data-v-b723b633"]]);
|
|
118
129
|
export {
|
|
119
130
|
A as default
|
|
120
131
|
};
|
|
121
|
-
//# sourceMappingURL=ImagesUploader-
|
|
132
|
+
//# sourceMappingURL=ImagesUploader-DETYCvHu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagesUploader-DETYCvHu.js","sources":["../src/framework/field/images/ImagesUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElDialog, ElIcon, ElButton } from \"element-plus\";\nimport { computed, ref } from \"vue\";\nimport { ElMessage } from \"element-plus\";\nimport { Plus } from \"@element-plus/icons-vue\";\nimport http from \"../../utils/http\";\n\nconst emit = defineEmits([\"on-remove\", \"on-upload\"]);\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst props = defineProps({\n images: {\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\",\n limit: 5,\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.images.map((item) => {\n if (!item?.url) {\n return { ...item, name: \"unknown\", fileType: \"unknown\" };\n }\n\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType,\n };\n return namedItem;\n });\n});\n\nfunction onRemove(uploadFile) {\n if (props.props.deleteParams) {\n const paramsData = props.props.deleteParams?.data\n ? props.props.deleteParams?.data\n : {};\n http\n .remove(\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\n paramsData,\n paramsData,\n )\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n}\n\nfunction onExceed() {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n}\n\nfunction onPreview(uploadFile) {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n}\n\nfunction beforeUpload(uploadFile) {\n const limitSize = 1024 * 1024 * 5;\n if (uploadFile.size > limitSize) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n\n return true;\n}\n\nfunction httpRequest(uploadFile) {\n const formData = new FormData();\n formData.append(\"file\", uploadFile.file);\n emit(\"on-upload\", formData);\n}\n</script>\n\n<template>\n <div>\n <el-upload\n :file-list=\"files\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"onRemove\"\n :on-exceed=\"onExceed\"\n :on-preview=\"onPreview\"\n :multiple=\"true\"\n :before-upload=\"beforeUpload\"\n :http-request=\"httpRequest\"\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 </div>\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","dialogImageUrl","ref","dialogVisible","props","__props","files","computed","item","fileType","parts","onRemove","uploadFile","paramsData","_a","_b","http","onExceed","ElMessage","onPreview","beforeUpload","httpRequest","formData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAiBC,EAAI,EAAE,GACvBC,IAAgBD,EAAI,EAAK,GACzBE,IAAQC,GAoBRC,IAAQC,EAAS,MACdH,EAAM,OAAO,IAAI,CAACI,MAAS;AAChC,UAAI,EAACA,KAAA,QAAAA,EAAM;AACT,eAAO,EAAE,GAAGA,GAAM,MAAM,WAAW,UAAU;AAG/C,YAAMC,IAAWD,EAAK,IAAI,UAAUA,EAAK,IAAI,YAAY,GAAG,IAAI,CAAC,GAC3DE,IAAQF,EAAK,IAAI,MAAM,GAAG;AAMhC,aALkB;AAAA,QAChB,GAAGA;AAAA,QACH,MAAME,EAAMA,EAAM,SAAS,CAAC;AAAA,QAC5B,UAAAD;AAAA,MACN;AAAA,IAEA,CAAG,CACF;AAED,aAASE,EAASC,GAAY;;AAC5B,UAAIR,EAAM,MAAM,cAAc;AAC5B,cAAMS,KAAaC,IAAAV,EAAM,MAAM,iBAAZ,QAAAU,EAA0B,QACzCC,IAAAX,EAAM,MAAM,iBAAZ,gBAAAW,EAA0B,OAC1B;AACJ,QAAAC,EACG;AAAA,UACC,GAAGZ,EAAM,MAAM,aAAa,GAAG,IAAIQ,EAAW,EAAE;AAAA,UAChDC;AAAA,UACAA;AAAA,QACD,EACA,KAAK,MAAM;AACV,UAAAd,EAAK,aAAaa,CAAU;AAAA,QACpC,CAAO;AAAA,MACP;AACI,QAAAb,EAAK,aAAaa,CAAU;AAAA,IAEhC;AAEA,aAASK,IAAW;AAClB,MAAAC,EAAU;AAAA,QACR,SAAS,UAAUd,EAAM,MAAM,KAAK;AAAA,QACpC,MAAM;AAAA,MACV,CAAG;AAAA,IACH;AAEA,aAASe,EAAUP,GAAY;AAC7B,MAAAX,EAAe,QAAQW,EAAW,KAClCT,EAAc,QAAQ;AAAA,IACxB;AAEA,aAASiB,EAAaR,GAAY;AAEhC,aAAIA,EAAW,OAAO,WACpBM,EAAU;AAAA,QACR,SAAS;AAAA,QACT,MAAM;AAAA,MACZ,CAAK,GACM,MAGF;AAAA,IACT;AAEA,aAASG,EAAYT,GAAY;AAC/B,YAAMU,IAAW,IAAI;AACrB,MAAAA,EAAS,OAAO,QAAQV,EAAW,IAAI,GACvCb,EAAK,aAAauB,CAAQ;AAAA,IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as rr, onMounted as ir, onBeforeUnmount as ar, ref as $n, watch as Pn, nextTick as Gn, h as or, computed as sr, openBlock as ur, createBlock as lr, unref as fr } from "vue";
|
|
2
2
|
import * as rt from "quill";
|
|
3
3
|
import Rn from "quill";
|
|
4
|
-
import {
|
|
4
|
+
import { o as W, r as cr, m as hr, j as dr } from "./index-CL6D4EuF.js";
|
|
5
5
|
import { ElMessage as Ln } from "element-plus";
|
|
6
6
|
var ue = -1, re = 1, Z = 0;
|
|
7
7
|
function at(r, a, n, u) {
|
|
@@ -1811,4 +1811,4 @@ const Wn = {
|
|
|
1811
1811
|
export {
|
|
1812
1812
|
Rr as default
|
|
1813
1813
|
};
|
|
1814
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1814
|
+
//# sourceMappingURL=RichTextEditor-CnEVXr9n.js.map
|