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.
- package/README.md +28 -0
- package/dist/es/Area.js +193 -0
- package/dist/es/Area.js.map +1 -0
- package/dist/es/Radio.css +1 -0
- package/dist/es/Radio.js +79 -0
- package/dist/es/Radio.js.map +1 -0
- package/dist/es/Uploader.css +1 -0
- package/dist/es/Uploader.js +128 -0
- package/dist/es/Uploader.js.map +1 -0
- package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
- package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
- package/dist/es/checkbox.css +1 -0
- package/dist/es/checkbox.js +86 -0
- package/dist/es/checkbox.js.map +1 -0
- package/dist/es/index.js +35 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/preview.css +1 -0
- package/dist/es/preview.js +192 -0
- package/dist/es/preview.js.map +1 -0
- package/dist/lib/Area.js +2 -0
- package/dist/lib/Area.js.map +1 -0
- package/dist/lib/Radio.css +1 -0
- package/dist/lib/Radio.js +2 -0
- package/dist/lib/Radio.js.map +1 -0
- package/dist/lib/Uploader.css +1 -0
- package/dist/lib/Uploader.js +2 -0
- package/dist/lib/Uploader.js.map +1 -0
- package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs +2 -0
- package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs.map +1 -0
- package/dist/lib/checkbox.css +1 -0
- package/dist/lib/checkbox.js +2 -0
- package/dist/lib/checkbox.js.map +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/preview.css +1 -0
- package/dist/lib/preview.js +2 -0
- package/dist/lib/preview.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/vant-vtk.es.js +626 -104
- package/dist/vant-vtk.es.js.map +1 -1
- package/dist/vant-vtk.umd.js +1 -2
- package/dist/vant-vtk.umd.js.map +1 -1
- package/package.json +20 -5
- package/types/index.d.ts +52 -4
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
## 本地测试步骤
|
|
2
|
+
|
|
3
|
+
### 1. 构建组件库
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm run build
|
|
7
|
+
npm run build:lib
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### 2. 创建 npm link(在组件库目录)
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm link
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 3. 在测试项目中链接组件库
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cd test-demo
|
|
20
|
+
npm link vant-vtk
|
|
21
|
+
npm install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 4. 运行测试项目
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run dev
|
|
28
|
+
```
|
package/dist/es/Area.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ref as i, watch as j, resolveComponent as g, openBlock as _, createElementBlock as F, Fragment as T, createVNode as y, mergeProps as $, withCtx as D } from "vue";
|
|
2
|
+
const C = /* @__PURE__ */ Object.assign({
|
|
3
|
+
name: "VtkArea"
|
|
4
|
+
}, {
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: {
|
|
7
|
+
// 绑定值,根据 valueType 返回不同类型
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: [String, Object, Array],
|
|
10
|
+
default: ""
|
|
11
|
+
},
|
|
12
|
+
// 默认地区编码,用于初始化加载
|
|
13
|
+
defaultAreaCode: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "33"
|
|
16
|
+
},
|
|
17
|
+
// 返回值类型: 'code' 返回最后一级areaCode, 'codes' 返回所有级别areaCode数组, 'object' 返回完整对象信息
|
|
18
|
+
valueType: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "code",
|
|
21
|
+
validator: (n) => ["code", "codes", "object"].includes(n)
|
|
22
|
+
},
|
|
23
|
+
// 显示分隔符
|
|
24
|
+
separator: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "/"
|
|
27
|
+
},
|
|
28
|
+
// 弹窗标题
|
|
29
|
+
title: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "请选择所在地区"
|
|
32
|
+
},
|
|
33
|
+
// 占位文本
|
|
34
|
+
placeholder: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "请选择所在地区"
|
|
37
|
+
},
|
|
38
|
+
// 最大层级限制,达到该层级后不再加载下级
|
|
39
|
+
maxLevel: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 12
|
|
42
|
+
},
|
|
43
|
+
// 显示模式: 'full' 显示完整路径, 'last' 只显示最后一级
|
|
44
|
+
displayMode: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "full",
|
|
47
|
+
validator: (n) => ["full", "last"].includes(n)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
emits: ["update:modelValue", "change", "finish"],
|
|
51
|
+
setup(n, { expose: N, emit: k }) {
|
|
52
|
+
const o = n, v = k, s = i(!1), m = i(""), p = i([]), u = i(""), h = i(!1), c = i([]), w = {
|
|
53
|
+
text: "areaName",
|
|
54
|
+
value: "areaCode",
|
|
55
|
+
children: "children"
|
|
56
|
+
};
|
|
57
|
+
j(
|
|
58
|
+
() => o.modelValue,
|
|
59
|
+
(e) => {
|
|
60
|
+
e || (u.value = "", m.value = "", c.value = []);
|
|
61
|
+
},
|
|
62
|
+
{ immediate: !0 }
|
|
63
|
+
);
|
|
64
|
+
const V = () => {
|
|
65
|
+
s.value = !0, p.value.length === 0 && A();
|
|
66
|
+
}, A = async () => {
|
|
67
|
+
if (!h.value) {
|
|
68
|
+
h.value = !0;
|
|
69
|
+
try {
|
|
70
|
+
const e = o.defaultAreaCode, a = await Request.getForm(`dict/area/show/${e}`);
|
|
71
|
+
if (a.data) {
|
|
72
|
+
const r = {
|
|
73
|
+
areaCode: a.data.areaCode,
|
|
74
|
+
areaName: a.data.areaName,
|
|
75
|
+
areaLeve: a.data.areaLeve,
|
|
76
|
+
children: a.data.areaLeve < o.maxLevel ? [] : void 0
|
|
77
|
+
};
|
|
78
|
+
p.value = [r];
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error("加载初始地区失败:", e);
|
|
82
|
+
} finally {
|
|
83
|
+
h.value = !1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, b = async (e) => {
|
|
87
|
+
if (!e._loading) {
|
|
88
|
+
e._loading = !0;
|
|
89
|
+
try {
|
|
90
|
+
const a = await Request.getForm(`dict/area/next/${e.areaCode}`);
|
|
91
|
+
a.data && a.data.length > 0 ? (a.data.forEach((r) => {
|
|
92
|
+
r.areaLeve < o.maxLevel && (r.children = []);
|
|
93
|
+
}), e.children = a.data) : delete e.children;
|
|
94
|
+
} catch (a) {
|
|
95
|
+
console.error("加载下级地区失败:", a);
|
|
96
|
+
} finally {
|
|
97
|
+
e._loading = !1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, x = ({ value: e, selectedOptions: a, tabIndex: r }) => {
|
|
101
|
+
const t = a[r];
|
|
102
|
+
t && t.areaLeve < o.maxLevel && Array.isArray(t.children) && t.children.length === 0 && b(t), v("change", { value: e, selectedOptions: a, tabIndex: r });
|
|
103
|
+
}, S = ({ selectedOptions: e }) => {
|
|
104
|
+
var r, t, f, d, L;
|
|
105
|
+
o.displayMode === "last" ? u.value = ((r = e[e.length - 1]) == null ? void 0 : r.areaName) || "" : u.value = e.map((l) => l.areaName).join(o.separator), c.value = e.map((l) => ({
|
|
106
|
+
areaCode: l.areaCode,
|
|
107
|
+
areaName: l.areaName,
|
|
108
|
+
areaLeve: l.areaLeve
|
|
109
|
+
}));
|
|
110
|
+
let a;
|
|
111
|
+
switch (o.valueType) {
|
|
112
|
+
case "code":
|
|
113
|
+
a = ((t = e[e.length - 1]) == null ? void 0 : t.areaCode) || "";
|
|
114
|
+
break;
|
|
115
|
+
case "codes":
|
|
116
|
+
a = e.map((l) => l.areaCode);
|
|
117
|
+
break;
|
|
118
|
+
case "object":
|
|
119
|
+
a = {
|
|
120
|
+
codes: e.map((l) => l.areaCode),
|
|
121
|
+
names: e.map((l) => l.areaName),
|
|
122
|
+
fullName: e.map((l) => l.areaName).join(o.separator),
|
|
123
|
+
lastCode: ((f = e[e.length - 1]) == null ? void 0 : f.areaCode) || "",
|
|
124
|
+
lastLevel: (d = e[e.length - 1]) == null ? void 0 : d.areaLeve,
|
|
125
|
+
options: c.value
|
|
126
|
+
};
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
a = ((L = e[e.length - 1]) == null ? void 0 : L.areaCode) || "";
|
|
130
|
+
}
|
|
131
|
+
v("update:modelValue", a), v("finish", { selectedOptions: e, value: a }), s.value = !1;
|
|
132
|
+
};
|
|
133
|
+
return N({
|
|
134
|
+
// 获取当前选中的完整数据
|
|
135
|
+
getSelectedData: () => c.value,
|
|
136
|
+
// 获取显示值
|
|
137
|
+
getDisplayValue: () => u.value,
|
|
138
|
+
// 重置选择
|
|
139
|
+
reset: () => {
|
|
140
|
+
u.value = "", m.value = "", c.value = [], v("update:modelValue", o.valueType === "codes" ? [] : o.valueType === "object" ? null : "");
|
|
141
|
+
},
|
|
142
|
+
// 打开选择器
|
|
143
|
+
open: () => {
|
|
144
|
+
V();
|
|
145
|
+
},
|
|
146
|
+
// 关闭选择器
|
|
147
|
+
close: () => {
|
|
148
|
+
s.value = !1;
|
|
149
|
+
}
|
|
150
|
+
}), (e, a) => {
|
|
151
|
+
const r = g("van-field"), t = g("van-cascader"), f = g("van-popup");
|
|
152
|
+
return _(), F(T, null, [
|
|
153
|
+
y(r, $({
|
|
154
|
+
modelValue: u.value,
|
|
155
|
+
"onUpdate:modelValue": a[0] || (a[0] = (d) => u.value = d),
|
|
156
|
+
"is-link": "",
|
|
157
|
+
readonly: ""
|
|
158
|
+
}, e.$attrs, {
|
|
159
|
+
placeholder: n.placeholder,
|
|
160
|
+
onClick: V
|
|
161
|
+
}), null, 16, ["modelValue", "placeholder"]),
|
|
162
|
+
y(f, {
|
|
163
|
+
show: s.value,
|
|
164
|
+
"onUpdate:show": a[3] || (a[3] = (d) => s.value = d),
|
|
165
|
+
round: "",
|
|
166
|
+
position: "bottom"
|
|
167
|
+
}, {
|
|
168
|
+
default: D(() => [
|
|
169
|
+
y(t, {
|
|
170
|
+
modelValue: m.value,
|
|
171
|
+
"onUpdate:modelValue": a[1] || (a[1] = (d) => m.value = d),
|
|
172
|
+
title: n.title,
|
|
173
|
+
options: p.value,
|
|
174
|
+
"field-names": w,
|
|
175
|
+
onClose: a[2] || (a[2] = (d) => s.value = !1),
|
|
176
|
+
onFinish: S,
|
|
177
|
+
onChange: x
|
|
178
|
+
}, null, 8, ["modelValue", "title", "options"])
|
|
179
|
+
]),
|
|
180
|
+
_: 1
|
|
181
|
+
}, 8, ["show"])
|
|
182
|
+
], 64);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
C.install = (n) => {
|
|
187
|
+
n.component(C.name || "VtkArea", C);
|
|
188
|
+
};
|
|
189
|
+
export {
|
|
190
|
+
C as Area,
|
|
191
|
+
C as default
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=Area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Area.js","sources":["../../packages/Area/index.vue","../../packages/Area/index.js"],"sourcesContent":["<template>\r\n\t<van-field v-model=\"displayValue\" is-link readonly v-bind=\"$attrs\" :placeholder=\"placeholder\" @click=\"handleClick\" />\r\n\t<van-popup v-model:show=\"show\" round position=\"bottom\">\r\n\t\t<van-cascader v-model=\"cascaderValue\" :title=\"title\" :options=\"options\" :field-names=\"fieldNames\" @close=\"show = false\" @finish=\"onFinish\" @change=\"onChange\" />\r\n\t</van-popup>\r\n</template>\r\n\r\n<script setup>\r\ndefineOptions({\r\n\tname: \"VtkArea\",\r\n});\r\nimport { ref, watch } from \"vue\";\r\n\r\nconst props = defineProps({\r\n\t// 绑定值,根据 valueType 返回不同类型\r\n\tmodelValue: {\r\n\t\ttype: [String, Object, Array],\r\n\t\tdefault: \"\",\r\n\t},\r\n\t// 默认地区编码,用于初始化加载\r\n\tdefaultAreaCode: {\r\n\t\ttype: String,\r\n\t\tdefault: \"33\",\r\n\t},\r\n\t// 返回值类型: 'code' 返回最后一级areaCode, 'codes' 返回所有级别areaCode数组, 'object' 返回完整对象信息\r\n\tvalueType: {\r\n\t\ttype: String,\r\n\t\tdefault: \"code\",\r\n\t\tvalidator: (val) => [\"code\", \"codes\", \"object\"].includes(val),\r\n\t},\r\n\t// 显示分隔符\r\n\tseparator: {\r\n\t\ttype: String,\r\n\t\tdefault: \"/\",\r\n\t},\r\n\t// 弹窗标题\r\n\ttitle: {\r\n\t\ttype: String,\r\n\t\tdefault: \"请选择所在地区\",\r\n\t},\r\n\t// 占位文本\r\n\tplaceholder: {\r\n\t\ttype: String,\r\n\t\tdefault: \"请选择所在地区\",\r\n\t},\r\n\t// 最大层级限制,达到该层级后不再加载下级\r\n\tmaxLevel: {\r\n\t\ttype: Number,\r\n\t\tdefault: 12,\r\n\t},\r\n\t// 显示模式: 'full' 显示完整路径, 'last' 只显示最后一级\r\n\tdisplayMode: {\r\n\t\ttype: String,\r\n\t\tdefault: \"full\",\r\n\t\tvalidator: (val) => [\"full\", \"last\"].includes(val),\r\n\t},\r\n});\r\n\r\nconst emit = defineEmits([\"update:modelValue\", \"change\", \"finish\"]);\r\n\r\nconst show = ref(false); //弹窗显示隐藏\r\nconst cascaderValue = ref(\"\"); //级联选择器绑定值\r\nconst options = ref([]); //级联选择器选项\r\nconst displayValue = ref(\"\"); //显示值\r\nconst loading = ref(false); //加载状态\r\n// 存储完整的选中信息\r\nconst selectedData = ref([]);\r\n\r\nconst fieldNames = {\r\n\ttext: \"areaName\",\r\n\tvalue: \"areaCode\",\r\n\tchildren: \"children\",\r\n};\r\n\r\n// 监听 modelValue 变化,用于回显\r\nwatch(\r\n\t() => props.modelValue,\r\n\t(val) => {\r\n\t\tif (!val) {\r\n\t\t\tdisplayValue.value = \"\";\r\n\t\t\tcascaderValue.value = \"\";\r\n\t\t\tselectedData.value = [];\r\n\t\t}\r\n\t},\r\n\t{ immediate: true },\r\n);\r\n\r\nconst handleClick = () => {\r\n\tshow.value = true;\r\n\tif (options.value.length === 0) {\r\n\t\tloadInitialArea();\r\n\t}\r\n};\r\n\r\n// 加载初始地区\r\nconst loadInitialArea = async () => {\r\n\tif (loading.value) return;\r\n\tloading.value = true;\r\n\ttry {\r\n\t\tconst areaCode = props.defaultAreaCode;\r\n\t\tconst res = await Request.getForm(`dict/area/show/${areaCode}`);\r\n\t\tif (res.data) {\r\n\t\t\tconst rootArea = {\r\n\t\t\t\tareaCode: res.data.areaCode,\r\n\t\t\t\tareaName: res.data.areaName,\r\n\t\t\t\tareaLeve: res.data.areaLeve,\r\n\t\t\t\tchildren: res.data.areaLeve < props.maxLevel ? [] : undefined,\r\n\t\t\t};\r\n\t\t\toptions.value = [rootArea];\r\n\t\t}\r\n\t} catch (error) {\r\n\t\tconsole.error(\"加载初始地区失败:\", error);\r\n\t} finally {\r\n\t\tloading.value = false;\r\n\t}\r\n};\r\n\r\n// 加载下级地区\r\nconst loadChildren = async (item) => {\r\n\tif (item._loading) return;\r\n\titem._loading = true;\r\n\ttry {\r\n\t\tconst res = await Request.getForm(`dict/area/next/${item.areaCode}`);\r\n\t\tif (res.data && res.data.length > 0) {\r\n\t\t\tres.data.forEach((it) => {\r\n\t\t\t\t// 根据 maxLevel 判断是否还有下级\r\n\t\t\t\tif (it.areaLeve < props.maxLevel) {\r\n\t\t\t\t\tit.children = [];\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\titem.children = res.data;\r\n\t\t} else {\r\n\t\t\t// 没有下级数据,移除 children 属性使其成为叶子节点\r\n\t\t\tdelete item.children;\r\n\t\t}\r\n\t} catch (error) {\r\n\t\tconsole.error(\"加载下级地区失败:\", error);\r\n\t} finally {\r\n\t\titem._loading = false;\r\n\t}\r\n};\r\n\r\n// 选项变化时加载下级\r\nconst onChange = ({ value, selectedOptions, tabIndex }) => {\r\n\tconst currentItem = selectedOptions[tabIndex];\r\n\tif (currentItem && currentItem.areaLeve < props.maxLevel && Array.isArray(currentItem.children) && currentItem.children.length === 0) {\r\n\t\tloadChildren(currentItem);\r\n\t}\r\n\temit(\"change\", { value, selectedOptions, tabIndex });\r\n};\r\n\r\n// 完成选择\r\nconst onFinish = ({ selectedOptions }) => {\r\n\t// 根据 displayMode 决定显示值\r\n\tif (props.displayMode === \"last\") {\r\n\t\t// 只显示最后一级\r\n\t\tdisplayValue.value = selectedOptions[selectedOptions.length - 1]?.areaName || \"\";\r\n\t} else {\r\n\t\t// 显示完整路径(默认)\r\n\t\tdisplayValue.value = selectedOptions.map((option) => option.areaName).join(props.separator);\r\n\t}\r\n\r\n\t// 存储完整选中数据\r\n\tselectedData.value = selectedOptions.map((option) => ({\r\n\t\tareaCode: option.areaCode,\r\n\t\tareaName: option.areaName,\r\n\t\tareaLeve: option.areaLeve,\r\n\t}));\r\n\r\n\t// 根据 valueType 返回不同格式的值\r\n\tlet emitValue;\r\n\tswitch (props.valueType) {\r\n\t\tcase \"code\":\r\n\t\t\t// 返回最后一级的 areaCode\r\n\t\t\temitValue = selectedOptions[selectedOptions.length - 1]?.areaCode || \"\";\r\n\t\t\tbreak;\r\n\t\tcase \"codes\":\r\n\t\t\t// 返回所有级别的 areaCode 数组\r\n\t\t\temitValue = selectedOptions.map((option) => option.areaCode);\r\n\t\t\tbreak;\r\n\t\tcase \"object\":\r\n\t\t\t// 返回完整对象信息\r\n\t\t\temitValue = {\r\n\t\t\t\tcodes: selectedOptions.map((option) => option.areaCode),\r\n\t\t\t\tnames: selectedOptions.map((option) => option.areaName),\r\n\t\t\t\tfullName: selectedOptions.map((option) => option.areaName).join(props.separator),\r\n\t\t\t\tlastCode: selectedOptions[selectedOptions.length - 1]?.areaCode || \"\",\r\n\t\t\t\tlastLevel: selectedOptions[selectedOptions.length - 1]?.areaLeve,\r\n\t\t\t\toptions: selectedData.value,\r\n\t\t\t};\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\temitValue = selectedOptions[selectedOptions.length - 1]?.areaCode || \"\";\r\n\t}\r\n\r\n\temit(\"update:modelValue\", emitValue);\r\n\temit(\"finish\", { selectedOptions, value: emitValue });\r\n\tshow.value = false;\r\n};\r\n\r\n// 暴露方法供外部调用\r\ndefineExpose({\r\n\t// 获取当前选中的完整数据\r\n\tgetSelectedData: () => selectedData.value,\r\n\t// 获取显示值\r\n\tgetDisplayValue: () => displayValue.value,\r\n\t// 重置选择\r\n\treset: () => {\r\n\t\tdisplayValue.value = \"\";\r\n\t\tcascaderValue.value = \"\";\r\n\t\tselectedData.value = [];\r\n\t\temit(\"update:modelValue\", props.valueType === \"codes\" ? [] : props.valueType === \"object\" ? null : \"\");\r\n\t},\r\n\t// 打开选择器\r\n\topen: () => {\r\n\t\thandleClick();\r\n\t},\r\n\t// 关闭选择器\r\n\tclose: () => {\r\n\t\tshow.value = false;\r\n\t},\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped></style>\r\n","/**\r\n * Area 组件单独导出入口\r\n * 支持按需引入\r\n */\r\nimport Area from './index.vue'\r\n\r\n// 为组件添加 install 方法,支持 app.use() 方式注册\r\nArea.install = (app) => {\r\n app.component(Area.name || 'VtkArea', Area)\r\n}\r\n\r\nexport default Area\r\nexport { Area }\r\n"],"names":["props","__props","emit","__emit","show","ref","cascaderValue","options","displayValue","loading","selectedData","fieldNames","watch","val","handleClick","loadInitialArea","areaCode","res","rootArea","error","loadChildren","item","it","onChange","value","selectedOptions","tabIndex","currentItem","onFinish","_a","option","emitValue","_b","_c","_d","_e","__expose","_createVNode","_component_van_field","_mergeProps","$event","$attrs","_component_van_popup","_component_van_cascader","Area","app"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;;;QA5NAiC,EAAqHC,GAArHC,EAAqH;AAAA,sBAAjG/B,EAAA;AAAA,wDAAAA,EAAY,QAAAgC;AAAA,UAAE,WAAA;AAAA,UAAQ,UAAA;AAAA,WAAiBC,EAAAA,QAAM;AAAA,UAAG,aAAaxC,EAAA;AAAA,UAAc,SAAOa;AAAA;QACtGuB,EAEYK,GAAA;AAAA,UAFO,MAAMtC,EAAA;AAAA,kDAAAA,EAAI,QAAAoC;AAAA,UAAE,OAAA;AAAA,UAAM,UAAS;AAAA;qBAC7C,MAAgK;AAAA,YAAhKH,EAAgKM,GAAA;AAAA,0BAAzIrC,EAAA;AAAA,4DAAAA,EAAa,QAAAkC;AAAA,cAAG,OAAOvC,EAAA;AAAA,cAAQ,SAASM,EAAA;AAAA,cAAU,eAAaI;AAAA,cAAa,gCAAOP,EAAA,QAAI;AAAA,cAAW,UAAQwB;AAAA,cAAW,UAAQL;AAAA;;;;;;;;ACItJqB,EAAK,UAAU,CAACC,MAAQ;AACtB,EAAAA,EAAI,UAAUD,EAAK,QAAQ,WAAWA,CAAI;AAC5C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-v-3482e335] .van-radio{margin-right:12px}
|
package/dist/es/Radio.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { computed as f, resolveComponent as u, openBlock as p, createBlock as g, normalizeProps as y, guardReactiveProps as V, withCtx as s, createVNode as b, createElementBlock as S, Fragment as x, renderList as j, createTextVNode as N, toDisplayString as k } from "vue";
|
|
2
|
+
import { _ as T } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
3
|
+
const B = /* @__PURE__ */ Object.assign({
|
|
4
|
+
name: "VtkRadio"
|
|
5
|
+
}, {
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: {
|
|
8
|
+
// 绑定值
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: [String, Number, Object],
|
|
11
|
+
default: ""
|
|
12
|
+
},
|
|
13
|
+
// 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'
|
|
14
|
+
options: {
|
|
15
|
+
type: [Array, String],
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
// 返回值类型: 'string' (基本类型), 'object' (完整对象)
|
|
19
|
+
valueType: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "string",
|
|
22
|
+
validator: (n) => ["string", "object"].includes(n)
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
emits: ["update:modelValue", "change"],
|
|
26
|
+
setup(n, { emit: _ }) {
|
|
27
|
+
const t = n, c = _, m = f(() => Array.isArray(t.options) ? t.options : typeof t.options == "string" && t.options ? t.options.split("/").filter(Boolean).map((e) => {
|
|
28
|
+
const [o, r] = e.split(":");
|
|
29
|
+
return {
|
|
30
|
+
text: r || o,
|
|
31
|
+
value: o
|
|
32
|
+
};
|
|
33
|
+
}) : []), v = f({
|
|
34
|
+
get: () => {
|
|
35
|
+
const e = t.modelValue;
|
|
36
|
+
return e == null ? "" : t.valueType === "object" && e && typeof e == "object" ? String(e.value ?? "") : String(e);
|
|
37
|
+
},
|
|
38
|
+
set: (e) => {
|
|
39
|
+
var l;
|
|
40
|
+
let o = e;
|
|
41
|
+
typeof (t.valueType === "object" ? (l = t.modelValue) == null ? void 0 : l.value : t.modelValue) == "number" && !isNaN(Number(e)) && (o = Number(e)), t.valueType === "object" && (o = m.value.find((i) => String(i.value) === String(e)) || null), c("update:modelValue", o), c("change", o);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return (e, o) => {
|
|
45
|
+
const r = u("van-radio"), l = u("van-radio-group"), i = u("van-field");
|
|
46
|
+
return p(), g(i, y(V(e.$attrs)), {
|
|
47
|
+
input: s(() => [
|
|
48
|
+
b(l, {
|
|
49
|
+
modelValue: v.value,
|
|
50
|
+
"onUpdate:modelValue": o[0] || (o[0] = (a) => v.value = a),
|
|
51
|
+
direction: "horizontal"
|
|
52
|
+
}, {
|
|
53
|
+
default: s(() => [
|
|
54
|
+
(p(!0), S(x, null, j(m.value, (a) => (p(), g(r, {
|
|
55
|
+
key: String(a.value),
|
|
56
|
+
name: String(a.value)
|
|
57
|
+
}, {
|
|
58
|
+
default: s(() => [
|
|
59
|
+
N(k(a.text), 1)
|
|
60
|
+
]),
|
|
61
|
+
_: 2
|
|
62
|
+
}, 1032, ["name"]))), 128))
|
|
63
|
+
]),
|
|
64
|
+
_: 1
|
|
65
|
+
}, 8, ["modelValue"])
|
|
66
|
+
]),
|
|
67
|
+
_: 1
|
|
68
|
+
}, 16);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}), d = /* @__PURE__ */ T(B, [["__scopeId", "data-v-3482e335"]]);
|
|
72
|
+
d.install = (n) => {
|
|
73
|
+
n.component(d.name || "VtkRadio", d);
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
d as Radio,
|
|
77
|
+
d as default
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=Radio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../packages/Radio/index.vue","../../packages/Radio/index.js"],"sourcesContent":["<template>\r\n\t<van-field v-bind=\"$attrs\">\r\n\t\t<template #input>\r\n\t\t\t<van-radio-group v-model=\"internalValue\" direction=\"horizontal\">\r\n\t\t\t\t<van-radio v-for=\"item in parsedOptions\" :key=\"String(item.value)\" :name=\"String(item.value)\">\r\n\t\t\t\t\t{{ item.text }}\r\n\t\t\t\t</van-radio>\r\n\t\t\t</van-radio-group>\r\n\t\t</template>\r\n\t</van-field>\r\n</template>\r\n\r\n<script setup>\r\ndefineOptions({\r\n\tname: \"VtkRadio\",\r\n});\r\nimport { computed } from \"vue\";\r\n\r\nconst props = defineProps({\r\n\t// 绑定值\r\n\tmodelValue: {\r\n\t\ttype: [String, Number, Object],\r\n\t\tdefault: \"\",\r\n\t},\r\n\t// 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'\r\n\toptions: {\r\n\t\ttype: [Array, String],\r\n\t\tdefault: () => [],\r\n\t},\r\n\t// 返回值类型: 'string' (基本类型), 'object' (完整对象)\r\n\tvalueType: {\r\n\t\ttype: String,\r\n\t\tdefault: \"string\",\r\n\t\tvalidator: (val) => [\"string\", \"object\"].includes(val),\r\n\t},\r\n});\r\n\r\nconst emit = defineEmits([\"update:modelValue\", \"change\"]);\r\n\r\n// 解析选项\r\nconst parsedOptions = computed(() => {\r\n\tif (Array.isArray(props.options)) {\r\n\t\treturn props.options;\r\n\t}\r\n\tif (typeof props.options === \"string\" && props.options) {\r\n\t\treturn props.options\r\n\t\t\t.split(\"/\")\r\n\t\t\t.filter(Boolean)\r\n\t\t\t.map((item) => {\r\n\t\t\t\tconst [value, text] = item.split(\":\");\r\n\t\t\t\treturn {\r\n\t\t\t\t\ttext: text || value,\r\n\t\t\t\t\tvalue: value,\r\n\t\t\t\t};\r\n\t\t\t});\r\n\t}\r\n\treturn [];\r\n});\r\n\r\n// 使用可写计算属性处理 v-model 绑定\r\nconst internalValue = computed({\r\n\tget: () => {\r\n\t\tconst val = props.modelValue;\r\n\t\tif (val === undefined || val === null) return \"\";\r\n\r\n\t\t// 如果是对象类型,提取其中的 value\r\n\t\tif (props.valueType === \"object\" && val && typeof val === \"object\") {\r\n\t\t\treturn String(val.value ?? \"\");\r\n\t\t}\r\n\t\treturn String(val);\r\n\t},\r\n\tset: (newValue) => {\r\n\t\tlet emitValue = newValue;\r\n\r\n\t\t// 处理原始数据类型逻辑(如果父组件传入的是数字,尝试转回数字)\r\n\t\tconst originalValue = props.valueType === \"object\" ? props.modelValue?.value : props.modelValue;\r\n\t\tif (typeof originalValue === \"number\" && !isNaN(Number(newValue))) {\r\n\t\t\temitValue = Number(newValue);\r\n\t\t}\r\n\r\n\t\tif (props.valueType === \"object\") {\r\n\t\t\t// 找回完整对象\r\n\t\t\temitValue = parsedOptions.value.find((opt) => String(opt.value) === String(newValue)) || null;\r\n\t\t}\r\n\r\n\t\temit(\"update:modelValue\", emitValue);\r\n\t\temit(\"change\", emitValue);\r\n\t},\r\n});\r\n</script>\r\n\r\n<style scoped>\r\n:deep(.van-radio) {\r\n\tmargin-right: 12px;\r\n}\r\n</style>\r\n","/**\r\n * Radio 组件单独导出入口\r\n * 支持按需引入\r\n */\r\nimport Radio from './index.vue'\r\n\r\n// 为组件添加 install 方法,支持 app.use() 方式注册\r\nRadio.install = (app) => {\r\n app.component(Radio.name || 'VtkRadio', Radio)\r\n}\r\n\r\nexport default Radio\r\nexport { Radio }\r\n"],"names":["props","__props","emit","__emit","parsedOptions","computed","item","value","text","internalValue","val","newValue","emitValue","_a","opt","_openBlock","_createBlock","_component_van_field","$attrs","_createVNode","_component_van_radio_group","$event","_createElementBlock","_Fragment","_renderList","_component_van_radio","_createTextVNode","_toDisplayString","Radio","app"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,UAAMA,IAAQC,GAmBRC,IAAOC,GAGPC,IAAgBC,EAAS,MAC1B,MAAM,QAAQL,EAAM,OAAO,IACvBA,EAAM,UAEV,OAAOA,EAAM,WAAY,YAAYA,EAAM,UACvCA,EAAM,QACX,MAAM,GAAG,EACT,OAAO,OAAO,EACd,IAAI,CAACM,MAAS;AACd,YAAM,CAACC,GAAOC,CAAI,IAAIF,EAAK,MAAM,GAAG;AACpC,aAAO;AAAA,QACN,MAAME,KAAQD;AAAA,QACd,OAAOA;AAAA,MACZ;AAAA,IACG,CAAC,IAEI,EACP,GAGKE,IAAgBJ,EAAS;AAAA,MAC9B,KAAK,MAAM;AACV,cAAMK,IAAMV,EAAM;AAClB,eAAyBU,KAAQ,OAAa,KAG1CV,EAAM,cAAc,YAAYU,KAAO,OAAOA,KAAQ,WAClD,OAAOA,EAAI,SAAS,EAAE,IAEvB,OAAOA,CAAG;AAAA,MAClB;AAAA,MACA,KAAK,CAACC,MAAa;;AAClB,YAAIC,IAAYD;AAIhB,QAAI,QADkBX,EAAM,cAAc,YAAWa,IAAAb,EAAM,eAAN,gBAAAa,EAAkB,QAAQb,EAAM,eACxD,YAAY,CAAC,MAAM,OAAOW,CAAQ,CAAC,MAC/DC,IAAY,OAAOD,CAAQ,IAGxBX,EAAM,cAAc,aAEvBY,IAAYR,EAAc,MAAM,KAAK,CAACU,MAAQ,OAAOA,EAAI,KAAK,MAAM,OAAOH,CAAQ,CAAC,KAAK,OAG1FT,EAAK,qBAAqBU,CAAS,GACnCV,EAAK,UAAUU,CAAS;AAAA,MACzB;AAAA,IACD,CAAC;;;AAvFA,aAAAG,EAAA,GAAAC,EAQYC,OAROC,EAAAA,MAAM,CAAA,GAAA;AAAA,QACb,SACV,MAIkB;AAAA,UAJlBC,EAIkBC,GAAA;AAAA,wBAJQX,EAAA;AAAA,0DAAAA,EAAa,QAAAY;AAAA,YAAE,WAAU;AAAA;uBACvC,MAA6B;AAAA,sBAAxCC,EAEYC,GAAA,MAAAC,EAFcpB,EAAA,OAAa,CAArBE,YAAlBU,EAEYS,GAAA;AAAA,gBAF8B,KAAK,OAAOnB,EAAK,KAAK;AAAA,gBAAI,MAAM,OAAOA,EAAK,KAAK;AAAA;2BAC1F,MAAe;AAAA,kBAAZoB,EAAAC,EAAArB,EAAK,IAAI,GAAA,CAAA;AAAA;;;;;;;;;;;;ACEjBsB,EAAM,UAAU,CAACC,MAAQ;AACvB,EAAAA,EAAI,UAAUD,EAAM,QAAQ,YAAYA,CAAK;AAC/C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-v-3ed9d102] .van-uploader__preview-image,[data-v-3ed9d102] .van-uploader__upload{border-radius:4px}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ref as V, watch as $, resolveComponent as _, openBlock as b, createBlock as k, mergeProps as T } from "vue";
|
|
2
|
+
import { showLoadingToast as g, closeToast as C, showToast as m } from "vant";
|
|
3
|
+
import { _ as M } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
4
|
+
const j = /* @__PURE__ */ Object.assign({
|
|
5
|
+
name: "VtkUploader",
|
|
6
|
+
inheritAttrs: !1
|
|
7
|
+
}, {
|
|
8
|
+
__name: "index",
|
|
9
|
+
props: {
|
|
10
|
+
/** 绑定值,支持字符串或数组 */
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: [String, Array],
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
/** 返回值类型:'string' 返回逗号分隔的字符串,'array' 返回数组 */
|
|
16
|
+
valueType: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "array",
|
|
19
|
+
validator: (o) => ["string", "array"].includes(o)
|
|
20
|
+
},
|
|
21
|
+
/** 单个文件最大大小(字节),默认10MB */
|
|
22
|
+
maxSize: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: 10 * 1024 * 1024
|
|
25
|
+
},
|
|
26
|
+
/** 接受的文件类型 */
|
|
27
|
+
accept: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "image/*"
|
|
30
|
+
},
|
|
31
|
+
/** 自定义上传方法(必填) */
|
|
32
|
+
uploadMethod: {
|
|
33
|
+
type: Function,
|
|
34
|
+
required: !0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
emits: ["update:modelValue", "change", "success", "error"],
|
|
38
|
+
setup(o, { expose: y, emit: h }) {
|
|
39
|
+
const n = o, u = h, l = V([]), x = (e) => {
|
|
40
|
+
if (!e) return [];
|
|
41
|
+
let t = [];
|
|
42
|
+
return typeof e == "string" ? t = e.split(",").filter((s) => s.trim()) : Array.isArray(e) && (t = e.filter((s) => s)), t.map((s) => ({
|
|
43
|
+
url: s,
|
|
44
|
+
status: "done",
|
|
45
|
+
message: ""
|
|
46
|
+
}));
|
|
47
|
+
}, d = () => l.value.filter((e) => e.status === "done" && e.url).map((e) => e.url), A = (e) => n.valueType === "string" ? e.join(",") : e, f = () => {
|
|
48
|
+
const e = d(), t = A(e);
|
|
49
|
+
u("update:modelValue", t), u("change", t);
|
|
50
|
+
};
|
|
51
|
+
$(
|
|
52
|
+
() => n.modelValue,
|
|
53
|
+
(e) => {
|
|
54
|
+
const t = d().join(","), s = Array.isArray(e) ? e.join(",") : e || "";
|
|
55
|
+
t !== s && (l.value = x(e));
|
|
56
|
+
},
|
|
57
|
+
{ immediate: !0 }
|
|
58
|
+
);
|
|
59
|
+
const v = (e) => {
|
|
60
|
+
const t = Array.isArray(e) ? e : [e];
|
|
61
|
+
for (const s of t)
|
|
62
|
+
if (s.size > n.maxSize) {
|
|
63
|
+
const a = (n.maxSize / 1024 / 1024).toFixed(1);
|
|
64
|
+
return m(`文件大小不能超过${a}MB`), !1;
|
|
65
|
+
}
|
|
66
|
+
return !0;
|
|
67
|
+
}, U = async (e) => {
|
|
68
|
+
try {
|
|
69
|
+
return await n.uploadMethod(e);
|
|
70
|
+
} catch (t) {
|
|
71
|
+
return { success: !1, message: t.message || "上传失败" };
|
|
72
|
+
}
|
|
73
|
+
}, z = async (e) => {
|
|
74
|
+
const t = Array.isArray(e) ? e : [e];
|
|
75
|
+
t.length > 1 && g({
|
|
76
|
+
message: `正在上传 0/${t.length}`,
|
|
77
|
+
forbidClick: !0,
|
|
78
|
+
duration: 0
|
|
79
|
+
});
|
|
80
|
+
let s = 0, a = 0;
|
|
81
|
+
for (let c = 0; c < t.length; c++) {
|
|
82
|
+
const r = t[c];
|
|
83
|
+
r.status = "uploading", r.message = "上传中...", t.length > 1 && g({
|
|
84
|
+
message: `正在上传 ${c + 1}/${t.length}`,
|
|
85
|
+
forbidClick: !0,
|
|
86
|
+
duration: 0
|
|
87
|
+
});
|
|
88
|
+
const i = await U(r);
|
|
89
|
+
i.success ? (r.status = "done", r.message = "", r.url = i.url, s++, u("success", { file: r, url: i.url })) : (r.status = "failed", r.message = i.message, a++, u("error", { file: r, message: i.message }));
|
|
90
|
+
}
|
|
91
|
+
C(), t.length > 1 ? a === 0 ? m(`${s}个文件上传成功`) : m(`${s}个成功,${a}个失败`) : a > 0 && m(t[0].message || "上传失败"), f();
|
|
92
|
+
}, S = () => {
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
f();
|
|
95
|
+
}, 0);
|
|
96
|
+
};
|
|
97
|
+
return y({
|
|
98
|
+
/** 获取已上传的URL列表 */
|
|
99
|
+
getUrls: d,
|
|
100
|
+
/** 清空文件列表 */
|
|
101
|
+
clear: () => {
|
|
102
|
+
l.value = [], f();
|
|
103
|
+
},
|
|
104
|
+
/** 获取文件列表 */
|
|
105
|
+
getFileList: () => l.value
|
|
106
|
+
}), (e, t) => {
|
|
107
|
+
const s = _("van-uploader");
|
|
108
|
+
return b(), k(s, T({
|
|
109
|
+
modelValue: l.value,
|
|
110
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => l.value = a)
|
|
111
|
+
}, e.$attrs, {
|
|
112
|
+
"max-size": o.maxSize,
|
|
113
|
+
accept: o.accept,
|
|
114
|
+
"before-read": v,
|
|
115
|
+
"after-read": z,
|
|
116
|
+
onDelete: S
|
|
117
|
+
}), null, 16, ["modelValue", "max-size", "accept"]);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}), p = /* @__PURE__ */ M(j, [["__scopeId", "data-v-3ed9d102"]]);
|
|
121
|
+
p.install = (o) => {
|
|
122
|
+
o.component(p.name || "VtkUploader", p);
|
|
123
|
+
};
|
|
124
|
+
export {
|
|
125
|
+
p as Uploader,
|
|
126
|
+
p as default
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=Uploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Uploader.js","sources":["../../packages/Uploader/index.vue","../../packages/Uploader/index.js"],"sourcesContent":["<template>\r\n\t<van-uploader v-model=\"fileList\" v-bind=\"$attrs\" :max-size=\"maxSize\" :accept=\"accept\" :before-read=\"beforeRead\" :after-read=\"afterRead\" @delete=\"onDelete\" />\r\n</template>\r\n\r\n<script setup>\r\ndefineOptions({\r\n\tname: \"VtkUploader\",\r\n\tinheritAttrs: false,\r\n});\r\nimport { ref, watch } from \"vue\";\r\nimport { showToast, showLoadingToast, closeToast } from \"vant\";\r\n\r\nconst props = defineProps({\r\n\t/** 绑定值,支持字符串或数组 */\r\n\tmodelValue: {\r\n\t\ttype: [String, Array],\r\n\t\tdefault: () => [],\r\n\t},\r\n\t/** 返回值类型:'string' 返回逗号分隔的字符串,'array' 返回数组 */\r\n\tvalueType: {\r\n\t\ttype: String,\r\n\t\tdefault: \"array\",\r\n\t\tvalidator: (val) => [\"string\", \"array\"].includes(val),\r\n\t},\r\n\t/** 单个文件最大大小(字节),默认10MB */\r\n\tmaxSize: {\r\n\t\ttype: Number,\r\n\t\tdefault: 10 * 1024 * 1024,\r\n\t},\r\n\t/** 接受的文件类型 */\r\n\taccept: {\r\n\t\ttype: String,\r\n\t\tdefault: \"image/*\",\r\n\t},\r\n\t/** 自定义上传方法(必填) */\r\n\tuploadMethod: {\r\n\t\ttype: Function,\r\n\t\trequired: true,\r\n\t},\r\n});\r\n\r\nconst emit = defineEmits([\"update:modelValue\", \"change\", \"success\", \"error\"]);\r\n\r\n// 文件列表\r\nconst fileList = ref([]);\r\n\r\n// 解析初始值\r\nconst parseModelValue = (value) => {\r\n\tif (!value) return [];\r\n\r\n\tlet urls = [];\r\n\tif (typeof value === \"string\") {\r\n\t\turls = value.split(\",\").filter((url) => url.trim());\r\n\t} else if (Array.isArray(value)) {\r\n\t\turls = value.filter((url) => url);\r\n\t}\r\n\r\n\treturn urls.map((url) => ({\r\n\t\turl,\r\n\t\tstatus: \"done\",\r\n\t\tmessage: \"\",\r\n\t}));\r\n};\r\n\r\n// 获取已上传的URL列表\r\nconst getUploadedUrls = () => {\r\n\treturn fileList.value.filter((file) => file.status === \"done\" && file.url).map((file) => file.url);\r\n};\r\n\r\n// 格式化输出值\r\nconst formatOutput = (urls) => {\r\n\tif (props.valueType === \"string\") {\r\n\t\treturn urls.join(\",\");\r\n\t}\r\n\treturn urls;\r\n};\r\n\r\n// 触发更新\r\nconst emitValue = () => {\r\n\tconst urls = getUploadedUrls();\r\n\tconst output = formatOutput(urls);\r\n\temit(\"update:modelValue\", output);\r\n\temit(\"change\", output);\r\n};\r\n\r\n// 监听外部值变化\r\nwatch(\r\n\t() => props.modelValue,\r\n\t(newVal) => {\r\n\t\tconst currentUrls = getUploadedUrls().join(\",\");\r\n\t\tconst newUrls = Array.isArray(newVal) ? newVal.join(\",\") : newVal || \"\";\r\n\r\n\t\t// 只有外部值确实改变时才更新\r\n\t\tif (currentUrls !== newUrls) {\r\n\t\t\tfileList.value = parseModelValue(newVal);\r\n\t\t}\r\n\t},\r\n\t{ immediate: true },\r\n);\r\n\r\n// 上传前校验\r\nconst beforeRead = (file) => {\r\n\tconst files = Array.isArray(file) ? file : [file];\r\n\r\n\tfor (const f of files) {\r\n\t\t// 文件大小校验\r\n\t\tif (f.size > props.maxSize) {\r\n\t\t\tconst maxSizeMB = (props.maxSize / 1024 / 1024).toFixed(1);\r\n\t\t\tshowToast(`文件大小不能超过${maxSizeMB}MB`);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\treturn true;\r\n};\r\n\r\n// 上传文件\r\nconst uploadFile = async (file) => {\r\n\ttry {\r\n\t\tconst result = await props.uploadMethod(file);\r\n\t\treturn result;\r\n\t} catch (error) {\r\n\t\treturn { success: false, message: error.message || \"上传失败\" };\r\n\t}\r\n};\r\n\r\n// 文件读取完成后处理\r\nconst afterRead = async (file) => {\r\n\tconst files = Array.isArray(file) ? file : [file];\r\n\r\n\t// 显示上传中提示\r\n\tif (files.length > 1) {\r\n\t\tshowLoadingToast({\r\n\t\t\tmessage: `正在上传 0/${files.length}`,\r\n\t\t\tforbidClick: true,\r\n\t\t\tduration: 0,\r\n\t\t});\r\n\t}\r\n\r\n\tlet successCount = 0;\r\n\tlet failCount = 0;\r\n\r\n\t// 逐个上传\r\n\tfor (let i = 0; i < files.length; i++) {\r\n\t\tconst fileItem = files[i];\r\n\t\tfileItem.status = \"uploading\";\r\n\t\tfileItem.message = \"上传中...\";\r\n\r\n\t\t// 更新进度提示\r\n\t\tif (files.length > 1) {\r\n\t\t\tshowLoadingToast({\r\n\t\t\t\tmessage: `正在上传 ${i + 1}/${files.length}`,\r\n\t\t\t\tforbidClick: true,\r\n\t\t\t\tduration: 0,\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst result = await uploadFile(fileItem);\r\n\r\n\t\tif (result.success) {\r\n\t\t\tfileItem.status = \"done\";\r\n\t\t\tfileItem.message = \"\";\r\n\t\t\tfileItem.url = result.url;\r\n\t\t\tsuccessCount++;\r\n\t\t\temit(\"success\", { file: fileItem, url: result.url });\r\n\t\t} else {\r\n\t\t\tfileItem.status = \"failed\";\r\n\t\t\tfileItem.message = result.message;\r\n\t\t\tfailCount++;\r\n\t\t\temit(\"error\", { file: fileItem, message: result.message });\r\n\t\t}\r\n\t}\r\n\r\n\tcloseToast();\r\n\r\n\t// 显示上传结果\r\n\tif (files.length > 1) {\r\n\t\tif (failCount === 0) {\r\n\t\t\tshowToast(`${successCount}个文件上传成功`);\r\n\t\t} else {\r\n\t\t\tshowToast(`${successCount}个成功,${failCount}个失败`);\r\n\t\t}\r\n\t} else if (failCount > 0) {\r\n\t\tshowToast(files[0].message || \"上传失败\");\r\n\t}\r\n\r\n\t// 触发值更新\r\n\temitValue();\r\n};\r\n\r\n// 删除文件\r\nconst onDelete = () => {\r\n\t// 下一个tick再触发,确保fileList已更新\r\n\tsetTimeout(() => {\r\n\t\temitValue();\r\n\t}, 0);\r\n};\r\n\r\n// 暴露方法给父组件\r\ndefineExpose({\r\n\t/** 获取已上传的URL列表 */\r\n\tgetUrls: getUploadedUrls,\r\n\t/** 清空文件列表 */\r\n\tclear: () => {\r\n\t\tfileList.value = [];\r\n\t\temitValue();\r\n\t},\r\n\t/** 获取文件列表 */\r\n\tgetFileList: () => fileList.value,\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n:deep(.van-uploader__preview-image) {\r\n\tborder-radius: 4px;\r\n}\r\n\r\n:deep(.van-uploader__upload) {\r\n\tborder-radius: 4px;\r\n}\r\n</style>\r\n","/**\r\n * Uploader 组件单独导出入口\r\n * 支持按需引入\r\n */\r\nimport Uploader from './index.vue'\r\n\r\n// 为组件添加 install 方法,支持 app.use() 方式注册\r\nUploader.install = (app) => {\r\n app.component(Uploader.name || 'VtkUploader', Uploader)\r\n}\r\n\r\nexport default Uploader\r\nexport { Uploader }\r\n"],"names":["props","__props","emit","__emit","fileList","ref","parseModelValue","value","urls","url","getUploadedUrls","file","formatOutput","emitValue","output","watch","newVal","currentUrls","newUrls","beforeRead","files","f","maxSizeMB","showToast","uploadFile","error","afterRead","showLoadingToast","successCount","failCount","i","fileItem","result","closeToast","onDelete","__expose","_openBlock","_createBlock","_component_van_uploader","_mergeProps","$event","$attrs","Uploader","app"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,UAAMA,IAAQC,GA6BRC,IAAOC,GAGPC,IAAWC,EAAI,CAAA,CAAE,GAGjBC,IAAkB,CAACC,MAAU;AAClC,UAAI,CAACA,EAAO,QAAO;AAEnB,UAAIC,IAAO,CAAA;AACX,aAAI,OAAOD,KAAU,WACpBC,IAAOD,EAAM,MAAM,GAAG,EAAE,OAAO,CAACE,MAAQA,EAAI,KAAI,CAAE,IACxC,MAAM,QAAQF,CAAK,MAC7BC,IAAOD,EAAM,OAAO,CAACE,MAAQA,CAAG,IAG1BD,EAAK,IAAI,CAACC,OAAS;AAAA,QACzB,KAAAA;AAAA,QACA,QAAQ;AAAA,QACR,SAAS;AAAA,MACX,EAAG;AAAA,IACH,GAGMC,IAAkB,MAChBN,EAAS,MAAM,OAAO,CAACO,MAASA,EAAK,WAAW,UAAUA,EAAK,GAAG,EAAE,IAAI,CAACA,MAASA,EAAK,GAAG,GAI5FC,IAAe,CAACJ,MACjBR,EAAM,cAAc,WAChBQ,EAAK,KAAK,GAAG,IAEdA,GAIFK,IAAY,MAAM;AACvB,YAAML,IAAOE,KACPI,IAASF,EAAaJ,CAAI;AAChC,MAAAN,EAAK,qBAAqBY,CAAM,GAChCZ,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
|
|
|
1
|
+
{"version":3,"file":"_plugin-vue_export-helper-CHgC5LLL.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-v-eb64e8a9] .van-checkbox{margin-bottom:8px;margin-right:12px}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { computed as m, resolveComponent as l, openBlock as s, createBlock as f, normalizeProps as _, guardReactiveProps as b, withCtx as i, createVNode as x, createElementBlock as k, Fragment as V, renderList as h, createTextVNode as A, toDisplayString as S } from "vue";
|
|
2
|
+
import { _ as j } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
3
|
+
const N = /* @__PURE__ */ Object.assign({
|
|
4
|
+
name: "VtkCheckbox"
|
|
5
|
+
}, {
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: {
|
|
8
|
+
// 绑定值
|
|
9
|
+
modelValue: {
|
|
10
|
+
type: [String, Array, Object],
|
|
11
|
+
default: () => []
|
|
12
|
+
},
|
|
13
|
+
// 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'
|
|
14
|
+
options: {
|
|
15
|
+
type: [Array, String],
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
// 返回值类型: 'string' (逗号分隔), 'array' (值数组), 'object' (对象数组)
|
|
19
|
+
valueType: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "array",
|
|
22
|
+
validator: (o) => ["string", "array", "object"].includes(o)
|
|
23
|
+
},
|
|
24
|
+
// 当 valueType 为 string 时的分隔符
|
|
25
|
+
separator: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ","
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
emits: ["update:modelValue", "change"],
|
|
31
|
+
setup(o, { emit: y }) {
|
|
32
|
+
const a = o, u = y, c = m(() => Array.isArray(a.options) ? a.options : typeof a.options == "string" && a.options ? a.options.split("/").filter(Boolean).map((t) => {
|
|
33
|
+
const [e, r] = t.split(":");
|
|
34
|
+
return {
|
|
35
|
+
text: r || e,
|
|
36
|
+
value: e
|
|
37
|
+
};
|
|
38
|
+
}) : []), d = m({
|
|
39
|
+
get: () => {
|
|
40
|
+
const t = a.modelValue;
|
|
41
|
+
if (!t) return [];
|
|
42
|
+
let e = [];
|
|
43
|
+
return a.valueType === "string" ? e = typeof t == "string" ? t.split(a.separator).filter(Boolean) : [] : a.valueType === "object" ? e = Array.isArray(t) ? t.map((r) => (r == null ? void 0 : r.value) ?? r) : [] : e = Array.isArray(t) ? t : [], e.map(String);
|
|
44
|
+
},
|
|
45
|
+
set: (t) => {
|
|
46
|
+
let e;
|
|
47
|
+
a.valueType === "string" ? e = t.join(a.separator) : a.valueType === "object" ? e = c.value.filter((r) => t.includes(String(r.value))) : e = t.map((r) => isNaN(Number(r)) ? r : Array.isArray(a.modelValue) && typeof a.modelValue[0] == "number" ? Number(r) : r), u("update:modelValue", e), u("change", e);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return (t, e) => {
|
|
51
|
+
const r = l("van-checkbox"), v = l("van-checkbox-group"), g = l("van-field");
|
|
52
|
+
return s(), f(g, _(b(t.$attrs)), {
|
|
53
|
+
input: i(() => [
|
|
54
|
+
x(v, {
|
|
55
|
+
modelValue: d.value,
|
|
56
|
+
"onUpdate:modelValue": e[0] || (e[0] = (n) => d.value = n),
|
|
57
|
+
direction: "horizontal"
|
|
58
|
+
}, {
|
|
59
|
+
default: i(() => [
|
|
60
|
+
(s(!0), k(V, null, h(c.value, (n) => (s(), f(r, {
|
|
61
|
+
key: String(n.value),
|
|
62
|
+
name: String(n.value),
|
|
63
|
+
shape: "square"
|
|
64
|
+
}, {
|
|
65
|
+
default: i(() => [
|
|
66
|
+
A(S(n.text), 1)
|
|
67
|
+
]),
|
|
68
|
+
_: 2
|
|
69
|
+
}, 1032, ["name"]))), 128))
|
|
70
|
+
]),
|
|
71
|
+
_: 1
|
|
72
|
+
}, 8, ["modelValue"])
|
|
73
|
+
]),
|
|
74
|
+
_: 1
|
|
75
|
+
}, 16);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}), p = /* @__PURE__ */ j(N, [["__scopeId", "data-v-eb64e8a9"]]);
|
|
79
|
+
p.install = (o) => {
|
|
80
|
+
o.component(p.name || "VtkCheckbox", p);
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
p as Checkbox,
|
|
84
|
+
p as default
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../packages/checkbox/index.vue","../../packages/checkbox/index.js"],"sourcesContent":["<template>\r\n <van-field v-bind=\"$attrs\">\r\n <template #input>\r\n <van-checkbox-group v-model=\"internalValue\" direction=\"horizontal\">\r\n <van-checkbox v-for=\"item in parsedOptions\" :key=\"String(item.value)\" :name=\"String(item.value)\" shape=\"square\">\r\n {{ item.text }}\r\n </van-checkbox>\r\n </van-checkbox-group>\r\n </template>\r\n </van-field>\r\n</template>\r\n\r\n<script setup>\r\n import { computed } from 'vue'\r\n\r\n defineOptions({\r\n name: 'VtkCheckbox'\r\n })\r\n\r\n const props = defineProps({\r\n // 绑定值\r\n modelValue: {\r\n type: [String, Array, Object],\r\n default: () => [],\r\n },\r\n // 选项数据:支持数组 [{value, text}] 或 字符串 '1:选项1/2:选项2'\r\n options: {\r\n type: [Array, String],\r\n default: () => [],\r\n },\r\n // 返回值类型: 'string' (逗号分隔), 'array' (值数组), 'object' (对象数组)\r\n valueType: {\r\n type: String,\r\n default: 'array',\r\n validator: (val) => ['string', 'array', 'object'].includes(val),\r\n },\r\n // 当 valueType 为 string 时的分隔符\r\n separator: {\r\n type: String,\r\n default: ',',\r\n },\r\n })\r\n\r\n const emit = defineEmits(['update:modelValue', 'change'])\r\n\r\n // 解析选项\r\n const parsedOptions = computed(() => {\r\n if (Array.isArray(props.options)) {\r\n return props.options\r\n }\r\n if (typeof props.options === 'string' && props.options) {\r\n return props.options\r\n .split('/')\r\n .filter(Boolean)\r\n .map((item) => {\r\n const [value, text] = item.split(':')\r\n return {\r\n text: text || value,\r\n value: value,\r\n }\r\n })\r\n }\r\n return []\r\n })\r\n\r\n // 使用可写计算属性处理 v-model 绑定\r\n const internalValue = computed({\r\n get: () => {\r\n const val = props.modelValue\r\n if (!val) return []\r\n\r\n let arr = []\r\n if (props.valueType === 'string') {\r\n arr = typeof val === 'string' ? val.split(props.separator).filter(Boolean) : []\r\n } else if (props.valueType === 'object') {\r\n arr = Array.isArray(val) ? val.map((item) => item?.value ?? item) : []\r\n } else {\r\n arr = Array.isArray(val) ? val : []\r\n }\r\n // 统一转为字符串,确保与 van-checkbox 的 name 匹配\r\n return arr.map(String)\r\n },\r\n set: (newValues) => {\r\n let emitValue\r\n if (props.valueType === 'string') {\r\n emitValue = newValues.join(props.separator)\r\n } else if (props.valueType === 'object') {\r\n // 从解析后的选项中过滤出完整的对象\r\n emitValue = parsedOptions.value.filter((opt) => newValues.includes(String(opt.value)))\r\n } else {\r\n // 如果原始数据是数字,则尝试转回数字,否则保持字符串\r\n emitValue = newValues.map((val) => {\r\n return isNaN(Number(val)) ? val : Array.isArray(props.modelValue) && typeof props.modelValue[0] === 'number' ? Number(val) : val\r\n })\r\n }\r\n\r\n emit('update:modelValue', emitValue)\r\n emit('change', emitValue)\r\n },\r\n })\r\n</script>\r\n\r\n<style scoped>\r\n :deep(.van-checkbox) {\r\n margin-bottom: 8px;\r\n margin-right: 12px;\r\n }\r\n</style>\r\n","/**\r\n * Checkbox 组件单独导出入口\r\n * 支持按需引入\r\n */\r\nimport Checkbox from './index.vue'\r\n\r\n// 为组件添加 install 方法,支持 app.use() 方式注册\r\nCheckbox.install = (app) => {\r\n app.component(Checkbox.name || 'VtkCheckbox', Checkbox)\r\n}\r\n\r\nexport default Checkbox\r\nexport { Checkbox }\r\n"],"names":["props","__props","emit","__emit","parsedOptions","computed","item","value","text","internalValue","val","arr","newValues","emitValue","opt","_openBlock","_createBlock","_component_van_field","$attrs","_createVNode","_component_van_checkbox_group","$event","_createElementBlock","_Fragment","_renderList","_component_van_checkbox","_createTextVNode","_toDisplayString","Checkbox","app"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBE,UAAMA,IAAQC,GAwBRC,IAAOC,GAGPC,IAAgBC,EAAS,MACzB,MAAM,QAAQL,EAAM,OAAO,IACtBA,EAAM,UAEX,OAAOA,EAAM,WAAY,YAAYA,EAAM,UACtCA,EAAM,QACV,MAAM,GAAG,EACT,OAAO,OAAO,EACd,IAAI,CAACM,MAAS;AACb,YAAM,CAACC,GAAOC,CAAI,IAAIF,EAAK,MAAM,GAAG;AACpC,aAAO;AAAA,QACL,MAAME,KAAQD;AAAA,QACd,OAAOA;AAAA,MACnB;AAAA,IACQ,CAAC,IAEE,CAAA,CACR,GAGKE,IAAgBJ,EAAS;AAAA,MAC7B,KAAK,MAAM;AACT,cAAMK,IAAMV,EAAM;AAClB,YAAI,CAACU,EAAK,QAAO,CAAA;AAEjB,YAAIC,IAAM,CAAA;AACV,eAAIX,EAAM,cAAc,WACtBW,IAAM,OAAOD,KAAQ,WAAWA,EAAI,MAAMV,EAAM,SAAS,EAAE,OAAO,OAAO,IAAI,CAAA,IACpEA,EAAM,cAAc,WAC7BW,IAAM,MAAM,QAAQD,CAAG,IAAIA,EAAI,IAAI,CAACJ,OAASA,KAAA,gBAAAA,EAAM,UAASA,CAAI,IAAI,CAAA,IAEpEK,IAAM,MAAM,QAAQD,CAAG,IAAIA,IAAM,CAAA,GAG5BC,EAAI,IAAI,MAAM;AAAA,MACvB;AAAA,MACA,KAAK,CAACC,MAAc;AAClB,YAAIC;AACJ,QAAIb,EAAM,cAAc,WACtBa,IAAYD,EAAU,KAAKZ,EAAM,SAAS,IACjCA,EAAM,cAAc,WAE7Ba,IAAYT,EAAc,MAAM,OAAO,CAACU,MAAQF,EAAU,SAAS,OAAOE,EAAI,KAAK,CAAC,CAAC,IAGrFD,IAAYD,EAAU,IAAI,CAACF,MAClB,MAAM,OAAOA,CAAG,CAAC,IAAIA,IAAM,MAAM,QAAQV,EAAM,UAAU,KAAK,OAAOA,EAAM,WAAW,CAAC,KAAM,WAAW,OAAOU,CAAG,IAAIA,CAC9H,GAGHR,EAAK,qBAAqBW,CAAS,GACnCX,EAAK,UAAUW,CAAS;AAAA,MAC1B;AAAA,IACJ,CAAG;;;AAlGD,aAAAE,EAAA,GAAAC,EAQYC,OAROC,EAAAA,MAAM,CAAA,GAAA;AAAA,QACZ,SACT,MAIqB;AAAA,UAJrBC,EAIqBC,GAAA;AAAA,wBAJQX,EAAA;AAAA,0DAAAA,EAAa,QAAAY;AAAA,YAAE,WAAU;AAAA;uBACtC,MAA6B;AAAA,sBAA3CC,EAEeC,GAAA,MAAAC,EAFcpB,EAAA,OAAa,CAArBE,YAArBU,EAEeS,GAAA;AAAA,gBAF8B,KAAK,OAAOnB,EAAK,KAAK;AAAA,gBAAI,MAAM,OAAOA,EAAK,KAAK;AAAA,gBAAG,OAAM;AAAA;2BACrG,MAAe;AAAA,kBAAZoB,EAAAC,EAAArB,EAAK,IAAI,GAAA,CAAA;AAAA;;;;;;;;;;;;ACEtBsB,EAAS,UAAU,CAACC,MAAQ;AAC1B,EAAAA,EAAI,UAAUD,EAAS,QAAQ,eAAeA,CAAQ;AACxD;"}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Checkbox as a } from "./checkbox.js";
|
|
2
|
+
import { Area as e } from "./Area.js";
|
|
3
|
+
import { Radio as i } from "./Radio.js";
|
|
4
|
+
import { Uploader as s } from "./Uploader.js";
|
|
5
|
+
import { Preview as m } from "./preview.js";
|
|
6
|
+
const t = [
|
|
7
|
+
a,
|
|
8
|
+
e,
|
|
9
|
+
i,
|
|
10
|
+
s,
|
|
11
|
+
m
|
|
12
|
+
], f = (o) => {
|
|
13
|
+
t.forEach((r) => {
|
|
14
|
+
r.install ? o.use(r) : r.name && o.component(r.name, r);
|
|
15
|
+
});
|
|
16
|
+
}, x = {
|
|
17
|
+
install: f,
|
|
18
|
+
// 也导出所有组件,方便直接访问
|
|
19
|
+
Checkbox: a,
|
|
20
|
+
Area: e,
|
|
21
|
+
Radio: i,
|
|
22
|
+
Uploader: s,
|
|
23
|
+
Preview: m
|
|
24
|
+
}, A = "1.0.0";
|
|
25
|
+
export {
|
|
26
|
+
e as Area,
|
|
27
|
+
a as Checkbox,
|
|
28
|
+
m as Preview,
|
|
29
|
+
i as Radio,
|
|
30
|
+
s as Uploader,
|
|
31
|
+
x as default,
|
|
32
|
+
f as install,
|
|
33
|
+
A as version
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|