Explorar o código

取消和map集合的依赖关系

nahida hai 1 ano
pai
achega
f10aae2f39
Modificáronse 4 ficheiros con 45 adicións e 22 borrados
  1. 2 1
      src/app/invoke/map.ts
  2. 40 17
      src/app/invoke/page.tsx
  3. 2 2
      src/app/timeTask/map.ts
  4. 1 2
      src/app/timeTask/page.tsx

+ 2 - 1
src/app/invoke/map.ts

@@ -103,4 +103,5 @@ serviceMap.set("xcrOtherInfo37ServiceImpl","interface/v1/datawarehouse/list");
 serviceMap.set("xcrOtherInfo38ServiceImpl","interface/v1/datawarehouse/list");
 serviceMap.set("xcrOtherInfo39ServiceImpl","interface/v1/datawarehouse/list");
 serviceMap.set("xcrTrustworthyIncentive42ServiceImpl","interface/v1/datawarehouse/list");
-serviceMap.set("xcrDishonestyPunishment19ServiceImpl","interface/v1/datawarehouse/list");
+serviceMap.set("xcrDishonestyPunishment19ServiceImpl","interface/v1/datawarehouse/list");
+serviceMap.set("xcrEBaseinfoServiceImpl","");

+ 40 - 17
src/app/invoke/page.tsx

@@ -1,5 +1,5 @@
 'use client'
-import React, { useCallback, useEffect, useState } from 'react';
+import React, {useCallback, useEffect, useRef, useState} from 'react';
 import { Button, Card, Col, List, message, Modal, Row, Table, type TablePaginationConfig } from 'antd';
 import LadderShapedTab from '@/components/LadderShapedTab';
 import { usePathname } from 'next/navigation';
@@ -10,9 +10,11 @@ import { PaginationConfig } from 'antd/es/pagination';
 import { serviceNameMap } from '@/app/timeTask/map';
 import { serverGet } from "@/utils/axiosServer";
 import Search from "antd/es/input/Search";
