Commit ce920890 authored by 周宏民's avatar 周宏民

feat: 添加泰来工作台组件

parent d73ede3b
Pipeline #88621 passed with stages
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
...@@ -231,5 +231,31 @@ ...@@ -231,5 +231,31 @@
background: url('@{imgSrc}/系统使用排名.png'); background: url('@{imgSrc}/系统使用排名.png');
background-size: 100% 100%; background-size: 100% 100%;
} }
&[widget='WATER_MONITORING_TAILAI'] {
height: 240px;
background: url('@{imgSrc}/泰来运营总览.png');
background-size: 100% 100%;
}
&[widget='MANAGE_OVERVIEW_TAILAI'] {
height: 50px;
background: url('@{imgSrc}/泰来水厂总览.png');
background-size: 100% 100%;
}
&[widget='PIPE_MONITORING_TAILAI'] {
height: 200px;
background: url('@{imgSrc}/泰来管网运营.png');
background-size: 100% 100%;
}
&[widget='DMA_OVERVIEW_TAILAI'] {
height: 120px;
background: url('@{imgSrc}/泰来DMA总览.png');
background-size: 100% 100%;
}
&[widget='REVENUE_OVERVIEW_TAILAI'] {
height: 120px;
background: url('@{imgSrc}/泰来营收总览.png');
background-size: 100% 100%;
}
} }
} }
\ No newline at end of file
import React, { useState, useRef, useContext, useMemo, useEffect } from 'react' import React, { useState, useRef, useContext, useMemo, useEffect } from 'react';
import { Checkbox, Row, Col, Button, message, Input } from 'antd' import { Checkbox, Row, Col, Button, message, Input } from 'antd';
import { useDrag, useDrop, DndProvider } from 'react-dnd' import { useDrag, useDrop, DndProvider } from 'react-dnd';
import { CaretRightOutlined } from '@ant-design/icons' import { CaretRightOutlined } from '@ant-design/icons';
import styles from './index.less' import styles from './index.less';
import { GlobalStore } from '../index' import { GlobalStore } from '../index';
import { getCardVersion, upgradeCardVersion } from '@/services/mobileConfig/api' import { getCardVersion, upgradeCardVersion } from '@/services/mobileConfig/api';
const { Search } = Input const { Search } = Input;
const cardTypes = ['管理', '执行', '运营'] const cardTypes = ['管理', '执行', '运营'];
const tabs = ['产品组件', '项目组件'] const tabs = ['产品组件', '项目组件'];
const cards = [ const cards = [
[ [
...@@ -19,7 +19,7 @@ const cards = [ ...@@ -19,7 +19,7 @@ const cards = [
children: [ children: [
{ name: '运营总览', widget: 'OVERVIEW', type: '运营' }, { name: '运营总览', widget: 'OVERVIEW', type: '运营' },
{ name: '经营概览', widget: 'MANAGE_OVERVIEW', type: '运营' }, { name: '经营概览', widget: 'MANAGE_OVERVIEW', type: '运营' },
] ],
}, },
{ {
title: '水厂', title: '水厂',
...@@ -28,7 +28,7 @@ const cards = [ ...@@ -28,7 +28,7 @@ const cards = [
{ name: '水厂总览', widget: 'WATER_OVERVIEW', type: '运营' }, { name: '水厂总览', widget: 'WATER_OVERVIEW', type: '运营' },
{ name: '供水量曲线', widget: 'WATER_CHART', type: '运营' }, { name: '供水量曲线', widget: 'WATER_CHART', type: '运营' },
{ name: '水厂监控', widget: 'WATER_MONITORING', type: '运营' }, { name: '水厂监控', widget: 'WATER_MONITORING', type: '运营' },
] ],
}, },
{ {
title: '管网', title: '管网',
...@@ -42,7 +42,7 @@ const cards = [ ...@@ -42,7 +42,7 @@ const cards = [
{ name: '维修工单', widget: 'MAINTENANCEORDER', type: '运营' }, { name: '维修工单', widget: 'MAINTENANCEORDER', type: '运营' },
{ name: '压力监控', widget: 'PRESSURE_MONITORING', type: '运营' }, { name: '压力监控', widget: 'PRESSURE_MONITORING', type: '运营' },
{ name: '采集工程', widget: 'PROJECT_OVERVIEW', type: '运营' }, { name: '采集工程', widget: 'PROJECT_OVERVIEW', type: '运营' },
] ],
}, },
{ {
title: '二供', title: '二供',
...@@ -51,14 +51,12 @@ const cards = [ ...@@ -51,14 +51,12 @@ const cards = [
{ name: '二供总览', widget: 'OPERATIONAL_OVERVIEW', type: '运营' }, { name: '二供总览', widget: 'OPERATIONAL_OVERVIEW', type: '运营' },
{ name: '泵房运行状态', widget: 'PUMP_STATUS', type: '运营' }, { name: '泵房运行状态', widget: 'PUMP_STATUS', type: '运营' },
{ name: '泵房维修保养', widget: 'PUMP_MAINTAIN', type: '运营' }, { name: '泵房维修保养', widget: 'PUMP_MAINTAIN', type: '运营' },
] ],
}, },
{ {
title: '营收', title: '营收',
count: 1, count: 1,
children: [ children: [{ name: '营收总览', widget: 'REVENUE_OVERVIEW', type: '运营' }],
{ name: '营收总览', widget: 'REVENUE_OVERVIEW', type: '运营' },
]
}, },
{ {
title: 'DMA', title: 'DMA',
...@@ -86,7 +84,7 @@ const cards = [ ...@@ -86,7 +84,7 @@ const cards = [
{ name: '巡检运维', widget: 'INSPECTIONMAINTENANCE', type: '运营' }, { name: '巡检运维', widget: 'INSPECTIONMAINTENANCE', type: '运营' },
{ name: '事件工单', widget: 'EVENTWORKORDER', type: '运营' }, { name: '事件工单', widget: 'EVENTWORKORDER', type: '运营' },
{ name: '子公司业务排行', widget: 'SUBSIDIARYBUSINESSRANKING', type: '运营' }, { name: '子公司业务排行', widget: 'SUBSIDIARYBUSINESSRANKING', type: '运营' },
] ],
}, },
{ {
title: '新乐智慧水务项目', title: '新乐智慧水务项目',
...@@ -95,14 +93,12 @@ const cards = [ ...@@ -95,14 +93,12 @@ const cards = [
{ name: '生产概览', widget: 'PRODUCT_OVERVIEW', type: '运营' }, { name: '生产概览', widget: 'PRODUCT_OVERVIEW', type: '运营' },
{ name: '三水厂送水泵房监控', widget: 'WATER_SUPPLY_MONITORING3', type: '运营' }, { name: '三水厂送水泵房监控', widget: 'WATER_SUPPLY_MONITORING3', type: '运营' },
{ name: '四水厂送水泵房监控', widget: 'WATER_SUPPLY_MONITORING4', type: '运营' }, { name: '四水厂送水泵房监控', widget: 'WATER_SUPPLY_MONITORING4', type: '运营' },
] ],
}, },
{ {
title: '广西农投天等县智慧水务项目', title: '广西农投天等县智慧水务项目',
count: 1, count: 1,
children: [ children: [{ name: '采集总览', widget: 'ACQUISITION_OVERVIEW', type: '运营' }],
{ name: '采集总览', widget: 'ACQUISITION_OVERVIEW', type: '运营' },
]
}, },
{ {
title: '瑞云智慧水务项目', title: '瑞云智慧水务项目',
...@@ -114,45 +110,55 @@ const cards = [ ...@@ -114,45 +110,55 @@ const cards = [
{ name: '工单运营', widget: 'RUIYUN_CASEOPERATION', type: '运营' }, { name: '工单运营', widget: 'RUIYUN_CASEOPERATION', type: '运营' },
{ name: '维修服务统计', widget: 'RUIYUN_MAINTAINSTATISTICS', type: '运营' }, { name: '维修服务统计', widget: 'RUIYUN_MAINTAINSTATISTICS', type: '运营' },
{ name: '人员业务排名', widget: 'RUIYUN_PERSONRANKING', type: '运营' }, { name: '人员业务排名', widget: 'RUIYUN_PERSONRANKING', type: '运营' },
] ],
}, },
] {
] title: '泰来县金泽自来水智慧水务建设项目',
count: 6,
children: [
{ name: '运营总览', widget: 'WATER_MONITORING_TAILAI', type: '运营' },
{ name: '水厂总览', widget: 'MANAGE_OVERVIEW_TAILAI', type: '运营' },
{ name: '管网运营', widget: 'PIPE_MONITORING_TAILAI', type: '运营' },
{ name: 'DMA总览', widget: 'DMA_OVERVIEW_TAILAI', type: '运营' },
{ name: '营收总览', widget: 'REVENUE_OVERVIEW_TAILAI', type: '运营' },
],
},
],
];
const getNanoid = (len = 10) => { const getNanoid = (len = 10) => {
var orgStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let orgStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let returnStr = ""; let returnStr = '';
for (var i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
returnStr += orgStr.charAt(Math.floor((Math.random() * orgStr.length))); returnStr += orgStr.charAt(Math.floor(Math.random() * orgStr.length));
} }
return `${returnStr}` return `${returnStr}`;
} };
const Group = (props) => {
const id = getNanoid() const Group = props => {
const ref = useRef(null) const id = getNanoid();
const ref = useRef(null);
const [{ dragging }, drag, dragPreview] = useDrag({ const [{ dragging }, drag, dragPreview] = useDrag({
type: 'box', type: 'box',
item: { item: {
id: id, id,
name: '通栏布局', name: '通栏布局',
widget: '通栏布局', widget: '通栏布局',
children: [] children: [],
}, },
collect(monitor) { collect(monitor) {
return { return {
dragging: monitor.isDragging() dragging: monitor.isDragging(),
} };
} },
}); });
drag(ref) drag(ref);
const boxClick = () => { const boxClick = () => {
props?.boxClick?.() props?.boxClick?.();
} };
return ( return (
<div <div
...@@ -160,20 +166,18 @@ const Group = (props) => { ...@@ -160,20 +166,18 @@ const Group = (props) => {
className={styles.group} className={styles.group}
style={{ border: dragging ? '2px solid #001bff' : '' }} style={{ border: dragging ? '2px solid #001bff' : '' }}
onClick={() => boxClick()} onClick={() => boxClick()}
> />
</div> );
) };
}
const Card = (props) => { const Card = props => {
const ref = useRef(null);
const ref = useRef(null) const id = getNanoid();
const id = getNanoid()
const [{ dragging }, drag] = useDrag({ const [{ dragging }, drag] = useDrag({
type: 'card', type: 'card',
item: { item: {
id: id, id,
name: props.name, name: props.name,
widget: props.widget, widget: props.widget,
iconShow: false, iconShow: false,
...@@ -181,33 +185,33 @@ const Card = (props) => { ...@@ -181,33 +185,33 @@ const Card = (props) => {
url: '', url: '',
param: '', param: '',
}, },
}) });
drag(ref) drag(ref);
return ( return (
<div <div ref={ref} className={styles.card}>
ref={ref} <div className={styles.cardType} type={props.type}>
className={styles.card} {`${props.type}组件`}
> </div>
<div className={styles.cardType} type={props.type}>{props.type + '组件'}</div>
<div className={styles.box}> <div className={styles.box}>
<div className={styles.cardBox} widget={props.widget}></div> <div className={styles.cardBox} widget={props.widget} />
</div> </div>
<div className={styles.swiper}>{props.name}</div> <div className={styles.swiper}>{props.name}</div>
</div> </div>
) );
} };
//卡片分组
const CardGroup = (props) => {
const [shrink, setShrink] = useState(false) // 卡片分组
const CardGroup = props => {
const [shrink, setShrink] = useState(false);
return ( return (
<div className={styles.cardGroup}> <div className={styles.cardGroup}>
<div className={styles['g-top']} onClick={() => setShrink(!shrink)}> <div className={styles['g-top']} onClick={() => setShrink(!shrink)}>
<CaretRightOutlined style={{ transition: '0.5s all', transform: !shrink ? 'rotate(90deg)' : '' }} /> <CaretRightOutlined
style={{ transition: '0.5s all', transform: !shrink ? 'rotate(90deg)' : '' }}
/>
<span>{props.title}</span> <span>{props.title}</span>
<span>{`(${props.count})`}</span> <span>{`(${props.count})`}</span>
</div> </div>
...@@ -215,52 +219,52 @@ const CardGroup = (props) => { ...@@ -215,52 +219,52 @@ const CardGroup = (props) => {
{props.children} {props.children}
</div> </div>
</div> </div>
) );
};
}
const Left = () => { const Left = () => {
const { shema, setShema } = useContext(GlobalStore);
const { shema, setShema } = useContext(GlobalStore) const [cardType, setCardType] = useState(cardTypes);
const [cardType, setCardType] = useState(cardTypes) const [version, setVersion] = useState({ Version: '', lastVersion: '' });
const [version, setVersion] = useState({ Version: '', lastVersion: '' }) const [activeIndex, setActiveIndex] = useState(0);
const [activeIndex, setActiveIndex] = useState(0) const [inputValue, setInputValue] = useState('');
const [inputValue, setInputValue] = useState('')
const cardsFilter = useMemo(() => { const cardsFilter = useMemo(() => {
let array = [] let array = [];
cards[activeIndex].forEach(v => { cards[activeIndex].forEach(v => {
let children = v.children.filter(s => cardType.includes(s.type) && (!inputValue || s.name.includes(inputValue))) let children = v.children.filter(
s => cardType.includes(s.type) && (!inputValue || s.name.includes(inputValue)),
);
if (children.length) { if (children.length) {
array.push({ ...v, children }) array.push({ ...v, children });
} }
}) });
return array return array;
}, [cards, cardType, activeIndex, inputValue]) }, [cards, cardType, activeIndex, inputValue]);
const cardTypeChange = (value) => { const cardTypeChange = value => {
setCardType(value) setCardType(value);
} };
const update = async () => { const update = async () => {
const { code, data, msg } = await upgradeCardVersion() const { code, data, msg } = await upgradeCardVersion();
if (code === 0) { if (code === 0) {
getData() getData();
} else { } else {
message.error(msg) message.error(msg);
} }
} };
const getData = async () => { const getData = async () => {
const { code, data } = await getCardVersion() const { code, data } = await getCardVersion();
if (code === 0) { if (code === 0) {
setVersion(data) setVersion(data);
} }
} };
useEffect(() => { useEffect(() => {
getData() getData();
}, []) }, []);
return ( return (
<div className={styles.left}> <div className={styles.left}>
...@@ -271,7 +275,7 @@ const Left = () => { ...@@ -271,7 +275,7 @@ const Left = () => {
</div> </div>
<div className={styles['r-right']}> <div className={styles['r-right']}>
<Button <Button
size='small' size="small"
onClick={() => update()} onClick={() => update()}
style={{ display: version.Version !== version.lastVersion ? 'block' : 'none' }} style={{ display: version.Version !== version.lastVersion ? 'block' : 'none' }}
> >
...@@ -283,68 +287,56 @@ const Left = () => { ...@@ -283,68 +287,56 @@ const Left = () => {
<div className={styles.item}> <div className={styles.item}>
<div className={styles['g-title']}>布局</div> <div className={styles['g-title']}>布局</div>
<div className={styles['g-content']}> <div className={styles['g-content']}>
<Group></Group> <Group />
</div> </div>
</div> </div>
<div className={styles.tabs}> <div className={styles.tabs}>
{tabs.map((v, i) => { {tabs.map((v, i) => (
return ( <div
<div className={styles.tab}
className={styles.tab} active={`${activeIndex === i}`}
active={`${activeIndex === i}`} onClick={() => setActiveIndex(i)}
onClick={() => setActiveIndex(i)} >
> {v}
{v} </div>
</div> ))}
)
})}
</div> </div>
<div className={styles.item}> <div className={styles.item}>
<div className={styles.search}> <div className={styles.search}>
<Search <Search
placeholder="请输入关键字搜索" placeholder="请输入关键字搜索"
value={inputValue} value={inputValue}
onChange={(e) => setInputValue(e.target.value)} onChange={e => setInputValue(e.target.value)}
style={{ width: 250 }} style={{ width: 250 }}
/> />
</div> </div>
<div className={styles['g-checks']}> <div className={styles['g-checks']}>
<Checkbox.Group <Checkbox.Group style={{ width: '100%' }} value={cardType} onChange={cardTypeChange}>
style={{ width: '100%' }}
value={cardType}
onChange={cardTypeChange}
>
<Row> <Row>
{ {cardTypes.map(v => (
cardTypes.map(v => { <Col
return ( key={v}
<Col key={v} style={{ display: 'flex', justifyContent: 'center', marginLeft: '10px' }}> style={{ display: 'flex', justifyContent: 'center', marginLeft: '10px' }}
<Checkbox value={v}>{v}</Checkbox> >
</Col> <Checkbox value={v}>{v}</Checkbox>
) </Col>
}) ))}
}
</Row> </Row>
</Checkbox.Group> </Checkbox.Group>
</div> </div>
<div className={styles['g-content']}> <div className={styles['g-content']}>
{ {cardsFilter.map(v => (
cardsFilter.map(v => { <CardGroup key={v.title} {...v}>
return ( {v.children.map(s => (
<CardGroup key={v.title} {...v}> <Card key={s.name} {...s} />
{ ))}
v.children.map(s => <Card key={s.name} {...s}></Card>) </CardGroup>
} ))}
</CardGroup>
)
})
}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
) );
};
}
export default Left export default Left;
\ No newline at end of file
...@@ -272,6 +272,31 @@ ...@@ -272,6 +272,31 @@
background: url('@{imgSrc}/系统使用排名.png'); background: url('@{imgSrc}/系统使用排名.png');
background-size: 100% 100%; background-size: 100% 100%;
} }
&[widget='WATER_MONITORING_TAILAI'] {
height: 140px;
background: url('@{imgSrc}/泰来运营总览.png');
background-size: 100% 100%;
}
&[widget='MANAGE_OVERVIEW_TAILAI'] {
height: 50px;
background: url('@{imgSrc}/泰来水厂总览.png');
background-size: 100% 100%;
}
&[widget='PIPE_MONITORING_TAILAI'] {
height: 140px;
background: url('@{imgSrc}/泰来管网运营.png');
background-size: 100% 100%;
}
&[widget='DMA_OVERVIEW_TAILAI'] {
height: 80px;
background: url('@{imgSrc}/泰来DMA总览.png');
background-size: 100% 100%;
}
&[widget='REVENUE_OVERVIEW_TAILAI'] {
height: 80px;
background: url('@{imgSrc}/泰来营收总览.png');
background-size: 100% 100%;
}
} }
} }
.cardType { .cardType {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment