@qynpm/ui 1.0.4 → 1.0.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.
Files changed (82) hide show
  1. package/README.md +228 -59
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.mjs +19 -15
  4. package/dist/lib/dialog/index.vue.cjs +1 -1
  5. package/dist/lib/dialog/index.vue.mjs +24 -25
  6. package/dist/lib/dialog/index.vue3.cjs +1 -0
  7. package/dist/lib/dialog/index.vue3.mjs +5 -0
  8. package/dist/lib/index.cjs +1 -1
  9. package/dist/lib/index.mjs +43 -30
  10. package/dist/lib/qy-action-bar/index.vue.cjs +1 -1
  11. package/dist/lib/qy-action-bar/index.vue.mjs +4 -53
  12. package/dist/lib/qy-action-bar/index.vue2.cjs +1 -0
  13. package/dist/lib/qy-action-bar/index.vue2.mjs +55 -0
  14. package/dist/lib/qy-form-section/index.vue.cjs +1 -1
  15. package/dist/lib/qy-form-section/index.vue.mjs +4 -86
  16. package/dist/lib/qy-form-section/index.vue2.cjs +1 -0
  17. package/dist/lib/qy-form-section/index.vue2.mjs +87 -0
  18. package/dist/lib/qy-input/index.vue.mjs +2 -1
  19. package/dist/lib/qy-input/index.vue2.cjs +1 -0
  20. package/dist/lib/qy-input/index.vue2.mjs +4 -0
  21. package/dist/lib/qy-money-input/index.vue.cjs +1 -0
  22. package/dist/lib/qy-money-input/index.vue.mjs +171 -0
  23. package/dist/lib/qy-money-input/index.vue2.cjs +1 -0
  24. package/dist/lib/qy-money-input/index.vue2.mjs +4 -0
  25. package/dist/lib/qy-radio-group/index.vue.cjs +1 -0
  26. package/dist/lib/qy-radio-group/index.vue.mjs +90 -0
  27. package/dist/lib/qy-radio-group/index.vue2.cjs +1 -0
  28. package/dist/lib/qy-radio-group/index.vue2.mjs +4 -0
  29. package/dist/lib/qy-record-quote-search/index.vue.cjs +1 -1
  30. package/dist/lib/qy-record-quote-search/index.vue.mjs +4 -203
  31. package/dist/lib/qy-record-quote-search/index.vue2.cjs +1 -0
  32. package/dist/lib/qy-record-quote-search/index.vue2.mjs +204 -0
  33. package/dist/lib/qy-remote-select/index.vue.cjs +1 -0
  34. package/dist/lib/qy-remote-select/index.vue.mjs +214 -0
  35. package/dist/lib/qy-remote-select/index.vue2.cjs +1 -0
  36. package/dist/lib/qy-remote-select/index.vue2.mjs +4 -0
  37. package/dist/lib/qy-search-input/index.vue.cjs +1 -1
  38. package/dist/lib/qy-search-input/index.vue.mjs +4 -274
  39. package/dist/lib/qy-search-input/index.vue2.cjs +1 -0
  40. package/dist/lib/qy-search-input/index.vue2.mjs +276 -0
  41. package/dist/lib/qy-select/index.vue.cjs +1 -1
  42. package/dist/lib/qy-select/index.vue.mjs +80 -55
  43. package/dist/lib/qy-select/index.vue2.cjs +1 -0
  44. package/dist/lib/qy-select/index.vue2.mjs +4 -0
  45. package/dist/lib/qy-voucher-upload/index.vue.cjs +1 -0
  46. package/dist/lib/qy-voucher-upload/index.vue.mjs +123 -0
  47. package/dist/lib/remark-image/index.vue.cjs +1 -1
  48. package/dist/lib/remark-image/index.vue.mjs +4 -195
  49. package/dist/lib/remark-image/index.vue2.cjs +1 -0
  50. package/dist/lib/remark-image/index.vue2.mjs +197 -0
  51. package/dist/lib/upload/index.vue.cjs +1 -1
  52. package/dist/lib/upload/index.vue.mjs +317 -217
  53. package/dist/lib/utils/auth.cjs +1 -1
  54. package/dist/lib/utils/auth.mjs +1 -1
  55. package/dist/node_modules/.pnpm/{js-cookie@3.0.1 → js-cookie@3.0.5}/node_modules/js-cookie/dist/js.cookie.cjs +1 -1
  56. package/dist/node_modules/.pnpm/{js-cookie@3.0.1 → js-cookie@3.0.5}/node_modules/js-cookie/dist/js.cookie.mjs +6 -6
  57. package/dist/qy-dialog/index.cjs +1 -1
  58. package/dist/qy-dialog/index.mjs +3 -2
  59. package/dist/qy-input/index.cjs +1 -1
  60. package/dist/qy-money-input/index.cjs +1 -0
  61. package/dist/qy-money-input/index.mjs +6 -0
  62. package/dist/qy-radio-group/index.cjs +1 -0
  63. package/dist/qy-radio-group/index.mjs +6 -0
  64. package/dist/qy-remark-image/index.cjs +1 -1
  65. package/dist/qy-remark-image/index.mjs +1 -1
  66. package/dist/qy-remote-select/index.cjs +1 -0
  67. package/dist/qy-remote-select/index.mjs +6 -0
  68. package/dist/qy-select/index.cjs +1 -1
  69. package/dist/qy-voucher-upload/index.cjs +1 -0
  70. package/dist/qy-voucher-upload/index.mjs +6 -0
  71. package/index.d.ts +20 -11
  72. package/package.json +25 -1
  73. package/qy-money-input/index.d.ts +12 -0
  74. package/qy-money-input/index.js +15 -0
  75. package/qy-radio-group/index.d.ts +12 -0
  76. package/qy-radio-group/index.js +15 -0
  77. package/qy-remote-select/index.d.ts +12 -0
  78. package/qy-remote-select/index.js +15 -0
  79. package/qy-voucher-upload/index.d.ts +12 -0
  80. package/qy-voucher-upload/index.js +15 -0
  81. /package/dist/_virtual/{plugin-vue_export-helper.cjs → _plugin-vue_export-helper.cjs} +0 -0
  82. /package/dist/_virtual/{plugin-vue_export-helper.mjs → _plugin-vue_export-helper.mjs} +0 -0