+import {spread} from "axios";
 
 function Page() {
   const pathname = usePathname();
+  const contentRef = useRef<HTMLDivElement>(null);
   const [dataList, setDataList] = useState<string[]>([]);
   const [paginationConfig, setPaginationConfig] = useState<PaginationConfig>({
     current: 1,
@@ -46,7 +48,7 @@ function Page() {
   const handleInvoke = (taskName: string) => {
     Modal.confirm({
       title: '确认同步',
-      content: `确定要同步数据 "${serviceNameMap.get(taskName)}" 吗?`,
+      content: `确定要同步数据 "${taskName}" 吗?`,
       onOk: async () => {
         // 调用任务的逻辑
         const res = await clientGet<any, ClientResponse>('/api/invokeTask', {
@@ -54,7 +56,7 @@ function Page() {
             taskName
           }
         });
-        console.log(res);
+        // console.log(res);
         if (res.code !== 200) {
           message.error(res.data);
           return;
@@ -68,13 +70,27 @@ function Page() {
     });
   };
 
-  const handleSearch = (text: string) => {
+  const handleSearch = async (text: string) => {
     if(text.length === 0){
       message.info('搜索内容不能为空');
       return;
     }
-    //todo
-    const filtered = dataList.filter(item => serviceNameMap.get(item)?.toLowerCase().includes(text.toLowerCase()));
+    const res = await clientGet<BasePageRequest, TimeTaskClientResponse>('/api/invoke', {
+      params: {
+        pageNum: 1,
+        pageSize: -1>>>1
+      }
+    });
+    if(res.code !== 200){
+      message.error("当次搜索出现问题");
+    }
+    // const arr = Array.from(serviceNameMap.values());
+    // const filter = arr.filter(q=>q.toLowerCase().includes(text.toLowerCase()));
+    // // console.log(filter);
+    // const filtered = Array.from(serviceNameMap.entries())
+    //   .filter(([key, value]) => filter.includes(value))
+    //   .map(([key, value]) => key);
+    const filtered = res.data.list.filter(q=>q.taskName.toLowerCase().includes(text.toLowerCase())).map((item)=>item.taskName)
     setSearchResults(filtered);
     if (filtered.length === 0) {
       Modal.info({
@@ -84,9 +100,15 @@ function Page() {
         cancelText: '取消'
       });
     } else {
-      Modal.info({
-        title: '搜索结果',
-        content: (
+      showInfoModal(filtered);
+    }
+  };
+
+  const showInfoModal = (filtered:string[]) => {
+    Modal.info({
+      title: '搜索结果',
+      content: (
+        <div ref={contentRef} style={{ maxHeight: '70vh', overflowY: 'auto', padding: 16 }}>
           <List
             size={'small'}
             dataSource={filtered}
@@ -94,16 +116,17 @@ function Page() {
               <List.Item actions={[
                 <Button type={'primary'} onClick={() => handleInvoke(item)}>调用</Button>
               ]}>
-                <span>{serviceNameMap.get(item)}</span>
+                <span>{item}</span>
               </List.Item>
             )}
           />
-        ),
-        okText: '确定',
-        cancelText: '取消',
-        maskClosable: true
-      });
-    }
+        </div>
+      ),
+      style: { top: 20, height: '80vh' },
+      okText: '确定',
+      cancelText: '取消',
+      maskClosable: true
+    });
   };
 
   useEffect(() => {
@@ -144,7 +167,7 @@ function Page() {
           renderItem={(item) => (
             <List.Item className={'flex justify-around'}>
               <Col span={18}>
-                {serviceNameMap.get(item)}
+                {item}
               </Col>
               <Col span={6}>
                 <Button type={'primary'} onClick={() => handleInvoke(item)}>调用</Button>

+ 2 - 2
src/app/timeTask/map.ts

@@ -27,7 +27,7 @@ serviceNameMap.set("xcrEnterprisePublicityDetailsContributionsContributorsServic
 serviceNameMap.set("xcrEnterprisePublicationSupplySubscribedDetailsInvestorsServiceImpl", "企业公示_出资人认缴明细");
 serviceNameMap.set("xcrRevisionInformationAgriculturalCollegeAnnualReportServiceImpl", "农专年报修改信息");
 serviceNameMap.set("xcrBasicSupplementAgriculturalCollegeAnnualServiceImpl", "农专年报基本信息补充");
-serviceNameMap.set("xcrEnterpriseBasicInformationServiceImpl", "企业基本信息");
+// serviceNameMap.set("xcrEnterpriseBasicInformationServiceImpl", "企业基本信息");
 serviceNameMap.set("xcrEnterpriseNameApprovalServiceImpl", "企业名称信息");
 serviceNameMap.set("xcrSeriousIllegalDishonestEnterprisesServiceImpl", "严重违法失信企业名单");
 serviceNameMap.set("xcrSeriousIllegalDishonestEnterprisesDetailServiceImpl", "严重违法失信企业详细信息");
@@ -105,4 +105,4 @@ serviceNameMap.set("xcrOtherInfo39ServiceImpl", "农业主体信息");
 serviceNameMap.set("xcrTrustworthyIncentive42ServiceImpl", "红名单");
 serviceNameMap.set("xcrDishonestyPunishment19ServiceImpl", "严重失信主体名单信息");
 serviceNameMap.set("xcrXinyonghuaihuaBaseInfoServiceImpl", "信用怀化基础信息");
-
+serviceNameMap.set("xcrEBaseinfoServiceImpl", "企业基本信息");

+ 1 - 2
src/app/timeTask/page.tsx

@@ -6,7 +6,6 @@ import LadderShapedTab from "@/components/LadderShapedTab";
 import {usePathname} from "next/navigation";
 import {clientGet, clientPost} from "@/utils/axiosClient";
 import {AreaType, ButtonType, TaskScheduleClientReponse} from "@/type/timeTask/type";
-import {serviceNameMap} from "@/app/timeTask/map";
 
 export default function page() {
   const [areas, setAreas] = useState<AreaType[]>([])
@@ -165,7 +164,7 @@ export default function page() {
                   onDrop={(e) => onDrop(e, area.id, index)}
                   style={{marginBottom: '8px'}}
                 >
-                  <Button onClick={handleClick(button)} type={button.enabled===0?'primary':'default'} danger={button.enabled===0}>{serviceNameMap.get(button.serviceName)}</Button>
+                  <Button onClick={handleClick(button)} type={button.enabled===0?'primary':'default'} danger={button.enabled===0}>{button.taskName}</Button>
                 </div>
               ))}
             </div>