kouxiangtang 0.0.78 → 0.0.80

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.
Files changed (58) hide show
  1. package/README.md +408 -4
  2. package/dist/{AttachmentUploader-Dk3pI8xI.js → AttachmentUploader-dO2PiIqG.js} +58 -48
  3. package/dist/AttachmentUploader-dO2PiIqG.js.map +1 -0
  4. package/dist/{ImageUploader-Sl6CARAH.js → ImageUploader-DJfujt_H.js} +2 -2
  5. package/dist/{ImageUploader-Sl6CARAH.js.map → ImageUploader-DJfujt_H.js.map} +1 -1
  6. package/dist/ImagesUploader-L2-m9pOt.js +132 -0
  7. package/dist/ImagesUploader-L2-m9pOt.js.map +1 -0
  8. package/dist/{RichTextEditor-BN-Grymy.js → RichTextEditor-B0009vbA.js} +2 -2
  9. package/dist/{RichTextEditor-BN-Grymy.js.map → RichTextEditor-B0009vbA.js.map} +1 -1
  10. package/dist/{config-3CmGvWbJ.js → config-4opkUG_U.js} +2 -2
  11. package/dist/{config-3CmGvWbJ.js.map → config-4opkUG_U.js.map} +1 -1
  12. package/dist/{config-kSnMLu_i.js → config-B7NLL7Za.js} +2 -2
  13. package/dist/{config-kSnMLu_i.js.map → config-B7NLL7Za.js.map} +1 -1
  14. package/dist/{config-BPF5NKbv.js → config-BOL73GVE.js} +2 -2
  15. package/dist/{config-BPF5NKbv.js.map → config-BOL73GVE.js.map} +1 -1
  16. package/dist/{config-Dfv9X_oH.js → config-B_jV9FcB.js} +3 -3
  17. package/dist/{config-Dfv9X_oH.js.map → config-B_jV9FcB.js.map} +1 -1
  18. package/dist/{config-nxWFYd4H.js → config-BbMhy1Am.js} +2 -2
  19. package/dist/{config-nxWFYd4H.js.map → config-BbMhy1Am.js.map} +1 -1
  20. package/dist/{config-DIgyOzyY.js → config-Bf2H_VXi.js} +2 -2
  21. package/dist/{config-DIgyOzyY.js.map → config-Bf2H_VXi.js.map} +1 -1
  22. package/dist/{config-BIoYHFta.js → config-BgIHsuau.js} +3 -3
  23. package/dist/{config-BIoYHFta.js.map → config-BgIHsuau.js.map} +1 -1
  24. package/dist/{config-DWQ07KGg.js → config-BnV5g1r6.js} +2 -2
  25. package/dist/{config-DWQ07KGg.js.map → config-BnV5g1r6.js.map} +1 -1
  26. package/dist/{config-B7sfuPS-.js → config-C9BwlRNg.js} +2 -2
  27. package/dist/{config-B7sfuPS-.js.map → config-C9BwlRNg.js.map} +1 -1
  28. package/dist/{config-DFY-g88P.js → config-CL0sbSSk.js} +2 -2
  29. package/dist/{config-DFY-g88P.js.map → config-CL0sbSSk.js.map} +1 -1
  30. package/dist/{config-BDUo3FW4.js → config-CXX_cyT5.js} +2 -2
  31. package/dist/{config-BDUo3FW4.js.map → config-CXX_cyT5.js.map} +1 -1
  32. package/dist/{config-D6JmkLzW.js → config-Ct-kk8lN.js} +2 -2
  33. package/dist/{config-D6JmkLzW.js.map → config-Ct-kk8lN.js.map} +1 -1
  34. package/dist/{config-urM6mrhD.js → config-DBWaP3c8.js} +2 -2
  35. package/dist/{config-urM6mrhD.js.map → config-DBWaP3c8.js.map} +1 -1
  36. package/dist/{config-Cs24dvIw.js → config-DD7Ikbt-.js} +2 -2
  37. package/dist/{config-Cs24dvIw.js.map → config-DD7Ikbt-.js.map} +1 -1
  38. package/dist/{config-CWEv8XKO.js → config-DmxS5C0R.js} +2 -2
  39. package/dist/{config-CWEv8XKO.js.map → config-DmxS5C0R.js.map} +1 -1
  40. package/dist/{config-BMegUoCu.js → config-POLpsRRx.js} +2 -2
  41. package/dist/{config-BMegUoCu.js.map → config-POLpsRRx.js.map} +1 -1
  42. package/dist/{config-CEbzlR4L.js → config-UhlNBDt2.js} +2 -2
  43. package/dist/{config-CEbzlR4L.js.map → config-UhlNBDt2.js.map} +1 -1
  44. package/dist/{config-Gr_n4RJU.js → config-jNNoK2HQ.js} +3 -3
  45. package/dist/{config-Gr_n4RJU.js.map → config-jNNoK2HQ.js.map} +1 -1
  46. package/dist/{config-7NNTCgWz.js → config-nq8OiIpn.js} +2 -2
  47. package/dist/{config-7NNTCgWz.js.map → config-nq8OiIpn.js.map} +1 -1
  48. package/dist/{index-DWaIPnvt.js → index-BDc0n3q3.js} +617 -606
  49. package/dist/index-BDc0n3q3.js.map +1 -0
  50. package/dist/kouxiangtang.js +1 -1
  51. package/dist/kouxiangtang.umd.cjs +8 -8
  52. package/dist/kouxiangtang.umd.cjs.map +1 -1
  53. package/dist/style.css +1 -1
  54. package/package.json +1 -1
  55. package/dist/AttachmentUploader-Dk3pI8xI.js.map +0 -1
  56. package/dist/ImagesUploader-CD6qu0oD.js +0 -123
  57. package/dist/ImagesUploader-CD6qu0oD.js.map +0 -1
  58. package/dist/index-DWaIPnvt.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,411 @@
