|
|
@@ -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>
|