Selaa lähdekoodia

进度统计跳转

shaogen1995 11 kuukautta sitten
vanhempi
commit
9af1b326a6

+ 21 - 20
src/pages/A2Psychz/data.ts

@@ -1,30 +1,31 @@
 export type A2FromDataType = {
-  siteArr: string[]|undefined;
-  province:string
-  city:string
-  region:string
-  searchKey: string;
-  pmUser: string;
-  typeIn: "" | "pc" | "app-scan" | "app-manual";
-  pageSize: number;
-  pageNum: number;
-};
+  siteArr: string[] | undefined
+  province: string
+  city: string
+  region: string
+  searchKey: string
+  pmUser: string
+  typeIn: '' | 'pc' | 'app-scan' | 'app-manual'
+  pageSize: number
+  pageNum: number
+  isSiteEmpty: 0 | 1
+}
 
 export const options1 = [
   {
-    value: "",
-    label: "全部",
+    value: '',
+    label: '全部'
   },
   {
-    value: "pc",
-    label: "系统",
+    value: 'pc',
+    label: '系统'
   },
   {
-    value: "app-scan",
-    label: "移动端扫码",
+    value: 'app-scan',
+    label: '移动端扫码'
   },
   {
-    value: "app-manual",
-    label: "移动端手工",
-  },
-];
+    value: 'app-manual',
+    label: '移动端手工'
+  }
+]

+ 258 - 246
src/pages/A2Psychz/index.tsx

@@ -1,306 +1,313 @@
-import React, {
-  useCallback,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
-import styles from "./index.module.scss";
-import { Button, Cascader, Input, Popconfirm, Select, Table } from "antd";
-import { useDispatch, useSelector } from "react-redux";
-import { A2FromDataType, options1 } from "./data";
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Cascader, Checkbox, Input, Popconfirm, Select, Table } from 'antd'
+import { useDispatch, useSelector } from 'react-redux'
+import { A2FromDataType, options1 } from './data'
 import {
   A2_APIgetCity,
   A2_APIgetlist,
   A2_APIgetlistDerive,
-  A2_APIremoves,
-} from "@/store/action/A2Psychz";
-import { RootState } from "@/store";
-import { A2tableType } from "@/types";
-import { MessageFu } from "@/utils/message";
-import { A1addType } from "../A1Camera/data";
-import AddPsychz from "./AddPsychz";
-import dayjs from "dayjs";
-import ExportJsonExcel from "js-export-excel";
+  A2_APIremoves
+} from '@/store/action/A2Psychz'
+import { RootState } from '@/store'
+import { A2tableType } from '@/types'
+import { MessageFu } from '@/utils/message'
+import { A1addType } from '../A1Camera/data'
+import AddPsychz from './AddPsychz'
+import dayjs from 'dayjs'
+import ExportJsonExcel from 'js-export-excel'
+
+const baseTableSelect: A2FromDataType = {
+  siteArr: undefined,
+  province: '',
+  city: '',
+  region: '',
+  searchKey: '',
+  pmUser: '',
+  typeIn: '',
+  pageSize: 10,
+  pageNum: 1,
+  isSiteEmpty: 0
+}
 
 function A2Psychz() {
   // 站址地区的数据-下拉框
 
-  const [optionsCity, setOptionsCity] = useState<any>([]);
+  const [optionsCity, setOptionsCity] = useState<any>([])
 
   const getCityFu = useCallback(async () => {
-    const res = await A2_APIgetCity();
+    const res = await A2_APIgetCity()
     if (res.code === 0) {
-      const obj = res.data;
+      const obj = res.data
 
-      const arr = [];
+      const arr = []
 
       for (const k in obj) {
         const temp1: any = {
           value: k,
           label: k,
-          children: [],
-        };
+          children: []
+        }
 
-        const children1Obj = Reflect.get(obj, k);
+        const children1Obj = Reflect.get(obj, k)
 
         for (const k2 in children1Obj) {
-          const children2Arr = Reflect.get(children1Obj, k2);
+          const children2Arr = Reflect.get(children1Obj, k2)
 
           const objTemp = {
             value: k2,
             label: k2,
             children: children2Arr.map((v2: any) => ({
               value: v2.region,
-              label: v2.region,
-            })),
-          };
-          temp1.children.push(objTemp);
+              label: v2.region
+            }))
+          }
+          temp1.children.push(objTemp)
         }
 
-        arr.push(temp1);
+        arr.push(temp1)
       }
 
-      setOptionsCity(arr);
-      // console.log(123, res);
+      setOptionsCity(arr)
     }
-  }, []);
+  }, [])
 
   useEffect(() => {
-    getCityFu();
-  }, [getCityFu]);
+    getCityFu()
+  }, [getCityFu])
 
-  const dispatch = useDispatch();
+  const dispatch = useDispatch()
 
   // 筛选和分页
-  const [tableSelect, setTableSelect] = useState<A2FromDataType>({
-    siteArr: undefined,
-    province: "",
-    city: "",
-    region: "",
-    searchKey: "",
-    pmUser: "",
-    typeIn: "",
-    pageSize: 10,
-    pageNum: 1,
-  });
-
-  const tableSelectRef = useRef({} as A2FromDataType);
+  const [tableSelect, setTableSelect] = useState(baseTableSelect)
+
+  const tableSelectRef = useRef({} as A2FromDataType)
 
   useEffect(() => {
-    tableSelectRef.current = { ...tableSelect };
-  }, [tableSelect]);
+    tableSelectRef.current = { ...tableSelect }
+  }, [tableSelect])
 
   // 点击搜索的 时间戳
-  const [timeKey, setTimeKey] = useState(-1);
+  const [timeKey, setTimeKey] = useState(-1)
 
   // 点击搜索
   const clickSearch = useCallback(() => {
-    setTableSelect({ ...tableSelect, pageNum: 1 });
+    setTableSelect({ ...tableSelect, pageNum: 1 })
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, [tableSelect]);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [tableSelect])
 
   // 发送接口的函数
   const getListFu = useCallback(() => {
-    const objTemp: any = {};
+    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 temp = tableSelectRef.current.siteArr
+      objTemp.province = temp[0] || ''
+      objTemp.city = temp[1] || ''
+      objTemp.region = temp[2] || ''
     }
 
     const obj = {
       ...tableSelectRef.current,
-      ...objTemp,
-    };
-    dispatch(A2_APIgetlist(obj));
-  }, [dispatch]);
+      ...objTemp
+    }
+    dispatch(A2_APIgetlist(obj))
+  }, [dispatch])
+
+  useEffect(() => {
+    // 从进度统计进来------带入参数
+    const urlStr = decodeURI(window.location.href)
+    if (urlStr.includes('?C=')) {
+      const path = urlStr.split('?C=')[1]
+      const pathArr = path.split('/')
+
+      const obj: A2FromDataType = {
+        ...baseTableSelect,
+        siteArr: pathArr
+      }
+
+      setTableSelect(obj)
+
+      // 注意 这里有个坑。 setTableSelect 不能直接设置 province 和 city
+      tableSelectRef.current = { ...obj, province: pathArr[0], city: pathArr[1] || '' }
+    }
+
+    if (urlStr.includes('?N=')) {
+      const obj: A2FromDataType = {
+        ...baseTableSelect,
+        isSiteEmpty: 1
+      }
+
+      setTableSelect(obj)
+      tableSelectRef.current = obj
+    }
+
+    getListFu()
+  }, [getListFu])
 
   useEffect(() => {
-    getListFu();
-  }, [getListFu, timeKey]);
+    if (timeKey !== -1) getListFu()
+  }, [getListFu, timeKey])
 
   // 输入框的改变
   const txtChangeFu = useCallback(
-    (txt: string, key: "pmUser" | "searchKey") => {
-      setTableSelect({ ...tableSelect, [key]: txt });
+    (txt: string, key: 'pmUser' | 'searchKey') => {
+      setTableSelect({ ...tableSelect, [key]: txt })
     },
     [tableSelect]
-  );
+  )
 
   // 点击重置
-  const [inputKey, setInputKey] = useState(1);
+  const [inputKey, setInputKey] = useState(1)
   const resetSelectFu = useCallback(() => {
     // 把2个输入框和时间选择器清空
-    setInputKey(Date.now());
-    setTableSelect({
-      siteArr: undefined,
-      province: "",
-      city: "",
-      region: "",
-      searchKey: "",
-      pmUser: "",
-      typeIn: "",
-      pageSize: 10,
-      pageNum: 1,
-    });
+    setInputKey(Date.now())
+    setTableSelect(baseTableSelect)
 
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, []);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [])
 
   // 从仓库获取列表
