Просмотр исходного кода

机房-站址地区筛选更新

shaogen1995 1 год назад
Родитель
Сommit
8de1d7f1c7
3 измененных файлов с 41 добавлено и 12 удалено
  1. 1 1
      src/pages/A2Psychz/data.ts
  2. 32 10
      src/pages/A2Psychz/index.tsx
  3. 8 1
      src/store/action/A2Psychz.ts

+ 1 - 1
src/pages/A2Psychz/data.ts

@@ -1,6 +1,6 @@
 export type A2FromDataType = {
   siteLevel: 2;
-  site: string[] | undefined;
+  site: string;
   searchKey: string;
   pmUser: string;
   typeIn: "" | "pc" | "app-scan" | "app-manual";

+ 32 - 10
src/pages/A2Psychz/index.tsx

@@ -6,11 +6,11 @@ import React, {
   useState,
 } from "react";
 import styles from "./index.module.scss";
-import { Button, Cascader, Input, Popconfirm, Select, Table } from "antd";
+import { Button, Input, Popconfirm, Select, Table } from "antd";
 import { useDispatch, useSelector } from "react-redux";
 import { A2FromDataType, options1 } from "./data";
-import mapDataAll from "../C1User/AddUser/city";
 import {
+  A2_APIgetCity,
   A2_APIgetlist,
   A2_APIgetlistDerive,
   A2_APIremoves,
@@ -24,12 +24,35 @@ import dayjs from "dayjs";
 import ExportJsonExcel from "js-export-excel";
 
 function A2Psychz() {
+  // 站址地区的数据-下拉框
+
+  const [optionsCity, setOptionsCity] = useState<
+    { value: string; label: string }[]
+  >([]);
+
+  const getCityFu = useCallback(async () => {
+    const res = await A2_APIgetCity();
+    if (res.code === 0) {
+      const data: string[] = res.data;
+      const arr = data.map((v) => ({
+        value: v,
+        label: v,
+      }));
+      setOptionsCity([{ value: "", label: "全部" }, ...arr]);
+      // console.log(123, res);
+    }
+  }, []);
+
+  useEffect(() => {
+    getCityFu();
+  }, [getCityFu]);
+
   const dispatch = useDispatch();
 
   // 筛选和分页
   const [tableSelect, setTableSelect] = useState<A2FromDataType>({
     siteLevel: 2,
-    site: undefined,
+    site: "",
     searchKey: "",
     pmUser: "",
     typeIn: "",
@@ -41,7 +64,7 @@ function A2Psychz() {
   const getListFu = useCallback(() => {
     const obj = {
       ...tableSelect,
-      site: tableSelect.site ? tableSelect.site[1] : null,
+      site: tableSelect.site ? tableSelect.site : null,
     };
     dispatch(A2_APIgetlist(obj));
   }, [dispatch, tableSelect]);
@@ -69,7 +92,7 @@ function A2Psychz() {
     setInputKey(Date.now());
     setTableSelect({
       siteLevel: 2,
-      site: undefined,
+      site: "",
       searchKey: "",
       pmUser: "",
       typeIn: "",
@@ -270,14 +293,13 @@ function A2Psychz() {
         <div className="A2top1">
           <div className="A2topRow">
             <span>站址地区:</span>
-            <Cascader
+            <Select
+              style={{ width: 130 }}
               value={tableSelect.site}
-              style={{ width: 160 }}
-              options={mapDataAll}
-              placeholder="全部"
               onChange={(e) =>
-                setTableSelect({ ...tableSelect, site: e as string[] })
+                setTableSelect({ ...tableSelect, site: e, pageNum: 1 })
               }
+              options={optionsCity}
             />
           </div>
 

+ 8 - 1
src/store/action/A2Psychz.ts

@@ -45,4 +45,11 @@ export const A2_APIadd = (data: any) => {
  */
 export const A2_APIgetInfo = (id:number) => {
   return http.get(`cms/room/detail/${id}`);
-};
+};
+
+/**
+ * 机房管理-站址地区下拉框
+ */
+export const A2_APIgetCity = () => {
+  return http.get('cms/room/getCity');
+};