|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import React, { useMemo, useState } from 'react';
|
|
|
|
|
import { Select, Tree } from 'antd';
|
|
|
|
|
import styles from './BasicAttribute.less';
|
|
|
|
|
|
|
|
|
|
@ -13,33 +13,69 @@ const factoryOptions = [
|
|
|
|
|
{ label: '南京油库', value: 'nanjing' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const treeData = [
|
|
|
|
|
const rawTreeData = [
|
|
|
|
|
{
|
|
|
|
|
title: '上海油库',
|
|
|
|
|
key: 'shanghai',
|
|
|
|
|
tag: { label: '油库', type: 'depot' },
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '汽油罐区',
|
|
|
|
|
key: 'gasoline-area',
|
|
|
|
|
tag: { label: '罐区', type: 'area' },
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: '汽油调合罐组',
|
|
|
|
|
key: 'blend-group',
|
|
|
|
|
tag: { label: '罐组', type: 'group' },
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: 'T-101 汽油储罐',
|
|
|
|
|
key: 't101',
|
|
|
|
|
tag: { label: '储罐', type: 'tank' },
|
|
|
|
|
children: [
|
|
|
|
|
{ title: 'LT-101 液位变送器', key: 'lt101' },
|
|
|
|
|
{ title: 'TT-101 温度变送器', key: 'tt101' },
|
|
|
|
|
{ title: 'PT-101 压力变送器', key: 'pt101' },
|
|
|
|
|
{ title: 'P-101A 输送泵', key: 'p101a' },
|
|
|
|
|
{ title: 'P-101B 输送泵', key: 'p101b' },
|
|
|
|
|
{ title: 'SP-101 密度计', key: 'sp101' },
|
|
|
|
|
{
|
|
|
|
|
title: 'LT-101 液位变送器',
|
|
|
|
|
key: 'lt101',
|
|
|
|
|
tag: { label: '测点', type: 'sensor' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'TT-101 温度变送器',
|
|
|
|
|
key: 'tt101',
|
|
|
|
|
tag: { label: '测点', type: 'sensor' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'PT-101 压力变送器',
|
|
|
|
|
key: 'pt101',
|
|
|
|
|
tag: { label: '测点', type: 'sensor' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'P-101A 输送泵',
|
|
|
|
|
key: 'p101a',
|
|
|
|
|
tag: { label: '设备', type: 'device' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'P-101B 输送泵',
|
|
|
|
|
key: 'p101b',
|
|
|
|
|
tag: { label: '设备', type: 'device' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'SP-101 密度计',
|
|
|
|
|
key: 'sp101',
|
|
|
|
|
tag: { label: '测点', type: 'sensor' },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ title: 'T-102 汽油储罐', key: 't102' },
|
|
|
|
|
{ title: 'T-103 汽油储罐', key: 't103' },
|
|
|
|
|
{
|
|
|
|
|
title: 'T-102 汽油储罐',
|
|
|
|
|
key: 't102',
|
|
|
|
|
tag: { label: '储罐', type: 'tank' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'T-103 汽油储罐',
|
|
|
|
|
key: 't103',
|
|
|
|
|
tag: { label: '储罐', type: 'tank' },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
@ -47,15 +83,35 @@ const treeData = [
|
|
|
|
|
{
|
|
|
|
|
title: '柴油罐区',
|
|
|
|
|
key: 'diesel-area',
|
|
|
|
|
tag: { label: '罐区', type: 'area' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '化危品库',
|
|
|
|
|
key: 'hazard',
|
|
|
|
|
tag: { label: '库区', type: 'depot' },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const TreeNodeTitle = ({ text, tag }) => (
|
|
|
|
|
<span className={styles.treeNodeTitle}>
|
|
|
|
|
<span className={styles.nodeText}>{text}</span>
|
|
|
|
|
{tag ? (
|
|
|
|
|
<span className={`${styles.nodeTag} ${styles[`tag-${tag.type}`] || ''}`}>
|
|
|
|
|
{tag.label}
|
|
|
|
|
</span>
|
|
|
|
|
) : null}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const formatTreeNodes = data =>
|
|
|
|
|
data.map(item => ({
|
|
|
|
|
key: item.key,
|
|
|
|
|
title: <TreeNodeTitle text={item.title} tag={item.tag} />,
|
|
|
|
|
children: item.children ? formatTreeNodes(item.children) : undefined,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const infoCards = [
|
|
|
|
|
{
|
|
|
|
|
title: '基本信息',
|
|
|
|
|
@ -107,6 +163,10 @@ const infoCards = [
|
|
|
|
|
const BasicAttribute = () => {
|
|
|
|
|
const [buildingType, setBuildingType] = useState('plant');
|
|
|
|
|
const [factory, setFactory] = useState('all');
|
|
|
|
|
const [selectedKeys, setSelectedKeys] = useState(['t101']);
|
|
|
|
|
const [checkedKeys, setCheckedKeys] = useState(['t101']);
|
|
|
|
|
|
|
|
|
|
const treeData = useMemo(() => formatTreeNodes(rawTreeData), []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.container}>
|
|
|
|
|
@ -136,9 +196,17 @@ const BasicAttribute = () => {
|
|
|
|
|
<div className={styles.treeWrapper}>
|
|
|
|
|
<Tree
|
|
|
|
|
showIcon={false}
|
|
|
|
|
showLine={{ showLeafIcon: false }}
|
|
|
|
|
defaultExpandAll
|
|
|
|
|
checkable
|
|
|
|
|
selectable
|
|
|
|
|
treeData={treeData}
|
|
|
|
|
checkedKeys={checkedKeys}
|
|
|
|
|
selectedKeys={selectedKeys}
|
|
|
|
|
onCheck={keys => setCheckedKeys(keys.checked || keys)}
|
|
|
|
|
onSelect={keys => setSelectedKeys(keys)}
|
|
|
|
|
className={styles.tree}
|
|
|
|
|
virtual={false}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|