瀏覽代碼

修复地址显示 - -的问题

shaogen1995 11 月之前
父節點
當前提交
9b92ac2da1

+ 7 - 2
src/pages/A1Camera/index.tsx

@@ -150,7 +150,10 @@ function A1Camera() {
             sheetData: res.data.records.map((item: A1ListType) => ({
               cameraType: item.cameraType ? (item.cameraType === 'KK' ? '看看' : '看见') : '空',
               cameraSn: item.cameraSn,
-              myCity: !item.zlProvince && !item.zlCity ? '空' : `${item.zlProvince}-${item.zlCity}`,
+              myCity:
+                !item.zlProvince && !item.zlCity
+                  ? '空'
+                  : `${item.zlProvince}${item.zlCity ? '-' + item.zlCity : ''}`,
               zlUser: item.zlUser || '空',
               zlPhone: item.zlPhone || '空',
               statusSale: item.statusSale || '空',
@@ -211,7 +214,9 @@ function A1Camera() {
       {
         title: '当前所在地区',
         render: (item: A1ListType) =>
-          !item.zlProvince && !item.zlCity ? '(空)' : `${item.zlProvince}-${item.zlCity}`
+          !item.zlProvince && !item.zlCity
+            ? '(空)'
+            : `${item.zlProvince}${item.zlCity ? '-' + item.zlCity : ''}`
       },
       {
         title: '城市负责人',

+ 7 - 2
src/pages/A2Abusiness/index.tsx

@@ -169,7 +169,10 @@ function A2Abusiness() {
               dateStart: item.dateStart || '空',
               dateEnd: item.dateEnd || '空',
               zlName: item.zlName || '空',
-              myCity: !item.zlProvince && !item.zlCity ? '空' : `${item.zlProvince}-${item.zlCity}`,
+              myCity:
+                !item.zlProvince && !item.zlCity
+                  ? '空'
+                  : `${item.zlProvince}${item.zlCity ? '-' + item.zlCity : ''}`,
               zlUser: item.zlUser || '空',
               zlPhone: item.zlPhone || '空',
               pcs: item.pcs || '空',
@@ -238,7 +241,9 @@ function A2Abusiness() {
       {
         title: '地区',
         render: (item: A2AListType) =>
-          !item.zlProvince && !item.zlCity ? '(空)' : `${item.zlProvince}-${item.zlCity}`
+          !item.zlProvince && !item.zlCity
+            ? '(空)'
+            : `${item.zlProvince}${item.zlCity ? '-' + item.zlCity : ''}`
       },
       {
         title: '负责人',

+ 4 - 2
src/pages/A2Psychz/index.tsx

@@ -204,7 +204,9 @@ function A2Psychz() {
         render: (item: A2tableType) =>
           !item.province && !item.city && !item.region
             ? '(空)'
-            : `${item.province}-${item.city}-${item.region}`
+            : `${item.province}${item.city ? '-' + item.city : ''}${
+                item.region ? '-' + item.region : ''
+              }`
       },
       {
         title: '详细地址',
@@ -318,7 +320,7 @@ function A2Psychz() {
               myCity:
                 !v.province && !v.city && !v.region
                   ? '(空)'
-                  : `${v.province}-${v.city}-${v.region}`,
+                  : `${v.province}${v.city ? '-' + v.city : ''}-${v.region ? '-' + v.region : ''}`,
               address: v.address || '(空)',
               name: v.name || '(空)',
               siteNum: v.siteNum || '(空)',

+ 4 - 2
src/pages/B2Scene/index.tsx

@@ -201,7 +201,9 @@ function B2Scene() {
         render: (item: B2tableType) =>
           !item.province && !item.city && !item.region
             ? '(空)'
-            : `${item.province}-${item.city}-${item.region}`
+            : `${item.province}${item.city ? '-' + item.city : ''}${
+                item.region ? '-' + item.region : ''
+              }`
       },
       {
         title: '站址名称',
@@ -370,7 +372,7 @@ function B2Scene() {
               myCity:
                 !v.province && !v.city && !v.region
                   ? '(空)'
-                  : `${v.province}-${v.city}-${v.region}`,
+                  : `${v.province}${v.city ? '-' + v.city : ''}${v.region ? '-' + v.region : ''}`,
               pmName: v.creatorId === 1 ? '管理员' : v.pmName || '(空)',
               sceneName: v.sceneName || '(空)',
               link: v.link || '(空)',

+ 182 - 212
src/pages/B3Push/index.tsx

@@ -1,388 +1,359 @@
-import React, {
-  useCallback,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
-import styles from "./index.module.scss";
-import {
-  Button,
-  Cascader,
-  Input,
-  Popconfirm,
-  Select,
-  Table,
-  Tooltip,
-} from "antd";
-import { useDispatch, useSelector } from "react-redux";
-import { B3FromDataType } from "./data";
-import { B1options2, B1options2Obj } from "../B1Plan/data";
-import { QuestionCircleOutlined } from "@ant-design/icons";
-import {
-  B3_APIgetlist,
-  B3_APIgetlistAll,
-  B3_APIpush,
-} from "@/store/action/B3Push";
-import { RootState } from "@/store";
-import { B3tableType } from "@/types";
-import { MessageFu } from "@/utils/message";
-import { mapDataAll1 } from "../C1User/AddUser/city";
-import ExportJsonExcel from "js-export-excel";
-import dayjs from "dayjs";
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { Button, Cascader, Input, Popconfirm, Select, Table, Tooltip } from 'antd'
+import { useDispatch, useSelector } from 'react-redux'
+import { B3FromDataType } from './data'
+import { B1options2, B1options2Obj } from '../B1Plan/data'
+import { QuestionCircleOutlined } from '@ant-design/icons'
+import { B3_APIgetlist, B3_APIgetlistAll, B3_APIpush } from '@/store/action/B3Push'
+import { RootState } from '@/store'
+import { B3tableType } from '@/types'
+import { MessageFu } from '@/utils/message'
+import { mapDataAll1 } from '../C1User/AddUser/city'
+import ExportJsonExcel from 'js-export-excel'
+import dayjs from 'dayjs'
 
 function B3Push() {
-  const dispatch = useDispatch();
+  const dispatch = useDispatch()
 
   // 筛选和分页
   const [tableSelect, setTableSelect] = useState<B3FromDataType>({
     siteArr: undefined,
-    province: "",
-    city: "",
-    region: "",
-    pmUser: "",
-    pushStatus: "",
-    searchKey: "",
+    province: '',
+    city: '',
+    region: '',
+    pmUser: '',
+    pushStatus: '',
+    searchKey: '',
     pageSize: 10,
-    pageNum: 1,
-  });
+    pageNum: 1
+  })
 
-  const tableSelectRef = useRef({} as B3FromDataType);
+  const tableSelectRef = useRef({} as B3FromDataType)
 
   useEffect(() => {
-    tableSelectRef.current = { ...tableSelect };
-  }, [tableSelect]);
+    tableSelectRef.current = { ...tableSelect }
+  }, [tableSelect])
 
   // 点击搜索的 时间戳
-  const [timeKey, setTimeKey] = useState(-1);
+  const [timeKey, setTimeKey] = useState(-1)
 
   // 发送接口的函数
   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(B3_APIgetlist(obj));
-  }, [dispatch]);
+      ...objTemp
+    }
+    dispatch(B3_APIgetlist(obj))
+  }, [dispatch])
 
   useEffect(() => {
-    getListFu();
-  }, [getListFu, timeKey]);
+    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 clickSearch = useCallback(() => {
-    setTableSelect({ ...tableSelect, pageNum: 1 });
+    setTableSelect({ ...tableSelect, pageNum: 1 })
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, [tableSelect]);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [tableSelect])
 
   // 点击重置
-  const [inputKey, setInputKey] = useState(1);
+  const [inputKey, setInputKey] = useState(1)
   const resetSelectFu = useCallback(() => {
     // 把2个输入框和时间选择器清空
-    setInputKey(Date.now());
+    setInputKey(Date.now())
     setTableSelect({
       siteArr: undefined,
-      province: "",
-      city: "",
-      region: "",
-      pmUser: "",
-      pushStatus: "",
-      searchKey: "",
+      province: '',
+      city: '',
+      region: '',
+      pmUser: '',
+      pushStatus: '',
+      searchKey: '',
       pageSize: 10,
-      pageNum: 1,
-    });
+      pageNum: 1
+    })
     setTimeout(() => {
-      setTimeKey(Date.now());
-    }, 50);
-  }, []);
+      setTimeKey(Date.now())
+    }, 50)
+  }, [])
 
   // 从仓库获取列表
