
v2.0.53版本
代码是这个
// 获取当前记录中的客户数据
const record = await ctx.getVar(‘ctx.record’);
// 客户是 m2m 关系,取第一个客户
const customers = record?.f_yu1py0gv9vw || ;
const customer = Array.isArray(customers) ? customers[0] : customers;
// 客户信息字段
const customerId = customer?.id;
const platform = customer?.f_33rfjb8shuf || ‘-’;
const nickname = customer?.f_ef9tikiuaen || ‘-’;
const account = customer?.f_z51lriq8onv || ‘-’;
const { Button, Card } = ctx.libs.antd;
const handleClick = async () => {
if (!customerId) {
ctx.message?.warning?.(ctx.t(‘未找到客户数据’));
return;
}
await ctx.openView(‘lr9ybqqdm73’, {
mode: ‘drawer’,
size: ‘medium’,
title: ctx.t(‘客户信息’),
filterByTk: customerId,
});
};
ctx.render(
<Card
size=“small”
style={{ marginBottom: 0, border: ‘1px solid #e8e8e8’, borderRadius: 6 }}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div style={{ flex: 1, lineHeight: 1.8 }}>
<div><strong>{ctx.t('ID')}:</strong> {customerId}</div>
<div><strong>{ctx.t('平台')}:</strong> {platform}</div>
<div><strong>{ctx.t('昵称')}:</strong> {nickname}</div>
<div><strong>{ctx.t('账号')}:</strong> {account}</div>
</div>
<Button type="primary" onClick={handleClick} style={{ marginLeft: 16, flexShrink: 0 }}>
{ctx.t('查看')}
</Button>
</div>
);