详细地址组件
· 阅读需 1 分钟
配置说明
- fieldName: 字段必须是字符串,会塞入 json 格式的内容;
- 必须搭配国家/地区(customerCountry)使用;
form-data.ts/data.ts 配置如下:
{
fieldName: 'detailByAddressFormat',
label: $t('web.crmCustomer.create.form.detailByAddressFormat', {
defaultValue: '地址格式的地址',
}),
component: 'DetailByAddressFormat',
componentProps: {
countryCode: undefined,
},
dependencies: {
triggerFields: ['customerCountry'],
show: (values: any) => !!(values.customerCountry ?? '').trim(),
componentProps: (values: any) => ({
countryCode: (values.customerCountry ?? '').trim() || undefined,
}),
rules: () => z.string().optional(),
},
defaultValue: undefined,
rules: z.string().optional(),
formItemClass: 'col-span-2',
},
组件说明
- 组件代码路径:yunfun-ui-admin-vben/apps/web-antd/src/views/crm/customer/components/DetailByAddressFormat.vue
相关解析函数
function parseDetailByAddressFormatValue(raw: unknown): null | {
components?: {
adminDiv?: string;
city?: string;
postalCode?: string;
};
fullText?: string;
} {
if (typeof raw !== 'string' || !raw.trim()) return null;
try {
const parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== 'object') return null;
return parsed as {
components?: { adminDiv?: string; city?: string; postalCode?: string };
fullText?: string;
};
} catch {
return null;
}
}
function mergeDetailedAddressMl(
fullText: string | undefined,
currentMl: Record<string, string>,
) {
const next = { ...(currentMl || {}) } as Record<string, string>;
const zh = (fullText ?? '').trim();
if (zh) {
next['zh-CN'] = zh;
}
return next;
}
