Commit 50195548 authored by 田翔's avatar 田翔

fix: 代码优化

parent a9ba22cf
...@@ -5,11 +5,12 @@ import { CaretRightOutlined } from '@ant-design/icons' ...@@ -5,11 +5,12 @@ 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'
import moment from 'moment'
const cardTypes = ['管理', '执行', '运营'] const cardTypes = ['管理', '执行', '运营']
const tabs = ['产品组件', '项目组件']
const cards = [ const cards = [
[
{ {
title: '运营总览', title: '运营总览',
count: 1, count: 1,
...@@ -56,6 +57,10 @@ const cards = [ ...@@ -56,6 +57,10 @@ const cards = [
count: 1, count: 1,
children: [{ name: '大表监控', widget: 'LARGE_MONITORING', type: '运营' }], children: [{ name: '大表监控', widget: 'LARGE_MONITORING', type: '运营' }],
}, },
],
[
]
] ]
const getNanoid = (len = 10) => { const getNanoid = (len = 10) => {
...@@ -163,17 +168,18 @@ const Left = () => { ...@@ -163,17 +168,18 @@ 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 cardsFilter = useMemo(() => { const cardsFilter = useMemo(() => {
let array = [] let array = []
cards.forEach(v => { cards[activeIndex].forEach(v => {
let children = v.children.filter(s => cardType.includes(s.type)) let children = v.children.filter(s => cardType.includes(s.type))
if (children.length) { if (children.length) {
array.push({ ...v, children }) array.push({ ...v, children })
} }
}) })
return array return array
}, [cards, cardType]) }, [cards, cardType, activeIndex])
const cardTypeChange = (value) => { const cardTypeChange = (value) => {
setCardType(value) setCardType(value)
...@@ -223,8 +229,21 @@ const Left = () => { ...@@ -223,8 +229,21 @@ const Left = () => {
<Group></Group> <Group></Group>
</div> </div>
</div> </div>
<div className={styles.tabs}>
{tabs.map((v, i) => {
return (
<div
className={styles.tab}
active={`${activeIndex === i}`}
onClick={() => setActiveIndex(i)}
>
{v}
</div>
)
})}
</div>
<div className={styles.item}> <div className={styles.item}>
<div className={styles['g-title']} style={{ paddingBottom: '0' }}>卡片组件</div> {/* <div className={styles['g-title']} style={{ paddingBottom: '0' }}>卡片组件</div> */}
<div className={styles['g-checks']}> <div className={styles['g-checks']}>
<Checkbox.Group <Checkbox.Group
style={{ width: '100%' }} style={{ width: '100%' }}
...@@ -235,7 +254,7 @@ const Left = () => { ...@@ -235,7 +254,7 @@ const Left = () => {
{ {
cardTypes.map(v => { cardTypes.map(v => {
return ( return (
<Col key={v} span={8} style={{ display: 'flex', justifyContent: 'center' }}> <Col key={v} style={{ display: 'flex', justifyContent: 'center', marginLeft: '10px' }}>
<Checkbox value={v}>{v}</Checkbox> <Checkbox value={v}>{v}</Checkbox>
</Col> </Col>
) )
......
...@@ -17,6 +17,28 @@ ...@@ -17,6 +17,28 @@
} }
.r-right {} .r-right {}
} }
.tabs {
display: flex;
margin-top: 10px;
background: #F5F5F5;
color: #A5A5A5;
font-size: 14px;
font-weight: 500;
height: 35px;
line-height: 35px;
&:hover {
cursor: pointer;
}
.tab {
flex: 1;
text-align: center;
&[active='true'] {
border-top: 2px solid #0082F0;
color: #0082F0;
background: linear-gradient(to bottom, #EEF7FF, #FFFFFF);
}
}
}
.l-content { .l-content {
height: calc(100% - 40px); height: calc(100% - 40px);
overflow: auto; overflow: auto;
...@@ -28,8 +50,8 @@ ...@@ -28,8 +50,8 @@
font-weight: 700; font-weight: 700;
} }
.g-checks { .g-checks {
padding: 9px 0; // padding: 9px 0;
background: linear-gradient(to top, #F3F3F3, #FFFFFF); // background: linear-gradient(to top, #F3F3F3, #FFFFFF);
} }
.g-content { .g-content {
padding: 0 10px; padding: 0 10px;
...@@ -165,11 +187,11 @@ ...@@ -165,11 +187,11 @@
} }
.cardGroup { .cardGroup {
padding-left: 10px;
font-size: 14px; font-size: 14px;
margin-top: 3px; margin-top: 3px;
.g-top { .g-top {
display: inline; display: inline;
font-size: 15px;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
color: #1890ff; color: #1890ff;
......
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