Sfoglia il codice sorgente

定向调用功能以及关闭功能

nahida 1 anno fa
parent
commit
ffcf68e9e8

+ 23 - 0
src/app/api/invoke/route.ts

@@ -0,0 +1,23 @@
+import {NextRequest, NextResponse} from "next/server";
+import {serverGet} from "@/utils/axiosServer";
+import {TimeTaskServerResponse} from "@/type/invoke/type";
+import {R} from '@/utils/R'
+
+export const GET = async (request: NextRequest) => {
+  const {searchParams} = new URL(request.url);
+  const pageNum = searchParams.get("pageNum");
+  const pageSize = searchParams.get("pageSize");
+  const conditionJson = searchParams.get("conditionJson");
+
+  const res = await serverGet<BasePageRequest,TimeTaskServerResponse>("/timeTask/list",{
+    params:{
+      pageNum,
+      pageSize,
+      conditionJson
+    }
+  });
+  if(res.code !== 200){
+    return NextResponse.json(R.error(res.msg))
+  }
+  return NextResponse.json(R.success(res.data));
+}

+ 19 - 0
src/app/api/invokeTask/route.ts

@@ -0,0 +1,19 @@
+import {serverGet} from "@/utils/axiosServer";
+import {NextRequest, NextResponse} from "next/server";
+import {R} from '@/utils/R'
+
+export const GET = async (request:NextRequest)=>{
+  //拿到params参数
+  const {searchParams} = new URL(request.url)
+  const targetTableString = searchParams.get("taskName")
+  const res = await serverGet<any,BaseResponse>("/invoker",{
+    params:{
+      targetTableString
+    }
+  })
+  console.log(res);
+  if(res.code !== 200){
+    return NextResponse.json(R.error(res.msg))
+  }
+  return NextResponse.json(R.success(res.data))
+}

+ 147 - 12
src/app/invoke/page.tsx

@@ -1,25 +1,160 @@
 'use client'