-  const A2TableList = useSelector(
-    (state: RootState) => state.A2Psychz.A2TableList
-  );
+  const A2TableList = useSelector((state: RootState) => state.A2Psychz.A2TableList)
   // 页码变化
   const paginationChange = useCallback(
     () => (pageNum: number, pageSize: number) => {
-      setTableSelect({ ...tableSelect, pageNum, pageSize });
+      setTableSelect({ ...tableSelect, pageNum, pageSize })
       setTimeout(() => {
-        setTimeKey(Date.now());
-      }, 50);
+        setTimeKey(Date.now())
+      }, 50)
     },
     [tableSelect]
-  );
+  )
 
   // 点击删除
   const delByIdFu = useCallback(
     async (id: number) => {
-      const res = await A2_APIremoves(id);
+      const res = await A2_APIremoves(id)
       if (res.code === 0) {
-        MessageFu.success("删除成功!");
-        getListFu();
-        getCityFu();
+        MessageFu.success('删除成功!')
+        getListFu()
+        getCityFu()
       }
     },
     [getCityFu, getListFu]
-  );
+  )
 
   const columns = useMemo(() => {
     return [
       {
-        title: "站址地区",
+        title: '站址地区',
         render: (item: A2tableType) =>
           !item.province && !item.city && !item.region
-            ? "(空)"
-            : `${item.province}-${item.city}-${item.region}`,
+            ? '(空)'
+            : `${item.province}-${item.city}-${item.region}`
       },
       {
-        title: "详细地址",
+        title: '详细地址',
         render: (item: A2tableType) =>
           item.address ? (
             item.address.length >= 25 ? (
-              <span style={{ cursor: "pointer" }} title={item.address}>
-                {item.address.substring(0, 25) + "..."}
+              <span style={{ cursor: 'pointer' }} title={item.address}>
+                {item.address.substring(0, 25) + '...'}
               </span>
             ) : (
               item.address
             )
           ) : (
-            "(空)"
-          ),
+            '(空)'
+          )
       },
       {
-        title: "站址名称",
-        render: (item: A2tableType) => item.name || "(空)",
+        title: '站址名称',
+        render: (item: A2tableType) => item.name || '(空)'
       },
       {
-        title: "站址编号",
-        render: (item: A2tableType) => item.siteNum || "(空)",
+        title: '站址编号',
+        render: (item: A2tableType) => item.siteNum || '(空)'
       },
       {
-        title: "机房编码",
-        dataIndex: "roomNum",
+        title: '机房编码',
+        dataIndex: 'roomNum'
       },
       {
-        title: "项目经理",
+        title: '项目经理',
         render: (item: A2tableType) => {
-          if (item.pmUserId === 1) return "管理员";
+          if (item.pmUserId === 1) return '管理员'
           else {
-            return item.pmName || "(空)";
+            return item.pmName || '(空)'
           }
-        },
+        }
       },
       {
-        title: "最近编辑时间",
-        dataIndex: "updateTime",
+        title: '最近编辑时间',
+        dataIndex: 'updateTime'
       },
 
       {
-        title: "录入方式",
+        title: '录入方式',
         render: (item: A2tableType) =>
-          item.typeIn === "pc"
-            ? "系统"
-            : item.typeIn === "app-scan"
-            ? "移动端扫码"
-            : "移动端手工",
+          item.typeIn === 'pc' ? '系统' : item.typeIn === 'app-scan' ? '移动端扫码' : '移动端手工'
       },
       {
-        title: "操作",
+        title: '操作',
         render: (item: A2tableType) => (
           <>
             <Button
-              size="small"
-              type="text"
-              onClick={() => setOpenInfo({ id: item.id, txt: "编辑" })}
+              size='small'
+              type='text'
+              onClick={() => setOpenInfo({ id: item.id, txt: '编辑' })}
             >
               编辑
             </Button>
             <Popconfirm
-              title="删除后无法恢复,是否删除?"
-              okText="删除"
-              cancelText="取消"
+              title='删除后无法恢复,是否删除?'
+              okText='删除'
+              cancelText='取消'
               onConfirm={() => delByIdFu(item.id)}
               okButtonProps={{ loading: false }}
             >
-              <Button size="small" type="text" danger>
+              <Button size='small' type='text' danger>
                 删除
               </Button>
             </Popconfirm>
           </>
-        ),
-      },
-    ];
-  }, [delByIdFu]);
+        )
+      }
+    ]
+  }, [delByIdFu])
 
-  const [openInfo, setOpenInfo] = useState<A1addType>({ id: 0, txt: "" });
+  const [openInfo, setOpenInfo] = useState<A1addType>({ id: 0, txt: '' })
 
   // 点击导出
   const deriveFu = useCallback(async () => {
     if (A2TableList.total > 30000)
-      return MessageFu.warning(
-        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
-      );
+      return MessageFu.warning('只支持导出最多30000条数据。请增加筛选条件,并重新尝试')
 
-    if (A2TableList.list.length === 0)
-      return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "机房管理" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+    if (A2TableList.list.length === 0) return MessageFu.warning('当前搜索条件没有数据!')
+    const name = '机房管理' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
 
-    const objTemp: any = {};
+    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 temp = tableSelectRef.current.siteArr
+      objTemp.province = temp[0] || ''
+      objTemp.city = temp[1] || ''
+      objTemp.region = temp[2] || ''
     }
 
     const res = await A2_APIgetlistDerive({
       ...tableSelectRef.current,
       ...objTemp,
       pageNum: 1,
-      pageSize: 99999,
-    });
+      pageSize: 99999
+    })
 
     if (res.code === 0) {
-      if (res.data.records.length <= 0)
-        return MessageFu.warning("当前搜索条件没有数据!");
+      if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
 
       const option = {
         fileName: name,
@@ -310,132 +317,137 @@ function A2Psychz() {
               ...v,
               myCity:
                 !v.province && !v.city && !v.region
-                  ? "(空)"
+                  ? '(空)'
                   : `${v.province}-${v.city}-${v.region}`,
-              address: v.address || "(空)",
-              name: v.name || "(空)",
-              siteNum: v.siteNum || "(空)",
-              pmName: v.pmUserId === 1 ? "管理员" : v.pmName || "(空)",
+              address: v.address || '(空)',
+              name: v.name || '(空)',
+              siteNum: v.siteNum || '(空)',
+              pmName: v.pmUserId === 1 ? '管理员' : v.pmName || '(空)',
               typeIn:
-                v.typeIn === "pc"
-                  ? "系统"
-                  : v.typeIn === "app-scan"
-                  ? "移动端扫码"
-                  : "移动端手工",
+                v.typeIn === 'pc' ? '系统' : v.typeIn === 'app-scan' ? '移动端扫码' : '移动端手工'
             })),
             sheetName: name,
             sheetFilter: [
-              "myCity",
-              "address",
-              "name",
-              "siteNum",
-              "roomNum",
-              "pmName",
-              "updateTime",
-              "typeIn",
+              'myCity',
+              'address',
+              'name',
+              'siteNum',
+              'roomNum',
+              'pmName',
+              'updateTime',
+              'typeIn'
             ],
             sheetHeader: [
-              "站址地区",
-              "详细地址",
-              "站址名称",
-              "站址编号",
-              "机房编码",
-              "项目经理",
-              "最近编辑时间",
-              "录入方式",
+              '站址地区',
+              '详细地址',
+              '站址名称',
+              '站址编号',
+              '机房编码',
+              '项目经理',
+              '最近编辑时间',
+              '录入方式'
             ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10],
-          },
-        ],
-      };
+            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10]
+          }
+        ]
+      }
 
-      const toExcel = new ExportJsonExcel(option); //new
-      toExcel.saveExcel(); //保存
+      const toExcel = new ExportJsonExcel(option) //new
+      toExcel.saveExcel() //保存
     }