@@ -1,24 +1,37 @@
1
- import { ElUpload as me, ElIcon as ye, ElPopover as ge, ElInput as be, ElImageViewer as xe, ElDialog as we } from "element-plus/es";
2
- import { ref as p, onMounted as he, computed as x, watch as ke, onBeforeUnmount as Ve, createElementBlock as w, openBlock as m, normalizeStyle as Ue, normalizeClass as I, createVNode as y, createBlock as Be, createCommentVNode as h, withCtx as U, withModifiers as B, createElementVNode as k, unref as Y, Fragment as M, toDisplayString as R, createTextVNode as $ } from "vue";
3
- import { Plus as Le, InfoFilled as Se } from "@element-plus/icons-vue";
4
- import { ElMessage as V, ElLoading as De } from "element-plus";
5
- import { getToken as Re } from "../utils/auth.mjs";
1
+ import { ElUpload as Le, ElIcon as Te, ElPopover as Re, ElInput as qe, ElImageViewer as je, ElDialog as Pe } from "element-plus/es";
2
+ import { ref as p, onMounted as ze, computed as V, watch as le, nextTick as Ce, onBeforeUnmount as Ie, createElementBlock as g, openBlock as m, normalizeStyle as Oe, normalizeClass as F, createVNode as b, createBlock as $e, createCommentVNode as h, withCtx as U, withModifiers as v, unref as ae, Fragment as N, createElementVNode as k, toDisplayString as R, createTextVNode as I } from "vue";
3
+ import { Plus as Ae, InfoFilled as Me } from "@element-plus/icons-vue";
4
+ import { ElMessage as S, ElLoading as Fe } from "element-plus";
5
+ import { getToken as Ne } from "../utils/auth.mjs";
6
6
  /* empty css */
7
7
  /* empty css */
