فهرست منبع

v2.0Json推送

shaogen1995 1 سال پیش
والد
کامیت
ee9ab7d514

+ 0 - 1
src/pages/B3Push/data.ts

@@ -3,7 +3,6 @@ export type B3FromDataType= {
   province:string
   city:string
   region:string
-  jsonStatus: "" | 0 | 2 | 3;
   pmUser: string;
   pushStatus: "" | 0 | 2 | 3;
   searchKey: string;

+ 8 - 94
src/pages/B3Push/index.tsx

@@ -40,7 +40,6 @@ function B3Push() {
     province: "",
     city: "",
     region: "",
-    jsonStatus: "",
     pmUser: "",
     pushStatus: "",
     searchKey: "",
@@ -105,7 +104,6 @@ function B3Push() {
       province: "",
       city: "",
       region: "",
-      jsonStatus: "",
       pmUser: "",
       pushStatus: "",
       searchKey: "",
@@ -202,59 +200,10 @@ function B3Push() {
         render: (item: B3tableType) => item.pushTime || "(空)",
       },
       {
-        title: "链接推送状态",
-        render: (item: B3tableType) => (
-          <>
-            {Reflect.get(B1options2Obj, item.pushLinkStatus) || "(空)"}
-            <span style={{ cursor: "pointer" }} hidden={!item.pushLinkDesc}>
-              <Tooltip title={item.pushLinkDesc}>
-                &nbsp;
-                <QuestionCircleOutlined rev={undefined} />
-              </Tooltip>
-            </span>
-          </>
-        ),
-      },
-      {
-        title: "链接推送时间",
-        render: (item: B3tableType) => item.pushLinkTime || "(空)",
-      },
-      // {
-      //   title: "Json类型",
-      //   render: (item: B3tableType) =>
-      //     item.jsonType === 1 ? "算法" : "人工" || "(空)",
-      // },
-      {
-        title: "Json更新时间",
-        render: (item: B3tableType) => item.jsonUpdateTime || "(空)",
-      },
-      {
-        title: "Json推送状态",
-        render: (item: B3tableType) => (
-          <>
-            {Reflect.get(B1options2Obj, item.jsonStatus) || "(空)"}
-            <span style={{ cursor: "pointer" }} hidden={!item.jsonDesc}>
-              <Tooltip title={item.jsonDesc}>
-                &nbsp;
-                <QuestionCircleOutlined rev={undefined} />
-              </Tooltip>
-            </span>
-          </>
-        ),
-      },
-      {
-        title: "Json推送时间",
-        render: (item: B3tableType) => item.jsonPushTime || "(空)",
-      },
-      {
         title: "操作",
         render: (item: B3tableType) => (
           <Button
-            disabled={
-              item.pushStatus === 2 &&
-              item.pushLinkStatus === 2 &&
-              item.jsonStatus === 2
-            }
+            disabled={item.pushStatus === 2 || item.pushStatus === 1}
             size="small"
             type="text"
             onClick={() => pushFu(item.sceneCode)}
@@ -275,7 +224,7 @@ function B3Push() {
 
     if (B3TableList.list.length === 0)
       return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "推送管理" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+    const name = "场景推送" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
 
     const objTemp: any = {};
 
@@ -310,13 +259,6 @@ function B3Push() {
               pushStatus: Reflect.get(B1options2Obj, v.pushStatus) || "(空)",
               pushStatusTxt: v.pushDesc || "(空)",
               pushTime: v.pushTime || "(空)",
-              pushLinkStatus:
-                Reflect.get(B1options2Obj, v.pushLinkStatus) || "(空)",
-              pushLinkTime: v.pushLinkTime || "(空)",
-              jsonUpdateTime: v.jsonUpdateTime || "(空)",
-              jsonStatus: Reflect.get(B1options2Obj, v.jsonStatus) || "(空)",
-              jsonStatusTxt: v.jsonDesc || "(空)",
-              jsonPushTime: v.jsonPushTime || "(空)",
             })),
             sheetName: name,
             sheetFilter: [
@@ -327,12 +269,6 @@ function B3Push() {
               "pushStatus",
               "pushStatusTxt",
               "pushTime",
-              "pushLinkStatus",
-              "pushLinkTime",
-              "jsonUpdateTime",
-              "jsonStatus",
-              "jsonStatusTxt",
-              "jsonPushTime",
             ],
             sheetHeader: [
               "机房编码",
@@ -342,14 +278,8 @@ function B3Push() {
               "场景推送状态",
               "场景推送状态描述",
               "场景推送时间",
-              "链接推送状态",
-              "链接推送时间",
-              "Json更新时间",
-              "Json推送状态",
-              "Json推送状态描述",
-              "Json推送时间",
             ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
+            columnWidths: [10, 10, 10, 10, 10, 10, 10],
           },
         ],
       };
@@ -362,7 +292,7 @@ function B3Push() {
   return (
     <div className={styles.B3Push}>
       <div className="pageTitle">
-        推送管理&emsp;<span>仅显示审核通过的场景</span>
+        场景推送&emsp;<span>仅显示审核通过的场景</span>
       </div>
       {/*顶部筛选 */}
       <div className="B3top">
@@ -418,17 +348,6 @@ function B3Push() {
                 options={B1options2}
               />
             </div>
-            <div className="B3topRow">
-              <span>Json推送状态:</span>
-              <Select
-                style={{ width: 194 }}
-                value={tableSelect.jsonStatus}
-                onChange={(e) =>
-                  setTableSelect({ ...tableSelect, jsonStatus: e })
-                }
-                options={B1options2}
-              />
-            </div>
           </div>
           <div>
             <Button onClick={resetSelectFu}>重置</Button>&emsp;
@@ -442,8 +361,7 @@ function B3Push() {
                 <>
                   请确定是否推送所选文件?
                   <br /> 当前共选中{pushsTit.current[0]}个机房编码 <br />共
-                  {pushsTit.current[1]}个场景可推送,{pushsTit.current[2]}
-                  个链接可推送,{pushsTit.current[3]}个Json文件可推送
+                  {pushsTit.current[1]}个场景可推送
                 </>
               }
               okText="推送"
@@ -487,17 +405,13 @@ function B3Push() {
               // 用于批量推送的文字提示
               pushsTit.current = [
                 arr.length,
-                arr.filter((v) => v.pushStatus !== 2).length,
-                arr.filter((v) => v.pushLinkStatus !== 2).length,
-                arr.filter((v) => v.jsonStatus !== 2).length,
+                arr.filter((v) => v.pushStatus !== 2 && v.pushStatus !== 1)
+                  .length,
               ];
             },
             getCheckboxProps: (item) => {
               return {
-                disabled:
-                  item.pushStatus === 2 &&
-                  item.pushLinkStatus === 2 &&
-                  item.jsonStatus === 2,
+                disabled: item.pushStatus === 2 || item.pushStatus === 1,
               };
             },
           }}

+ 12 - 0
src/pages/B4JsonPush/data.ts

@@ -0,0 +1,12 @@
+export type B4FromDataType = {
+  siteArr: undefined | string[];
+  province: string;
+  city: string;
+  region: string;
+  pmUser: string;
+  jsonStatus: "" | 1 | 0 | 2 | 3;
+  linkStatus: "" | 1 | 0 | 2 | 3;
+  searchKey: string;
+  pageSize: number;
+  pageNum: number;
+};

+ 53 - 0
src/pages/B4JsonPush/index.module.scss

@@ -0,0 +1,53 @@
+.B4JsonPush {
+  :global {
+    .pageTitle {
+      &>span {
+        font-size: 14px;
+        color: #999;
+      }
+    }
+
+    .B4top {
+      background-color: #fff;
+      border-radius: 10px;
+      padding: 15px 24px;
+
+      .B4topSon {
+        display: flex;
+
+        .B4topRow {
+          margin-right: 20px;
+
+          // 级联选择器的 placeholder
+          .ant-select-selection-placeholder {
+            color: black;
+          }
+        }
+      }
+
+      .B4topSon2 {
+        margin-top: 15px;
+        display: flex;
+        justify-content: space-between;
+
+        &>div {
+          display: flex;
+        }
+      }
+    }
+
+    .tableMain {
+      border-radius: 10px;
+      margin-top: 15px;
+      height: calc(100% - 127px);
+      background-color: #fff;
+
+      .ant-table-body {
+        height: 578px;
+        overflow-y: auto !important;
+        overflow-y: overlay !important;
+
+      }
+    }
+  }
+}

+ 383 - 0
src/pages/B4JsonPush/index.tsx

@@ -0,0 +1,383 @@
+import React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+} from "react";
+import styles from "./index.module.scss";
+import { useDispatch, useSelector } from "react-redux";
+import { B4FromDataType } from "./data";
+import { B4_APIgetlist, B4_APIgetlistAll } from "@/store/action/B4JsonPush";
+import { RootState } from "@/store";
+import { B4tableType } from "@/types";
+import { B1options2, B1options2Obj } from "../B1Plan/data";
+import { Button, Cascader, Input, Select, Table, Tooltip } from "antd";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import { MessageFu } from "@/utils/message";
+import dayjs from "dayjs";
+import ExportJsonExcel from "js-export-excel";
+import { mapDataAll1 } from "../C1User/AddUser/city";
+
+function B4JsonPush() {
+  const dispatch = useDispatch();
+
+  // 筛选和分页
+  const [tableSelect, setTableSelect] = useState<B4FromDataType>({
+    siteArr: undefined,
+    province: "",
+    city: "",
+    region: "",
+    pmUser: "",
+    jsonStatus: "",
+    linkStatus: "",
+    searchKey: "",
+    pageSize: 10,
+    pageNum: 1,
+  });
+
+  const tableSelectRef = useRef({} as B4FromDataType);
+
+  useEffect(() => {
+    tableSelectRef.current = { ...tableSelect };
+  }, [tableSelect]);
+
+  // 点击搜索的 时间戳
+  const [timeKey, setTimeKey] = useState(-1);
+
+  // 发送接口的函数
+  const getListFu = useCallback(() => {
+    const objTemp: any = {};
+
+    if (tableSelectRef.current.siteArr) {
+      const temp = tableSelectRef.current.siteArr;
+      objTemp.province = temp[0] || "";
+      objTemp.city = temp[1] || "";
+      objTemp.region = temp[2] || "";
+    }
+
+    const obj = {
+      ...tableSelectRef.current,
+      ...objTemp,
+    };
+    dispatch(B4_APIgetlist(obj));
+  }, [dispatch]);
+
+  useEffect(() => {
+    getListFu();
+  }, [getListFu, timeKey]);
+
+  // 输入框的改变
+  const txtChangeFu = useCallback(
+    (txt: string, key: "pmUser" | "searchKey") => {
+      setTableSelect({ ...tableSelect, [key]: txt });
+    },
+    [tableSelect]
+  );
+
+  // 点击搜索
+  const clickSearch = useCallback(() => {
+    setTableSelect({ ...tableSelect, pageNum: 1 });
+    setTimeout(() => {
+      setTimeKey(Date.now());
+    }, 50);
+  }, [tableSelect]);
+
+  // 点击重置
+  const [inputKey, setInputKey] = useState(1);
+  const resetSelectFu = useCallback(() => {
+    // 把2个输入框和时间选择器清空
+    setInputKey(Date.now());
+    setTableSelect({
+      siteArr: undefined,
+      province: "",
+      city: "",
+      region: "",
+      pmUser: "",
+      jsonStatus: "",
+      linkStatus: "",
+      searchKey: "",
+      pageSize: 10,
+      pageNum: 1,
+    });
+    setTimeout(() => {
+      setTimeKey(Date.now());
+    }, 50);
+  }, []);
+
+  // 从仓库获取列表
+  const B4TableList = useSelector(
+    (state: RootState) => state.B4JsonPush.B4TableList
+  );
+
+  // 页码变化
+  const paginationChange = useCallback(
+    () => (pageNum: number, pageSize: number) => {
+      setTableSelect({ ...tableSelect, pageNum, pageSize });
+      setTimeout(() => {
+        setTimeKey(Date.now());
+      }, 50);
+    },
+    [tableSelect]
+  );
+
+  const columns = useMemo(() => {
+    return [
+      {
+        title: "机房编码",
+        render: (item: B4tableType) => item.roomNum || "(空)",
+      },
+      {
+        title: "站址地区",
+        render: (item: B4tableType) =>
+          !item.province && !item.city && !item.region
+            ? "(空)"
+            : `${item.province}-${item.city}-${item.region}`,
+      },
+      {
+        title: "项目经理",
+        render: (item: B4tableType) => {
+          if (item.creatorId === 1) return "管理员";
+          else {
+            return item.pmName || "(空)";
+          }
+        },
+      },
+      {
+        title: "场景码",
+        render: (item: B4tableType) => item.sceneCode || "(空)",
+      },
+      {
+        title: "链接推送状态",
+        render: (item: B4tableType) => (
+          <>
+            {Reflect.get(B1options2Obj, item.pushLinkStatus) || "(空)"}
+            <span style={{ cursor: "pointer" }} hidden={!item.pushLinkDesc}>
+              <Tooltip title={item.pushLinkDesc}>
+                &nbsp;
+                <QuestionCircleOutlined rev={undefined} />
+              </Tooltip>
+            </span>
+          </>
+        ),
+      },
+      {
+        title: "状态更新时间",
+        render: (item: B4tableType) => item.pushLinkTime || "(空)",
+      },
+      {
+        title: "Json推送状态",
+        render: (item: B4tableType) => (
+          <>
+            {Reflect.get(B1options2Obj, item.jsonStatus) || "(空)"}
+            <span style={{ cursor: "pointer" }} hidden={!item.jsonDesc}>
+              <Tooltip title={item.jsonDesc}>
+                &nbsp;
+                <QuestionCircleOutlined rev={undefined} />
+              </Tooltip>
+            </span>
+          </>
+        ),
+      },
+      {
+        title: "状态更新时间",
+        render: (item: B4tableType) => item.jsonUpdateTime || "(空)",
+      },
+    ];
+  }, []);
+
+  // 点击导出
+  const deriveFu = useCallback(async () => {
+    if (B4TableList.total > 30000)
+      return MessageFu.warning(
+        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
+      );
+
+    if (B4TableList.list.length === 0)
+      return MessageFu.warning("当前搜索条件没有数据!");
+    const name = "Json推送" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+
+    const objTemp: any = {};
+
+    if (tableSelectRef.current.siteArr) {
+      const temp = tableSelectRef.current.siteArr;
+      objTemp.province = temp[0] || "";
+      objTemp.city = temp[1] || "";
+      objTemp.region = temp[2] || "";
+    }
+
+    const res = await B4_APIgetlistAll({
+      ...tableSelect,
+      ...objTemp,
+      pageNum: 1,
+      pageSize: 99999,
+    });
+    if (res.code === 0) {
+      if (res.data.records.length <= 0)
+        return MessageFu.warning("当前搜索条件没有数据!");
+      const option = {
+        fileName: name,
+        datas: [
+          {
+            sheetData: res.data.records.map((v: B4tableType) => ({
+              roomNum: v.roomNum || "(空)",
+              myCity:
+                !v.province && !v.city && !v.region
+                  ? "(空)"
+                  : `${v.province}-${v.city}-${v.region}`,
+              pmName: v.creatorId === 1 ? "管理员" : v.pmName || "(空)",
+              sceneCode: v.sceneCode || "(空)",
+              pushLinkStatus:
+                Reflect.get(B1options2Obj, v.pushLinkStatus) || "(空)",
+              pushLinkDesc: v.pushLinkDesc || "(空)",
+              pushLinkTime: v.pushLinkTime || "(空)",
+              jsonStatus: Reflect.get(B1options2Obj, v.jsonStatus) || "(空)",
+              jsonDesc: v.jsonDesc || "(空)",
+              jsonUpdateTime: v.jsonUpdateTime || "(空)",
+            })),
+            sheetName: name,
+            sheetFilter: [
+              "roomNum",
+              "myCity",
+              "pmName",
+              "sceneCode",
+              "pushLinkStatus",
+              "pushLinkDesc",
+              "pushLinkTime",
+              "jsonStatus",
+              "jsonDesc",
+              "jsonUpdateTime",
+            ],
+            sheetHeader: [
+              "机房编码",
+              "站址地区",
+              "项目经理",
+              "场景码",
+              "链接推送状态",
+              "链接推送状态描述",
+              "状态更新时间",
+              "Json推送状态",
+              "Json推送状态描述",
+              "状态更新时间",
+            ],
+            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
+          },
+        ],
+      };
+
+      const toExcel = new ExportJsonExcel(option); //new
+      toExcel.saveExcel(); //保存
+    }
+  }, [B4TableList.list.length, B4TableList.total, tableSelect]);
+
+  return (
+    <div className={styles.B4JsonPush}>
+      <div className="pageTitle">Json推送</div>
+      {/*顶部筛选 */}
+      <div className="B4top">
+        <div className="B4topSon">
+          <div className="B4topRow">
+            <span>搜索项:</span>
+            <Input
+              key={inputKey}
+              maxLength={24}
+              style={{ width: 260 }}
+              placeholder="请输入机房编码/场景码,最多24字"
+              allowClear
+              onChange={(e) => txtChangeFu(e.target.value, "searchKey")}
+            />
+          </div>
+
+          <div className="B4topRow">
+            <span>站址地区:</span>
+            <Cascader
+              changeOnSelect
+              value={tableSelect.siteArr}
+              style={{ width: 200 }}
+              options={mapDataAll1}
+              placeholder="全部"
+              onChange={(e) =>
+                setTableSelect({ ...tableSelect, siteArr: e as string[] })
+              }
+            />
+          </div>
+
+          <div className="B4topRow">
+            <span>项目经理:</span>
+            <Input
+              key={inputKey}
+              maxLength={10}
+              style={{ width: 200 }}
+              placeholder="请输入姓名,最多10字"
+              allowClear
+              onChange={(e) => txtChangeFu(e.target.value, "pmUser")}
+            />
+          </div>
+        </div>
+        <div className="B4topSon B4topSon2">
+          <div>
+            <div className="B4topRow">
+              <span>链接推送状态:</span>
+              <Select
+                style={{ width: 194 }}
+                value={tableSelect.linkStatus}
+                onChange={(e) =>
+                  setTableSelect({ ...tableSelect, linkStatus: e })
+                }
+                options={B1options2}
+              />
+            </div>
+            <div className="B4topRow">
+              <span>Json推送状态:</span>
+              <Select
+                style={{ width: 194 }}
+                value={tableSelect.jsonStatus}
+                onChange={(e) =>
+                  setTableSelect({ ...tableSelect, jsonStatus: e })
+                }
+                options={B1options2}
+              />
+            </div>
+          </div>
+          <div>
+            <Button onClick={resetSelectFu}>重置</Button>&emsp;
+            <Button type="primary" onClick={clickSearch}>
+              查询
+            </Button>
+            &emsp;
+            <Button type="primary" onClick={deriveFu}>
+              导出表格
+            </Button>
+          </div>
+        </div>
+      </div>
+
+      {/* 表格主体 */}
+      <div className="tableMain">
+        <Table
+          scroll={{ y: 578 }}
+          dataSource={B4TableList.list}
+          columns={columns}
+          rowKey="id"
+          pagination={{
+            showQuickJumper: true,
+            position: ["bottomCenter"],
+            showSizeChanger: true,
+            current: tableSelect.pageNum,
+            pageSize: tableSelect.pageSize,
+            total: B4TableList.total,
+            onChange: paginationChange(),
+          }}
+        />
+      </div>
+      {/*  右下角的列表数量 */}
+      <div className="tableNumBox">
+        共 <span>{B4TableList.total}</span> 条数据
+      </div>
+    </div>
+  );
+}
+
+const MemoB4JsonPush = React.memo(B4JsonPush);
+
+export default MemoB4JsonPush;

+ 8 - 1
src/pages/Layout/data.ts

@@ -43,11 +43,18 @@ const tabLeftArr: RouterType = [
       },
       {
         id: "2.3",
-        name: "推送管理",
+        name: "场景推送",
         path: "/push",
         Com: React.lazy(() => import("../B3Push")),
         done: false,
       },
+      {
+        id: "2.4",
+        name: "Json推送",
+        path: "/jsonpush",
+        Com: React.lazy(() => import("../B4JsonPush")),
+        done: false,
+      },
     ],
   },
 

+ 24 - 0
src/store/action/B4JsonPush.ts

@@ -0,0 +1,24 @@
+import http from "@/utils/http";
+import { AppDispatch } from "..";
+/**
+ *Json推送 表格列表(存到仓库)
+ */
+export const B4_APIgetlist = (data: any) => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post("cms/json/pageList", data);
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total,
+      };
+      dispatch({ type: "B4/getList", payload: obj });
+    }
+  };
+};
+
+/**
+ *Json推送 表格列表(导出表格)
+ */
+export const B4_APIgetlistAll = (data: any) => {
+  return http.post("cms/json/pageList", data);
+};