-  }, [A2TableList.list.length, A2TableList.total]);
+  }, [A2TableList.list.length, A2TableList.total])
 
   return (
     <div className={styles.A2Psychz}>
-      <div className="pageTitle">
-        {openInfo.txt === "新增"
-          ? "新增机房"
-          : openInfo.txt === "编辑"
-          ? "编辑机房"
-          : "机房管理"}
+      <div className='pageTitle'>
+        {openInfo.txt === '新增' ? '新增机房' : openInfo.txt === '编辑' ? '编辑机房' : '机房管理'}
       </div>
       {/* 顶部筛选 */}
-      <div className="A2top">
+      <div className='A2top'>
         {/* 左侧输入框 */}
-        <div className="A2top1">
-          <div className="A2topRow">
+        <div className='A2top1'>
+          <div className='A2topRow'>
+            <span>项目经理:</span>
+            <Input
+              key={inputKey}
+              maxLength={10}
+              style={{ width: 240 }}
+              placeholder='请输入姓名,最多10字'
+              allowClear
+              onChange={e => txtChangeFu(e.target.value, 'pmUser')}
+            />
+          </div>
+
+          <div className='A2topRow'>
             <span>站址地区:</span>
 
             <Cascader
+              disabled={!!tableSelect.isSiteEmpty}
               changeOnSelect
-              style={{ width: 240 }}
+              style={{ width: 308 }}
               options={optionsCity}
               value={tableSelect.siteArr}
-              placeholder="全部"
-              onChange={(e) =>
+              placeholder='全部'
+              onChange={e => {
                 setTableSelect({
                   ...tableSelect,
-                  siteArr: e as string[],
+                  siteArr: e as string[]
                 })
-              }
+              }}
             />
           </div>
 
-          <div className="A2topRow">
-            <span>搜索项:</span>
-            <Input
-              key={inputKey}
-              maxLength={24}
-              style={{ width: 322 }}
-              placeholder="请输入站址名称/站置编号/机房编码,最多24字"
-              allowClear
-              onChange={(e) => txtChangeFu(e.target.value, "searchKey")}
-            />
+          <div className='A2topRow'>
+            <Checkbox
+              checked={!!tableSelect.isSiteEmpty}
+              onChange={e =>
+                setTableSelect({
+                  ...tableSelect,
+                  siteArr: e.target.checked ? undefined : tableSelect.siteArr,
+                  isSiteEmpty: e.target.checked ? 1 : 0
+                })
+              }
+            >
+              仅查看站址地区为空的场景
+            </Checkbox>
           </div>
         </div>
 
-        <div className="A2top2">
+        <div className='A2top2'>
           <div>
-            <div className="A2topRow">
-              <span>项目经理:</span>
-              <Input
-                key={inputKey}
-                maxLength={10}
-                style={{ width: 240 }}
-                placeholder="请输入姓名,最多10字"
-                allowClear
-                onChange={(e) => txtChangeFu(e.target.value, "pmUser")}
-              />
-            </div>
-            <div className="A2topRow">
+            <div className='A2topRow'>
               <span>录入方式:</span>
               <Select
-                style={{ width: 150 }}
+                style={{ width: 240 }}
                 value={tableSelect.typeIn}
-                onChange={(e) => setTableSelect({ ...tableSelect, typeIn: e })}
+                onChange={e => setTableSelect({ ...tableSelect, typeIn: e })}
                 options={options1}
               />
             </div>
+            <div className='A2topRow'>
+              <span>搜索项:</span>
+              <Input
+                key={inputKey}
+                maxLength={24}
+                style={{ width: 322 }}
+                placeholder='请输入站址名称/站置编号/机房编码,最多24字'
+                allowClear
+                onChange={e => txtChangeFu(e.target.value, 'searchKey')}
+              />
+            </div>
           </div>
           {/* 按钮 */}
           <div>
             <Button onClick={resetSelectFu}>重置</Button>&emsp;
-            <Button type="primary" onClick={clickSearch}>
+            <Button type='primary' onClick={clickSearch}>
               查询
             </Button>
             &emsp;
-            <Button
-              type="primary"
-              onClick={() => setOpenInfo({ id: -1, txt: "新增" })}
-            >
+            <Button type='primary' onClick={() => setOpenInfo({ id: -1, txt: '新增' })}>
               新增
             </Button>
             &emsp;
-            <Button type="primary" onClick={deriveFu}>
+            <Button type='primary' onClick={deriveFu}>
               导出表格
             </Button>
           </div>
@@ -443,20 +455,20 @@ function A2Psychz() {
       </div>
 
       {/* 表格主体 */}
-      <div className="tableMain">
+      <div className='tableMain'>
         <Table
           scroll={{ y: 578 }}
           dataSource={A2TableList.list}
           columns={columns}
-          rowKey="id"
+          rowKey='id'
           pagination={{
             showQuickJumper: true,
-            position: ["bottomCenter"],
+            position: ['bottomCenter'],
             showSizeChanger: true,
             current: tableSelect.pageNum,
             pageSize: tableSelect.pageSize,
             total: A2TableList.total,
-            onChange: paginationChange(),
+            onChange: paginationChange()
           }}
         />
       </div>
@@ -465,26 +477,26 @@ function A2Psychz() {
       {openInfo.id ? (
         <AddPsychz
           openInfo={openInfo}
-          closeFu={() => setOpenInfo({ id: 0, txt: "" })}
+          closeFu={() => setOpenInfo({ id: 0, txt: '' })}
           upTableFu={() => {
-            getListFu();
-            getCityFu();
+            getListFu()
+            getCityFu()
           }}
           addTableFu={() => {
-            resetSelectFu();
-            getCityFu();
+            resetSelectFu()
+            getCityFu()
           }}
         />
       ) : null}
 
       {/*  右下角的列表数量 */}
-      <div className="tableNumBox">
+      <div className='tableNumBox'>
         共 <span>{A2TableList.total}</span> 条数据
       </div>
     </div>
-  );
+  )
 }
 
-const MemoA2Psychz = React.memo(A2Psychz);
+const MemoA2Psychz = React.memo(A2Psychz)
 
-export default MemoA2Psychz;
+export default MemoA2Psychz

+ 148 - 206
src/pages/B1Plan/B1tab1.tsx

@@ -1,186 +1,163 @@
-import React, {
-  useCallback,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
-import { B2FromDataArer } from "./data";
-import { useDispatch, useSelector } from "react-redux";
-import { B1_APIgetlistArea } from "@/store/action/B1Plan";
-import { RootState } from "@/store";
-import { B1tableAreaType } from "@/types";
-import { Button, Cascader, Table } from "antd";
-import { MessageFu } from "@/utils/message";
-import dayjs from "dayjs";
-import ExportJsonExcel from "js-export-excel";
-import { ExclamationCircleOutlined } from "@ant-design/icons";
-import { mapDataAll2 } from "../C1User/AddUser/city";
-import PlanModal from "./PlanModal";
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { B2FromDataArer } from './data'
+import { useDispatch, useSelector } from 'react-redux'
+import { B1_APIgetlistArea } from '@/store/action/B1Plan'
+import { RootState } from '@/store'
+import { B1tableAreaType } from '@/types'
+import { Button, Table } from 'antd'
+import { MessageFu } from '@/utils/message'
+import dayjs from 'dayjs'
+import ExportJsonExcel from 'js-export-excel'
+import PlanModal from './PlanModal'
+import history from '@/utils/history'
 
 const tableSelectTemp: B2FromDataArer = {
   // 按机房统计
   siteArr: undefined,
-  province: "",
-  city: "",
-};
-
-const topTypeArr = ["区域", "机房"] as ("机房" | "区域")[];
-
-type Props = {
-  topType: "区域" | "机房";
-  setTopType: (val: "机房", arrTemp?: string[]) => void;
-};
-
-function B1tab1({ topType, setTopType }: Props) {
-  // 切换 区域 和 机房
-  const setTopTypeFu = useCallback(
-    (value: "区域" | "机房", flag?: string) => {
-      if (value === "区域") return;
-
-      if (flag) {
-        const arrTemp = flag.split("/");
-
-        // 传给父组件
-        setTopType("机房", arrTemp);
-      } else setTopType("机房");
-    },
-    [setTopType]
-  );
+  province: '',
+  city: ''
+}
 
-  const dispatch = useDispatch();
+function B1tab1() {
+  const dispatch = useDispatch()
 
   // 筛选和分页
   const [tableSelect, setTableSelect] = useState<B2FromDataArer>({
-    ...tableSelectTemp,
-  });
+    ...tableSelectTemp
+  })
 
-  const tableSelectRef = useRef({} as B2FromDataArer);
+  const tableSelectRef = useRef({} as B2FromDataArer)
 
   useEffect(() => {
-    tableSelectRef.current = { ...tableSelect };
-  }, [tableSelect]);
+    tableSelectRef.current = { ...tableSelect }
+  }, [tableSelect])
 
   // 点击搜索的 时间戳
