vant-vtk 1.0.2 → 1.0.4

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 (44) hide show
  1. package/README.md +28 -0
  2. package/dist/es/Area.js +193 -0
  3. package/dist/es/Area.js.map +1 -0
  4. package/dist/es/Radio.css +1 -0
  5. package/dist/es/Radio.js +79 -0
  6. package/dist/es/Radio.js.map +1 -0
  7. package/dist/es/Uploader.css +1 -0
  8. package/dist/es/Uploader.js +128 -0
  9. package/dist/es/Uploader.js.map +1 -0
  10. package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
  11. package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
  12. package/dist/es/checkbox.css +1 -0
  13. package/dist/es/checkbox.js +86 -0
  14. package/dist/es/checkbox.js.map +1 -0
  15. package/dist/es/index.js +35 -0
  16. package/dist/es/index.js.map +1 -0
  17. package/dist/es/preview.css +1 -0
  18. package/dist/es/preview.js +192 -0
  19. package/dist/es/preview.js.map +1 -0
  20. package/dist/lib/Area.js +2 -0
  21. package/dist/lib/Area.js.map +1 -0
  22. package/dist/lib/Radio.css +1 -0
  23. package/dist/lib/Radio.js +2 -0
  24. package/dist/lib/Radio.js.map +1 -0
  25. package/dist/lib/Uploader.css +1 -0
  26. package/dist/lib/Uploader.js +2 -0
  27. package/dist/lib/Uploader.js.map +1 -0
  28. package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs +2 -0
  29. package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs.map +1 -0
  30. package/dist/lib/checkbox.css +1 -0
  31. package/dist/lib/checkbox.js +2 -0
  32. package/dist/lib/checkbox.js.map +1 -0
  33. package/dist/lib/index.js +2 -0
  34. package/dist/lib/index.js.map +1 -0
  35. package/dist/lib/preview.css +1 -0
  36. package/dist/lib/preview.js +2 -0
  37. package/dist/lib/preview.js.map +1 -0
  38. package/dist/style.css +1 -0
  39. package/dist/vant-vtk.es.js +626 -104
  40. package/dist/vant-vtk.es.js.map +1 -1
  41. package/dist/vant-vtk.umd.js +1 -2
  42. package/dist/vant-vtk.umd.js.map +1 -1
  43. package/package.json +20 -5
  44. package/types/index.d.ts +52 -4