-import React from 'react';
-import {Card, Col, Row} from "antd";
-import LadderShapedTab from "@/components/LadderShapedTab";
-import {usePathname} from "next/navigation";
+import React, { useCallback, useEffect, 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';
+import { clientGet } from '@/utils/axiosClient';
+import { TimeTaskClientResponse } from '@/type/invoke/type';
+import { TaskScheduleItem } from '@/type/timeTask/type';
+import { PaginationConfig } from 'antd/es/pagination';
+import { serviceNameMap } from '@/app/timeTask/map';
+import { serverGet } from "@/utils/axiosServer";
+import Search from "antd/es/input/Search";
 
 function Page() {
   const pathname = usePathname();
+  const [dataList, setDataList] = useState<string[]>([]);
+  const [paginationConfig, setPaginationConfig] = useState<PaginationConfig>({
+    current: 1,
+    pageSize: 10,
+    total: 0,
+    showTotal: (total) => `共 ${total} 条数据`,
+    locale: {
+      items_per_page: '条/页'
+    }
+  });
+  const [searchResults, setSearchResults] = useState<string[]>([]);
+
+  const getList = async (params: BasePageRequest) => {
+    const res = await clientGet<BasePageRequest, TimeTaskClientResponse>('/api/invoke', {
+      params: {
+        pageNum: params.pageNum,
+        pageSize: params.pageSize
+      }
+    });
+    if (res.code !== 200) {
+      message.error(res.message);
+    }
+    setPaginationConfig({ ...paginationConfig, total: res.data.total });
+    setDataList(res.data.list.map((item) => item.taskName));
+  };
+
+  const handlePageChange = (page: number, pageSize: number) => {
+    setPaginationConfig({ ...paginationConfig, current: page, pageSize });
+  };
+
+  const handleInvoke = (taskName: string) => {
+    Modal.confirm({
+      title: '确认同步',
+      content: `确定要同步数据 "${serviceNameMap.get(taskName)}" 吗?`,
+      onOk: async () => {
+        // 调用任务的逻辑
+        const res = await clientGet<any, ClientResponse>('/api/invokeTask', {
+          params: {
+            taskName
+          }
+        });
+        console.log(res);
+        if (res.code !== 200) {
+          message.error(res.data);
+          return;
+        }
+        message.success(res.data);
+      },
+      onCancel: () => {
+        message.info('调用已取消');
+      },
+      maskClosable: true
+    });
+  };
+
+  const handleSearch = (text: string) => {
+    if(text.length === 0){
+      message.info('搜索内容不能为空');
+      return;
+    }
+    //todo
+    const filtered = dataList.filter(item => serviceNameMap.get(item)?.toLowerCase().includes(text.toLowerCase()));
+    setSearchResults(filtered);
+    if (filtered.length === 0) {
+      Modal.info({
+        title: '搜索结果',
+        content: '暂无搜索结果',
+        okText: '确定',
+        cancelText: '取消'
+      });
+    } else {
+      Modal.info({
+        title: '搜索结果',
+        content: (
+          <List
+            size={'small'}
+            dataSource={filtered}
+            renderItem={(item) => (
+              <List.Item actions={[
+                <Button type={'primary'} onClick={() => handleInvoke(item)}>调用</Button>
+              ]}>
+                <span>{serviceNameMap.get(item)}</span>
+              </List.Item>
+            )}
+          />
+        ),
+        okText: '确定',
+        cancelText: '取消',
+        maskClosable: true
+      });
+    }
+  };
+
+  useEffect(() => {
+    getList({ pageNum: paginationConfig.current, pageSize: paginationConfig.pageSize });
+  }, [paginationConfig.current, paginationConfig.pageSize]);
+
   return (
     <Row>
       <Col span={24}>
-        <LadderShapedTab currentTab={pathname}/>
+        <LadderShapedTab currentTab={pathname} />
       </Col>
-      <Col span={20}>
-        <Card title="Card title">
-          <p>Card content</p>
-          <p>Card content</p>
-          <p>Card content</p>
-        </Card>
+      <Col span={12} className={'my-5 mx-auto'}>
+        <Search
+          placeholder="输入关键词搜索"
+          allowClear
+          enterButton="搜索"
+          size="large"
+          onSearch={handleSearch}
+        />
+      </Col>
+      <Col span={24}>
+        <List
+          size={'large'}
+          pagination={{
+            ...paginationConfig,
+            onChange: handlePageChange
+          }}
+          dataSource={dataList}
+          bordered={true}
+          header={<div className={'flex border-solid font-600'}>
+            <Col span={18}>
+              <span className={'text-xl'}>服务名称</span>
+            </Col>
+            <Col span={6}>
+              <span className={'text-xl'}>操作</span>
+            </Col>
+          </div>}
+          renderItem={(item) => (
+            <List.Item className={'flex justify-around'}>
+              <Col span={18}>
+                {serviceNameMap.get(item)}
+              </Col>
+              <Col span={6}>
+                <Button type={'primary'} onClick={() => handleInvoke(item)}>调用</Button>
+              </Col>
+            </List.Item>
+          )}
+        />
       </Col>
     </Row>
   );
 }
 
-export default Page;
+export default Page;

+ 108 - 0
src/app/timeTask/map.ts

@@ -0,0 +1,108 @@
+export const serviceNameMap = new Map<string, string>()
+serviceNameMap.set("xcrCompanyInvestmentServiceImpl", "企业公示_股东及出资修改信息");
+serviceNameMap.set("xcrEquityChangeServiceImpl", "企业公示_股权变更信息");
+serviceNameMap.set("xcrSupplementaryForeignInvestmentServiceImpl", "外资补充信息");
+serviceNameMap.set("xcrAppointDelegatesServiceImpl", "委派代表信息");
+serviceNameMap.set("xcrAgriculturalSupplementServiceImpl", "农专补充信息");
+serviceNameMap.set("xcrDomesticCapitalSupplementServiceImpl", "内资补充信息");
+serviceNameMap.set("xcrInstallmentPaymentServiceImpl", "分期实缴信息");
+serviceNameMap.set("xcrInvestorSubscriptionDetailsServiceImpl", "投资人认缴详细");
+serviceNameMap.set("xcrNonNaturalPersonContributionServiceImpl", "非自然人出资信息");
+serviceNameMap.set("xcrNaturalPersonContributionsServiceImpl", "自然人出资信息");
+serviceNameMap.set("xcrHistoryNameServiceImpl", "历史名称信息");
+serviceNameMap.set("xcrHistoricalLegalRepresentativeServiceImpl", "历史法定代表人信息");
+serviceNameMap.set("xcrAbnormalHouseholdTerminationServiceImpl", "企业异常名录详细信息"); // 标记:原键名不明确,根据功能猜测
+serviceNameMap.set("xcrTaxAdministrativePenaltyServiceImpl", "纳税人税务行政处罚信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrAffiliatedEnterpriseServiceImpl", "隶属企业信息");
+serviceNameMap.set("xcrInstallmentSubscriptionServiceImpl", "分期认缴信息");
+serviceNameMap.set("xcrAdministrativeLicensingAgriculturalCollegesServiceImpl", "农专年报行政许可信息");
+serviceNameMap.set("xcrEnterpriseExceptionListServiceImpl", "企业异常名录信息");
+serviceNameMap.set("xcrInvestorAbnormalRecordServiceImpl", "企业经营异常名录股东信息");
+serviceNameMap.set("xcrEnterprisePublicityLicenseServiceImpl", "企业公示_许可信息");
+serviceNameMap.set("xcrEnterprisePublicityEquityChangeServiceImpl", "企业公示_股权变更信息");
+serviceNameMap.set("xcrSimplifiedCancellationAnnouncementServiceImpl", "简易注销公告信息");
+serviceNameMap.set("xcrCancelTaxRegistrationServiceImpl", "注销税务登记信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrEnterprisePublicityInvestorInformationStatusServiceImpl", "企业公示_出资人信息情况");
+serviceNameMap.set("xcrEnterprisePublicityDetailsContributionsContributorsServiceImpl", "企业公示_出资人实缴明细");
+serviceNameMap.set("xcrEnterprisePublicationSupplySubscribedDetailsInvestorsServiceImpl", "企业公示_出资人认缴明细");
+serviceNameMap.set("xcrRevisionInformationAgriculturalCollegeAnnualReportServiceImpl", "农专年报修改信息");
+serviceNameMap.set("xcrBasicSupplementAgriculturalCollegeAnnualServiceImpl", "农专年报基本信息补充");
+serviceNameMap.set("xcrEnterpriseBasicInformationServiceImpl", "企业基本信息");
+serviceNameMap.set("xcrEnterpriseNameApprovalServiceImpl", "企业名称信息");
+serviceNameMap.set("xcrSeriousIllegalDishonestEnterprisesServiceImpl", "严重违法失信企业名单");
+serviceNameMap.set("xcrSeriousIllegalDishonestEnterprisesDetailServiceImpl", "严重违法失信企业详细信息");
+serviceNameMap.set("xcrEquityPledgeInfoServiceImpl", "股权出质登记信息");
+serviceNameMap.set("xcrEquityFreezeServiceImpl", "股权冻结信息");
+serviceNameMap.set("xcrEquityChangeInfoServiceImpl", "股权变更信息");
+serviceNameMap.set("xcrEquityFreezeExecutionServiceImpl", "股权冻结被执行人信息");
+serviceNameMap.set("xcrAbnormalBusinessOperationsServiceImpl", "企业异常名录详细信息");
+serviceNameMap.set("xcrCheckWorkInfoServiceImpl", "检查工作信息");
+serviceNameMap.set("xcrTaxRegistrationEstablishmentServiceImpl", "税务登记设立信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrStopBusinessInformationServiceImpl", "个体工商户停歇业信息");
+serviceNameMap.set("xcrAbnormalHouseholdIdentificationServiceImpl", "非正常户认定信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrIncomeTaxReturnServiceImpl", "企业所得税申报信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrMainFinancialStatementsServiceImpl", "财务报表主表");
+serviceNameMap.set("xcrInvoiceIssuanceServiceImpl", "发票开票信息");
+serviceNameMap.set("xcrConfirmationTerminationServiceImpl", "非正常户认定解除信息表"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrTaxpayerCreditRatingServiceImpl", "纳税人信用等级");
+serviceNameMap.set("xcrInstitutionalClientsServiceImpl", "机构客户信息");
+serviceNameMap.set("xcrRecordDishonestyServiceImpl", "失信记录名单");
+serviceNameMap.set("xcrTechnologyPlanProjectServiceImpl", "科技计划项目安排表");
+serviceNameMap.set("xcrTechnologyAwardSupplementServiceImpl", "科技奖补项目及资金情况");
+serviceNameMap.set("xcrMinorEnterprisesServiceImpl", "科技型中小企业名单");
+serviceNameMap.set("xcrInnovationPlatformServiceImpl", "国家、省、市创新平台名单");
+serviceNameMap.set("xcrHighTechServiceImpl", "高新技术企业名单");
+serviceNameMap.set("xcrFoodProductionLicenseDetaliServiceImpl", "食品生产许可证品种明细");
+serviceNameMap.set("xcrLegalRepresentativeServiceImpl", "食品生产法定代表人信息");
+serviceNameMap.set("xcrFoodProductionLicenseServiceImpl", "食品生产许可证基本信息");
+serviceNameMap.set("xcrFoodBusinessLicenseServiceImpl", "食品经营许可证基本信息");
+serviceNameMap.set("xcrMsAdministrativeLicenseServiceImpl", "市场监管_行政许可信息");
+serviceNameMap.set("xcrContactInformationServiceImpl", "联络员信息");
+serviceNameMap.set("xcrFinancialManagerServiceImpl", "财务负责人");
+serviceNameMap.set("xcrPersonalRevokeRecordServiceImpl", "个体撤销登记信息");
+serviceNameMap.set("xcrNoticeRecordServiceImpl", "公示公告信息");
+serviceNameMap.set("xcrWebsiteInfoServiceImpl", "个体年报网站或网店信息");
+serviceNameMap.set("xcrSmallAndMicroEnterprisesServiceImpl", "小微企业名录基本信息");
+serviceNameMap.set("xcrRandomInspectionTaskServiceImpl", "检查工作信息名录");
+serviceNameMap.set("xcrAnnualReportExternalInvestmentServiceImpl", "企业年报对外投资信息");
+serviceNameMap.set("xcrExternalGuaranteeServiceImpl", "企业年报对外提供保证担保信息");
+serviceNameMap.set("xcrRevokeInfoServiceImpl", "吊销信息");
+serviceNameMap.set("xcrBranchOfficesInfoServiceImpl", "分支机构备案信息");
+serviceNameMap.set("xcrLicenseInfoServiceImpl", "许可信息");
+serviceNameMap.set("xcrChangeFilingServiceImpl", "变更备案信息");
+serviceNameMap.set("xcrSocialInsuranceDataServiceImpl", "企业年报社会保险信息"); // 标记:Excel中未找到精确匹配项
+serviceNameMap.set("xcrAgriculturalCollegeAnnualReportServiceImpl", "农专年报基本信息");
+serviceNameMap.set("xcrEnterprisePollutionPermitInfoServiceImpl", "企业排污许可信息");
+serviceNameMap.set("xcrKeyPollutionSourcesServiceImpl", "重点排污单位名录");
+serviceNameMap.set("xcrEnvironmentalPenaltyDecisionServiceImpl", "环保处罚决定情况信息");
+serviceNameMap.set("xcrIndividualBusinessInformationServiceImpl", "个体经营者基本信息");
+serviceNameMap.set("xcrIndustryCommerceServiceImpl", "个体工商户基本信息");
+serviceNameMap.set("xcrAgriculturalSpecializedWebsiteService", "农专年报网站或网店信息");
+serviceNameMap.set("xcrIndividualChangeInformationServiceImpl", "个体变更信息");
+serviceNameMap.set("xcrIndividualCancellationServiceImpl", "个体注销信息");
+serviceNameMap.set("xcrIndividualBusinessAbnormalityServiceImpl", "个体经营异常标记信息");
+serviceNameMap.set("xcrMoveOutServiceImpl", "迁出信息");
+serviceNameMap.set("xcrMoveInServiceImpl", "迁入信息");
+serviceNameMap.set("xcrDeregistrationServiceImpl", "撤销登记信息");
+serviceNameMap.set("xcrCancellationServiceImpl", "注销信息");
+serviceNameMap.set("xcrLiquidationBasicInfoServiceImpl", "清算基本信息");
+serviceNameMap.set("xcrLiquidationMemberInfoServiceImpl", "清算成员信息");
+serviceNameMap.set("xcrAbnormalOperationAnnouncementServiceImpl", "经营异常公告批量名单信息");
+serviceNameMap.set("xcrFarmSpecialAbnormalDetailServiceImpl", "农专异常名录详细信息");
+serviceNameMap.set("xcrEnterpriseAnnualReportWebsiteServiceImpl", "企业年报网站或网店信息");
+serviceNameMap.set("xcrEnterpriseAnnualReportEquityChangeServiceImpl", "企业年报股权变更信息");
+serviceNameMap.set("xcrIndividualCancellationObjectionServiceImpl", "简易注销异议信息");
+serviceNameMap.set("xcrRevokeRegistrationServiceImpl", "个体撤销登记信息");
+serviceNameMap.set("xcrAgriculturalSpecializedWebsiteServiceImpl", "农专年报网站或网店信息");
+serviceNameMap.set("xcrAnSfcBranchinfoServiceImpl", "农专年报分支机构信息");
+serviceNameMap.set("xcrMajorMembersServiceImpl", "主要人员");
+serviceNameMap.set("xcrOtherInfo36ServiceImpl", "水费清单");
+serviceNameMap.set("xcrAdministrativeLicensingServiceImpl", "行政许可信息");
+serviceNameMap.set("xcrAdministrativePenaltyServiceImpl", "行政处罚信息");
+serviceNameMap.set("xcrOtherInfo37ServiceImpl", "燃气费清单");
+serviceNameMap.set("xcrOtherInfo38ServiceImpl", "科技研发清单");
+serviceNameMap.set("xcrOtherInfo39ServiceImpl", "农业主体信息");
+serviceNameMap.set("xcrTrustworthyIncentive42ServiceImpl", "红名单");
+serviceNameMap.set("xcrDishonestyPunishment19ServiceImpl", "严重失信主体名单信息");
+serviceNameMap.set("xcrXinyonghuaihuaBaseInfoServiceImpl", "信用怀化基础信息");
+

+ 40 - 8
src/app/timeTask/page.tsx

@@ -6,13 +6,16 @@ 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[]>([])
   const [open, setOpen] = useState(false);
   const [confirmLoading, setConfirmLoading] = useState(false);
   const [modalText, setModalText] = useState('确定要同步这个定时任务控制?');
-  const pathname = usePathname();
+  const [menuCard, setMenuCard] = useState(false);
+  const [cradPosition, setcradPosition] = useState({x: 0, y: 0});
+  const [processCard, setProcessCard] = useState<ButtonType|null>(null);
   const showModal = () => {
     setOpen(true);
     setModalText("确定要同步这个定时任务控制?");
@@ -69,7 +72,6 @@ export default function page() {
     if (res.code !== 200) {
       message.error(res.message)
     }
-    console.log(res.data);
     setAreas(res.data)
   }
   const generateSchedule = (schedule: string): string => {
@@ -95,10 +97,28 @@ export default function page() {
     message.success(res.message)
   }
 
-  const rightClick = (button: ButtonType)=> (e: React.MouseEvent)=>{
+  const handleClick = (button: ButtonType)=> (e: React.MouseEvent)=>{
     e.preventDefault()
-    message.info('右键菜单')
-    console.log(button)
+    e.stopPropagation();
+    setMenuCard(!menuCard)
+    setcradPosition({x:e.clientX,y:e.clientY});
+    setProcessCard(button);
+  }
+
+  const disAbledOrAbledButton = (button: ButtonType|null)=> {
+    try {
+      if (!!button) {
+        if (button.enabled === 1) {
+          button.enabled = 0;
+          setAreas(areas);
+        } else {
+          button.enabled = 1;
+          setAreas(areas);
+        }
+      }
+    } finally {
+      setMenuCard(false);
+    }
   }
 
   useEffect(() => {
@@ -106,7 +126,7 @@ export default function page() {
   }, []);
 
   return (
-    <Row gutter={[16, 16]}>
+    <Row gutter={[16, 16]} style={{margin:0}}>
       <Col span={24}>
         <LadderShapedTab currentTab={usePathname()}/>
       </Col>
@@ -125,8 +145,11 @@ export default function page() {
         </Modal>
       </Col>
       {areas.map(area => (
-        <Col xs={24} sm={12} md={8} key={area.id}>
+        <Col xs={24} sm={12} md={8} lg={6} key={area.id} >
           <Card
+            onClick={(e)=>{
+              setMenuCard(false)
+            }}
             title={generateSchedule(area.title)}
             onDragOver={onDragOver}
             onDrop={(e) => onDrop(e, area.id, area.buttons.length)}
@@ -142,13 +165,22 @@ export default function page() {
                   onDrop={(e) => onDrop(e, area.id, index)}
                   style={{marginBottom: '8px'}}
                 >
-                  <Button onContextMenu={rightClick(button)}>{button.serviceName}</Button>
+                  <Button onClick={handleClick(button)} type={button.enabled===0?'primary':'default'} danger={button.enabled===0}>{serviceNameMap.get(button.serviceName)}</Button>
                 </div>
               ))}
             </div>
           </Card>
         </Col>
       ))}
+      {menuCard &&
+          <Button
+          style={{position:"fixed",left:cradPosition.x,top:cradPosition.y}}
+          type={'primary'}
+          danger={processCard?.enabled===1}
+          onClick={()=>disAbledOrAbledButton(processCard)}>
+          {processCard?.enabled===1?'禁用':'启用'}
+        </Button>
+      }
     </Row>
   )
 }

+ 15 - 0
src/type/invoke/type.ts

@@ -0,0 +1,15 @@
+import {TaskScheduleItem} from "@/type/timeTask/type";
+
+export interface TimeTaskResponse {
+  total: number;
+  pages: string;
+  list: TaskScheduleItem[];
+}
+
+export interface TimeTaskClientResponse extends ClientResponse{
+  data: TimeTaskResponse;
+}
+
+export interface TimeTaskServerResponse extends BaseResponse{
+  data: TaskScheduleItem;
+}