-  const [timeKey, setTimeKey] = useState(-1);
+  const [timeKey, setTimeKey] = useState(-1)
 
   // 点击搜索
   const clickSearch = useCallback(() => {
-    setTableSelect({ ...tableSelect });
+    setTableSelect({ ...tableSelect })
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, [tableSelect]);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [tableSelect])
 
   // 发送接口的函数
   const getListFu = useCallback(() => {
-    const objTemp: any = {};
+    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 temp = tableSelectRef.current.siteArr
+      objTemp.province = temp[0] || ''
+      objTemp.city = temp[1] || ''
+      objTemp.region = temp[2] || ''
     }
-    dispatch(B1_APIgetlistArea({ ...tableSelectRef.current, ...objTemp }));
-  }, [dispatch]);
+    dispatch(B1_APIgetlistArea({ ...tableSelectRef.current, ...objTemp }))
+  }, [dispatch])
 
   useEffect(() => {
-    getListFu();
-  }, [getListFu, timeKey]);
+    getListFu()
+  }, [getListFu, timeKey])
 
   // 点击重置
   const resetSelectFu = useCallback(() => {
-    setTableSelect({ ...tableSelectTemp });
+    setTableSelect({ ...tableSelectTemp })
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, []);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [])
 
   // 从仓库获取列表
-  const B1TableList = useSelector(
-    (state: RootState) => state.B1Plan.B1TableListArea
-  );
+  const B1TableList = useSelector((state: RootState) => state.B1Plan.B1TableListArea)
+
+  // 跳到 机房管理 或者 场景审核
+  const skipUrlFu = useCallback((val: string, url: '/psychz' | '/scene') => {
+    if (val === '其他') history.push(encodeURI(`${url}?N=1`))
+    else history.push(encodeURI(`${url}?C=${val}`))
+  }, [])
 
   const columns = useMemo(() => {
     return [
       {
-        title: "站址地区",
-        render: (item: B1tableAreaType) => item.cityAll || "空",
+        title: '站址地区',
+        render: (item: B1tableAreaType) => item.cityAll || '空'
+      },
+      {
+        title: '机房总数',
+        render: (item: B1tableAreaType) => (
+          <span onClick={() => skipUrlFu(item.cityAll, '/psychz')} className='B1tableClick'>
+            {item.pcsRoom || 0}
+          </span>
+        )
       },
       {
-        title: "机房总数",
-        render: (item: B1tableAreaType) => item.pcsRoom || 0,
+        title: '上传机房',
+        render: (item: B1tableAreaType) => item.pcsSceneDistinct || 0
       },
       {
-        title: "上传场景",
-        render: (item: B1tableAreaType) => item.pcsScene || 0,
+        title: '上传场景',
+        render: (item: B1tableAreaType) => (
+          <span onClick={() => skipUrlFu(item.cityAll, '/scene')} className='B1tableClick'>
+            {item.pcsScene || 0}
+          </span>
+        )
       },
       {
-        title: "完成场景计算",
-        render: (item: B1tableAreaType) => item.pcsCalculate || 0,
+        title: '完成场景计算',
+        render: (item: B1tableAreaType) => item.pcsCalculate || 0
       },
       {
-        title: "初审通过",
-        render: (item: B1tableAreaType) => item.pcsFirst || 0,
+        title: '审核驳回',
+        render: (item: B1tableAreaType) => item.pcsReject || 0
       },
       {
-        title: "审核通过",
-        render: (item: B1tableAreaType) => item.pcsPass || 0,
+        title: '初审通过',
+        render: (item: B1tableAreaType) => item.pcsFirst || 0
       },
       {
-        title: "审核驳回",
-        render: (item: B1tableAreaType) => item.pcsReject || 0,
+        title: '审核通过',
+        render: (item: B1tableAreaType) => item.pcsPass || 0
       },
+
       {
-        title: "场景推送成功",
-        render: (item: B1tableAreaType) => item.pcsPushScene || 0,
+        title: '场景推送成功',
+        render: (item: B1tableAreaType) => item.pcsPushScene || 0
       },
       {
-        title: "链接推送成功",
-        render: (item: B1tableAreaType) => item.pcsPushLink || 0,
+        title: '链接推送成功',
+        render: (item: B1tableAreaType) => item.pcsPushLink || 0
       },
       {
-        title: "Json推送成功",
-        render: (item: B1tableAreaType) => item.pcsPushJson || 0,
+        title: 'Json推送成功',
+        render: (item: B1tableAreaType) => item.pcsPushJson || 0
       },
       {
-        title: "操作",
+        title: '操作',
         render: (item: B1tableAreaType) => (
           <>
-            {/* 带完善 */}
-            <Button
-              size="small"
-              type="text"
-              disabled={!item.cityAll}
-              onClick={() => setModalTitle(item.cityAll)}
-            >
-              按日期查看
-            </Button>
-            <Button
-              size="small"
-              type="text"
-              disabled={!item.cityAll}
-              onClick={() => setTopTypeFu("机房", item.cityAll)}
-            >
-              按机房查看
+            <Button size='small' type='text' onClick={() => setModalTitle(item.cityAll)}>
+              按日期统计
             </Button>
+            {['上海市', '北京市', '天津市', '重庆市', '其他'].includes(item.cityAll) ? null : (
+              <Button size='small' type='text'>
+                查看城市
+              </Button>
+              // 待完善
+            )}
           </>
-        ),
-      },
-    ];
-  }, [setTopTypeFu]);
+        )
+      }
+    ]
+  }, [skipUrlFu])
 
   // 点击导出
   const deriveFu = useCallback(async () => {
     if (B1TableList.total > 30000)
-      return MessageFu.warning(
-        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
-      );
+      return MessageFu.warning('只支持导出最多30000条数据。请增加筛选条件,并重新尝试')
 
-    if (B1TableList.list.length === 0)
-      return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "进度统计" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+    if (B1TableList.list.length === 0) return MessageFu.warning('当前搜索条件没有数据!')
+    const name = '进度统计' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
 
     const option = {
       fileName: name,
@@ -188,123 +165,88 @@ function B1tab1({ topType, setTopType }: Props) {
         {
           sheetData: B1TableList.list.map((v: B1tableAreaType) => ({
             ...v,
-            id: v.cityAll || "(空)",
+            id: v.cityAll || '(空)'
           })),
           sheetName: name,
           sheetFilter: [
-            "id",
-            "pcsRoom",
-            "pcsScene",
-            "pcsCalculate",
-            "pcsFirst",
-            "pcsPass",
-            "pcsReject",
-            "pcsPushScene",
-            "pcsPushLink",
-            "pcsPushJson",
+            'id',
+            'pcsRoom',
+            'pcsSceneDistinct',
+            'pcsScene',
+            'pcsCalculate',
+            'pcsReject',
+            'pcsFirst',
+            'pcsPass',
+            'pcsPushScene',
+            'pcsPushLink',
+            'pcsPushJson'
           ],
           sheetHeader: [
-            "站址地区",
-            "机房总数",
-            "上传场景",
-            "完成场景计算",
-            "初审通过",
-            "审核通过",
-            "审核驳回",
-            "场景推送成功",
-            "链接推送成功",
-            "Json推送成功",
+            '站址地区',
+            '机房总数',
+            '上传机房',
+            '上传场景',
+            '完成场景计算',
+            '审核驳回',
+            '初审通过',
+            '审核通过',
+            '场景推送成功',
+            '链接推送成功',
+            'Json推送成功'
           ],
-          columnWidths: [10, 5, 5, 5, 5, 5, 5, 5, 5, 5],
-        },
-      ],
-    };
+          columnWidths: [10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
+        }
+      ]
+    }
 
-    const toExcel = new ExportJsonExcel(option); //new
-    toExcel.saveExcel(); //保存
-  }, [B1TableList.list, B1TableList.total]);
+    const toExcel = new ExportJsonExcel(option) //new
+    toExcel.saveExcel() //保存
+  }, [B1TableList.list, B1TableList.total])
 
   // 点击 按日期查看
