标签增加key

This commit is contained in:
wkj 2024-01-20 11:34:36 +08:00
parent 9068dfc33a
commit 6921b2f896
6 changed files with 138 additions and 74 deletions

View File

@ -11,33 +11,57 @@ export default function Render(props) {
const [openStation, setStation] = useState(false);
const [subwayId, setSubwayId] = useState('');
const [stationId, setStationId] = useState('');
return (<>
<div>
点击切换城市
<Select placeholder={'切换城市'} value={areaId} onChange={(value) => {
setAreaId(value);
setFilterByAreaId(value);
}} style={{ width: '20%' }} options={areaOptions} allowClear></Select>
return (
<>
<div style={{ marginBottom: 16 }}>
城市
<Select
placeholder={'选择城市'}
value={areaId}
onChange={(value) => {
setAreaId(value);
setFilterByAreaId(value);
}}
style={{ width: '20%' }}
options={areaOptions}
allowClear
></Select>
</div>
<Tree className={Style.tree} blockNode={true} treeData={treeData} titleRender={(nodeData) => {
return (<Row align="middle" style={{ flex: 1 }}>
<Tree
className={Style.tree}
blockNode={true}
treeData={treeData}
titleRender={(nodeData) => {
return (
<Row align="middle" style={{ flex: 1 }}>
<Col flex="auto">{nodeData.title}</Col>
<Col flex="none">
<Space>
{!nodeData.isLeaf ? (<Button onClick={() => {
setSubwayId(nodeData.key);
setSubway(true);
}}>
{!nodeData.isLeaf ? (
<Button
onClick={() => {
setSubwayId(nodeData.key);
setSubway(true);
}}
>
编辑
</Button>) : (<Button onClick={() => {
const index = nodeData.key.indexOf('/') + 1;
const temp = nodeData.key.substr(index);
setStationId(temp);
setStation(true);
}}>
</Button>
) : (
<Button
onClick={() => {
const index =
nodeData.key.indexOf('/') +
1;
const temp =
nodeData.key.substr(index);
setStationId(temp);
setStation(true);
}}
>
编辑
</Button>)}
</Button>
)}
{/* {!nodeData.isLeaf && (
<Button
@ -64,10 +88,30 @@ export default function Render(props) {
)} */}
</Space>
</Col>
</Row>);
}}/>
{openSubway && (<UpsertSubway onClose={() => setSubway(false)} openSubway={openSubway} oakId={subwayId} oakPath={`${oakFullpath}.${subwayId}`} oakAutoUnmount={true}/>)}
</Row>
);
}}
/>
{openSubway && (
<UpsertSubway
onClose={() => setSubway(false)}
openSubway={openSubway}
oakId={subwayId}
oakPath={`${oakFullpath}.${subwayId}`}
oakAutoUnmount={true}
/>
)}
{openStation && (<UpsertStation onClose={() => setStation(false)} openStation={openStation} oakId={stationId} subwayId={subwayId} oakPath={`$subwayLine/upsertStation,${stationId}`} oakAutoUnmount={true}/>)}
</>);
{openStation && (
<UpsertStation
onClose={() => setStation(false)}
openStation={openStation}
oakId={stationId}
subwayId={subwayId}
oakPath={`$subwayLine/upsertStation,${stationId}`}
oakAutoUnmount={true}
/>
)}
</>
);
}

View File

@ -3,11 +3,22 @@ import { Checkbox } from 'antd-mobile';
export default function Render(props) {
const { entity, relations2 } = props.data;
const { t, onRelationChange } = props.methods;
return (<>
{relations2?.map(({ relation, isChecked }) => (<Checkbox style={{ marginRight: 20 }} checked={isChecked} onChange={(checked) => {
onRelationChange(relation, checked);
}}>
{relation.name ? t(`${entity}:r.${relation.name}`) : relation.display}
</Checkbox>))}
</>);
return (
<>
{relations2?.map(({ relation, isChecked }) => (
<Checkbox
key={`userRelation_${relation}`}
style={{ marginRight: 20 }}
checked={isChecked}
onChange={(checked) => {
onRelationChange(relation, checked);
}}
>
{relation.name
? t(`${entity}:r.${relation.name}`)
: relation.display}
</Checkbox>
))}
</>
);
}

View File

@ -3,12 +3,23 @@ import { Checkbox } from 'antd';
export default function Render(props) {
const { entity, relations2 } = props.data;
const { t, onRelationChange } = props.methods;
return (<>
{relations2?.map(({ relation, isChecked }) => (<Checkbox checked={isChecked} value={relation} onChange={({ target }) => {
const { checked } = target;
onRelationChange(relation, checked);
}}>
{relation.name ? t(`${entity}:r.${relation.name}`) : relation.display}
</Checkbox>))}
</>);
return (
<>
{relations2?.map(({ relation, isChecked }) => (
<Checkbox
key={`userRelation_${relation}`}
checked={isChecked}
value={relation}
onChange={({ target }) => {
const { checked } = target;
onRelationChange(relation, checked);
}}
>
{relation.name
? t(`${entity}:r.${relation.name}`)
: relation.display}
</Checkbox>
))}
</>
);
}

View File

@ -37,10 +37,10 @@ export default function Render(
return (
<>
<div>
<div style={{ marginBottom: 16 }}>
<Select
placeholder={'切换城市'}
placeholder={'选择城市'}
value={areaId}
onChange={(value) => {
setAreaId(value);

View File

@ -16,22 +16,21 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
const { t, onRelationChange } = props.methods;
return (
<>
{
relations2?.map(
({ relation, isChecked }) => (
<Checkbox
checked={isChecked}
value={relation}
onChange={({ target }) => {
const { checked } = target;
onRelationChange(relation, checked);
}}
>
{relation.name ? t(`${entity}:r.${relation.name}`) : relation.display}
</Checkbox>
)
)
}
{relations2?.map(({ relation, isChecked }) => (
<Checkbox
key={`userRelation_${relation}`}
checked={isChecked}
value={relation}
onChange={({ target }) => {
const { checked } = target;
onRelationChange(relation, checked);
}}
>
{relation.name
? t(`${entity}:r.${relation.name}`)
: relation.display}
</Checkbox>
))}
</>
);
}

View File

@ -16,21 +16,20 @@ export default function Render(props: WebComponentProps<EntityDict, 'user', fals
const { t, onRelationChange } = props.methods;
return (
<>
{
relations2?.map(
({ relation, isChecked }) => (
<Checkbox
style={{ marginRight: 20 }}
checked={isChecked}
onChange={(checked) => {
onRelationChange(relation, checked);
}}
>
{relation.name ? t(`${entity}:r.${relation.name}`) : relation.display}
</Checkbox>
)
)
}
{relations2?.map(({ relation, isChecked }) => (
<Checkbox
key={`userRelation_${relation}`}
style={{ marginRight: 20 }}
checked={isChecked}
onChange={(checked) => {
onRelationChange(relation, checked);
}}
>
{relation.name
? t(`${entity}:r.${relation.name}`)
: relation.display}
</Checkbox>
))}
</>
);
}