|
@@ -8,13 +8,13 @@ import { LeftOutlined } from "@ant-design/icons";
|
|
|
|
|
|
type ListType = {
|
|
type ListType = {
|
|
id: string;
|
|
id: string;
|
|
- link?: string;
|
|
|
|
name: string;
|
|
name: string;
|
|
|
|
+ flag?: boolean;
|
|
children?: ListType[];
|
|
children?: ListType[];
|
|
};
|
|
};
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
- sId: number;
|
|
|
|
|
|
+ sId: string;
|
|
closeFu: () => void;
|
|
closeFu: () => void;
|
|
isOpen?: boolean;
|
|
isOpen?: boolean;
|
|
};
|
|
};
|
|
@@ -25,43 +25,31 @@ function Tab5Info({ sId, closeFu, isOpen }: Props) {
|
|
const getInfoFu = useCallback(async () => {
|
|
const getInfoFu = useCallback(async () => {
|
|
const res = await A2_APItab5Info(sId);
|
|
const res = await A2_APItab5Info(sId);
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
- // 先写一个假数据
|
|
|
|
- const cccc = [
|
|
|
|
- {
|
|
|
|
- id: "1",
|
|
|
|
- name: "一级1",
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- id: "1.1",
|
|
|
|
- name: "二级1",
|
|
|
|
- link: "http://app.ypzz.cn:8001/weixin/getCmsArticleDetail.htm?item.id=e344faaa650d11e6937300155d00887d",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: "1.2",
|
|
|
|
- name: "二级2",
|
|
|
|
- link: "http://app.ypzz.cn:8001/weixin/getCmsArticleDetail.htm?item.id=8310a930650f11e6937300155d00887d",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: "2",
|
|
|
|
- name: "一级2",
|
|
|
|
- link: "http://app.ypzz.cn:8001/weixin/getCmsArticleDetail.htm?item.id=7bace6705f9211e6937300155d00887d",
|
|
|
|
- children: [
|
|
|
|
- {
|
|
|
|
- id: "2.1",
|
|
|
|
- name: "二级2222",
|
|
|
|
- link: "http://app.ypzz.cn:8001/weixin/getCmsArticleDetail.htm?item.id=a40567d6650f11e6937300155d00887d",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- id: "2.2",
|
|
|
|
- name: "二级2222-222",
|
|
|
|
- link: "http://app.ypzz.cn:8001/weixin/getCmsArticleDetail.htm?item.id=ba4c71f2650f11e6937300155d00887d",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
- setData(cccc);
|
|
|
|
|
|
+ let tempArr: any[] = [];
|
|
|
|
+
|
|
|
|
+ if (res.data && res.data[0] && res.data[0].channelChildren)
|
|
|
|
+ tempArr = res.data[0].channelChildren;
|
|
|
|
+
|
|
|
|
+ const arrRes: ListType[] = [];
|
|
|
|
+ tempArr.forEach((v) => {
|
|
|
|
+ const obj: ListType = {
|
|
|
|
+ id: v.id,
|
|
|
|
+ name: v.text,
|
|
|
|
+ flag: v.flag,
|
|
|
|
+ children: [],
|
|
|
|
+ };
|
|
|
|
+ if (v.children && v.children.length) {
|
|
|
|
+ v.children.forEach((v2: any) => {
|
|
|
|
+ obj.children!.push({
|
|
|
|
+ id: v2.id,
|
|
|
|
+ name: v2.text,
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ arrRes.push(obj);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ setData(arrRes);
|
|
}
|
|
}
|
|
}, [sId]);
|
|
}, [sId]);
|
|
|
|
|
|
@@ -72,39 +60,22 @@ function Tab5Info({ sId, closeFu, isOpen }: Props) {
|
|
// 选中的id
|
|
// 选中的id
|
|
const [acId, setAcId] = useState("");
|
|
const [acId, setAcId] = useState("");
|
|
|
|
|
|
- // 选中的 嵌套网页
|
|
|
|
- const [waiUrl, setWaiUrl] = useState("");
|
|
|
|
-
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (data[0]) {
|
|
if (data[0]) {
|
|
- if (data[0].link) {
|
|
|
|
|
|
+ if (data[0].flag) {
|
|
setAcId(data[0].id);
|
|
setAcId(data[0].id);
|
|
- setWaiUrl(data[0].link);
|
|
|
|
- } else if (
|
|
|
|
- data[0].children &&
|
|
|
|
- data[0].children[0] &&
|
|
|
|
- data[0].children[0].link
|
|
|
|
- ) {
|
|
|
|
|
|
+ } else if (data[0].children && data[0].children[0]) {
|
|
setAcId(data[0].children[0].id);
|
|
setAcId(data[0].children[0].id);
|
|
- setWaiUrl(data[0].children[0].link);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, [data]);
|
|
}, [data]);
|
|
|
|
|
|
- // 切换url
|
|
|
|
- const cutAcFu = useCallback((id: string, url?: string) => {
|
|
|
|
- if (url) {
|
|
|
|
- setAcId(id);
|
|
|
|
- setWaiUrl(url);
|
|
|
|
- }
|
|
|
|
- }, []);
|
|
|
|
-
|
|
|
|
// 右边嵌套页面的加载loding
|
|
// 右边嵌套页面的加载loding
|
|
const [isLoding, setIsLoding] = useState(true);
|
|
const [isLoding, setIsLoding] = useState(true);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
setIsLoding(true);
|
|
setIsLoding(true);
|
|
- }, [waiUrl]);
|
|
|
|
|
|
+ }, [acId]);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.Tab5Info}>
|
|
<div className={styles.Tab5Info}>
|
|
@@ -113,10 +84,10 @@ function Tab5Info({ sId, closeFu, isOpen }: Props) {
|
|
{data.map((v1) => (
|
|
{data.map((v1) => (
|
|
<div className="tab5Row" key={v1.id}>
|
|
<div className="tab5Row" key={v1.id}>
|
|
<div
|
|
<div
|
|
- onClick={() => cutAcFu(v1.id, v1.link)}
|
|
|
|
|
|
+ onClick={() => setAcId(v1.id)}
|
|
className={classNames(
|
|
className={classNames(
|
|
"tab5Row1",
|
|
"tab5Row1",
|
|
- !!v1.link ? "tab5Row1Ac" : "",
|
|
|
|
|
|
+ !!v1.flag ? "tab5Row1Ac" : "",
|
|
acId === v1.id ? "tab5IsActive" : ""
|
|
acId === v1.id ? "tab5IsActive" : ""
|
|
)}
|
|
)}
|
|
>
|
|
>
|
|
@@ -126,7 +97,7 @@ function Tab5Info({ sId, closeFu, isOpen }: Props) {
|
|
<>
|
|
<>
|
|
{v1.children.map((v2) => (
|
|
{v1.children.map((v2) => (
|
|
<div
|
|
<div
|
|
- onClick={() => cutAcFu(v2.id, v2.link)}
|
|
|
|
|
|
+ onClick={() => setAcId(v2.id)}
|
|
className={classNames(
|
|
className={classNames(
|
|
"tab5RowSon",
|
|
"tab5RowSon",
|
|
acId === v2.id ? "tab5IsActive" : ""
|
|
acId === v2.id ? "tab5IsActive" : ""
|
|
@@ -163,11 +134,11 @@ function Tab5Info({ sId, closeFu, isOpen }: Props) {
|
|
<LeftOutlined hidden={isOpen} />
|
|
<LeftOutlined hidden={isOpen} />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- {waiUrl ? (
|
|
|
|
|
|
+ {acId ? (
|
|
<iframe
|
|
<iframe
|
|
onLoad={() => setIsLoding(false)}
|
|
onLoad={() => setIsLoding(false)}
|
|
- key={waiUrl}
|
|
|
|
- src={waiUrl}
|
|
|
|
|
|
+ key={acId}
|
|
|
|
+ src={`/knowInfo.html?sId=${acId}`}
|
|
frameBorder="0"
|
|
frameBorder="0"
|
|
></iframe>
|
|
></iframe>
|
|
) : null}
|
|
) : null}
|