-  const [modalTitle, setModalTitle] = useState("");
+  const [modalTitle, setModalTitle] = useState('')
 
   return (
     <>
-      <div className="pageTitle">
+      <div className='pageTitle'>
         进度统计&emsp;
-        <ExclamationCircleOutlined rev={undefined} />
-        <div>
-          当存在重复的机房编码时,请在[场景审核]中删除多余场景码后,重新统计
-        </div>
+        {/* <ExclamationCircleOutlined rev={undefined} /> */}
+        <div>数据更新时间:{B1TableList.time}</div>
       </div>
       {/* 顶部筛选 */}
-      <div className="B1top">
-        <div className="B1topSon">
-          <div className="B1topRow">
-            {topTypeArr.map((v) => (
-              <Button
-                onClick={() => setTopTypeFu(v)}
-                type={v === topType ? "primary" : "default"}
-                key={v}
-              >
-                按{v}统计
-              </Button>
-            ))}
-          </div>
-
-          <div className="B1topRow">
-            <span>站址地区:</span>
-            <Cascader
-              changeOnSelect
-              value={tableSelect.siteArr}
-              style={{ width: 160 }}
-              options={mapDataAll2}
-              placeholder="全部"
-              onChange={(e) =>
-                setTableSelect({
-                  ...tableSelect,
-                  siteArr: e as string[],
-                })
-              }
-            />
-          </div>
-        </div>
-        <div className="B1topSon B1topSon2">
-          <div></div>
-          <div>
-            <Button onClick={resetSelectFu}>重置</Button>&emsp;
-            <Button type="primary" onClick={clickSearch}>
-              查询
-            </Button>
-            &emsp;
-            <Button type="primary" onClick={deriveFu}>
-              导出表格
-            </Button>
-          </div>
+      <div className='B1top'>
+        <div>
+          <Button onClick={resetSelectFu}>重置</Button>&emsp;
+          <Button type='primary' onClick={clickSearch}>
+            查询
+          </Button>
+          &emsp;
+          <Button type='primary' onClick={deriveFu}>
+            导出表格
+          </Button>
         </div>
       </div>
       {/* 表格主体 */}
-      <div className="tableMain">
+      <div className='tableMain'>
         <Table
-          scroll={{ y: 578 }}
+          scroll={{ y: 650 }}
           dataSource={B1TableList.list}
           columns={columns}
-          rowKey="id"
+          rowKey='id'
           pagination={false}
         />
       </div>
       {/*  右下角的列表数量 */}
-      <div className="tableNumBox">
+      <div className='tableNumBox'>
         共 <span>{B1TableList.total}</span> 条数据
       </div>
 
       {/* 点击 按日期查看 出来的页面 */}
-      {modalTitle ? (
-        <PlanModal title={modalTitle} closePageFu={() => setModalTitle("")} />
-      ) : null}
+      {modalTitle ? <PlanModal title={modalTitle} closePageFu={() => setModalTitle('')} /> : null}
     </>
-  );
+  )
 }
 
-const MemoB1tab1 = React.memo(B1tab1);
+const MemoB1tab1 = React.memo(B1tab1)
 
-export default MemoB1tab1;
+export default MemoB1tab1

+ 0 - 466
src/pages/B1Plan/B1tab2.tsx

