Merge branch 'auth' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into auth

This commit is contained in:
Xu Chang 2023-08-18 12:32:34 +08:00
commit 14d700224f
3 changed files with 21 additions and 23 deletions

View File

@ -68,8 +68,8 @@ export default OakComponent({
const transformer = makeDataTransformer(
schema,
entity!,
attributes!
// (k, params) => this.t(k, params)
attributes!,
this.t,
);
this.setState({
transformer,

View File

@ -73,24 +73,22 @@ export default function Render(
} = oakData;
return (
<Card>
<Descriptions title={title} column={column} bordered={bordered} layout={layout}>
{renderData?.map((ele) => {
let renderValue = ele.value || t('not_filled_in');
const color = colorDict && colorDict[entity]?.[ele.attr]?.[ele.value] as string || 'default';
if (ele.type === 'enum') {
renderValue = ele.value && t(`${entity}:v.${ele.attr}.${ele.value}`)
}
if (ele.type === 'datetime') {
renderValue = ele.value && dayjs(ele.value).format('YYYY-MM-DD');
}
return (
<Descriptions.Item label={t(ele.label)} span={ele.span || 1}>
<RenderRow type={ele.type} value={renderValue} color={color} />
</Descriptions.Item>
)
})}
</Descriptions>
</Card>
<Descriptions title={title} column={column} bordered={bordered} layout={layout}>
{renderData?.map((ele) => {
let renderValue = ele.value || t('not_filled_in');
const color = colorDict && colorDict[entity]?.[ele.attr]?.[ele.value] as string || 'default';
if (ele.type === 'enum') {
renderValue = ele.value && t(`${entity}:v.${ele.attr}.${ele.value}`)
}
if (ele.type === 'datetime') {
renderValue = ele.value && dayjs(ele.value).format('YYYY-MM-DD');
}
return (
<Descriptions.Item label={ele.label} span={ele.span || 1}>
<RenderRow type={ele.type} value={renderValue} color={color} />
</Descriptions.Item>
)
})}
</Descriptions>
);
}

View File

@ -242,7 +242,7 @@ export function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(
dataSchema: StorageSchema<ED>,
entity: keyof ED,
attrDefs: OakAbsAttrDef[],
// t: (k: string, params?: object) => string,
t: (k: string, params?: object) => string,
colorDict?: ColorDict<ED>
): DataTransformer {
const transformerFixedPart = attrDefs.map((ele) => {
@ -253,7 +253,7 @@ export function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(
attr,
entity: entityI8n,
} = resolvePath(dataSchema, entity, path);
const label = `${entityI8n as string}:attr.${attr}`;
const label = getLabel(ele, entityI8n, attr, t);
const type = attrType;
return {
path,