@fast-form-designer/vue 0.1.1 → 0.1.2
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 +62 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4001 -3985
- package/dist/index.umd.cjs +2 -2
- package/dist/pca-BXk_jle3.js +4 -0
- package/dist/style.css +1 -1
- package/dist/utils/pca.d.ts +20 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -239,6 +239,68 @@ interface DesignerActionContext {
|
|
|
239
239
|
| `validate` | `() => Promise<boolean>` | 触发表单校验 |
|
|
240
240
|
| `resetFields` | `() => void` | 重置表单字段 |
|
|
241
241
|
|
|
242
|
+
### 省市区数据工具函数
|
|
243
|
+
|
|
244
|
+
省市区(PCA)数据采用动态导入,仅在使用省市区组件时按需加载,减少主包体积。
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { loadPcaData, setPcaData, getPcaOptions, type PcaNode } from '@fast-form-designer/vue'
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### loadPcaData
|
|
251
|
+
|
|
252
|
+
动态加载内置省市区数据,返回原始数据结构。
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
const loadPcaData: () => Promise<PcaNode[]>
|
|
256
|
+
|
|
257
|
+
// 示例
|
|
258
|
+
const pcaData = await loadPcaData()
|
|
259
|
+
console.log(pcaData) // [{ code: '11', name: '北京市', children: [...] }, ...]
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### setPcaData
|
|
263
|
+
|
|
264
|
+
注入自定义省市区数据,用于替换内置数据或在 SSR 场景下预加载。
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
const setPcaData: (data: PcaNode[]) => void
|
|
268
|
+
|
|
269
|
+
// 示例:使用自定义数据
|
|
270
|
+
const customData: PcaNode[] = [
|
|
271
|
+
{ code: '11', name: '北京市', children: [{ code: '1101', name: '市辖区', children: [...] }] }
|
|
272
|
+
]
|
|
273
|
+
setPcaData(customData)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### getPcaOptions
|
|
277
|
+
|
|
278
|
+
获取指定深度的省市区选项数据,返回格式化后的 `OptionItem[]`。
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const getPcaOptions: (depth: 1 | 2 | 3) => Promise<OptionItem[]>
|
|
282
|
+
|
|
283
|
+
// depth 参数说明:
|
|
284
|
+
// 1 = 仅省份
|
|
285
|
+
// 2 = 省份 + 城市
|
|
286
|
+
// 3 = 省份 + 城市 + 区县
|
|
287
|
+
|
|
288
|
+
// 示例
|
|
289
|
+
const provinceOptions = await getPcaOptions(1) // 省份列表
|
|
290
|
+
const cityOptions = await getPcaOptions(2) // 省市两级
|
|
291
|
+
const districtOptions = await getPcaOptions(3) // 省市区三级
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### PcaNode 类型
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
interface PcaNode {
|
|
298
|
+
code: string // 行政区划代码
|
|
299
|
+
name: string // 名称
|
|
300
|
+
children?: PcaNode[] // 下级区划
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
242
304
|
## 类型定义
|
|
243
305
|
|
|
244
306
|
### FormSchema
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ import FastFormDesigner from './FastFormDesigner.vue';
|
|
|
3
3
|
import FormRenderer from './components/FormRenderer.vue';
|
|
4
4
|
export { FastFormDesigner, FormRenderer };
|
|
5
5
|
export * from './types';
|
|
6
|
+
export { loadPcaData, setPcaData, getPcaOptions, type PcaNode } from './utils/pca';
|
|
6
7
|
export default FastFormDesigner;
|