Files
frontend/apps/web-antd/src/components/form-create/rules/use-area-select-rule.ts
puhui999 d0a7065991 feat(form-create): 【ele/antd】新增 iframe 和省市区选择器组件
- 新增 iframe 网页嵌入组件,支持 URL 配置和实时预览
- 新增省市区三级联动选择器组件
- 支持 web-ele 和 web-antd 双版本
2026-02-08 11:56:02 +08:00

78 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cloneDeep } from '@vben/utils';
import {
localeProps,
makeRequiredRule,
} from '#/components/form-create/helpers';
/** 省市区选择器规则 */
export function useAreaSelectRule() {
const label = '省市区选择器';
const name = 'AreaSelect';
return {
icon: 'icon-location',
label,
name,
rule() {
return {
type: name,
field: `area_${Date.now()}`,
title: label,
info: '',
$required: false,
modelField: 'value', // 特殊ele 里是 model-valueantd 里是 value
};
},
props(_: any, { t }: any) {
return localeProps(t, `${name}.props`, [
makeRequiredRule(),
{
type: 'select',
field: 'level',
title: '选择层级',
value: 3,
options: [
{ label: '省', value: 1 },
{ label: '省/市', value: 2 },
{ label: '省/市/区', value: 3 },
],
info: '限制可选择的地区层级',
},
{
type: 'input',
field: 'placeholder',
title: '占位符',
value: '请选择省市区',
},
{
type: 'switch',
field: 'clearable',
title: '是否可清空',
value: true,
},
{
type: 'switch',
field: 'showAllLevels',
title: '显示完整路径',
value: true,
info: '输入框中是否显示选中值的完整路径',
},
{
type: 'input',
field: 'separator',
title: '分隔符',
value: '/',
info: '选项分隔符',
},
{
type: 'switch',
field: 'disabled',
title: '是否禁用',
value: false,
},
]);
},
};
}