@@ -1,466 +0,0 @@
-import React, {
-  useCallback,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
-import {
-  Button,
-  Cascader,
-  Checkbox,
-  Input,
-  Select,
-  Table,
-  Tooltip,
-} from "antd";
-import {
-  B1options1,
-  B1options1Obj,
-  B1options2,
-  B1options2Obj,
-  B1options3,
-  B2FromDataType,
-} from "./data";
-import {
-  ExclamationCircleOutlined,
-  QuestionCircleOutlined,
-} from "@ant-design/icons";
-import { useDispatch, useSelector } from "react-redux";
-
-import { RootState } from "@/store";
-import { B1tableType } from "@/types";
-import ExportJsonExcel from "js-export-excel";
-import { MessageFu } from "@/utils/message";
-import dayjs from "dayjs";
-import { mapDataAll1 } from "../C1User/AddUser/city";
-import { B1_APIgetlist, B1_APIgetlistAll } from "@/store/action/B1Plan";
-import { forwardRef, useImperativeHandle } from "react";
-
-const tableSelectTemp: B2FromDataType = {
-  // 按机房统计
-  siteArr: undefined,
-  isUploadScene: 1,
-  province: "",
-  city: "",
-  region: "",
-  searchKey: "",
-  pmUser: "",
-  auditStatus: "",
-  pushStatus: "",
-  jsonStatus: "",
-  pageSize: 10,
-  pageNum: 1,
-};
-
-const topTypeArr = ["区域", "机房"] as ("机房" | "区域")[];
-
-type Props = {
-  topType: "区域" | "机房";
-  setTopType: (val: "区域") => void;
-  ref: any;
-};
-
-function B1tab1({ topType, setTopType }: Props, ref: any) {
-  // 切换 区域 和 机房
-  const setTopTypeFu = useCallback(
-    (value: "机房" | "区域") => {
-      if (value === "机房") return;
-
-      // 传给父组件
-      setTopType("区域");
-    },
-    [setTopType]
-  );
-
-  const dispatch = useDispatch();
-
-  // 筛选和分页
-  const [tableSelect, setTableSelect] = useState<B2FromDataType>({
-    ...tableSelectTemp,
-  });
-
-  const tableSelectRef = useRef({} as B2FromDataType);
-
-  useEffect(() => {
-    tableSelectRef.current = { ...tableSelect };
-  }, [tableSelect]);
-
-  // 点击搜索的 时间戳
-  const [timeKey, setTimeKey] = useState(-1);
-
-  // 点击搜索
-  const clickSearch = useCallback(() => {
-    setTableSelect({ ...tableSelect, pageNum: 1 });
-    setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, [tableSelect]);
-
-  // 发送接口的函数
-  const getListFu = useCallback(() => {
-    const objTemp: any = {};
-
-    const temp = tableSelectRef.current.siteArr || [];
-    objTemp.province = temp[0] || "";
-    objTemp.city = temp[1] || "";
-    objTemp.region = temp[2] || "";
-
-    const obj = {
-      ...tableSelectRef.current,
-      ...objTemp,
-    };
-
-    dispatch(B1_APIgetlist(obj));
-  }, [dispatch]);
-
-  useEffect(() => {
-    getListFu();
-  }, [getListFu, timeKey]);
-
-  // 输入框的改变
-  const txtChangeFu = useCallback(
-    (txt: string, key: "pmUser" | "searchKey") => {
-      setTableSelect({ ...tableSelect, [key]: txt });
-    },
-    [tableSelect]
-  );
-
-  // 点击重置
-  const [inputKey, setInputKey] = useState(1);
-  const resetSelectFu = useCallback(() => {
-    // 把2个输入框和时间选择器清空
-    setInputKey(Date.now());
-    setTableSelect({ ...tableSelectTemp });
-    setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, []);
-
-  // 从仓库获取列表
-  const B1TableList: any = useSelector(
-    (state: RootState) => state.B1Plan.B1TableList
-  );
-
-  // 页码变化
-  const paginationChange = useCallback(
-    () => (pageNum: number, pageSize: number) => {
-      setTableSelect({ ...tableSelect, pageNum, pageSize });
-      setTimeout(() => {
-        setTimeKey(Date.now());
-      }, 50);
-    },
-    [tableSelect]
-  );
-
-  // 给父组件调用,设置站址地区
-  const fatherFu = useCallback((obj: any) => {
-    // 把2个输入框和时间选择器清空
-    setInputKey(Date.now());
-
-    setTableSelect({ ...tableSelectTemp, ...obj });
-    setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, []);
-
-  // 可以让父组件调用子组件的方法
-  useImperativeHandle(ref, () => ({
-    fatherFu,
-  }));
-
-  const columns = useMemo(() => {
-    return [
-      {
-        title: "站址名称",
-        render: (item: B1tableType) => item.name || "(空)",
-      },
-      {
-        title: "站址编号",
-        render: (item: B1tableType) => item.siteNum || "(空)",
-      },
-      {
-        title: "站址地区",
-        render: (item: B1tableType) =>
-          !item.province && !item.city && !item.region
-            ? "(空)"
-            : `${item.province}-${item.city}-${item.region}`,
-      },
-      {
-        title: "机房编码",
-        dataIndex: "roomNum",
-      },
-      {
-        title: "项目经理",
-        render: (item: B1tableType) => item.pmName || "(空)",
-      },
-      {
-        title: "场景码",
-        render: (item: B1tableType) => item.sceneCode || "(空)",
-      },
-      {
-        title: "场景审核状态",
-        render: (item: B1tableType) =>
-          Reflect.get(B1options1Obj, item.auditStatus) || "(空)",
-      },
-      {
-        title: "场景推送状态",
-        render: (item: B1tableType) => (
-          <>
-            {Reflect.get(B1options2Obj, item.pushStatus) || "(空)"}
-            <span style={{ cursor: "pointer" }} hidden={!item.pushDesc}>
-              <Tooltip title={item.pushDesc}>
-                &nbsp;
-                <QuestionCircleOutlined rev={undefined} />
-              </Tooltip>
-            </span>
-          </>
-        ),
-      },
-      {
-        title: "Json推送状态",
-        render: (item: B1tableType) =>
-          Reflect.get(B1options2Obj, item.jsonStatus) || "(空)",
-      },
-    ];
-  }, []);
-  // 点击导出
-  const deriveFu = useCallback(async () => {
-    if (B1TableList.total > 30000)
-      return MessageFu.warning(
-        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
-      );
-
-    if (B1TableList.list.length === 0)
-      return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "进度统计" + 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 B1_APIgetlistAll({
-      ...tableSelectRef.current,
-      ...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: B1tableType) => ({
-              name: v.name || "(空)",
-              siteNum: v.siteNum || "(空)",
-              myCity:
-                !v.province && !v.city && !v.region
-                  ? "(空)"
-                  : `${v.province}-${v.city}-${v.region}`,
-              roomNum: v.roomNum,
-              pmName: v.pmName || "(空)",
-              sceneCode: v.sceneCode || "(空)",
-              auditStatus:
-                Reflect.get(B1options1Obj, v.auditStatus) || "(空)",
-              pushStatus: Reflect.get(B1options2Obj, v.pushStatus) || "(空)",
-              jsonStatus: Reflect.get(B1options2Obj, v.jsonStatus) || "(空)",
-            })),
-            sheetName: name,
-            sheetFilter: [
-              "name",
-              "siteNum",
-              "myCity",
-              "roomNum",
-              "pmName",
-              "sceneCode",
-              "auditStatus",
-              "pushStatus",
-              "jsonStatus",
-            ],
-            sheetHeader: [
-              "站址名称",
-              "站址编号",
-              "站址地区",
-              "机房编码",
-              "项目经理",
-              "场景码",
-              "场景审核状态",
-              "场景推送状态",
-              "Json推送状态",
-            ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10],
-          },
-        ],
-      };
-
-      const toExcel = new ExportJsonExcel(option); //new
-      toExcel.saveExcel(); //保存
-    }
-  }, [B1TableList.list.length, B1TableList.total]);
-
-  return (
-    <>
-      <div className="pageTitle">
-        进度统计&emsp;
-        <ExclamationCircleOutlined rev={undefined} />
-        <div>
-          当存在重复的机房编码时,请在[场景审核]中删除多余场景码后,重新统计
-        </div>
-      </div>
-      {/* 顶部筛选 */}
-      <div className="B1top">
-        <div className="B1topSon">
-          <div className="B1topRow">
-            {topTypeArr.map((v) => (
-              <Button
-                onClick={() => setTopTypeFu(v)}
-                type={v === topType ? "primary" : "default"}
-                key={v}
-              >
-                按{v}统计
-              </Button>
-            ))}
-          </div>
-          <div className="B1topRow">
-            <span>搜索项:</span>
-            <Input
-              key={inputKey}
-              maxLength={24}
-              style={{ width: 323 }}
-              placeholder="请输入站址名称/站置编号/机房编码,最多24字"
-              allowClear
-              onChange={(e) => txtChangeFu(e.target.value, "searchKey")}
-            />
-          </div>
-          <div className="B1topRow">
-            <span>站址地区:</span>
-            <Cascader
-              changeOnSelect
-              value={tableSelect.siteArr}
-              style={{ width: 160 }}
-              options={mapDataAll1}
-              placeholder="全部"
-              onChange={(e) =>
-                setTableSelect({
-                  ...tableSelect,
-                  siteArr: e as string[],
-                })
-              }
-            />
-          </div>
-          <div className="B1topRow">
-            <span>项目经理:</span>
-            <Input
-              key={inputKey}
-              maxLength={10}
-              style={{ width: 200 }}
-              placeholder="请输入姓名,最多10字"
-              allowClear
-              onChange={(e) => txtChangeFu(e.target.value, "pmUser")}
-            />
-          </div>
-        </div>
-        <div className="B1topSon B1topSon2">
-          <div>
-            <div className="B1topRow">
-              <span>场景审核:</span>
-              <Select
-                disabled={!tableSelect.isUploadScene}
-                style={{ width: 200 }}
-                value={tableSelect.auditStatus}
-                onChange={(e) =>
-                  setTableSelect({ ...tableSelect, auditStatus: e })
-                }
-                options={B1options1}
-              />
-            </div>
-            <div className="B1topRow">
-              <span>场景推送:</span>
-              <Select
-                disabled={!tableSelect.isUploadScene}
-                style={{ width: 200 }}
-                value={tableSelect.pushStatus}
-                onChange={(e) =>
-                  setTableSelect({ ...tableSelect, pushStatus: e })
-                }
-                options={B1options2}
-              />
-            </div>
-            <div className="B1topRow">
-              <span>Json推送:</span>
-              <Select
-                disabled={!tableSelect.isUploadScene}
-                style={{ width: 200 }}
-                value={tableSelect.jsonStatus}
-                onChange={(e) =>
-                  setTableSelect({ ...tableSelect, jsonStatus: e })
-                }
-                options={B1options3}
-              />
-            </div>
-            <div className="B1topRowCheck">
-              <Checkbox
-                checked={tableSelect.isUploadScene === 0}
-                onChange={(e) => {
-                  setTableSelect({
-                    ...tableSelect,
-                    isUploadScene: e.target.checked ? 0 : 1,
-                    // 把 场景审核 场景推送 Json推送变成初始值
-                    auditStatus: "",
-                    pushStatus: "",
-                    jsonStatus: "",
-                  });
-                }}
-              >
-                仅查看未上传的机房
-              </Checkbox>
-            </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={B1TableList.list}
-          columns={columns}
-          rowKey="idKey"
-          pagination={{
-            showQuickJumper: true,
-            position: ["bottomCenter"],
-            showSizeChanger: true,
-            current: tableSelect.pageNum,
-            pageSize: tableSelect.pageSize,
-            total: B1TableList.total,
-            onChange: paginationChange(),
-          }}
-        />
-      </div>
-      {/*  右下角的列表数量 */}
-      <div className="tableNumBox">
-        共 <span>{B1TableList.total}</span> 条数据
-      </div>
-    </>
-  );
-}
-
-export default forwardRef(B1tab1);

+ 8 - 31
src/pages/B1Plan/index.module.scss

@@ -20,45 +20,17 @@
       background-color: #fff;
       border-radius: 10px;
       padding: 15px 24px;
-      height: 109px;
-
-      .B1topSon {
-        display: flex;
-
-        .B1topRow {
-          margin-right: 20px;
-
-          // 级联选择器的 placeholder
-          .ant-select-selection-placeholder {
-            color: black;
-          }
-        }
-      }
-
-      .B1topRowCheck {
-        position: relative;
-        top: 3px;
-      }
-
-      .B1topSon2 {
-        display: flex;
-        justify-content: space-between;
-        margin-top: 15px;
-
-        & > div {
-          display: flex;
-        }
-      }
+      text-align: right;
     }
 
     .tableMain {
       border-radius: 10px;
       margin-top: 15px;
-      height: calc(100% - 127px);
+      height: calc(100% - 80px);
       background-color: #fff;
 
       .ant-table-body {
-        height: 578px;
+        height: 650px;
         overflow-y: auto !important;
         overflow-y: overlay !important;
 
@@ -66,6 +38,11 @@
           padding: 8px !important;
         }
       }
+      .B1tableClick {
+        display: block;
+        cursor: pointer;
+        color: var(--themeColor);
+      }
     }
   }
 }

+ 8 - 42
src/pages/B1Plan/index.tsx