-  const B3TableList = useSelector(
-    (state: RootState) => state.B3Push.B3TableList
-  );
+  const B3TableList = useSelector((state: RootState) => state.B3Push.B3TableList)
 
   // 页码变化
   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 [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
-  const selectedRef = useRef([] as string[]);
+  const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
+  const selectedRef = useRef([] as string[])
 
   // 点击推送
-  const pushsTit = useRef([0, 0, 0]);
+  const pushsTit = useRef([0, 0, 0])
 
   const pushFu = useCallback(
     async (code: string) => {
-      if (code.split(",").length <= 0) return;
+      if (code.split(',').length <= 0) return
 
-      const res = await B3_APIpush(code.split(","));
+      const res = await B3_APIpush(code.split(','))
 
       if (res.code === 0) {
-        MessageFu.success("操作成功!");
+        MessageFu.success('操作成功!')
         // 清空选中
-        setSelectedRowKeys([]);
-        selectedRef.current = [];
-        getListFu();
+        setSelectedRowKeys([])
+        selectedRef.current = []
+        getListFu()
       }
     },
     [getListFu]
-  );
+  )
 
   const columns = useMemo(() => {
     return [
       {
-        title: "机房编码",
-        render: (item: B3tableType) => item.roomNum || "(空)",
+        title: '机房编码',
+        render: (item: B3tableType) => item.roomNum || '(空)'
       },
       {
-        title: "站址地区",
+        title: '站址地区',
         render: (item: B3tableType) =>
           !item.province && !item.city && !item.region
-            ? "(空)"
-            : `${item.province}-${item.city}-${item.region}`,
+            ? '(空)'
+            : `${item.province}${item.city ? '-' + item.city : ''}${
+                item.region ? '-' + item.region : ''
+              }`
       },
       {
-        title: "项目经理",
+        title: '项目经理',
         render: (item: B3tableType) => {
-          if (item.creatorId === 1) return "管理员";
+          if (item.creatorId === 1) return '管理员'
           else {
-            return item.pmName || "(空)";
+            return item.pmName || '(空)'
           }
-        },
+        }
       },
       {
-        title: "场景码",
-        render: (item: B3tableType) => item.sceneCode || "(空)",
+        title: '场景码',
+        render: (item: B3tableType) => item.sceneCode || '(空)'
       },
       {
-        title: "场景推送状态",
+        title: '场景推送状态',
         render: (item: B3tableType) => (
           <>
-            {Reflect.get(B1options2Obj, item.pushStatus) || "(空)"}
-            <span style={{ cursor: "pointer" }} hidden={!item.pushDesc}>
+            {Reflect.get(B1options2Obj, item.pushStatus) || '(空)'}
+            <span style={{ cursor: 'pointer' }} hidden={!item.pushDesc}>
               <Tooltip title={item.pushDesc}>
                 &nbsp;
                 <QuestionCircleOutlined rev={undefined} />
               </Tooltip>
             </span>
           </>
-        ),
+        )
       },
       {
-        title: "场景推送时间",
-        render: (item: B3tableType) => item.pushTime || "(空)",
+        title: '场景推送时间',
+        render: (item: B3tableType) => item.pushTime || '(空)'
       },
       {
-        title: "操作",
+        title: '操作',
         render: (item: B3tableType) => (
           <Button
             disabled={item.pushStatus === 2 || item.pushStatus === 1}
-            size="small"
-            type="text"
+            size='small'
+            type='text'
             onClick={() => pushFu(item.sceneCode)}
           >
             推送
           </Button>
-        ),
-      },
-    ];
-  }, [pushFu]);
+        )
+      }
+    ]
+  }, [pushFu])
 
   // 点击导出
   const deriveFu = useCallback(async () => {
     if (B3TableList.total > 30000)
-      return MessageFu.warning(
-        "只支持导出最多30000条数据。请增加筛选条件,并重新尝试"
-      );
+      return MessageFu.warning('只支持导出最多30000条数据。请增加筛选条件,并重新尝试')
 
-    if (B3TableList.list.length === 0)
-      return MessageFu.warning("当前搜索条件没有数据!");
-    const name = "场景推送" + dayjs(new Date()).format("YYYY-MM-DD HH:mm");
+    if (B3TableList.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 B3_APIgetlistAll({
       ...tableSelect,
       ...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,
         datas: [
           {
             sheetData: res.data.records.map((v: B3tableType) => ({
-              roomNum: v.roomNum || "(空)",
+              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 || "(空)",
-              pushStatus: Reflect.get(B1options2Obj, v.pushStatus) || "(空)",
-              pushStatusTxt: v.pushDesc || "(空)",
-              pushTime: v.pushTime || "(空)",
+                  ? '(空)'
+                  : `${v.province}${v.city ? '-' + v.city : ''}${v.region ? '-' + v.region : ''}`,
+              pmName: v.creatorId === 1 ? '管理员' : v.pmName || '(空)',
+              sceneCode: v.sceneCode || '(空)',
+              pushStatus: Reflect.get(B1options2Obj, v.pushStatus) || '(空)',
+              pushStatusTxt: v.pushDesc || '(空)',
+              pushTime: v.pushTime || '(空)'
             })),
             sheetName: name,
             sheetFilter: [
-              "roomNum",
-              "myCity",
-              "pmName",
-              "sceneCode",
-              "pushStatus",
-              "pushStatusTxt",
-              "pushTime",
+              'roomNum',
+              'myCity',
+              'pmName',
+              'sceneCode',
+              'pushStatus',
+              'pushStatusTxt',
+              'pushTime'
             ],
             sheetHeader: [
-              "机房编码",
-              "站址地区",
-              "项目经理",
-              "场景码",
-              "场景推送状态",
-              "场景推送状态描述",
-              "场景推送时间",
+              '机房编码',
+              '站址地区',
+              '项目经理',
+              '场景码',
+              '场景推送状态',
+              '场景推送状态描述',
+              '场景推送时间'
             ],
-            columnWidths: [10, 10, 10, 10, 10, 10, 10],
-          },
-        ],
-      };
+            columnWidths: [10, 10, 10, 10, 10, 10, 10]
+          }
+        ]
+      }
 
-      const toExcel = new ExportJsonExcel(option); //new
-      toExcel.saveExcel(); //保存
+      const toExcel = new ExportJsonExcel(option) //new
+      toExcel.saveExcel() //保存
     }
