vant-vtk 1.0.2 → 1.0.3

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