8
- import qe from "../../_virtual/plugin-vue_export-helper.mjs";
9
- const ze = { class: "qy-upload__hint" }, Te = ["src"], je = {
8
+ import _e from "../../_virtual/_plugin-vue_export-helper.mjs";
9
+ const Ee = { class: "qy-upload__hint" }, He = ["placeholder", "disabled"], We = ["src"], Xe = {
10
10
  key: 1,
11
11
  class: "qy-upload__tip"
12
- }, _e = { class: "error" }, $e = { class: "error" }, Ce = Object.assign({
12
+ }, Ke = { class: "error" }, Qe = { class: "error" }, Je = /* @__PURE__ */ Object.assign({
13
13
  name: "QyUpload"
14
14
  }, {
15
15
  __name: "index",
16
16
  props: {
17
+ /**
18
+ * 受控值。valueFormat 为 object 时结构为 { files, text },
19
+ * array 时为 string[],string 时为逗号分隔 URL。
20
+ */
21
+ modelValue: { type: [Object, Array, String], default: void 0 },
17
22
  /**
18
23
  * 初始值,结构为 { files: '逗号分隔的URL', text: '文字内容' }
19
24
  * 非受控模式,仅初始化时读取一次
20
25
  */
21
26
  defaultValue: { type: Object, default: () => ({ files: "", text: "" }) },
27
+ /** v-model 输出格式:object | array | string */
28
+ valueFormat: { type: String, default: "object" },
29
+ /** 是否显示底部文字备注区 */
30
+ showText: { type: Boolean, default: !0 },
31
+ /** 是否显示纯粘贴输入条,不保存文字,仅用于承接 Ctrl+V 图片 */
32
+ showPasteInput: { type: Boolean, default: !1 },
33
+ /** 文字区占位文案,也用于凭证上传的粘贴提示 */
34
+ pastePlaceholder: { type: String, default: "输入文字" },
22
35
  /** 是否多选 */
23
36
  multiple: { type: Boolean, default: !0 },
24
37
  /** 是否禁用 */
@@ -35,6 +48,7 @@ const ze = { class: "qy-upload__hint" }, Te = ["src"], je = {
35
48
  api: { type: String, default: "/permission-api/common/uploads" },
36
49
  /** FormData 中文件字段名 */
37
50
  name: { type: String, default: "file" },
51
+ /** token 读取 key,对应 utils/auth 中的存储字段 */
38
52
  tokenKey: { type: String, default: "Admin-Token" },
39
53
  /** 是否支持视频模式(强制 limit=1) */
40
54
  supportVideo: { type: Boolean, default: !1 },
@@ -51,332 +65,418 @@ const ze = { class: "qy-upload__hint" }, Te = ["src"], je = {
51
65
  /** 上传时附加的额外 FormData 字段 */
52
66
  extraData: { type: Object, default: () => ({}) }
53
67
  },
54
- emits: ["change", "success", "error", "remove"],
55
- setup(c, { expose: Z, emit: ee }) {
56
- const o = c, g = ee, q = p(null), u = p([]), N = p(null), L = [], C = p(!1), F = p([]), P = p(0), S = p(!1), E = p(""), H = p(""), z = /* @__PURE__ */ new Set(), T = p(!1), f = p(""), O = p(!1);
57
- he(() => {
58
- const t = o.defaultValue;
59
- if (!t) return;
60
- f.value = t.text ?? "";
61
- const e = t.files ?? "", a = Array.isArray(e) ? e.filter(Boolean) : String(e).split(",").filter(Boolean);
62
- a.length && (u.value = a.map((l, i) => ({
63
- name: l.split("/").pop() || `file-${i}`,
64
- url: l,
65
- status: "success",
66
- uid: Date.now() + i
67
- })));
68
+ emits: [
69
+ "update:modelValue",
70
+ "change",
71
+ "success",
72
+ "error",
73
+ "remove"
74
+ ],
75
+ setup(r, { expose: ie, emit: oe }) {
76
+ const a = r, y = oe, q = p(null), n = p([]), _ = p(null), se = p(null), B = [];
77
+ let O = !1;
78
+ const $ = p(!1), A = p([]), E = p(0), D = p(!1), H = p(""), W = p(""), j = /* @__PURE__ */ new Set(), P = p(!1), c = p(""), M = p(!1);
79
+ ze(() => {
80
+ a.modelValue === void 0 && K(a.defaultValue);
68
81
  });
69
- const te = x(() => ({ large: "160px", default: "140px", small: "80px" })[o.size] ?? o.size), le = x(() => o.disabled), ae = x(
82
+ const ne = V(() => ({ large: "160px", default: "140px", small: "80px" })[a.size] ?? a.size), ue = V(() => a.disabled), re = V(
70
83
  () => {
71
- var t;
72
- return o.isShowTip && (o.fileSize || ((t = v.value) == null ? void 0 : t.length));
84
+ var e;
85
+ return a.isShowTip && (a.fileSize || ((e = x.value) == null ? void 0 : e.length));
73
86
  }
74
- ), v = x(() => {
75
- var t;
76
- return (t = o.fileType) != null && t.length ? o.fileType.map((e) => e.toLowerCase()) : o.supportVideo ? ["mp4", "mov", "avi"] : ["jpg", "jpeg", "png", "gif", "webp"];
77
- }), j = x(() => {
78
- const t = o.supportVideo ? 1 : o.limit;
79
- return u.value.length >= t;
80
- }), ie = x(
81
- () => v.value.map((t) => `.${t}`).join(",")
82
- ), oe = x(() => ({
83
- "qy-upload--reached-limit": j.value,
84
- "qy-upload--disabled": o.disabled,
85
- "qy-upload--video": o.supportVideo
87
+ ), x = V(() => {
88
+ var e;
89
+ return (e = a.fileType) != null && e.length ? a.fileType.map((t) => t.toLowerCase()) : a.supportVideo ? ["mp4", "mov", "avi"] : ["jpg", "jpeg", "png", "gif", "webp"];
90
+ }), z = V(() => {
91
+ const e = a.supportVideo ? 1 : a.limit;
92
+ return n.value.length >= e;
93
+ }), de = V(
94
+ () => x.value.map((e) => `.${e}`).join(",")
95
+ ), pe = V(() => ({
96
+ "qy-upload--reached-limit": z.value,
97
+ "qy-upload--disabled": a.disabled,
98
+ "qy-upload--video": a.supportVideo,
99
+ "qy-upload--without-text": !a.showText && !a.showPasteInput
86
100
  }));
87
- ke(f, () => D());
88
- function se() {
89
- var t;
90
- (t = N.value) == null || t.focus();
101
+ le(c, () => {
102
+ O || L();
103
+ }), le(
104
+ () => a.modelValue,
105
+ (e) => {
106
+ e !== void 0 && K(e);
107
+ },
108
+ { immediate: !0, deep: !0 }
109
+ );
110
+ function X(e) {
111
+ return Array.isArray(e) ? e.filter(Boolean) : e ? String(e).split(",").filter(Boolean) : [];
112
+ }
113
+ function fe(e) {
114
+ return Array.isArray(e) ? { files: e, text: "" } : typeof e == "string" ? { files: X(e), text: "" } : e && typeof e == "object" ? {
115
+ files: X(e.files),
116
+ text: e.text ?? ""
117
+ } : { files: [], text: "" };
118
+ }
119
+ function ce(e = []) {
120
+ return e.map((t, i) => ({
121
+ name: String(t).split("/").pop() || `file-${i}`,
122
+ url: t,
123
+ status: "success",
124
+ uid: Date.now() + i
125
+ }));
126
+ }
127
+ function me(e) {
128
+ const t = new Set(e.map((l) => l.url)), i = n.value.filter(
129
+ (l) => l.status === "uploading" && !t.has(l.url)
130
+ );
131
+ return [...e, ...i];
132
+ }
133
+ function K(e) {
134
+ const t = fe(e);
135
+ O = !0, c.value = t.text, n.value = me(ce(t.files)), Ce(() => {
136
+ O = !1;
137
+ });
91
138
  }
92
- function D(t) {
93
- const l = { files: (t ?? u.value).filter((i) => i.status === "success" && i.url).map((i) => i.url), text: f.value };
94
- g("change", l), o.callBack && o.callBack(l);
139
+ function Q(e) {
140
+ return a.valueFormat === "array" ? e.files : a.valueFormat === "string" ? e.files.join(",") : e;
95
141
  }
96
- function ne(t, e) {
97
- D(e);
142
+ function ve() {
143
+ var e;
144
+ (e = _.value) == null || e.focus();
98
145
  }
99
- function ue(t) {
146
+ function ye(e) {
147
+ e.target.value = "";
148
+ }
149
+ function L(e) {
150
+ const l = { files: (e ?? n.value).filter((o) => o.status === "success" && o.url).map((o) => o.url), text: c.value };
151
+ y("update:modelValue", Q(l)), y("change", l), a.callBack && a.callBack(l);
152
+ }
153
+ function ge(e, t) {
154
+ L(t), y("remove", e, t);
155
+ }
156
+ function xe(e) {
100
157
  var l;
101
- if (!(t.size / 1024 / 1024 < o.fileSize))
102
- return V.warning(`文件大小不能超过${o.fileSize}M`), !1;
103
- const a = ((l = t.name.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
104
- return v.value.includes(a) ? !0 : (V.warning(
105
- `格式不支持,仅允许: ${v.value.join("/")}`
158
+ if (!(e.size / 1024 / 1024 < a.fileSize))
159
+ return S.warning(`文件大小不能超过${a.fileSize}M`), !1;
160
+ const i = ((l = e.name.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
161
+ return x.value.includes(i) ? !0 : (S.warning(
162
+ `格式不支持,仅允许: ${x.value.join("/")}`
106
163
  ), !1);
107
164
  }
108
- function W(t, e, a, l) {
109
- var J, G;
110
- const i = o.api.startsWith("http") ? o.api : window.location.origin + o.api.replace(/^([^/])/, "/$1"), r = new FormData();
111
- r.append(o.name, t), o.extraData && Object.entries(o.extraData).forEach(([n, ve]) => r.append(n, ve));
165
+ function J(e, t, i, l) {
166
+ var ee, te;
167
+ const o = a.api.startsWith("http") ? a.api : window.location.origin + a.api.replace(/^([^/])/, "/$1"), d = new FormData();
168
+ d.append(a.name, e), a.extraData && Object.entries(a.extraData).forEach(([u, De]) => d.append(u, De));
112
169
  const s = new XMLHttpRequest();
113
- L.push(s);
114
- const b = ((J = q.value) == null ? void 0 : J.$el.querySelector(".el-upload--picture-card")) || ((G = q.value) == null ? void 0 : G.$el), _ = De.service({
115
- target: b,
170
+ B.push(s);
171
+ const w = ((ee = q.value) == null ? void 0 : ee.$el.querySelector(".el-upload--picture-card")) || ((te = q.value) == null ? void 0 : te.$el), C = Fe.service({
172
+ target: w,
116
173
  text: "上传中",
117
174
  background: "rgba(255,255,255,0.7)"
118
- }), d = () => {
119
- const n = L.indexOf(s);
120
- n !== -1 && L.splice(n, 1), _.close();
175
+ }), f = () => {
176
+ const u = B.indexOf(s);
177
+ u !== -1 && B.splice(u, 1), C.close();
121
178
  };
122
- s.open("POST", i);
123
- const Q = Re(o.tokenKey);
124
- Q && s.setRequestHeader("Authorization", `Bearer ${Q}`), s.upload.onprogress = (n) => {
125
- n.total > 0 && (e == null || e({ percent: n.loaded / n.total * 100 }));
179
+ s.open("POST", o);
180
+ const Z = Ne(a.tokenKey);
181
+ Z && s.setRequestHeader("Authorization", `Bearer ${Z}`), s.upload.onprogress = (u) => {
182
+ u.total > 0 && (t == null || t({ percent: u.loaded / u.total * 100 }));
126
183
  }, s.onload = () => {
127
- if (d(), s.status < 200 || s.status >= 300) {
128
- const n = `上传失败 (HTTP ${s.status})`;
129
- V.error(n), g("error", { msg: n, status: s.status }), l == null || l(new Error(n));
184
+ if (f(), s.status < 200 || s.status >= 300) {
185
+ const u = `上传失败 (HTTP ${s.status})`;
186
+ S.error(u), y("error", { msg: u, status: s.status }), l == null || l(new Error(u));
130
187
  return;
131
188
  }
132
189
  try {
133
- const n = JSON.parse(s.responseText);
134
- n.code === 200 && n.urls ? (V.success("上传成功"), a == null || a({ ...n, url: n.urls })) : (V.error(n.msg || "上传失败"), g("error", n), l == null || l(n));
190
+ const u = JSON.parse(s.responseText);
191
+ u.code === 200 && u.urls ? (S.success("上传成功"), i == null || i({ ...u, url: u.urls })) : (S.error(u.msg || "上传失败"), y("error", u), l == null || l(u));
135
192
  } catch {
136
- V.error("上传失败,响应格式错误"), g("error", new Error("Response parse error")), l == null || l(new Error("Response parse error"));
193
+ S.error("上传失败,响应格式错误"), y("error", new Error("Response parse error")), l == null || l(new Error("Response parse error"));
137
194
  }
138
195
  }, s.onerror = () => {
139
- d(), V.error("上传失败,网络异常"), g("error", new Error("Network error")), l == null || l(new Error("Network error"));
140
- }, s.send(r);
196
+ f(), S.error("上传失败,网络异常"), y("error", new Error("Network error")), l == null || l(new Error("Network error"));
197
+ }, s.send(d);
198
+ }
199
+ function G(e) {
200
+ return a.disabled ? !1 : xe(e);
141
201
  }
142
- function X(t) {
143
- return o.disabled ? !1 : ue(t);
202
+ function be(e, t) {
203
+ const i = n.value.find(
204
+ (l) => {
205
+ var o;
206
+ return l.uid === (e == null ? void 0 : e.uid) || ((o = l.raw) == null ? void 0 : o.uid) === (e == null ? void 0 : e.uid);
207
+ }
208
+ );
209
+ i && (i.url = t, i.status = "success");
144
210
  }
145
- function re(t) {
146
- W(
147
- t.file,
148
- t.onProgress,
149
- (e) => {
150
- t.onSuccess(e), D(), g("success", e);
211
+ function he(e) {
212
+ J(
213
+ e.file,
214
+ e.onProgress,
215
+ (t) => {
216
+ be(e.file, t.url), e.onSuccess(t), L(), y("success", t);
151
217
  },
152
- (e) => t.onError(e)
218
+ (t) => e.onError(t)
153
219
  );
154
220
  }
155
- function de(t) {
221
+ function we(e) {
156
222
  var l;
157
- if (!t.url) return;
158
- const e = ((l = t.url.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
159
- if (["mp4", "mov", "avi", "webm"].includes(e)) {
160
- E.value = t.url, H.value = t.name || "视频预览", S.value = !0;
223
+ if (!e.url) return;
224
+ const t = ((l = e.url.split(".").pop()) == null ? void 0 : l.toLowerCase()) || "";
225
+ if (["mp4", "mov", "avi", "webm"].includes(t)) {
226
+ H.value = e.url, W.value = e.name || "视频预览", D.value = !0;
161
227
  return;
162
228
  }
163
- const a = u.value.filter(
164
- (i) => {
165
- var r;
166
- return i.status === "success" && i.url && !["mp4", "mov", "avi", "webm"].includes(
167
- (r = i.url.split(".").pop()) == null ? void 0 : r.toLowerCase()
229
+ const i = n.value.filter(
230
+ (o) => {
231
+ var d;
232
+ return o.status === "success" && o.url && !["mp4", "mov", "avi", "webm"].includes(
233
+ (d = o.url.split(".").pop()) == null ? void 0 : d.toLowerCase()
168
234
  );
169
235
  }
170
236
  );
171
- F.value = a.map((i) => i.url), P.value = a.findIndex((i) => i.uid === t.uid) || 0, C.value = !0;
237
+ A.value = i.map((o) => o.url), E.value = i.findIndex((o) => o.uid === e.uid) || 0, $.value = !0;
172
238
  }
173
- function pe() {
174
- C.value = !1, F.value = [];
239
+ function Ve() {
240
+ $.value = !1, A.value = [];
175
241
  }
176
- function K(t) {
177
- for (let e = 0; e < t.length; e++) {
178
- const a = t[e];
179
- if (!X(a)) continue;
180
- const l = Date.now() + e, i = URL.createObjectURL(a);
181
- z.add(i), u.value.push({
242
+ function Y(e) {
243
+ for (let t = 0; t < e.length; t++) {
244
+ const i = e[t];
245
+ if (!G(i)) continue;
246
+ const l = Date.now() + t, o = URL.createObjectURL(i);
247
+ j.add(o), n.value.push({
182
248
  uid: l,
183
- name: a.name || `file-${l}`,
249
+ name: i.name || `file-${l}`,
184
250
  status: "uploading",
185
251
  percentage: 0,
186
- url: i
187
- }), W(
188
- a,
189
- (r) => {
190
- const s = u.value.find((b) => b.uid === l);
191
- s && (s.percentage = r.percent);
252
+ url: o
253
+ }), J(
254
+ i,
255
+ (d) => {
256
+ const s = n.value.find((w) => w.uid === l);
257
+ s && (s.percentage = d.percent);
192
258
  },
193
- (r) => {
194
- const s = u.value.find((b) => b.uid === l);
195
- s && (s.status = "success", s.url = r.url, D(), g("success", r));
259
+ (d) => {
260
+ const s = n.value.find((w) => w.uid === l);
261
+ s && (s.status = "success", s.url = d.url, L(), y("success", d));
196
262
  },
197
- () => fe(l)
263
+ () => Be(l)
198
264
  );
199
265
  }
200
266
  }
201
- function A(t) {
267
+ function T(e) {
202
268
  var l;
203
- if (o.disabled) return;
204
- const e = (l = t.clipboardData) == null ? void 0 : l.items;
205
- if (!e) return;
206
- const a = [];
207
- for (let i = 0; i < e.length; i++) {
208
- const r = e[i];
209
- if (r.kind === "file" && r.type.startsWith("image/")) {
210
- const s = r.getAsFile();
211
- s && a.push(s);
269
+ if (a.disabled) return;
270
+ const t = (l = e.clipboardData) == null ? void 0 : l.items;
271
+ if (!t) return;
272
+ const i = [];
273
+ for (let o = 0; o < t.length; o++) {
274
+ const d = t[o];
275
+ if (d.kind === "file" && d.type.startsWith("image/")) {
276
+ const s = d.getAsFile();
277
+ s && i.push(s);
212
278
  }
213
279
  }
214
- a.length && (t.preventDefault(), K(a));
280
+ i.length && (e.preventDefault(), Y(i));
281
+ }
282
+ function ke() {
283
+ a.disabled || a.disableDrag || (P.value = !0);
284
+ }
285
+ function Se() {
286
+ P.value = !1;
215
287
  }
216
- function ce(t) {
217
- var a;
218
- if (T.value = !1, o.disabled || j.value) return;
219
- const e = Array.from(((a = t.dataTransfer) == null ? void 0 : a.files) || []).filter(
288
+ function Ue(e) {
289
+ var i;
290
+ if (P.value = !1, a.disabled || a.disableDrag || z.value) return;
291
+ const t = Array.from(((i = e.dataTransfer) == null ? void 0 : i.files) || []).filter(
220
292
  (l) => {
221
- var i;
222
- return v.value.includes((i = l.name.split(".").pop()) == null ? void 0 : i.toLowerCase());
293
+ var o;
294
+ return x.value.includes((o = l.name.split(".").pop()) == null ? void 0 : o.toLowerCase());
223
295
  }
224
296
  );
225
- e.length && K(e);
297
+ t.length && Y(t);
226
298
  }
227
- function fe(t) {
228
- var a;
229
- const e = u.value.findIndex((l) => l.uid === t);
230
- e !== -1 && ((a = u.value[e].url) != null && a.startsWith("blob:") && (URL.revokeObjectURL(u.value[e].url), z.delete(u.value[e].url)), u.value.splice(e, 1));
299
+ function Be(e) {
300
+ var i;
301
+ const t = n.value.findIndex((l) => l.uid === e);
302
+ t !== -1 && ((i = n.value[t].url) != null && i.startsWith("blob:") && (URL.revokeObjectURL(n.value[t].url), j.delete(n.value[t].url)), n.value.splice(t, 1));
231
303
  }
232
- return Ve(() => {
233
- L.forEach((t) => t.abort()), L.length = 0, z.forEach((t) => URL.revokeObjectURL(t)), z.clear();
234
- }), Z({
304
+ return Ie(() => {
305
+ B.forEach((e) => e.abort()), B.length = 0, j.forEach((e) => URL.revokeObjectURL(e)), j.clear();
306
+ }), ie({
307
+ /** 主动打开文件选择框,供表单或快捷操作调用 */
235
308
  openFileDialog: () => {
236
- var t, e;
237
- o.disabled || j.value || (e = (t = q.value) == null ? void 0 : t.$el.querySelector('input[type="file"]')) == null || e.click();
309
+ var e, t;
310
+ a.disabled || z.value || (t = (e = q.value) == null ? void 0 : e.$el.querySelector('input[type="file"]')) == null || t.click();
238
311
  },
239
- getPathList: () => u.value.filter((t) => t.status === "success").map((t) => t.url),
312
+ /** 获取已上传成功的文件 URL 列表 */
313
+ getPathList: () => n.value.filter((e) => e.status === "success").map((e) => e.url),
314
+ /** 清空文件和文字,并同步 change 事件 */
240
315
  clearFiles: () => {
241
- u.value = [], f.value = "", D();
316
+ n.value = [], c.value = "", L();
242
317
  },
318
+ /** 获取完整值,结构与 change 事件保持一致 */
243
319
  getValue: () => ({
244
- files: u.value.filter((t) => t.status === "success" && t.url).map((t) => t.url),
245
- text: f.value
320
+ files: n.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
321
+ text: c.value
322
+ }),
323
+ /** 获取按 valueFormat 输出的值,便于外部不走 v-model 时读取 */
324
+ getModelValue: () => Q({
325
+ files: n.value.filter((e) => e.status === "success" && e.url).map((e) => e.url),
326
+ text: c.value
246
327
  })
247
- }), (t, e) => {
248
- var _;
249
- const a = ye, l = be, i = ge, r = me, s = xe, b = we;
250
- return m(), w("div", {
251
- class: I(["qy-upload", oe.value]),
252
- style: Ue({ "--qy-upload-size": te.value })
328
+ }), (e, t) => {
329
+ var C;
330
+ const i = Te, l = qe, o = Re, d = Le, s = je, w = Pe;
331
+ return m(), g("div", {
332
+ class: F(["qy-upload", pe.value]),
333
+ style: Oe({ "--qy-upload-size": ne.value })
253
334
  }, [
254
- y(r, {
335
+ b(d, {
255
336
  ref_key: "uploadRef",
256
337
  ref: q,
257
- "file-list": u.value,
258
- "onUpdate:fileList": e[6] || (e[6] = (d) => u.value = d),
338
+ "file-list": n.value,
339
+ "onUpdate:fileList": t[6] || (t[6] = (f) => n.value = f),
259
340
  action: "#",
260
- multiple: c.supportVideo ? !1 : c.multiple,
261
- limit: c.supportVideo ? 1 : c.limit,
262
- "list-type": c.supportVideo ? "text" : "picture-card",
263
- accept: ie.value,
264
- disabled: le.value,
265
- "http-request": re,
266
- "before-upload": X,
267
- "on-preview": de,
268
- "on-remove": ne
341
+ multiple: r.supportVideo ? !1 : r.multiple,
342
+ limit: r.supportVideo ? 1 : r.limit,
343
+ "list-type": r.supportVideo ? "text" : "picture-card",
344
+ accept: de.value,
345
+ disabled: ue.value,
346
+ "http-request": he,
347
+ "before-upload": G,
348
+ "on-preview": we,
349
+ "on-remove": ge
269
350
  }, {
270
351
  default: U(() => [
271
- j.value ? h("", !0) : (m(), w("div", {
352
+ z.value ? h("", !0) : (m(), g("div", {
272
353
  key: 0,
273
- class: I(["qy-upload__trigger", { "is-dragover": T.value }]),
274
- onPaste: A,
275
- onDragover: e[4] || (e[4] = B((d) => T.value = !0, ["prevent"])),
276
- onDragleave: e[5] || (e[5] = B((d) => T.value = !1, ["prevent"])),
277
- onDrop: B(ce, ["prevent"])
354
+ class: F(["qy-upload__trigger", { "is-dragover": P.value }]),
355
+ onPaste: T,
356
+ onDragover: v(ke, ["prevent"]),
357
+ onDragleave: v(Se, ["prevent"]),
358
+ onDrop: v(Ue, ["prevent"])
278
359
  }, [
279
- y(a, { class: "qy-upload__icon" }, {
360
+ b(i, { class: "qy-upload__icon" }, {
280
361
  default: U(() => [
281
- y(Y(Le))
362
+ b(ae(Ae))
282
363
  ]),
283
364
  _: 1
284
365
  }),
285
- c.supportVideo ? (m(), w(M, { key: 0 }, [
286
- e[9] || (e[9] = k("span", { class: "qy-upload__label" }, "点击上传视频", -1)),
287
- k("span", ze, "支持 " + R(v.value.join(" / ")) + ",不超过 " + R(c.fileSize) + "MB", 1)
366
+ r.supportVideo ? (m(), g(N, { key: 0 }, [
367
+ t[9] || (t[9] = k("span", { class: "qy-upload__label" }, "点击上传视频", -1)),
368
+ k("span", Ee, "支持 " + R(x.value.join(" / ")) + ",不超过 " + R(r.fileSize) + "MB", 1)
288
369
  ], 64)) : h("", !0),
289
- k("div", {
370
+ r.showText ? (m(), g("div", {
371
+ key: 1,
290
372
  class: "qy-upload__text",
291
- onClick: e[3] || (e[3] = B(() => {
373
+ onClick: t[3] || (t[3] = v(() => {
292
374
  }, ["stop"])),
293
- onPaste: B(A, ["stop"])
375
+ onPaste: v(T, ["stop"])
294
376
  }, [
295
- y(i, {
296
- visible: O.value,
297
- "onUpdate:visible": e[2] || (e[2] = (d) => O.value = d),
377
+ b(o, {
378
+ visible: M.value,
379
+ "onUpdate:visible": t[2] || (t[2] = (f) => M.value = f),
298
380
  placement: "bottom-start",
299
381
  width: 220,
300
382
  trigger: "click",
301
383
  "popper-class": "qy-upload__text-popover",
302
- onAfterEnter: se
384
+ onAfterEnter: ve
303
385
  }, {
304
386
  reference: U(() => [
305
387
  k("div", {
306
- class: I(["qy-upload__text-preview", { "is-placeholder": !f.value }])
307
- }, R(f.value || "输入文字"), 3)
388
+ class: F(["qy-upload__text-preview", { "is-placeholder": !c.value }])
389
+ }, R(c.value || r.pastePlaceholder), 3)
308
390
  ]),
309
391
  default: U(() => [
310
- y(l, {
392
+ b(l, {
311
393
  ref_key: "inputRef",
312
- ref: N,
313
- modelValue: f.value,
314
- "onUpdate:modelValue": e[0] || (e[0] = (d) => f.value = d),
394
+ ref: _,
395
+ modelValue: c.value,
396
+ "onUpdate:modelValue": t[0] || (t[0] = (f) => c.value = f),
315
397
  type: "textarea",
316
398
  autosize: { minRows: 2, maxRows: 5 },
317
- placeholder: "输入文字或粘贴图片",
318
- disabled: c.disabled,
319
- onBlur: e[1] || (e[1] = (d) => O.value = !1),
320
- onPaste: B(A, ["stop"])
321
- }, null, 8, ["modelValue", "disabled"])
399
+ placeholder: r.pastePlaceholder,
400
+ disabled: r.disabled,
401
+ onBlur: t[1] || (t[1] = (f) => M.value = !1),
402
+ onPaste: v(T, ["stop"])
403
+ }, null, 8, ["modelValue", "placeholder", "disabled"])
322
404
  ]),
323
405
  _: 1
324
406
  }, 8, ["visible"])
325
- ], 32)
407
+ ], 32)) : r.showPasteInput ? (m(), g("div", {
408
+ key: 2,
409
+ class: "qy-upload__text",
410
+ onClick: t[5] || (t[5] = v(() => {
411
+ }, ["stop"])),
412
+ onPaste: v(T, ["stop"])
413
+ }, [
414
+ k("input", {
415
+ ref_key: "pasteInputRef",
416
+ ref: se,
417
+ class: "qy-upload__paste-input",
418
+ placeholder: r.pastePlaceholder,
419
+ disabled: r.disabled,
420
+ onPaste: v(T, ["stop"]),
421
+ onInput: ye,
422
+ onClick: t[4] || (t[4] = v(() => {
423
+ }, ["stop"]))
424
+ }, null, 40, He)
425
+ ], 32)) : h("", !0)
326
426
  ], 34))
327
427
  ]),
328
428
  _: 1
329
429
  }, 8, ["file-list", "multiple", "limit", "list-type", "accept", "disabled"]),
330
- C.value ? (m(), Be(s, {
430
+ $.value ? (m(), $e(s, {
331
431
  key: 0,
332
- "url-list": F.value,
333
- "initial-index": P.value,
334
- onClose: pe
432
+ "url-list": A.value,
433
+ "initial-index": E.value,
434
+ onClose: Ve
335
435
  }, null, 8, ["url-list", "initial-index"])) : h("", !0),
336
- y(b, {
337
- modelValue: S.value,
338
- "onUpdate:modelValue": e[7] || (e[7] = (d) => S.value = d),
339
- title: H.value,
436
+ b(w, {
437
+ modelValue: D.value,
438
+ "onUpdate:modelValue": t[7] || (t[7] = (f) => D.value = f),
439
+ title: W.value,
340
440
  width: "640px",
341
441
  "append-to-body": "",
342
442
  "destroy-on-close": "",
343
- onClose: e[8] || (e[8] = (d) => S.value = !1)
443
+ onClose: t[8] || (t[8] = (f) => D.value = !1)
344
444
  }, {
345
445
  default: U(() => [
346
- S.value ? (m(), w("video", {
446
+ D.value ? (m(), g("video", {
347
447
  key: 0,
348
- src: E.value,
448
+ src: H.value,
349
449
  controls: "",
350
450
  autoplay: "",
351
451
  style: { width: "100%", "max-height": "400px", "border-radius": "4px" }
352
- }, null, 8, Te)) : h("", !0)
452
+ }, null, 8, We)) : h("", !0)
353
453
  ]),
354
454
  _: 1
355
455
  }, 8, ["modelValue", "title"]),
356
- ae.value ? (m(), w("div", je, [
357
- y(a, null, {
456
+ re.value ? (m(), g("div", Xe, [
457
+ b(i, null, {
358
458
  default: U(() => [
359
- y(Y(Se))
459
+ b(ae(Me))
360
460
  ]),
361
461
  _: 1
362
462
  }),
363
463
  k("span", null, [
364
- e[12] || (e[12] = $(" 请上传 ", -1)),
365
- c.fileSize ? (m(), w(M, { key: 0 }, [
366
- e[10] || (e[10] = $("大小不超过 ", -1)),
367
- k("b", _e, R(c.fileSize) + "MB", 1)
464
+ t[12] || (t[12] = I(" 请上传 ", -1)),
465
+ r.fileSize ? (m(), g(N, { key: 0 }, [
466
+ t[10] || (t[10] = I("大小不超过 ", -1)),
467
+ k("b", Ke, R(r.fileSize) + "MB", 1)
368
468
  ], 64)) : h("", !0),
369
- (_ = v.value) != null && _.length ? (m(), w(M, { key: 1 }, [
370
- e[11] || (e[11] = $(",格式为 ", -1)),
371
- k("b", $e, R(v.value.join("/")), 1)
469
+ (C = x.value) != null && C.length ? (m(), g(N, { key: 1 }, [
470
+ t[11] || (t[11] = I(",格式为 ", -1)),
471
+ k("b", Qe, R(x.value.join("/")), 1)
372
472
  ], 64)) : h("", !0),
373
- e[13] || (e[13] = $(" 的文件。 ", -1))
473
+ t[13] || (t[13] = I(" 的文件。 ", -1))
374
474
  ])
375
475
  ])) : h("", !0)
376
476
  ], 6);
377
477
  };
378
478
  }
379
- }), He = /* @__PURE__ */ qe(Ce, [["__scopeId", "data-v-c1472320"]]);
479
+ }), ot = /* @__PURE__ */ _e(Je, [["__scopeId", "data-v-1d6de9b6"]]);
380
480
  export {
381
- He as default
481
+ ot as default
382
482
  };