1
- # Vue 3 + Vite
1
+ ## kouxiangtang
2
+
3
+ ### 介绍
4
+ `kouxiangtang` 通用的管理后台前端框架,此框架带有明确的后台数据管理目的。
5
+
6
+
7
+ ### (一)安装使用
8
+ 通过 `npm` 命令行安装
9
+ ```
10
+ npm install kouxiangtang -S
11
+ ```
12
+
13
+ ### (二)定义一个领域模型(`domain`)
14
+ * src下创建`domains`文件夹
15
+
16
+ * 文件夹中创建 `config.js` ,export `domainConfigs`
17
+ ``` JAVASCRIPT
18
+ const domainConfigs = {
19
+ admin: {
20
+ admins: { name: "管理员" },
21
+ user: { name: "用户" },
22
+ "city-users": { name: "城市用户统计" }
23
+ }
24
+ };
25
+
26
+ export default domainConfigs;
27
+ ```
28
+
29
+ * 创建如命名为`admin`文件夹,文件夹内包含页面结构信息
30
+ <img src="doc/image-5.png" width="400" height="200" style="margin: 20px auto;">
31
+
32
+ * src下创建`layouts`文件夹
33
+ * layout.vue
34
+
35
+ ``` HTML
36
+ <template>
37
+ <BaseLayout :config="props.config">
38
+ <template #user-profile>
39
+ <UserProfile />
40
+ </template>
41
+ </BaseLayout>
42
+ </template>
43
+
44
+ <script setup>
45
+ import { BaseLayout } from "kouxiangtang";
46
+ import UserProfile from "./UserProfile.vue";
47
+
48
+ const props = defineProps({
49
+ config: {
50
+ type: Object,
51
+ },
52
+ });
53
+ </script>
54
+
55
+ <style scoped lang="scss"></style>
56
+ ```
57
+ * side-menus.js ,用于项目菜单管理。
58
+
59
+ ``` javascript
60
+ import {
61
+ House,
62
+ PieChart,
63
+ Refrigerator,
64
+ Setting,
65
+ Location
66
+ } from "@element-plus/icons-vue";
67
+
68
+ const adminMenus = [
69
+ { title: "首页", home: true, icon: House, route: "/admin/home" },
70
+ { title: "统计", home: true, icon: PieChart, route: "/admin/statistics" },
71
+ {
72
+ title: "用户",
73
+ icon: User,
74
+ children: [
75
+ { title: "用户", route: "/admin/user/list" },
76
+ { title: "SSO", route: "/admin/user-sso/list" },
77
+ { title: "城市用户统计", route: "/admin/city-users/list" },
78
+ { title: "信息更正申请", route: "/admin/identity-update-apply/list" },
79
+ { title: "登录日志", route: "/admin/user-login-ip/list" },
80
+ { title: "黑名单", route: "/admin/black-list/list" },
81
+ ],
82
+ }
83
+ ];
84
+
85
+ export default {
86
+ admin: adminMenus,
87
+ };
88
+
89
+ ```
90
+
91
+ * UserProfile.vue
92
+
93
+ ``` HTML
94
+ <template>
95
+ <el-dropdown trigger="click">
96
+ <span class="username">
97
+ {{ currentUser }}
98
+ <el-icon class="el-icon--right">
99
+ <ArrowDown />
100
+ </el-icon>
101
+ </span>
102
+ <template #dropdown>
103
+ <el-dropdown-menu>
104
+ <el-dropdown-item @click="logout"> 退出</el-dropdown-item>
105
+ </el-dropdown-menu>
106
+ </template>
107
+ </el-dropdown>
108
+ </template>
109
+
110
+ <script setup>
111
+ import { useRouter } from "vue-router";
112
+ import { ArrowDown } from "@element-plus/icons-vue";
113
+ import { ref, watch } from "vue";
114
+ import adminApi from "@/requests/admin";
115
+
116
+ const router = useRouter();
117
+ const currentUser = ref("...");
118
+
119
+ function logout() {
120
+ ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
121
+ confirmButtonText: "确定",
122
+ cancelButtonText: "取消",
123
+ type: "warning",
124
+ }).then(() => {
125
+ localStorage.clear();
126
+ router.replace("/sso/login");
127
+ });
128
+ }
129
+
130
+ watch(
131
+ () => router.currentRoute.value,
132
+ () => {
133
+ currentUser.value = localStorage.getItem("currentUser");
134
+ },
135
+ { immediate: true },
136
+ );
137
+ </script>
138
+ <style lang="scss" scoped>
139
+ .username {
140
+ cursor: pointer;
141
+ display: flex;
142
+ align-items: center;
143
+ }
144
+ </style>
145
+ ```
146
+
147
+
148
+ ### (三)每个领域模型都有列表页
149
+ <img src="doc/image-6.png" width="400" height="200" style="margin: 20px auto;">
150
+
151
+ 页面文件夹下fields.js
152
+ * 字段为列表,详情,编辑 通用字段
153
+ * 可通过`editable: true,`等属性控制具体的页面显示。`showInList: false,`等。
154
+
155
+ ``` JAVASCRIPT
156
+ import SSOTenant from "./components/SSOTenant.vue";
157
+ import bannerTypes from "@/constants/banner-types";
158
+
159
+ const fields = [
160
+ {
161
+ code: "id",
162
+ label: "ID",
163
+ rowQuery: (row) => {
164
+ return { stationCode: row.code };
165
+ },
166
+ },
167
+ {
168
+ code: "indexLetter",
169
+ label: "索引",
170
+ width: 50,
171
+ editable: true,
172
+ showInList: false,
173
+ },
174
+ {
175
+ code: "enabled",
176
+ label: "启用",
177
+ type: "boolean",
178
+ width: 60,
179
+ editable: true,
180
+ },
181
+ {
182
+ code: "mode",
183
+ label: "首页模版",
184
+ editable: true,
185
+ type: "select",
186
+ options: () =>
187
+ bannerTypes.filter((item) => {
188
+ return item.code?.toString().charAt(0) == 6;
189
+ }),
190
+ width: 150,
191
+ },
192
+ { code: "createdAt", label: "创建时间" },
193
+ { code: "updatedAt", label: "更新时间" },
194
+ ];
195
+
196
+ export default fields;
197
+
198
+ ```
199
+
200
+ ### (四)每个领域模型都有详情页
201
+ ```javascript
202
+ {
203
+ code: "id",
204
+ label: "ID",
205
+ rowQuery: (row) => {
206
+ return { stationCode: row.code };
207
+ },
208
+ },
209
+ ```
210
+
211
+ ### (五)每个领域模型根据 `API` 接口情况提供标准的增删改查的操作
212
+ 页面文件夹下rest.js
213
+ * 为领域下的接口请求,`getList` `update` `create` 等。
214
+
215
+ ``` JAVASCRIPT
216
+ import http from "@/utils/http";
217
+
218
+ function getList(data) {
219
+ return http.get("stations", data).then((res) => ({ data: res }));
220
+ }
221
+
222
+ function getOne({ id }) {
223
+ return http.get(`stations/${id}`).then((res) => ({ data: res }));
224
+ }
225
+
226
+ function update(station) {
227
+ return http.put(`stations/${station.id}`, station);
228
+ }
229
+
230
+ function create(station) {
231
+ return http.post("stations", station);
232
+ }
233
+
234
+ function getBound(data) {
235
+ return http.get("station-customers/binds", data);
236
+ }
237
+
238
+ function getUnbound() {
239
+ return http.get("station-customers/unbound");
240
+ }
241
+
242
+ function updateStationCustomers(data) {
243
+ return http.put(`station-customers/${data.id}/bind`, data);
244
+ }
245
+
246
+ function removeStationCustomers(id) {
247
+ return http.remove(`station-customers/${id}/bind`);
248
+ }
249
+
250
+ function bindStationCustomers(data) {
251
+ return http.post(`station-customers/bind`, data);
252
+ }
253
+
254
+ export default {
255
+ getList,
256
+ getOne,
257
+ update,
258
+ create,
259
+ getBound,
260
+ getUnbound,
261
+ updateStationCustomers,
262
+ removeStationCustomers,
263
+ bindStationCustomers,
264
+ };
265
+
266
+
267
+ ```
268
+
269
+ ### (六)列表页提供可配置的数据过滤方式
270
+ 页面文件夹下filters.js
271
+ * 为领域下的设置搜索条件。
272
+ ``` JAVASCRIPT
273
+ import http from "@/utils/http";
274
+
275
+ const filters = {
276
+ name: {
277
+ name: "名称",
278
+ },
279
+ cityCode: {
280
+ name: "城市",
281
+ },
282
+ enabled: {
283
+ name: "启用",
284
+ type: "boolean",
285
+ },
286
+ defaultStation: {
287
+ name: "默认",
288
+ type: "boolean",
289
+ },
290
+ hasLocalService: {
291
+ name: "开通服务",
292
+ type: "boolean",
293
+ },
294
+ isPriority: {
295
+ name: "重要客户",
296
+ type: "boolean",
297
+ },
298
+ };
299
+
300
+ export default filters;
301
+
302
+ ```
303
+ ### (七)提供针对列表页数据集的批量操作(`PageAction`)
304
+ 页面文件夹下page-actions.js
305
+ * 为列表数据集的批量操作。
306
+ ``` JAVASCRIPT
307
+ import Test from "./components/Test.vue";
308
+
309
+ const pageActions = [
310
+ {
311
+ name: "敏感词测试",
312
+ component: Test,
313
+ },
314
+ ];
315
+
316
+ export default pageActions;
317
+
318
+ ```
319
+ ### (八)提供针对单条数据的操作(`RowAction`)
320
+ 页面文件夹下row-actions.js
321
+ * 为针对单挑数据操作。
322
+ ``` JAVASCRIPT
323
+ import RegionEditor from "./components/ToExamine.vue";
324
+
325
+ const rowActions = [
326
+ {
327
+ component: RegionEditor,
328
+ isVisible: (data) => {
329
+ return true;
330
+ },
331
+ },
332
+ ];
333
+
334
+ export default rowActions;
335
+ ```
336
+ ### (九)提供针对数据关联的显示
337
+
338
+ * 从属于:`belongs-to`
339
+
340
+ * 为跳转到其他功能的详情页面。
341
+ ``` JAVASCRIPT
342
+ {
343
+ code: "messageRuleId",
344
+ label: "规则名称",
345
+ width: 150,
346
+ type: "belongs-to",
347
+ belongsTo: "message-send-rule",
348
+ },
349
+
350
+ ```
351
+ * `belongs-to`对应为目标功能页面的code
352
+ ``` JAVASCRIPT
353
+ export default defineDomain("admin", {
354
+ name: "消息发送规则",
355
+ code: "message-send-rule",
356
+ fields,
357
+ filters,
358
+ rest,
359
+ hasMany: ["message-push"],
360
+ });
361
+
362
+ ```
363
+
364
+ * 一对多:`has-many`。
365
+ * 功能页面 `config.js` 配置 `hasMany` ,对应为此功能页面的子功能。
366
+ * 可以为系统内的任何其他功能页面,hasMany对应数组,item为子功能的code。
367
+
368
+ ``` JAVASCRIPT
369
+ import { defineDomain } from "kouxiangtang";
370
+ import rest from "./rest.js";
371
+ import fields from "./fields.js";
372
+ import filters from "./filters.js";
373
+ import rowActions from "./row-actions.js";
374
+
375
+ export default defineDomain("admin", {
376
+ name: "资产",
377
+ code: "currency",
378
+ fields,
379
+ rest,
380
+ filters,
381
+ rowActions,
382
+ actionsWidth: 240,
383
+ hasMany: ["account", "asset-details", "rewards-rules"],
384
+ });
385
+
386
+ ```
387
+ * 如下图
388
+ ![alt text](doc/image-8.png)
389
+ ### (十)组件的使用
390
+ 页面文件夹下`components`
391
+
392
+ ![alt text](doc/image-7.png)
393
+ * 使用组件示例。
394
+
395
+ ``` JAVASCRIPT
396
+ import Approved from "./components/Approved.vue";
397
+
398
+ const rowActions = [
399
+ {
400
+ component: Approved,
401
+ isVisible: (data) => {
402
+ return true;
403
+ },
404
+ },
405
+ ];
406
+
407
+ export default rowActions;
408
+ ```
2
409
 