@@ -1,50 +1,16 @@
-import React, { useCallback, useRef, useState } from "react";
-import styles from "./index.module.scss";
-import B1tab1 from "./B1tab1";
-import B1tab2 from "./B1tab2";
+import React from 'react'
+import styles from './index.module.scss'
+import B1tab1 from './B1tab1'
 function B1Plan() {
-  const [topType, setTopType] = useState<"机房" | "区域">("区域");
-
-  const sonSetTopTypeFu = useCallback(
-    (val: "机房" | "区域", arrTemp?: string[]) => {
-      setTopType(val);
-      if (arrTemp) {
-        // 设置 机房 组件  站址地区 回显
-        if (sonRef2.current) {
-          const objTemp: any = {};
-          objTemp.siteArr = arrTemp;
-          objTemp.province = arrTemp[0] || "";
-          objTemp.city = arrTemp[1 || ""];
-          objTemp.region = arrTemp[2] || "";
-
-          sonRef2.current.fatherFu(objTemp);
-        }
-      }
-    },
-    []
-  );
-
-  const sonRef2 = useRef<any>(null);
-
   return (
     <div className={styles.B1Plan}>
-      <div className="B1box" hidden={topType === "机房"}>
-        <B1tab1
-          topType={topType}
-          setTopType={(val, arrTemp) => sonSetTopTypeFu(val, arrTemp)}
-        />
-      </div>
-      <div className="B1box" hidden={topType === "区域"}>
-        <B1tab2
-          topType={topType}
-          setTopType={(val) => sonSetTopTypeFu(val)}
-          ref={sonRef2}
-        />
+      <div className='B1box'>
+        <B1tab1 />
       </div>
     </div>
-  );
+  )
 }
 
-const MemoB1Plan = React.memo(B1Plan);
+const MemoB1Plan = React.memo(B1Plan)
 
-export default MemoB1Plan;
+export default MemoB1Plan

+ 7 - 2
src/pages/B2Scene/B2DelList/index.tsx

@@ -9,6 +9,7 @@ import { mapDataAll1 } from '@/pages/C1User/AddUser/city'
 import { LeftOutlined, QuestionCircleOutlined } from '@ant-design/icons'
 import { B2tableType } from '@/types'
 import { B2ResNum } from '../data'
+import LookReDo from '../LookReDo'
 
 type TopObjType = {
   siteArr: undefined | string[]
@@ -259,6 +260,9 @@ function B2DelList({ sonDelCloseFu, upTableFu }: Props) {
     ]
   }, [delByIdFu, recoversByIdFu])
 
+  // 查看重复的场景
+  const [lookReDo, setLookReDo] = useState(false)
+
   return (
     <div className={styles.B2DelList}>
       {/* 顶部筛选 */}
@@ -327,8 +331,7 @@ function B2DelList({ sonDelCloseFu, upTableFu }: Props) {
             </div>
           </div>
           <div>
-            {/* 待完善 */}
-            {/* <Button onClick={() => setLookReDo(true)}>查看重复的场景</Button> */}
+            <Button onClick={() => setLookReDo(true)}>查看重复的场景</Button>
             &emsp;
             <Button onClick={resetSelectFu}>重置</Button>&emsp;
             <Button type='primary' onClick={clickSearch}>
@@ -357,6 +360,8 @@ function B2DelList({ sonDelCloseFu, upTableFu }: Props) {
           }}
         />
       </div>
+      {/* 查看重复的场景 */}
+      {lookReDo ? <LookReDo closePageFu={() => setLookReDo(false)} apiUrl='recycle' /> : null}
     </div>
   )
 }

+ 60 - 67
src/pages/B2Scene/LookReDo.tsx

@@ -1,109 +1,102 @@
-import React, { useCallback, useEffect, useMemo, useState } from "react";
-import styles from "./index.module.scss";
-import { Button, Modal, Table } from "antd";
-import { B2_APIlookReDo } from "@/store/action/B2Scene";
-import { MessageFu } from "@/utils/message";
-import dayjs from "dayjs";
-import ExportJsonExcel from "js-export-excel";
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Modal, Table } from 'antd'
+import { B2_APIlookReDo } from '@/store/action/B2Scene'
+import { MessageFu } from '@/utils/message'
+import dayjs from 'dayjs'
+import ExportJsonExcel from 'js-export-excel'
 
 type ListType = {
-  id: string;
-  city: string;
-  province: string;
-  region: string;
-  roomNum: string;
-  sceneCode: string;
-};
+  id: string
+  city: string
+  province: string
+  region: string
+  roomNum: string
+  sceneCode: string
+}
 
 type Props = {
-  closePageFu: () => void;
-};
+  closePageFu: () => void
+  apiUrl: 'recycle' | 'scene'
+}
 
-function LookReDo({ closePageFu }: Props) {
-  const [list, setList] = useState<ListType[]>([]);
+function LookReDo({ closePageFu, apiUrl }: Props) {
+  const [list, setList] = useState<ListType[]>([])
 
   const geiListFu = useCallback(async () => {
-    const res = await B2_APIlookReDo();
+    const res = await B2_APIlookReDo(apiUrl)
     if (res.code === 0) {
       setList(
         res.data.map((v: ListType) => ({
           ...v,
-          id: v.city + "" + v.province + v.region + v.roomNum + v.sceneCode,
+          id: v.city + '' + v.province + v.region + v.roomNum + v.sceneCode
         }))
-      );
+      )
     }
-  }, []);
+  }, [apiUrl])
 
   useEffect(() => {
-    geiListFu();
-  }, [geiListFu]);
+    geiListFu()
+  }, [geiListFu])
 
   const column = useMemo(() => {
     return [
       {
-        title: "机房编码",
-        render: (item: ListType) => item.roomNum || "空",
+        title: '机房编码',
+        render: (item: ListType) => item.roomNum || '空'
       },
       {
-        title: "站址地区",
+        title: '站址地区',
         render: (item: ListType) =>
           !item.province && !item.city && !item.region
-            ? "(空)"
-            : `${item.province}-${item.city}-${item.region}`,
+            ? '(空)'
+            : `${item.province}-${item.city}-${item.region}`
       },
       {
-        title: "场景码",
-        render: (item: ListType) => item.sceneCode || "空",
-      },
-    ];
-  }, []);
+        title: '场景码',
+        render: (item: ListType) => item.sceneCode || '空'
+      }
+    ]
+  }, [])
 
   // 点击导出
   const deriveFu = useCallback(async () => {
     if (list.length > 30000)
-      return MessageFu.warning(
-        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
-      );
+      return MessageFu.warning('只支持导出最多30000条数据。请增加筛选条件,并重新尝试')
 
-    if (list.length === 0) return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "重复场景" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+    if (list.length === 0) return MessageFu.warning('当前搜索条件没有数据!')
+    const name = '重复场景' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
 
     const option = {
       fileName: name,
       datas: [
         {
-          sheetData: list.map((v) => ({
+          sheetData: list.map(v => ({
             ...v,
             myCity:
-              !v.province && !v.city && !v.region
-                ? "(空)"
-                : `${v.province}-${v.city}-${v.region}`,
+              !v.province && !v.city && !v.region ? '(空)' : `${v.province}-${v.city}-${v.region}`
           })),
           sheetName: name,
-          sheetFilter: ["roomNum", "myCity", "sceneCode"],
-          sheetHeader: ["机房编码", "站址地区", "场景码"],
-          columnWidths: [10, 10, 10],
-        },
-      ],
-    };
+          sheetFilter: ['roomNum', 'myCity', 'sceneCode'],
+          sheetHeader: ['机房编码', '站址地区', '场景码'],
+          columnWidths: [10, 10, 10]
+        }
+      ]
+    }
 
-    const toExcel = new ExportJsonExcel(option); //new
-    toExcel.saveExcel(); //保存
-  }, [list]);
+    const toExcel = new ExportJsonExcel(option) //new
+    toExcel.saveExcel() //保存
+  }, [list])
 
   return (
     <Modal
       wrapClassName={styles.LookReDo}
       open={true}
       title={
-        <div className="B2Mtitle">
+        <div className='B2Mtitle'>
           <div>重复场景</div>
           <div>
-            <Button
-              type="primary"
-              disabled={list.length === 0}
-              onClick={deriveFu}
-            >
+            <Button type='primary' disabled={list.length === 0} onClick={deriveFu}>
               导出表格
             </Button>
           </div>
@@ -113,30 +106,30 @@ function LookReDo({ closePageFu }: Props) {
         [] // 设置footer为空,去掉 取消 确定默认按钮
       }
     >
-      <div className="B2Mmain">
-        <div className="B1MTable">
+      <div className='B2Mmain'>
+        <div className='B1MTable'>
           <Table
-            size="small"
+            size='small'
             scroll={{ y: 578 }}
             dataSource={list}
             columns={column}
-            rowKey="id"
+            rowKey='id'
             pagination={false}
           />
         </div>
 
-        <div className="B2Mbtn">
+        <div className='B2Mbtn'>
           <Button onClick={closePageFu}>关闭</Button>
           {/*  右下角的列表数量 */}
-          <div className="tableNumBox">
+          <div className='tableNumBox'>
             共 <span>{list.length}</span> 条数据
           </div>
         </div>
       </div>
     </Modal>
-  );
+  )
 }
 