+ 27 - 0
src/store/reducer/B4JsonPush.ts

@@ -0,0 +1,27 @@
+import { B4tableType } from "@/types";
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  B4TableList: {
+    list: [] as B4tableType[],
+    total: 0,
+  },
+};
+
+// 定义 action 类型
+type Props = {
+  type: "B4/getList";
+  payload: { list: B4tableType[]; total: number };
+};
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case "B4/getList":
+      return { ...state, B4TableList: action.payload };
+    default:
+      return state;
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -8,6 +8,7 @@ import A2Psychz from "./A2Psychz";
 import B1Plan from "./B1Plan";
 import B2Scene from "./B2Scene";
 import B3Push from "./B3Push";
+import B4JsonPush from "./B4JsonPush";
 import C1User from "./C1User";
 import C2Log from "./C2Log";
 
@@ -19,6 +20,7 @@ const rootReducer = combineReducers({
   B1Plan,
   B2Scene,
   B3Push,
+  B4JsonPush,
   C1User,
   C2Log,
 });

+ 20 - 0
src/types/api/B4JsonPush.ts

@@ -0,0 +1,20 @@
+export type B4tableType = {
+	creatorId:number
+	pmName:string
+	city: string;
+	createTime: string;
+	creatorName: string;
+	id: number;
+	jsonDesc: string;
+	jsonPushTime: string;
+	jsonStatus: number;
+	jsonUpdateTime: any;
+	province: string;
+	pushLinkDesc: string;
+	pushLinkStatus: number;
+	pushLinkTime: any;
+	region: string;
+	roomNum: string;
+	sceneCode: string;
+	updateTime: string;
+}

+ 1 - 0
src/types/index.d.ts

@@ -4,5 +4,6 @@ export * from './api/A2Psychz'
 export * from './api/B1Plan'
 export * from './api/B2Scene'
 export * from './api/B3Push'
+export * from './api/B4JsonPush'
 export * from './api/C1User'
 export * from './api/C2Log'