vant-vtk 1.0.5 → 1.0.7

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