提交 b4a76471 作者: 18928357778

添-首页-布局修改

上级 bc0e29c8
...@@ -10,6 +10,7 @@ export default function ContentBox(props: BoxProps) { ...@@ -10,6 +10,7 @@ export default function ContentBox(props: BoxProps) {
boxIndex={props.boxIndex} boxIndex={props.boxIndex}
leftRenderDom={props.leftRenderDom} leftRenderDom={props.leftRenderDom}
leftcontentstyle={props.leftcontentstyle} leftcontentstyle={props.leftcontentstyle}
leftWaterfallDom={props.leftWaterfallDom}
/> />
<Right rightRenderDom={props.rightRenderDom} /> <Right rightRenderDom={props.rightRenderDom} />
</Box> </Box>
......
...@@ -5,9 +5,18 @@ export interface DomType { ...@@ -5,9 +5,18 @@ export interface DomType {
}[]; }[];
pagination?: JSX.Element; pagination?: JSX.Element;
} }
export interface WaterfallType {
columns: {
noFor?: boolean;
type?: string,
element: JSX.Element;
}[];
pagination?: JSX.Element;
}
export interface leftBoxProps { export interface leftBoxProps {
boxIndex: number; boxIndex: number;
leftRenderDom: DomType; leftRenderDom?: DomType;
leftWaterfallDom?: WaterfallType;
leftcontentstyle?: { leftcontentstyle?: {
width?: string; width?: string;
margin?: { margin?: {
...@@ -24,7 +33,8 @@ export interface rightBoxProps { ...@@ -24,7 +33,8 @@ export interface rightBoxProps {
export interface BoxProps { export interface BoxProps {
boxIndex: number; boxIndex: number;
leftRenderDom: DomType; leftRenderDom?: DomType;
leftWaterfallDom?: WaterfallType;
leftcontentstyle?: { leftcontentstyle?: {
width?: string; width?: string;
margin?: { margin?: {
......
import React from "react"; import React from "react";
import { Empty } from "antd"; import { Empty } from "antd";
import { Box } from "./styled"; import { Box , WaterfallBox } from "./styled";
import { leftBoxProps } from "../interface"; import { leftBoxProps } from "../interface";
export default function Left(props: leftBoxProps) { export default function Left(props: leftBoxProps) {
const { boxIndex, leftRenderDom, leftcontentstyle } = props; const { boxIndex, leftRenderDom, leftcontentstyle, leftWaterfallDom } = props;
return ( return (
<div> <div>
{leftRenderDom.columns.map((item) => { {leftRenderDom?.columns.map((item) => {
if (item.noFor) { if (item.noFor) {
return item.element; return item.element;
} }
...@@ -16,7 +15,7 @@ export default function Left(props: leftBoxProps) { ...@@ -16,7 +15,7 @@ export default function Left(props: leftBoxProps) {
})} })}
{ {
<Box index={boxIndex} leftcontentstyle={leftcontentstyle}> <Box index={boxIndex} leftcontentstyle={leftcontentstyle}>
{leftRenderDom.columns.map((item) => { {leftRenderDom?.columns.map((item) => {
if (!item.noFor) { if (!item.noFor) {
return item.element; return item.element;
} }
...@@ -24,8 +23,29 @@ export default function Left(props: leftBoxProps) { ...@@ -24,8 +23,29 @@ export default function Left(props: leftBoxProps) {
})} })}
</Box> </Box>
} }
{leftRenderDom.pagination ? leftRenderDom.pagination : null} {
{!leftRenderDom.columns.length ? ( <WaterfallBox index={boxIndex} leftcontentstyle={leftcontentstyle}>
{ <div className="left-columns">
{leftWaterfallDom?.columns.map((item) => {
if (!item.noFor && item.type === "left") {
return item.element
}
return null
})}
</div>}
{ <div className="right-columns">
{leftWaterfallDom?.columns.map((item) => {
if (!item.noFor && item.type === "right") {
return item.element
}
return null
})}
</div>}
</WaterfallBox>
}
{leftRenderDom?.pagination ? leftRenderDom?.pagination : null}
{!leftRenderDom?.columns.length && !leftWaterfallDom?.columns.length? (
<Empty description={"暂无数据"} /> <Empty description={"暂无数据"} />
) : null} ) : null}
</div> </div>
......
...@@ -33,4 +33,31 @@ export const Box = styled.div<BoxProps>` ...@@ -33,4 +33,31 @@ export const Box = styled.div<BoxProps>`
margin-right: 0; margin-right: 0;
} }
} }
`
export const WaterfallBox = styled.div<BoxProps>`
box-sizing: border-box;
display: flex;
width: ${props => props.leftcontentstyle?.width ? props.leftcontentstyle?.width : "790px"};
.item{
// 每个元素都要设置右边距margin-right(每个元素的左右间隙)
// 同时设置下边距margin-bottom(每个元素的上下间隙)
/* margin: 0 24px 15px 0; */
margin: ${props => props.leftcontentstyle?.margin ? (`${props.leftcontentstyle?.margin.top} ${props.leftcontentstyle?.margin.right} ${props.leftcontentstyle?.margin.bottom} ${props.leftcontentstyle?.margin.left}`) : "0 24px 15px 0"};;
width: calc(( 100% - ${props => props.index} * ${props => props.leftcontentstyle?.margin ? props.leftcontentstyle?.margin.right : "24px" }) / ${props => props.index});
// 这里一行显示index个,所以是/index,一行显示几个就除以几
// 这里的72px = (分布个数index-1)*间隙20px, 可以根据实际的分布个数和间隙区调整
min-width: calc(( 100% - ${props => props.index} * ${props => props.leftcontentstyle?.margin ? props.leftcontentstyle?.margin.right : "24px" }) / ${props => props.index});
max-width: calc(( 100% - ${props => props.index} * ${props => props.leftcontentstyle?.margin ? props.leftcontentstyle?.margin.right : "24px" }) / ${props => props.index});
// 每行最右侧的那个不设置右外边距
&:nth-child(${props => props.index}n + ${props => props.index}) {
margin-right: 0;
}
}
.left-columns{
}
.right-columns{
}
` `
\ No newline at end of file
...@@ -96,16 +96,16 @@ export default function WaterfallFlowBody() { ...@@ -96,16 +96,16 @@ export default function WaterfallFlowBody() {
router: "/mall", router: "/mall",
}, },
{ {
title: "无人机服务", title: "无人机保险",
router: "/jobServices", router: "",
}, },
{ {
title: "无人机培训", title: "无人机培训",
router: "flyingHandService", router: "flyingHandService",
}, },
{ {
title: "无人机保险", title: "无人机服务",
router: "", router: "/jobServices",
}, },
{ {
title: "无人机工具软件", title: "无人机工具软件",
...@@ -114,7 +114,7 @@ export default function WaterfallFlowBody() { ...@@ -114,7 +114,7 @@ export default function WaterfallFlowBody() {
]; ];
const [leftDomList, setLeftDomList] = useState( const [leftDomList, setLeftDomList] = useState(
Array<{ element: JSX.Element }> Array<{ element: JSX.Element , type?: string,}>
); );
const [rightTopDomList, setRightTopDomList] = useState<JSX.Element>(); const [rightTopDomList, setRightTopDomList] = useState<JSX.Element>();
const [rightBottomDomList, setRightBottomDomList] = useState<JSX.Element>(); const [rightBottomDomList, setRightBottomDomList] = useState<JSX.Element>();
...@@ -130,11 +130,12 @@ export default function WaterfallFlowBody() { ...@@ -130,11 +130,12 @@ export default function WaterfallFlowBody() {
"modelId", "modelId",
"qualityId", "qualityId",
]; ];
const { IndustryFlightSkills } = flightSkillsApi;
const flightApiTypeList = ["licenseId", "flightSkillsId"];
const { listAllIndustry, listAllAppType } = jobServicesApi; const { listAllIndustry, listAllAppType } = jobServicesApi;
const jobApiTypeList = ["industryId", "appTypeId"]; const jobApiTypeList = ["industryId", "appTypeId"];
const { IndustryFlightSkills } = flightSkillsApi;
const flightApiTypeList = ["licenseId", "flightSkillsId"];
useEffect(() => { useEffect(() => {
(async () => { (async () => {
...@@ -155,8 +156,8 @@ export default function WaterfallFlowBody() { ...@@ -155,8 +156,8 @@ export default function WaterfallFlowBody() {
listAllParts(), listAllParts(),
listAllQuality(), listAllQuality(),
]); ]);
let res3 = await Promise.all([listAllIndustry(), listAllAppType()]); let res3 = await Promise.all([IndustryFlightSkills()]);
let res4 = await Promise.all([IndustryFlightSkills()]); let res4 = await Promise.all([listAllIndustry(), listAllAppType()]);
// let res4 = await Promise.all([deviceCategory(),deviceBrand(),deviceModel()]) // let res4 = await Promise.all([deviceCategory(),deviceBrand(),deviceModel()])
// let res6 = await Promise.all([deviceCategory(),deviceBrand(),deviceModel()]) // let res6 = await Promise.all([deviceCategory(),deviceBrand(),deviceModel()])
...@@ -201,16 +202,22 @@ export default function WaterfallFlowBody() { ...@@ -201,16 +202,22 @@ export default function WaterfallFlowBody() {
const listValue: any = [ const listValue: any = [
resValuelist1, resValuelist1,
resValuelist2, resValuelist2,
[],
resValuelist3, resValuelist3,
resValuelist4.flat(), resValuelist4.flat(),
[], [],
[],
]; ];
setMoreEqList(res1.map((item) => item.result).flat()); setMoreEqList(res1.map((item) => item.result).flat());
setLeftDomList( setLeftDomList(
columns.map((item, index) => { columns.map((item, index) => {
return { element: leftDom(item, index, listValue) };
if (index < 3) {
console.log("路由跳转",index);
return { element: leftDom(item, index, listValue) , type:"left" };
}
console.log("路由跳转",index);
return { element: leftDom(item, index, listValue) , type:"right" };
}) })
); );
...@@ -220,6 +227,8 @@ export default function WaterfallFlowBody() { ...@@ -220,6 +227,8 @@ export default function WaterfallFlowBody() {
}, []); }, []);
const routerPath = (index: number, item?: AllType) => { const routerPath = (index: number, item?: AllType) => {
console.log(index);
if (item) { if (item) {
router.push({ router.push({
pathname: columns[index].router, pathname: columns[index].router,
...@@ -260,7 +269,7 @@ export default function WaterfallFlowBody() { ...@@ -260,7 +269,7 @@ export default function WaterfallFlowBody() {
</div> </div>
<div className="item-body"> <div className="item-body">
<Space size={[15, 0]} wrap> <Space size={[15, 0]} wrap>
{index === 4 {index === 2
? list.map((item, index) => ( ? list.map((item, index) => (
<div <div
key={item} key={item}
...@@ -282,12 +291,12 @@ export default function WaterfallFlowBody() { ...@@ -282,12 +291,12 @@ export default function WaterfallFlowBody() {
{item} {item}
</div> </div>
)) ))
: resultList[index].map((item, index) => { : resultList[index].map((item, indexer) => {
return ( return (
<div <div
key={item?.name || item?.appName || item?.skillsName} key={item?.name || item?.appName || item?.skillsName}
className={`item-bubble ${ className={`item-bubble ${
index === 0 || index === 1 || index === 2 indexer === 0 || indexer === 1 || indexer === 2
? "active" ? "active"
: "" : ""
}`} }`}
...@@ -380,12 +389,12 @@ export default function WaterfallFlowBody() { ...@@ -380,12 +389,12 @@ export default function WaterfallFlowBody() {
return ( return (
<Box> <Box>
<ContentBox <ContentBox
boxIndex={2} boxIndex={1} //分为左右两列,每列一个,从上而下
leftcontentstyle={{ leftcontentstyle={{
width: "806px", width: "806px",
margin: { top: 0, right: "10px", bottom: "10px", left: 0 }, margin: { top: 0, right: "10px", bottom: "10px", left: 0 },
}} }}
leftRenderDom={{ leftWaterfallDom={{
columns: [ columns: [
{ noFor: true, element: <RotationChart key={45645645} /> }, { noFor: true, element: <RotationChart key={45645645} /> },
...leftDomList, ...leftDomList,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论