| | |
| | | () => extractRelationItems(info, ['routeList', 'routes', 'routeRefs']), |
| | | [info] |
| | | ); |
| | | const funcStaBool = detectBoolean( |
| | | info?.funcStaBool ?? info?.isFuncSta ?? info?.funcStation ?? info?.funcStaFlag |
| | | const funcStaRelations = useMemo( |
| | | () => extractRelationItems(info, ['funcStaList', 'funcStas']), |
| | | [info] |
| | | ); |
| | | const funcStaText = info?.funcSta$ || info?.funcStaName || info?.funcStaType || info?.funcStaCode || info?.funcStaUuid || info?.funcSta; |
| | | |
| | | const ruleList = useMemo(() => normalizeDirRule(info?.dirRule), [info?.dirRule]); |
| | | |
| | | const spatialItems = [ |
| | | { label: translate('table.field.code.x'), value: formatNumber(info?.x, 0), hideWhenEmpty: true }, |
| | | { label: translate('table.field.code.y'), value: formatNumber(info?.y, 0), hideWhenEmpty: true }, |
| | | { |
| | | label: translate('page.map.insight.code.fields.mapPosition', { _: '地图坐标' }), |
| | | render: () => ( |
| | |
| | | redirect('edit', 'code', info.id); |
| | | } |
| | | }; |
| | | |
| | | const funcStaLabel = funcStaBool == null |
| | | ? translate('common.enums.na') |
| | | : translate(funcStaBool ? 'common.enums.true' : 'common.enums.false'); |
| | | |
| | | return ( |
| | | <Box sx={{ pr: 1, pb: 3 }}> |
| | |
| | | disabled={!info?.id} |
| | | sx={{ alignSelf: 'flex-start', textTransform: 'none', px: 3 }} |
| | | > |
| | | {translate('page.map.insight.code.actions.openDetail', { _: '进入 Code 页面' })} |
| | | {translate('page.map.insight.code.actions.openDetail', { _: '编辑' })} |
| | | </Button> |
| | | </Stack> |
| | | </Paper> |
| | |
| | | /> |
| | | </InfoPanel> |
| | | <InfoPanel title={translate('page.map.insight.code.relations.routes', { _: '关联路线' })}> |
| | | <RelationsChips |
| | | <RelationsList |
| | | items={routeRelations} |
| | | emptyLabel={translate('page.map.insight.code.relations.empty', { _: '暂无关联信息' })} |
| | | /> |
| | | </InfoPanel> |
| | | <InfoPanel title={translate('menu.funcSta', { _: '功能站' })}> |
| | | <Stack spacing={1}> |
| | | <BooleanDisplay |
| | | value={funcStaBool} |
| | | label={funcStaLabel} |
| | | /> |
| | | {funcStaText && funcStaText !== funcStaLabel && ( |
| | | <Typography variant="body2" color="text.secondary"> |
| | | {funcStaText} |
| | | </Typography> |
| | | )} |
| | | </Stack> |
| | | <RelationsChips |
| | | items={funcStaRelations} |
| | | emptyLabel={translate('page.map.insight.code.relations.empty', { _: '暂无关联信息' })} |
| | | /> |
| | | </InfoPanel> |
| | | </Stack> |
| | | </Paper> |
| | |
| | | label={`+${items.length - MAX_RELATION_ITEMS}`} |
| | | size="small" |
| | | /> |
| | | )} |
| | | </Stack> |
| | | ); |
| | | }; |
| | | |
| | | const RelationsList = ({ items, emptyLabel }) => { |
| | | if (!items?.length) { |
| | | return ( |
| | | <Typography variant="body2" color="text.disabled"> |
| | | {emptyLabel} |
| | | </Typography> |
| | | ); |
| | | } |
| | | |
| | | return ( |
| | | <Stack spacing={1}> |
| | | {items.slice(0, MAX_RELATION_ITEMS).map((item, index) => ( |
| | | <Box |
| | | key={`${getRelationKey(item)}-${index}`} |
| | | sx={{ |
| | | px: 1.25, |
| | | py: 0.75, |
| | | borderRadius: 999, |
| | | border: '1px solid', |
| | | borderColor: 'divider', |
| | | backgroundColor: 'background.default', |
| | | }} |
| | | > |
| | | <Typography variant="body2" sx={{ lineHeight: 1.2 }}> |
| | | {getRelationLabel(item)} |
| | | </Typography> |
| | | </Box> |
| | | ))} |
| | | {items.length > MAX_RELATION_ITEMS && ( |
| | | <Typography variant="caption" color="text.secondary"> |
| | | +{items.length - MAX_RELATION_ITEMS} |
| | | </Typography> |
| | | )} |
| | | </Stack> |
| | | ); |
| | |
| | | return item; |
| | | } |
| | | if (typeof item === 'object') { |
| | | if (item.startCode$ && item.endCode$) { |
| | | return `${item.startCode$} -> ${item.endCode$}`; |
| | | } |
| | | if (item.name || item.type || item.state) { |
| | | return [item.name, item.type, item.state].filter(Boolean).join(' / '); |
| | | } |
| | | return item.name || item.code || item.data || item.no || item.uuid || item.locNo || item.staNo || JSON.stringify(item); |
| | | } |
| | | return String(item); |