-  }, [B3TableList.list.length, B3TableList.total, tableSelect]);
+  }, [B3TableList.list.length, B3TableList.total, tableSelect])
 
   return (
     <div className={styles.B3Push}>
-      <div className="pageTitle">
+      <div className='pageTitle'>
         场景推送&emsp;<span>仅显示审核通过的场景</span>
       </div>
       {/*顶部筛选 */}
-      <div className="B3top">
-        <div className="B3topSon">
-          <div className="B3topRow">
+      <div className='B3top'>
+        <div className='B3topSon'>
+          <div className='B3topRow'>
             <span>搜索项:</span>
             <Input
               key={inputKey}
               maxLength={24}
               style={{ width: 260 }}
-              placeholder="请输入机房编码/场景码,最多24字"
+              placeholder='请输入机房编码/场景码,最多24字'
               allowClear
-              onChange={(e) => txtChangeFu(e.target.value, "searchKey")}
+              onChange={e => txtChangeFu(e.target.value, 'searchKey')}
             />
           </div>
 
-          <div className="B3topRow">
+          <div className='B3topRow'>
             <span>站址地区:</span>
             <Cascader
               changeOnSelect
               value={tableSelect.siteArr}
               style={{ width: 200 }}
               options={mapDataAll1}
-              placeholder="全部"
-              onChange={(e) =>
-                setTableSelect({ ...tableSelect, siteArr: e as string[] })
-              }
+              placeholder='全部'
+              onChange={e => setTableSelect({ ...tableSelect, siteArr: e as string[] })}
             />
           </div>
 
-          <div className="B3topRow">
+          <div className='B3topRow'>
             <span>项目经理:</span>
             <Input
               key={inputKey}
               maxLength={10}
               style={{ width: 200 }}
-              placeholder="请输入姓名,最多10字"
+              placeholder='请输入姓名,最多10字'
               allowClear
-              onChange={(e) => txtChangeFu(e.target.value, "pmUser")}
+              onChange={e => txtChangeFu(e.target.value, 'pmUser')}
             />
           </div>
         </div>
-        <div className="B3topSon B3topSon2">
+        <div className='B3topSon B3topSon2'>
           <div>
-            <div className="B3topRow">
+            <div className='B3topRow'>
               <span>场景推送状态:</span>
               <Select
                 style={{ width: 194 }}
                 value={tableSelect.pushStatus}
-                onChange={(e) =>
-                  setTableSelect({ ...tableSelect, pushStatus: e })
-                }
+                onChange={e => setTableSelect({ ...tableSelect, pushStatus: e })}
                 options={B1options2}
               />
             </div>
           </div>
           <div>
             <Button onClick={resetSelectFu}>重置</Button>&emsp;
-            <Button type="primary" onClick={clickSearch}>
+            <Button type='primary' onClick={clickSearch}>
               查询
             </Button>
             &emsp;
             <Popconfirm
-              placement="bottomRight"
+              placement='bottomRight'
               title={
                 <>
                   请确定是否推送所选文件?
-                  <br /> 当前共选中{pushsTit.current[0]}个机房编码 <br />共
-                  {pushsTit.current[1]}个场景可推送
+                  <br /> 当前共选中{pushsTit.current[0]}个机房编码 <br />共{pushsTit.current[1]}
+                  个场景可推送
                 </>
               }
-              okText="推送"
-              cancelText="取消"
-              onConfirm={() => pushFu(selectedRef.current.join(","))}
+              okText='推送'
+              cancelText='取消'
+              onConfirm={() => pushFu(selectedRef.current.join(','))}
               okButtonProps={{ loading: false }}
               disabled={selectedRowKeys.length <= 0}
             >
-              <Button type="primary" disabled={selectedRowKeys.length <= 0}>
+              <Button type='primary' disabled={selectedRowKeys.length <= 0}>
                 批量推送
               </Button>
             </Popconfirm>
             &nbsp;
-            <Tooltip title="仅推送审核通过 且 未推送或推送失败的文件">
-              <QuestionCircleOutlined
-                rev={undefined}
-                style={{ cursor: "pointer" }}
-              />
+            <Tooltip title='仅推送审核通过 且 未推送或推送失败的文件'>
+              <QuestionCircleOutlined rev={undefined} style={{ cursor: 'pointer' }} />
             </Tooltip>
             &emsp;
-            <Button type="primary" onClick={deriveFu}>
+            <Button type='primary' onClick={deriveFu}>
               导出表格
             </Button>
           </div>
@@ -390,54 +361,53 @@ function B3Push() {
       </div>
 
       {/* 表格主体 */}
-      <div className="tableMain">
+      <div className='tableMain'>
         <Table
           rowSelection={{
-            type: "checkbox",
+            type: 'checkbox',
             selectedRowKeys,
             onChange: (keys: React.Key[], arr) => {
               // 用于表格数据的勾选状态在页面显示
-              setSelectedRowKeys(keys);
+              setSelectedRowKeys(keys)
 
               // 用于发送接口的code数组
-              selectedRef.current = arr.map((v) => v.sceneCode);
+              selectedRef.current = arr.map(v => v.sceneCode)
 
               // 用于批量推送的文字提示
               pushsTit.current = [
                 arr.length,
-                arr.filter((v) => v.pushStatus !== 2 && v.pushStatus !== 1)
-                  .length,
-              ];
+                arr.filter(v => v.pushStatus !== 2 && v.pushStatus !== 1).length
+              ]
             },
-            getCheckboxProps: (item) => {
+            getCheckboxProps: item => {
               return {
-                disabled: item.pushStatus === 2 || item.pushStatus === 1,
-              };
-            },
+                disabled: item.pushStatus === 2 || item.pushStatus === 1
+              }
+            }
           }}
           scroll={{ y: 578 }}
           dataSource={B3TableList.list}
           columns={columns}
-          rowKey="id"
+          rowKey='id'
           pagination={{
             showQuickJumper: true,
-            position: ["bottomCenter"],
+            position: ['bottomCenter'],
             showSizeChanger: true,
             current: tableSelect.pageNum,
             pageSize: tableSelect.pageSize,
             total: B3TableList.total,
-            onChange: paginationChange(),
+            onChange: paginationChange()
           }}
         />
       </div>
       {/*  右下角的列表数量 */}
-      <div className="tableNumBox">
+      <div className='tableNumBox'>
         共 <span>{B3TableList.total}</span> 条数据
       </div>
     </div>
-  );
+  )
 }
 
-const MemoB3Push = React.memo(B3Push);
+const MemoB3Push = React.memo(B3Push)
 
-export default MemoB3Push;
+export default MemoB3Push

+ 169 - 186
src/pages/B4JsonPush/index.tsx

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