3
- This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
410
 
5
- ## Recommended IDE Setup
6
411
 
7
- - [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur
@@ -1,6 +1,6 @@
1
- import { computed as F, ref as y, openBlock as p, createElementBlock as I, Fragment as b, createVNode as r, unref as s, normalizeClass as M, withModifiers as R, withCtx as i, createBlock as f, createTextVNode as j, createElementVNode as k, renderList as L, toDisplayString as O, createCommentVNode as S } from "vue";
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
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-DWaIPnvt.js";
3
+ import { _ as Q, j as X, p as Y, d as Z, k as ee, h as te, m as ae } from "./index-BDc0n3q3.js";
4
4
  import "./el-progress-l0sNRNKZ.js";
5
5
  const se = ["src"], ne = { class: "file-type" }, le = {
6
6
  __name: "AttachmentUploader",
@@ -26,8 +26,8 @@ const se = ["src"], ne = { class: "file-type" }, le = {
26
26
  }
27
27
  },
28
28
  emits: ["on-success", "on-remove", "on-change"],
29
- setup(E, { emit: C }) {
30
- const m = C, n = E, g = F(() => n.pics.map((e) => {
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;
@@ -41,7 +41,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
41
41
  }
42
42
  return { ...e, name: e.id, fileType: t };
43
43
  })), _ = y(""), h = y(!1);
44
- y(n);
44
+ y(s);
45
45
  const x = X().fileUploadUrl;
46
46
  `${localStorage.getItem("token")}`;
47
47
  const V = (e) => {
@@ -50,14 +50,14 @@ const se = ["src"], ne = { class: "file-type" }, le = {
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"), z = c.getContext("2d");
54
- c.width = d.width, c.height = d.height, z.drawImage(d, 0, 0, c.width, c.height), c.toBlob(
55
- (A) => {
56
- const P = new File([A], e.name, {
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(P);
60
+ a(A);
61
61
  },
62
62
  e.type,
63
63
  0.5
@@ -65,30 +65,40 @@ const se = ["src"], ne = { class: "file-type" }, le = {
65
65
  };
66
66
  }, !1) : (a(e), !1);
67
67
  });
68
- }, U = (e) => {
69
- e.status === "success" && (n.props.deleteUrl ? te.remove(`${n.props.deleteUrl}/${e.id}/attachment`).then(() => {
70
- m("on-remove", e);
71
- }) : m("on-remove", e));
68
+ }, I = (e) => {
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);
72
82
  }, T = () => {
73
83
  u({
74
- message: `最多只能上传 ${n.props.limit} 个文件!`,
84
+ message: `最多只能上传 ${s.props.limit} 个文件!`,
75
85
  type: "warning"
76
86
  });
77
- }, B = (e) => {
87
+ }, P = (e) => {
78
88
  _.value = e.url, h.value = !0;
79
- }, N = (e) => {
89
+ }, B = (e) => {
80
90
  const t = e.name.substring(0, e.name.lastIndexOf("."));
81
91
  if (!/^[\u4e00-\u9fa5\w-_]+$/.test(t))
82
92
  return u({
83
93
  message: "请勿输入特殊字符!",
84
94
  type: "warning"
85
95
  }), !1;
86
- V(e).then((l) => l.size / 1024 / 1024 < 5 ? (D(l), !1) : (u({
96
+ V(e).then((l) => l.size / 1024 / 1024 < 5 ? (N(l), !1) : (u({
87
97
  message: "上传大小不能超过 5MB!",
88
98
  type: "warning"
89
99
  }), !1));
90
100
  };
91
- function $(e, t) {
101
+ function D(e, t) {
92
102
  if (!e.name) {
93
103
  u({
94
104
  message: "附件名称不能为空!",
@@ -98,7 +108,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
98
108
  }
99
109
  m("on-change", e);
100
110
  }
101
- function D(e) {
111
+ function N(e) {
102
112
  return w.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((t, a) => {
103
113
  const l = new FormData();
104
114
  l.append("file", e), ae.post(x, l, {}).then((o) => (w.service().close(), u({
@@ -112,37 +122,37 @@ const se = ["src"], ne = { class: "file-type" }, le = {
112
122
  });
113
123
  });
114
124
  }
115
- return (e, t) => (p(), I(b, null, [
116
- r(s(q), {
125
+ return (e, t) => (p(), k(E, null, [
126
+ r(n(q), {
117
127
  "file-list": g.value,
118
- action: s(x),
119
- limit: n.props.limit,
120
- accept: n.props.accept,
121
- "list-type": n.props.listType,
122
- "on-remove": U,
123
- "before-upload": N,
128
+ action: n(x),
129
+ limit: s.props.limit,
130
+ accept: s.props.accept,
131
+ "list-type": s.props.listType,
132
+ "on-remove": I,
133
+ "before-upload": B,
124
134
  "on-exceed": T,
125
- "on-preview": B,
135
+ "on-preview": P,
126
136
  multiple: !0,
127
137
  "http-request": () => !1,
128
- "show-file-list": n.props.listType !== "text",
138
+ "show-file-list": s.props.listType !== "text",
129
139
  class: M([
130
140
  "upload-main",
131
- { "disable-upload": g.value.length >= n.props.limit }
141
+ { "disable-upload": g.value.length >= s.props.limit }
132
142
  ]),
133
143
  onClick: t[0] || (t[0] = R(() => {
134
144
  }, ["prevent"]))
135
145
  }, {
136
146
  default: i(() => [
137
- n.props.listType !== "text" ? (p(), f(s(v), {
147
+ s.props.listType !== "text" ? (p(), f(n(v), {
138
148
  key: 0,
139
149
  disabled: !0
140
150
  }, {
141
151
  default: i(() => [
142
- r(s(Y))
152
+ r(n(Y))
143
153
  ]),
144
154
  _: 1
145
- })) : (p(), f(s(W), {
155
+ })) : (p(), f(n(W), {
146
156
  key: 1,
147
157
  class: "upload-button",
148
158
  type: "primary"
@@ -155,12 +165,12 @@ const se = ["src"], ne = { class: "file-type" }, le = {
155
165
  ]),
156
166
  _: 1
157
167
  }, 8, ["file-list", "action", "limit", "accept", "list-type", "show-file-list", "class"]),
158
- r(s(G), {
168
+ r(n(G), {
159
169
  modelValue: h.value,
160
170
  "onUpdate:modelValue": t[1] || (t[1] = (a) => h.value = a)
161
171
  }, {
162
172
  default: i(() => [
163
- k("img", {
173
+ U("img", {
164
174
  "w-full": "",
165
175
  src: _.value,
166
176
  alt: "Preview Image"
@@ -168,35 +178,35 @@ const se = ["src"], ne = { class: "file-type" }, le = {
168
178
  ]),
169
179
  _: 1
170
180
  }, 8, ["modelValue"]),
171
- n.props.listType == "text" ? (p(), f(s(H), { key: 0 }, {
181
+ s.props.listType == "text" ? (p(), f(n(H), { key: 0 }, {
172
182
  default: i(() => [
173
- (p(!0), I(b, null, L(g.value, (a, l) => (p(), f(s(J), {
183
+ (p(!0), k(E, null, L(g.value, (a, l) => (p(), f(n(J), {
174
184
  key: l,
175
185
  class: "file-list"
176
186
  }, {
177
187
  default: i(() => [
178
- r(s(v), {
188
+ r(n(v), {
179
189
  color: "#73767a",
180
190
  size: 14
181
191
  }, {
182
192
  default: i(() => [
183
- r(s(Z))
193
+ r(n(Z))
184
194
  ]),
185
195
  _: 1
186
196
  }),
187
- r(s(K), {
197
+ r(n(K), {
188
198
  modelValue: a.name,
189
199
  "onUpdate:modelValue": (o) => a.name = o,
190
- onChange: (o) => $(a)
200
+ onChange: (o) => D(a)
191
201
  }, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"]),
192
- k("span", ne, "." + O(a.fileType), 1),
193
- r(s(v), {
202
+ U("span", ne, "." + O(a.fileType), 1),
203
+ r(n(v), {
194
204
  color: "#73767a",
195
205
  size: 12,
196
- onClick: (o) => U(a)
206
+ onClick: (o) => I(a)
197
207
  }, {
198
208
  default: i(() => [
199
- r(s(ee))
209
+ r(n(ee))
200
210
  ]),
201
211
  _: 2
202
212
  }, 1032, ["onClick"])
@@ -208,8 +218,8 @@ const se = ["src"], ne = { class: "file-type" }, le = {
208
218
  })) : S("", !0)
209
219
  ], 64));
210
220
  }
211
- }, pe = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-bea56e43"]]);
221
+ }, pe = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-4c31cc76"]]);
212
222
  export {
213
223
  pe as default
214
224
  };
215
- //# sourceMappingURL=AttachmentUploader-Dk3pI8xI.js.map
225
+ //# sourceMappingURL=AttachmentUploader-dO2PiIqG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentUploader-dO2PiIqG.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,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,aAAO,EAAE,GAAGD,GAAM,MAAMA,EAAK,IAAI,UAAUC;IAC/C,CAAG,CACF,GACKE,IAAiBC,EAAI,EAAE,GACvBC,IAAgBD,EAAI,EAAK;AACd,IAAAA,EAAIR,CAAK;AAC1B,UAAMU,IAAYC,EAAW,EAAC;AACf,IACY,gBAAa,QAAQ,OAAO;AAEvD,UAAMC,IAAc,CAACC,MAAS;AAC5B,YAAMC,IAAS,IAAI;AACnB,aAAAA,EAAO,cAA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MAAM,MAAM;AACX,UAAAH,EAAU,UAAU,SACpBP,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDd,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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, j as C, l as S, p as L, n as N, m as V } from "./index-DWaIPnvt.js";
3
+ import { _ as M, j as C, l as S, p as L, n as N, m as V } from "./index-BDc0n3q3.js";
4
4
  import "./el-progress-l0sNRNKZ.js";
5
5
  const q = { class: "image-slot" }, z = {
6
6
  __name: "ImageUploader",
@@ -94,4 +94,4 @@ const q = { class: "image-slot" }, z = {
94
94
  export {
95
95
  F as default
96
96
  };
97
- //# sourceMappingURL=ImageUploader-Sl6CARAH.js.map
97
+ //# sourceMappingURL=ImageUploader-DJfujt_H.js.map