|
@@ -1,4 +1,4 @@
|
|
-import React, { useCallback, useEffect, useState } from "react";
|
|
|
|
|
|
+import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
import { ExclamationCircleFilled, CalendarOutlined } from "@ant-design/icons";
|
|
import { ExclamationCircleFilled, CalendarOutlined } from "@ant-design/icons";
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
import { Empty, Select, Tooltip } from "antd";
|
|
import { Empty, Select, Tooltip } from "antd";
|
|
@@ -22,7 +22,13 @@ import {
|
|
getHotInfo5API,
|
|
getHotInfo5API,
|
|
getHotInfo6API,
|
|
getHotInfo6API,
|
|
} from "@/store/action/A1Hot";
|
|
} from "@/store/action/A1Hot";
|
|
-import { HotInfo1Type, HotInfo3Type, HotInfo4Type } from "@/types";
|
|
|
|
|
|
+import {
|
|
|
|
+ HotGoodsItem,
|
|
|
|
+ HotGoodsType,
|
|
|
|
+ HotInfo1Type,
|
|
|
|
+ HotInfo3Type,
|
|
|
|
+ HotInfo4Type,
|
|
|
|
+} from "@/types";
|
|
import { hotChangeObj } from "@/utils/changeData";
|
|
import { hotChangeObj } from "@/utils/changeData";
|
|
|
|
|
|
echarts.use([
|
|
echarts.use([
|
|
@@ -210,18 +216,23 @@ function Hot() {
|
|
}, [select1, select3]);
|
|
}, [select1, select3]);
|
|
|
|
|
|
// 馆藏统计---第二个饼图
|
|
// 馆藏统计---第二个饼图
|
|
|
|
+ // 把全部的第二个饼图的数据存起来
|
|
|
|
+ const goodsAllDataRef = useRef<HotGoodsType>({
|
|
|
|
+ age: [],
|
|
|
|
+ level: [],
|
|
|
|
+ texture: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ });
|
|
const getGoodsAllFu = useCallback(async () => {
|
|
const getGoodsAllFu = useCallback(async () => {
|
|
const res = await getHotInfo6API();
|
|
const res = await getHotInfo6API();
|
|
- const data: any = res.data;
|
|
|
|
- const data7: any = [];
|
|
|
|
- setAllNum5(data.total);
|
|
|
|
- for (const k in data) {
|
|
|
|
- if (k === select4) {
|
|
|
|
- data[k].forEach((v: any) => {
|
|
|
|
- data7.push({ icon: "circle", value: v.pcs, name: v.type });
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ goodsAllDataRef.current = res.data;
|
|
|
|
+ // 第一次把 按 类别的数据 渲染出来
|
|
|
|
+ setAllNum5(goodsAllDataRef.current.total);
|
|
|
|
+ const data7 = goodsAllDataRef.current["texture"].map((v) => ({
|
|
|
|
+ icon: "circle",
|
|
|
|
+ value: v.pcs,
|
|
|
|
+ name: v.type,
|
|
|
|
+ }));
|
|
|
|
|
|
// 右边饼图配置文件
|
|
// 右边饼图配置文件
|
|
const data7Obj = {
|
|
const data7Obj = {
|
|
@@ -229,7 +240,7 @@ function Hot() {
|
|
series: { center: ["50%", "35%"], radius: ["40%", "60%"] },
|
|
series: { center: ["50%", "35%"], radius: ["40%", "60%"] },
|
|
};
|
|
};
|
|
echartsFu2("#echarts7", data7, data7Obj);
|
|
echartsFu2("#echarts7", data7, data7Obj);
|
|
- }, [echartsFu2, select4]);
|
|
|
|
|
|
+ }, [echartsFu2]);
|
|
|
|
|
|
// 关于浏览总数改变重新发请求拿数据
|
|
// 关于浏览总数改变重新发请求拿数据
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -246,11 +257,40 @@ function Hot() {
|
|
getlikeData2Fu();
|
|
getlikeData2Fu();
|
|
}, [getlikeData2Fu]);
|
|
}, [getlikeData2Fu]);
|
|
|
|
|
|
- // 关于馆藏统计改变数据重新发请求拿数据
|
|
|
|
|
|
+ // 关于馆藏统计进页面把所有数据保存到 goodsAllDataRef 中
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
getGoodsAllFu();
|
|
getGoodsAllFu();
|
|
}, [getGoodsAllFu]);
|
|
}, [getGoodsAllFu]);
|
|
|
|
|
|
|
|
+ // 改变馆藏下拉框的时候修改数据
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ let data7: HotGoodsItem = [];
|
|
|
|
+ setAllNum5(goodsAllDataRef.current.total);
|
|
|
|
+ for (const k in goodsAllDataRef.current) {
|
|
|
|
+ if (k === select4) {
|
|
|
|
+ const selecData: { pcs: number; type: string }[] = Reflect.get(
|
|
|
|
+ goodsAllDataRef.current,
|
|
|
|
+ k
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ data7 = selecData.map((v) => {
|
|
|
|
+ return {
|
|
|
|
+ icon: "circle",
|
|
|
|
+ value: v.pcs,
|
|
|
|
+ name: v.type,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 右边饼图配置文件
|
|
|
|
+ const data7Obj = {
|
|
|
|
+ legend: { left: "center", top: 280 },
|
|
|
|
+ series: { center: ["50%", "35%"], radius: ["40%", "60%"] },
|
|
|
|
+ };
|
|
|
|
+ echartsFu2("#echarts7", data7, data7Obj);
|
|
|
|
+ }, [echartsFu2, select4]);
|
|
|
|
+
|
|
const getInfoFu = useCallback(async () => {
|
|
const getInfoFu = useCallback(async () => {
|
|
// 第一个折线 echarts----------------------------
|
|
// 第一个折线 echarts----------------------------
|
|
const res1 = await getHotInfo1API();
|
|
const res1 = await getHotInfo1API();
|