-const MemoLookReDo = React.memo(LookReDo);
+const MemoLookReDo = React.memo(LookReDo)
 
-export default MemoLookReDo;
+export default MemoLookReDo

+ 47 - 25
src/pages/B2Scene/index.tsx

@@ -20,22 +20,24 @@ import MateNum from './MateNum'
 import { getTokenInfo } from '@/utils/storage'
 import B2DelList from './B2DelList'
 
+const baseTableSelect: B2FromDataType = {
+  siteArr: undefined,
+  province: '',
+  city: '',
+  region: '',
+  auditStatus: '',
+  roomName: '',
+  searchKey: '',
+  pageSize: 10,
+  pageNum: 1,
+  isSiteEmpty: 0
+}
+
 function B2Scene() {
   const dispatch = useDispatch()
 
   // 筛选和分页
-  const [tableSelect, setTableSelect] = useState<B2FromDataType>({
-    siteArr: undefined,
-    province: '',
-    city: '',
-    region: '',
-    auditStatus: '',
-    roomName: '',
-    searchKey: '',
-    pageSize: 10,
-    pageNum: 1,
-    isSiteEmpty: 0
-  })
+  const [tableSelect, setTableSelect] = useState(baseTableSelect)
 
   const tableSelectRef = useRef({} as B2FromDataType)
 
@@ -65,7 +67,38 @@ function B2Scene() {
   }, [dispatch])
 
   useEffect(() => {
+    // 从进度统计进来------带入参数
+    const urlStr = decodeURI(window.location.href)
+    if (urlStr.includes('?C=')) {
+      const path = urlStr.split('?C=')[1]
+      const pathArr = path.split('/')
+
+      const obj: B2FromDataType = {
+        ...baseTableSelect,
+        siteArr: pathArr
+      }
+
+      setTableSelect(obj)
+
+      // 注意 这里有个坑。 setTableSelect 不能直接设置 province 和 city
+      tableSelectRef.current = { ...obj, province: pathArr[0], city: pathArr[1] || '' }
+    }
+
+    if (urlStr.includes('?N=')) {
+      const obj: B2FromDataType = {
+        ...baseTableSelect,
+        isSiteEmpty: 1
+      }
+
+      setTableSelect(obj)
+      tableSelectRef.current = obj
+    }
+
     getListFu()
+  }, [getListFu])
+
+  useEffect(() => {
+    if (timeKey !== -1) getListFu()
   }, [getListFu, timeKey])
 
   // 输入框的改变
@@ -89,18 +122,7 @@ function B2Scene() {
   const resetSelectFu = useCallback(() => {
     // 把2个输入框和时间选择器清空
     setInputKey(Date.now())
-    setTableSelect({
-      siteArr: undefined,
-      province: '',
-      city: '',
-      region: '',
-      auditStatus: '',
-      roomName: '',
-      searchKey: '',
-      pageSize: 10,
-      pageNum: 1,
-      isSiteEmpty: 0
-    })
+    setTableSelect(baseTableSelect)
     setTimeout(() => {
       setTimeKey(Date.now())
     }, 50)
@@ -555,7 +577,7 @@ function B2Scene() {
       ) : null}
 
       {/* 查看重复的场景 */}
-      {lookReDo ? <LookReDo closePageFu={() => setLookReDo(false)} /> : null}
+      {lookReDo ? <LookReDo closePageFu={() => setLookReDo(false)} apiUrl='scene' /> : null}
 
       {/* 修改机房编码 */}
       {editNum.num ? (

+ 3 - 27
src/store/action/B1Plan.ts

@@ -1,30 +1,5 @@
 import http from '@/utils/http'
 import { AppDispatch } from '..'
-/**
- * 获取 进度统计 表格列表(存到仓库)-按机房
- */
-export const B1_APIgetlist = (data: any): any => {
-  return async (dispatch: AppDispatch) => {
-    const res = await http.post('cms/schedule/pageList', data)
-    if (res.code === 0) {
-      const obj = {
-        list: res.data.records.map((v: any, index: number) => ({
-          ...v,
-          idKey: v.id + '' + index
-        })),
-        total: res.data.total
-      }
-      dispatch({ type: 'B1/getList', payload: obj })
-    }
-  }
-}
-
-/**
- * 获取 机房管理 表格列表(导出表格)-按机房
- */
-export const B1_APIgetlistAll = (data: any) => {
-  return http.post('cms/schedule/pageList', data)
-}
 
 /**
  * 获取 进度统计 表格列表(存到仓库)-按区域
@@ -33,7 +8,7 @@ export const B1_APIgetlistArea = (data: any): any => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post('cms/schedule/report/region', data)
     if (res.code === 0) {
-      const arr: any = res.data
+      const arr: any = res.data.region || []
 
       const arr2: any = []
 
@@ -50,7 +25,8 @@ export const B1_APIgetlistArea = (data: any): any => {
 
       const obj = {
         list: arr2,
-        total: res.data.length
+        total: arr.length,
+        time: res.data.cacheTime
       }
       dispatch({ type: 'B1/getListArea', payload: obj })
     }

+ 2 - 2
src/store/action/B2Scene.ts

@@ -47,8 +47,8 @@ export const B2_APIAudit = (data: any) => {
 /**
  * 重复的场景
  */
-export const B2_APIlookReDo = () => {
-  return http.get('cms/scene/duplicateRoom')
+export const B2_APIlookReDo = (url: 'recycle' | 'scene') => {
+  return http.get(`cms/${url}/duplicateRoom`)
 }
 
 // /**

+ 11 - 23
src/store/reducer/B1Plan.ts

@@ -1,38 +1,26 @@
-import { B1tableAreaType, B1tableType } from "@/types";
+import { B1tableAreaType } from '@/types'
 
 // 初始化状态
 const initState = {
-  // 列表数据
-  B1TableList: {
-    list: [] as B1tableType[],
-    total: 0,
-  },
   B1TableListArea: {
     list: [] as B1tableAreaType[],
     total: 0,
-  },
-};
+    time: ''
+  }
+}
 
 // 定义 action 类型
-type Props =
-  | {
-      type: "B1/getList";
-      payload: { list: B1tableType[]; total: number };
-    }
-  | {
-      type: "B1/getListArea";
-      payload: { list: B1tableAreaType[]; total: number };
-    };
+type Props = {
+  type: 'B1/getListArea'
+  payload: { list: B1tableAreaType[]; total: number; time: string }
+}
 
 // reducer
 export default function Reducer(state = initState, action: Props) {
   switch (action.type) {
-    // 获取列表数据
-    case "B1/getList":
-      return { ...state, B1TableList: action.payload };
-    case "B1/getListArea":
-      return { ...state, B1TableListArea: action.payload };
+    case 'B1/getListArea':
+      return { ...state, B1TableListArea: action.payload }
     default:
-      return state;
+      return state
   }
 }

+ 14 - 34
src/types/api/B1Plan.d.ts

@@ -1,35 +1,15 @@
-export type B1tableType = {
-  auditDesc: string;
-  auditStatus: number;
-  city: string;
-  region: string;
-  creatorId: nulll | number;
-  createTime: string;
-  creatorName: string;
-  id: number;
-  jsonDesc: string;
-  jsonStatus: number;
-  name: string;
-  pmName: string;
-  province: string;
-  pushDesc: string;
-  pushStatus: number;
-  roomNum: string;
-  sceneCode: string;
-  siteNum: string;
-  updateTime: string;
-};
 export type B1tableAreaType = {
-  cityAll:string
-  id:string
-  pcsCalculate: number;
-  pcsFirst: number;
-  pcsPass: number;
-  pcsPushJson: number;
-  pcsPushLink: number;
-  pcsPushScene: number;
-  pcsReject: number;
-  pcsRoom: number;
-  pcsScene: number;
-  region: string;
-};
+  cityAll: string
+  id: string
+  pcsCalculate: number
+  pcsFirst: number
+  pcsPass: number
+  pcsPushJson: number
+  pcsPushLink: number
+  pcsPushScene: number
+  pcsReject: number
+  pcsRoom: number
+  pcsScene: number
+  region: string
+  pcsSceneDistinct: number
+}