@@ -1,12 +1,13 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("[data-v-54417869] .van-checkbox{margin-bottom:8px;margin-right:12px}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { computed as v, resolveComponent as d, openBlock as g, createBlock as k, normalizeProps as h, guardReactiveProps as C, withCtx as V, createVNode as _, createElementBlock as x, Fragment as b, renderList as F, createTextVNode as P, toDisplayString as j, ref as N, mergeProps as B } from "vue";
3
- const T = (a, i) => {
4
- const e = a.__vccOpts || a;
5
- for (const [p, u] of i)
6
- e[p] = u;
7
- return e;
8
- }, O = /* @__PURE__ */ Object.assign({
9
- name: "VtkCheckboxField"
1
+ import { computed as R, resolveComponent as V, openBlock as C, createBlock as z, normalizeProps as Y, guardReactiveProps as Z, withCtx as A, createVNode as x, createElementBlock as D, Fragment as K, renderList as O, createTextVNode as F, toDisplayString as T, inject as ee, getCurrentInstance as ae, ref as S, watch as I, mergeProps as te, createElementVNode as $, unref as le, createCommentVNode as ne } from "vue";
2
+ import { showLoadingToast as X, closeToast as re, showToast as H } from "vant";
3
+ import oe from "vue-pdf-embed";
4
+ const J = (l, d) => {
5
+ const n = l.__vccOpts || l;
6
+ for (const [_, c] of d)
7
+ n[_] = c;
8
+ return n;
9
+ }, se = /* @__PURE__ */ Object.assign({
10
+ name: "VtkCheckbox"
10
11
  }, {
11
12
  __name: "index",
12
13
  props: {
@@ -24,7 +25,7 @@ const T = (a, i) => {
24
25
  valueType: {
25
26
  type: String,
26
27
  default: "array",
27
- validator: (a) => ["string", "array", "object"].includes(a)
28
+ validator: (l) => ["string", "array", "object"].includes(l)
28
29
  },
29
30
  // 当 valueType 为 string 时的分隔符
30
31
  separator: {
@@ -33,42 +34,42 @@ const T = (a, i) => {
33
34
  }
34
35
  },
35
36
  emits: ["update:modelValue", "change"],
36
- setup(a, { emit: i }) {
37
- const e = a, p = i, u = v(() => Array.isArray(e.options) ? e.options : typeof e.options == "string" && e.options ? e.options.split("/").filter(Boolean).map((t) => {
38
- const [n, l] = t.split(":");
37
+ setup(l, { emit: d }) {
38
+ const n = l, _ = d, c = R(() => Array.isArray(n.options) ? n.options : typeof n.options == "string" && n.options ? n.options.split("/").filter(Boolean).map((r) => {
39
+ const [t, s] = r.split(":");
39
40
  return {
40
- text: l || n,
41
- value: n
41
+ text: s || t,
42
+ value: t
42
43
  };
43
- }) : []), c = v({
44
+ }) : []), p = R({
44
45
  get: () => {
45
- const t = e.modelValue;
46
- if (!t) return [];
47
- let n = [];
48
- return e.valueType === "string" ? n = typeof t == "string" ? t.split(e.separator).filter(Boolean) : [] : e.valueType === "object" ? n = Array.isArray(t) ? t.map((l) => (l == null ? void 0 : l.value) ?? l) : [] : n = Array.isArray(t) ? t : [], n.map(String);
46
+ const r = n.modelValue;
47
+ if (!r) return [];
48
+ let t = [];
49
+ return n.valueType === "string" ? t = typeof r == "string" ? r.split(n.separator).filter(Boolean) : [] : n.valueType === "object" ? t = Array.isArray(r) ? r.map((s) => (s == null ? void 0 : s.value) ?? s) : [] : t = Array.isArray(r) ? r : [], t.map(String);
49
50
  },
50
- set: (t) => {
51
- let n;
52
- e.valueType === "string" ? n = t.join(e.separator) : e.valueType === "object" ? n = u.value.filter((l) => t.includes(String(l.value))) : n = t.map((l) => isNaN(Number(l)) ? l : Array.isArray(e.modelValue) && typeof e.modelValue[0] == "number" ? Number(l) : l), p("update:modelValue", n), p("change", n);
51
+ set: (r) => {
52
+ let t;
53
+ n.valueType === "string" ? t = r.join(n.separator) : n.valueType === "object" ? t = c.value.filter((s) => r.includes(String(s.value))) : t = r.map((s) => isNaN(Number(s)) ? s : Array.isArray(n.modelValue) && typeof n.modelValue[0] == "number" ? Number(s) : s), _("update:modelValue", t), _("change", t);
53
54
  }
54
55
  });
55
- return (t, n) => {
56
- const l = d("van-checkbox"), s = d("van-checkbox-group"), o = d("van-field");
57
- return g(), k(o, h(C(t.$attrs)), {
58
- input: V(() => [
59
- _(s, {
60
- modelValue: c.value,
61
- "onUpdate:modelValue": n[0] || (n[0] = (r) => c.value = r),
56
+ return (r, t) => {
57
+ const s = V("van-checkbox"), f = V("van-checkbox-group"), h = V("van-field");
58
+ return C(), z(h, Y(Z(r.$attrs)), {
59
+ input: A(() => [
60
+ x(f, {
61
+ modelValue: p.value,
62
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => p.value = g),
62
63
  direction: "horizontal"
63
64
  }, {
64
- default: V(() => [
65
- (g(!0), x(b, null, F(u.value, (r) => (g(), k(l, {
66
- key: String(r.value),
67
- name: String(r.value),
65
+ default: A(() => [
66
+ (C(!0), D(K, null, O(c.value, (g) => (C(), z(s, {
67
+ key: String(g.value),
68
+ name: String(g.value),
68
69
  shape: "square"
69
70
  }, {
70
- default: V(() => [
71
- P(j(r.text), 1)
71
+ default: A(() => [
72
+ F(T(g.text), 1)
72
73
  ]),
73
74
  _: 2
74
75
  }, 1032, ["name"]))), 128))
@@ -80,72 +81,193 @@ const T = (a, i) => {
80
81
  }, 16);
81
82
  };
82
83
  }
83
- }), f = /* @__PURE__ */ T(O, [["__scopeId", "data-v-54417869"]]);
84
- f.install = (a) => {
85
- a.component(f.name || "VtkCheckboxField", f);
84
+ }), B = /* @__PURE__ */ J(se, [["__scopeId", "data-v-eb64e8a9"]]);
85
+ B.install = (l) => {
86
+ l.component(B.name || "VtkCheckbox", B);
86
87
  };
87
- const y = /* @__PURE__ */ Object.assign({
88
- name: "VtkPickerField"
88
+ const E = /* @__PURE__ */ Object.assign({
89
+ name: "VtkArea"
89
90
  }, {
90
91
  __name: "index",
91
92
  props: {
92
- // 绑定值 (value)
93
+ // 绑定值,根据 valueType 返回不同类型
93
94
  modelValue: {
94
- type: [String, Number],
95
+ type: [String, Object, Array],
95
96
  default: ""
96
97
  },
97
- // 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'
98
- options: {
99
- type: [Array, String],
100
- default: () => []
98
+ // 默认地区编码,用于初始化加载
99
+ defaultAreaCode: {
100
+ type: String,
101
+ default: "33"
102
+ },
103
+ // 返回值类型: 'code' 返回最后一级areaCode, 'codes' 返回所有级别areaCode数组, 'object' 返回完整对象信息
104
+ valueType: {
105
+ type: String,
106
+ default: "code",
107
+ validator: (l) => ["code", "codes", "object"].includes(l)
108
+ },
109
+ // 显示分隔符
110
+ separator: {
111
+ type: String,
112
+ default: "/"
101
113
  },
102
114
  // 弹窗标题
103
115
  title: {
104
116
  type: String,
105
- default: "请选择"
117
+ default: "请选择所在地区"
118
+ },
119
+ // 占位文本
120
+ placeholder: {
121
+ type: String,
122
+ default: "请选择所在地区"
123
+ },
124
+ // 最大层级限制,达到该层级后不再加载下级
125
+ maxLevel: {
126
+ type: Number,
127
+ default: 12
128
+ },
129
+ // 显示模式: 'full' 显示完整路径, 'last' 只显示最后一级
130
+ displayMode: {
131
+ type: String,
132
+ default: "full",
133
+ validator: (l) => ["full", "last"].includes(l)
106
134
  }
107
135
  },
108
- emits: ["update:modelValue", "change"],
109
- setup(a, { emit: i }) {
110
- const e = a, p = i, u = N(!1), c = v(() => Array.isArray(e.options) ? e.options : typeof e.options == "string" && e.options ? e.options.split("/").filter(Boolean).map((s) => {
111
- const [o, r] = s.split(":");
112
- return {
113
- text: r || o,
114
- // 如果没有冒号,则 text value 相同
115
- value: o
116
- };
117
- }) : []), t = v(() => {
118
- const s = c.value.find((o) => String(o.value) === String(e.modelValue));
119
- return s ? s.text : e.modelValue;
120
- }), n = v(() => e.modelValue !== void 0 && e.modelValue !== null && e.modelValue !== "" ? [e.modelValue] : []), l = ({ selectedOptions: s }) => {
121
- var r;
122
- const o = (r = s[0]) == null ? void 0 : r.value;
123
- p("update:modelValue", o), p("change", o, s[0]), u.value = !1;
136
+ emits: ["update:modelValue", "change", "finish"],
137
+ setup(l, { expose: d, emit: n }) {
138
+ var y;
139
+ const _ = ee("vant-vtk:request", null), c = (y = ae()) == null ? void 0 : y.appContext.config.globalProperties, p = (c == null ? void 0 : c.$vtkRequest) || (c == null ? void 0 : c.$request), r = () => {
140
+ const e = _ || p;
141
+ if (!e)
142
+ throw new Error("VantVtk request 未配置");
143
+ return e;
144
+ }, t = l, s = n, f = S(!1), h = S(""), g = S([]), b = S(""), q = S(!1), w = S([]), U = {
145
+ text: "areaName",
146
+ value: "areaCode",
147
+ children: "children"
148
+ };
149
+ I(
150
+ () => t.modelValue,
151
+ (e) => {
152
+ e || (b.value = "", h.value = "", w.value = []);
153
+ },
154
+ { immediate: !0 }
155
+ );
156
+ const j = () => {
157
+ f.value = !0, g.value.length === 0 && P();
158
+ }, P = async () => {
159
+ if (!q.value) {
160
+ q.value = !0;
161
+ try {
162
+ const e = t.defaultAreaCode, o = await r().getForm(`dict/area/show/${e}`);
163
+ if (o.data) {
164
+ const i = {
165
+ areaCode: o.data.areaCode,
166
+ areaName: o.data.areaName,
167
+ areaLeve: o.data.areaLeve,
168
+ children: o.data.areaLeve < t.maxLevel ? [] : void 0
169
+ };
170
+ g.value = [i];
171
+ }
172
+ } catch (e) {
173
+ console.error("加载初始地区失败:", e);
174
+ } finally {
175
+ q.value = !1;
176
+ }
177
+ }
178
+ }, m = async (e) => {
179
+ if (!e._loading) {
180
+ e._loading = !0;
181
+ try {
182
+ const o = await r().getForm(`dict/area/next/${e.areaCode}`);
183
+ o.data && o.data.length > 0 ? (o.data.forEach((i) => {
184
+ i.areaLeve < t.maxLevel && (i.children = []);
185
+ }), e.children = o.data) : delete e.children;
186
+ } catch (o) {
187
+ console.error("加载下级地区失败:", o);
188
+ } finally {
189
+ e._loading = !1;
190
+ }
191
+ }
192
+ }, a = ({ value: e, selectedOptions: o, tabIndex: i }) => {
193
+ const v = o[i];
194
+ v && v.areaLeve < t.maxLevel && Array.isArray(v.children) && v.children.length === 0 && m(v), s("change", { value: e, selectedOptions: o, tabIndex: i });
195
+ }, u = ({ selectedOptions: e }) => {
196
+ var i, v, L, N, Q;
197
+ t.displayMode === "last" ? b.value = ((i = e[e.length - 1]) == null ? void 0 : i.areaName) || "" : b.value = e.map((k) => k.areaName).join(t.separator), w.value = e.map((k) => ({
198
+ areaCode: k.areaCode,
199
+ areaName: k.areaName,
200
+ areaLeve: k.areaLeve
201
+ }));
202
+ let o;
203
+ switch (t.valueType) {
204
+ case "code":
205
+ o = ((v = e[e.length - 1]) == null ? void 0 : v.areaCode) || "";
206
+ break;
207
+ case "codes":
208
+ o = e.map((k) => k.areaCode);
209
+ break;
210
+ case "object":
211
+ o = {
212
+ codes: e.map((k) => k.areaCode),
213
+ names: e.map((k) => k.areaName),
214
+ fullName: e.map((k) => k.areaName).join(t.separator),
215
+ lastCode: ((L = e[e.length - 1]) == null ? void 0 : L.areaCode) || "",
216
+ lastLevel: (N = e[e.length - 1]) == null ? void 0 : N.areaLeve,
217
+ options: w.value
218
+ };
219
+ break;
220
+ default:
221
+ o = ((Q = e[e.length - 1]) == null ? void 0 : Q.areaCode) || "";
222
+ }
223
+ s("update:modelValue", o), s("finish", { selectedOptions: e, value: o }), f.value = !1;
124
224
  };
125
- return (s, o) => {
126
- const r = d("van-field"), S = d("van-picker"), A = d("van-popup");
127
- return g(), x(b, null, [
128
- _(r, B({
129
- modelValue: t.value,
130
- "onUpdate:modelValue": o[0] || (o[0] = (m) => t.value = m),
225
+ return d({
226
+ // 获取当前选中的完整数据
227
+ getSelectedData: () => w.value,
228
+ // 获取显示值
229
+ getDisplayValue: () => b.value,
230
+ // 重置选择
231
+ reset: () => {
232
+ b.value = "", h.value = "", w.value = [], s("update:modelValue", t.valueType === "codes" ? [] : t.valueType === "object" ? null : "");
233
+ },
234
+ // 打开选择器
235
+ open: () => {
236
+ j();
237
+ },
238
+ // 关闭选择器
239
+ close: () => {
240
+ f.value = !1;
241
+ }
242
+ }), (e, o) => {
243
+ const i = V("van-field"), v = V("van-cascader"), L = V("van-popup");
244
+ return C(), D(K, null, [
245
+ x(i, te({
246
+ modelValue: b.value,
247
+ "onUpdate:modelValue": o[0] || (o[0] = (N) => b.value = N),
131
248
  "is-link": "",
132
- readonly: "",
133
- onClick: o[1] || (o[1] = (m) => u.value = !0)
134
- }, s.$attrs), null, 16, ["modelValue"]),
135
- _(A, {
136
- show: u.value,
137
- "onUpdate:show": o[3] || (o[3] = (m) => u.value = m),
138
- position: "bottom",
139
- round: ""
249
+ readonly: ""
250
+ }, e.$attrs, {
251
+ placeholder: l.placeholder,
252
+ onClick: j
253
+ }), null, 16, ["modelValue", "placeholder"]),
254
+ x(L, {
255
+ show: f.value,
256
+ "onUpdate:show": o[3] || (o[3] = (N) => f.value = N),
257
+ round: "",
258
+ position: "bottom"
140
259
  }, {
141
- default: V(() => [
142
- _(S, {
143
- title: a.title,
144
- columns: c.value,
145
- "model-value": n.value,
146
- onConfirm: l,
147
- onCancel: o[2] || (o[2] = (m) => u.value = !1)
148
- }, null, 8, ["title", "columns", "model-value"])
260
+ default: A(() => [
261
+ x(v, {
262
+ modelValue: h.value,
263
+ "onUpdate:modelValue": o[1] || (o[1] = (N) => h.value = N),
264
+ title: l.title,
265
+ options: g.value,
266
+ "field-names": U,
267
+ onClose: o[2] || (o[2] = (N) => f.value = !1),
268
+ onFinish: u,
269
+ onChange: a
270
+ }, null, 8, ["modelValue", "title", "options"])
149
271
  ]),
150
272
  _: 1
151
273
  }, 8, ["show"])
@@ -153,27 +275,427 @@ const y = /* @__PURE__ */ Object.assign({
153
275
  };
154
276
  }
155
277
  });
156
- y.install = (a) => {
157
- a.component(y.name || "VtkPickerField", y);
278
+ E.install = (l, d = {}) => {
279
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), l.component(E.name || "VtkArea", E);
280
+ };
281
+ const ue = /* @__PURE__ */ Object.assign({
282
+ name: "VtkRadio"
283
+ }, {
284
+ __name: "index",
285
+ props: {
286
+ // 绑定值
287
+ modelValue: {
288
+ type: [String, Number, Object],
289
+ default: ""
290
+ },
291
+ // 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'
292
+ options: {
293
+ type: [Array, String],
294
+ default: () => []
295
+ },
296
+ // 返回值类型: 'string' (基本类型), 'object' (完整对象)
297
+ valueType: {
298
+ type: String,
299
+ default: "string",
300
+ validator: (l) => ["string", "object"].includes(l)
301
+ }
302
+ },
303
+ emits: ["update:modelValue", "change"],
304
+ setup(l, { emit: d }) {
305
+ const n = l, _ = d, c = R(() => Array.isArray(n.options) ? n.options : typeof n.options == "string" && n.options ? n.options.split("/").filter(Boolean).map((r) => {
306
+ const [t, s] = r.split(":");
307
+ return {
308
+ text: s || t,
309
+ value: t
310
+ };
311
+ }) : []), p = R({
312
+ get: () => {
313
+ const r = n.modelValue;
314
+ return r == null ? "" : n.valueType === "object" && r && typeof r == "object" ? String(r.value ?? "") : String(r);
315
+ },
316
+ set: (r) => {
317
+ var f;
318
+ let t = r;
319
+ typeof (n.valueType === "object" ? (f = n.modelValue) == null ? void 0 : f.value : n.modelValue) == "number" && !isNaN(Number(r)) && (t = Number(r)), n.valueType === "object" && (t = c.value.find((h) => String(h.value) === String(r)) || null), _("update:modelValue", t), _("change", t);
320
+ }
321
+ });
322
+ return (r, t) => {
323
+ const s = V("van-radio"), f = V("van-radio-group"), h = V("van-field");
324
+ return C(), z(h, Y(Z(r.$attrs)), {
325
+ input: A(() => [
326
+ x(f, {
327
+ modelValue: p.value,
328
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => p.value = g),
329
+ direction: "horizontal"
330
+ }, {
331
+ default: A(() => [
332
+ (C(!0), D(K, null, O(c.value, (g) => (C(), z(s, {
333
+ key: String(g.value),
334
+ name: String(g.value)
335
+ }, {
336
+ default: A(() => [
337
+ F(T(g.text), 1)
338
+ ]),
339
+ _: 2
340
+ }, 1032, ["name"]))), 128))
341
+ ]),
342
+ _: 1
343
+ }, 8, ["modelValue"])
344
+ ]),
345
+ _: 1
346
+ }, 16);
347
+ };
348
+ }
349
+ }), M = /* @__PURE__ */ J(ue, [["__scopeId", "data-v-3482e335"]]);
350
+ M.install = (l) => {
351
+ l.component(M.name || "VtkRadio", M);
352
+ };
353
+ const ie = /* @__PURE__ */ Object.assign({
354
+ name: "VtkUploader",
355
+ inheritAttrs: !1
356
+ }, {
357
+ __name: "index",
358
+ props: {
359
+ /** 绑定值,支持字符串或数组 */
360
+ modelValue: {
361
+ type: [String, Array],
362
+ default: () => []
363
+ },
364
+ /** 返回值类型:'string' 返回逗号分隔的字符串,'array' 返回数组 */
365
+ valueType: {
366
+ type: String,
367
+ default: "array",
368
+ validator: (l) => ["string", "array"].includes(l)
369
+ },
370
+ /** 单个文件最大大小(字节),默认10MB */
371
+ maxSize: {
372
+ type: Number,
373
+ default: 10 * 1024 * 1024
374
+ },
375
+ /** 接受的文件类型 */
376
+ accept: {
377
+ type: String,
378
+ default: "image/*"
379
+ },
380
+ /** 上传接口地址 */
381
+ uploadUrl: {
382
+ type: String,
383
+ default: "/bizp/admin/upload"
384
+ },
385
+ /** 上传文件的字段名 */
386
+ fieldName: {
387
+ type: String,
388
+ default: "file"
389
+ }
390
+ },
391
+ emits: ["update:modelValue", "change", "success", "error"],
392
+ setup(l, { expose: d, emit: n }) {
393
+ var m;
394
+ const _ = ee("vant-vtk:request", null), c = (m = ae()) == null ? void 0 : m.appContext.config.globalProperties, p = (c == null ? void 0 : c.$vtkRequest) || (c == null ? void 0 : c.$request), r = () => {
395
+ const a = _ || p;
396
+ if (!a)
397
+ throw new Error("VantVtk request 未配置");
398
+ return a;
399
+ }, t = l, s = n, f = S([]), h = (a) => {
400
+ if (!a) return [];
401
+ let u = [];
402
+ return typeof a == "string" ? u = a.split(",").filter((y) => y.trim()) : Array.isArray(a) && (u = a.filter((y) => y)), u.map((y) => ({
403
+ url: y,
404
+ status: "done",
405
+ message: ""
406
+ }));
407
+ }, g = () => f.value.filter((a) => a.status === "done" && a.url).map((a) => a.url), b = (a) => t.valueType === "string" ? a.join(",") : a, q = () => {
408
+ const a = g(), u = b(a);
409
+ s("update:modelValue", u), s("change", u);
410
+ };
411
+ I(
412
+ () => t.modelValue,
413
+ (a) => {
414
+ const u = g().join(","), y = Array.isArray(a) ? a.join(",") : a || "";
415
+ u !== y && (f.value = h(a));
416
+ },
417
+ { immediate: !0 }
418
+ );
419
+ const w = (a) => {
420
+ const u = Array.isArray(a) ? a : [a];
421
+ for (const y of u)
422
+ if (y.size > t.maxSize) {
423
+ const e = (t.maxSize / 1024 / 1024).toFixed(1);
424
+ return H(`文件大小不能超过${e}MB`), !1;
425
+ }
426
+ return !0;
427
+ }, U = async (a) => {
428
+ var y, e, o, i;
429
+ const u = new FormData();
430
+ u.append(t.fieldName, a.file);
431
+ try {
432
+ const v = await r().imp(t.uploadUrl, u);
433
+ return (y = v.meta) != null && y.success ? { success: !0, url: ((e = v.data) == null ? void 0 : e.url) || ((o = v.data) == null ? void 0 : o.path) || v.data } : { success: !1, message: ((i = v.meta) == null ? void 0 : i.message) || "上传失败" };
434
+ } catch (v) {
435
+ return { success: !1, message: v.message || "上传失败" };
436
+ }
437
+ }, j = async (a) => {
438
+ const u = Array.isArray(a) ? a : [a];
439
+ u.length > 1 && X({
440
+ message: `正在上传 0/${u.length}`,
441
+ forbidClick: !0,
442
+ duration: 0
443
+ });
444
+ let y = 0, e = 0;
445
+ for (let o = 0; o < u.length; o++) {
446
+ const i = u[o];
447
+ i.status = "uploading", i.message = "上传中...", u.length > 1 && X({
448
+ message: `正在上传 ${o + 1}/${u.length}`,
449
+ forbidClick: !0,
450
+ duration: 0
451
+ });
452
+ const v = await U(i);
453
+ v.success ? (i.status = "done", i.message = "", i.url = v.url, y++, s("success", { file: i, url: v.url })) : (i.status = "failed", i.message = v.message, e++, s("error", { file: i, message: v.message }));
454
+ }
455
+ re(), u.length > 1 ? e === 0 ? H(`${y}个文件上传成功`) : H(`${y}个成功,${e}个失败`) : e > 0 && H(u[0].message || "上传失败"), q();
456
+ }, P = () => {
457
+ setTimeout(() => {
458
+ q();
459
+ }, 0);
460
+ };
461
+ return d({
462
+ /** 获取已上传的URL列表 */
463
+ getUrls: g,
464
+ /** 清空文件列表 */
465
+ clear: () => {
466
+ f.value = [], q();
467
+ },
468
+ /** 获取文件列表 */
469
+ getFileList: () => f.value
470
+ }), (a, u) => {
471
+ const y = V("van-uploader");
472
+ return C(), z(y, te({
473
+ modelValue: f.value,
474
+ "onUpdate:modelValue": u[0] || (u[0] = (e) => f.value = e)
475
+ }, a.$attrs, {
476
+ "max-size": l.maxSize,
477
+ accept: l.accept,
478
+ "before-read": w,
479
+ "after-read": j,
480
+ onDelete: P
481
+ }), null, 16, ["modelValue", "max-size", "accept"]);
482
+ };
483
+ }
484
+ }), W = /* @__PURE__ */ J(ie, [["__scopeId", "data-v-620ae5d0"]]);
485
+ W.install = (l, d = {}) => {
486
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), l.component(W.name || "VtkUploader", W);
487
+ };
488
+ const de = { class: "file-preview-container" }, ce = { class: "file-header" }, me = { class: "file-title" }, ve = { class: "file-content" }, fe = {
489
+ key: 0,
490
+ class: "image-preview"
491
+ }, pe = { class: "image-footer" }, ge = { class: "file-info" }, ye = {
492
+ key: 1,
493
+ class: "pdf-preview"
494
+ }, he = {
495
+ key: 1,
496
+ class: "pdf-placeholder"
497
+ }, _e = { class: "pdf-footer" }, Ve = { class: "page-info" }, be = { class: "footer" }, ke = /* @__PURE__ */ Object.assign({
498
+ name: "VtkPreview"
499
+ }, {
500
+ __name: "index",
501
+ props: {
502
+ modelValue: {
503
+ type: Boolean,
504
+ default: !1
505
+ },
506
+ files: {
507
+ type: Array,
508
+ default: () => []
509
+ },
510
+ startIndex: {
511
+ type: Number,
512
+ default: 0
513
+ }
514
+ },
515
+ emits: ["update:modelValue", "close"],
516
+ setup(l, { emit: d }) {
517
+ const n = l, _ = d, c = S(n.modelValue), p = S(n.startIndex), r = S(1), t = S(null), s = S(0), f = R(() => n.files.map((m, a) => {
518
+ if (typeof m == "string") {
519
+ const u = m.toLowerCase().endsWith(".pdf");
520
+ return {
521
+ name: u ? `文档${a + 1}.pdf` : `图片${a + 1}`,
522
+ url: m,
523
+ type: u ? "pdf" : "image"
524
+ };
525
+ }
526
+ return m;
527
+ })), h = R(() => f.value[p.value] || null), g = R(() => {
528
+ if (!h.value) return null;
529
+ const m = h.value.url || h.value;
530
+ return typeof m == "string" ? m.toLowerCase().endsWith(".pdf") ? "pdf" : "image" : h.value.type || "image";
531
+ });
532
+ I(
533
+ () => n.modelValue,
534
+ (m) => {
535
+ c.value = m, m && f.value.length > 0 && (p.value = n.startIndex, b());
536
+ }
537
+ ), I(
538
+ () => n.startIndex,
539
+ (m) => {
540
+ p.value = m, b();
541
+ }
542
+ ), I(c, (m) => {
543
+ _("update:modelValue", m), m || P();
544
+ }), I(p, () => {
545
+ r.value = 1, s.value = 0, b();
546
+ });
547
+ const b = () => {
548
+ const m = h.value;
549
+ m && (g.value === "pdf" ? t.value = m.url || m : t.value = null);
550
+ }, q = (m) => {
551
+ s.value = m.numPages || 0;
552
+ }, w = () => {
553
+ console.log("PDF rendered successfully");
554
+ }, U = () => {
555
+ p.value > 0 && p.value--;
556
+ }, j = () => {
557
+ p.value < f.value.length - 1 && p.value++;
558
+ }, P = () => {
559
+ c.value = !1, t.value = null, r.value = 1, s.value = 0, _("close");
560
+ };
561
+ return (m, a) => {
562
+ const u = V("van-icon"), y = V("van-image"), e = V("van-button"), o = V("van-popup");
563
+ return C(), z(o, {
564
+ show: c.value,
565
+ "onUpdate:show": a[2] || (a[2] = (i) => c.value = i),
566
+ position: "bottom",
567
+ style: { height: "100vh" }
568
+ }, {
569
+ default: A(() => {
570
+ var i, v;
571
+ return [
572
+ $("div", de, [
573
+ $("div", ce, [
574
+ $("div", me, T(((i = h.value) == null ? void 0 : i.name) || "文件预览"), 1),
575
+ x(u, {
576
+ name: "cross",
577
+ size: "20",
578
+ onClick: P
579
+ })
580
+ ]),
581
+ $("div", ve, [
582
+ g.value === "image" ? (C(), D("div", fe, [
583
+ x(y, {
584
+ src: (v = h.value) == null ? void 0 : v.url,
585
+ fit: "contain",
586
+ class: "preview-image"
587
+ }, null, 8, ["src"]),
588
+ $("div", pe, [
589
+ x(e, {
590
+ size: "small",
591
+ disabled: p.value <= 0,
592
+ onClick: U
593
+ }, {
594
+ default: A(() => [...a[3] || (a[3] = [
595
+ F("上一个", -1)
596
+ ])]),
597
+ _: 1
598
+ }, 8, ["disabled"]),
599
+ $("span", ge, T(p.value + 1) + " / " + T(l.files.length), 1),
600
+ x(e, {
601
+ size: "small",
602
+ disabled: p.value >= l.files.length - 1,
603
+ onClick: j
604
+ }, {
605
+ default: A(() => [...a[4] || (a[4] = [
606
+ F("下一个", -1)
607
+ ])]),
608
+ _: 1
609
+ }, 8, ["disabled"])
610
+ ])
611
+ ])) : g.value === "pdf" ? (C(), D("div", ye, [
612
+ t.value ? (C(), z(le(oe), {
613
+ key: 0,
614
+ source: t.value,
615
+ page: r.value,
616
+ class: "pdf-embed-preview",
617
+ onRendered: w,
618
+ onLoaded: q
619
+ }, null, 8, ["source", "page"])) : (C(), D("div", he, "请选择PDF文件")),
620
+ $("div", _e, [
621
+ x(e, {
622
+ size: "small",
623
+ disabled: r.value <= 1,
624
+ onClick: a[0] || (a[0] = (L) => r.value--)
625
+ }, {
626
+ default: A(() => [...a[5] || (a[5] = [
627
+ F("上一页", -1)
628
+ ])]),
629
+ _: 1
630
+ }, 8, ["disabled"]),
631
+ $("span", Ve, "第 " + T(r.value) + " / " + T(s.value || "?") + " 页", 1),
632
+ x(e, {
633
+ size: "small",
634
+ disabled: !t.value || r.value >= s.value,
635
+ onClick: a[1] || (a[1] = (L) => r.value++)
636
+ }, {
637
+ default: A(() => [...a[6] || (a[6] = [
638
+ F("下一页", -1)
639
+ ])]),
640
+ _: 1
641
+ }, 8, ["disabled"])
642
+ ])
643
+ ])) : ne("", !0),
644
+ $("div", be, [
645
+ x(e, {
646
+ disabled: p.value <= 0,
647
+ onClick: U,
648
+ icon: "arrow-left",
649
+ type: "primary",
650
+ round: ""
651
+ }, null, 8, ["disabled"]),
652
+ x(e, {
653
+ disabled: p.value >= l.files.length - 1,
654
+ onClick: j,
655
+ icon: "arrow",
656
+ type: "primary",
657
+ round: ""
658
+ }, null, 8, ["disabled"])
659
+ ])
660
+ ])
661
+ ])
662
+ ];
663
+ }),
664
+ _: 1
665
+ }, 8, ["show"]);
666
+ };
667
+ }
668
+ }), G = /* @__PURE__ */ J(ke, [["__scopeId", "data-v-1ad2c749"]]);
669
+ G.install = (l) => {
670
+ l.component(G.name || "VtkPreview", G);
158
671
  };
159
- const $ = [
160
- f,
161
- y
162
- ], w = (a) => {
163
- $.forEach((i) => {
164
- i.install ? a.use(i) : i.name && a.component(i.name, i);
672
+ const xe = [
673
+ B,
674
+ E,
675
+ M,
676
+ W,
677
+ G
678
+ ], Ce = (l, d = {}) => {
679
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), xe.forEach((n) => {
680
+ n.install ? l.use(n, d) : n.name && l.component(n.name, n);
165
681
  });
166
- }, z = {
167
- install: w,
682
+ }, we = {
683
+ install: Ce,
168
684
  // 也导出所有组件,方便直接访问
169
- CheckboxField: f,
170
- PickerField: y
171
- }, E = "1.0.0";
685
+ Checkbox: B,
686
+ Area: E,
687
+ Radio: M,
688
+ Uploader: W,
689
+ Preview: G
690
+ }, Ne = "1.0.0";
172
691
  export {
173
- f as CheckboxField,
174
- y as PickerField,
175
- z as default,
176
- w as install,
177
- E as version
692
+ E as Area,
693
+ B as Checkbox,
694
+ G as Preview,
695
+ M as Radio,
696
+ W as Uploader,
697
+ we as default,
698
+ Ce as install,
699
+ Ne as version
178
700
  };
179
701
  //# sourceMappingURL=vant-vtk.es.js.map