瀏覽代碼

处理报表展示逻辑

CodeLife Leno 1 月之前
父節點
當前提交
8aa0b57e0e

+ 7 - 3
Procedure/backend/project/src/main/java/com/sundata/product/rwa/reportformconfigreportcreater/action/ReportFileExportController.java

@@ -43,7 +43,7 @@ public class ReportFileExportController extends BaseAction {
             HtmlUtil.writeJson(response, rsp);
             return;
         }
-        if (reportResultDirPath.list() == null || reportResultDirPath.list().length == 0) {
+        if (reportResultDirPath.listFiles() == null || reportResultDirPath.listFiles().length == 0) {
             rsp.put("flag", false);
             HtmlUtil.writeJson(response, rsp);
             return;
@@ -75,10 +75,12 @@ public class ReportFileExportController extends BaseAction {
             if (!reportResultDirPath.exists()) {
                 rsp.put("flag", false);
                 HtmlUtil.writeJson(response, rsp);
+                return;
             }
-            if (reportResultDirPath.list() == null || reportResultDirPath.list().length == 0) {
+            if (reportResultDirPath.listFiles() == null || reportResultDirPath.listFiles().length == 0) {
                 rsp.put("flag", false);
                 HtmlUtil.writeJson(response, rsp);
+                return;
             }
             File report = reportResultDirPath.listFiles()[0];
             if (!report.exists()) {
@@ -89,7 +91,9 @@ public class ReportFileExportController extends BaseAction {
             ToHtml toHtml = ToHtml.create(Files.newInputStream(report.toPath()), writer);
             toHtml.setCompleteHTML(false);
             toHtml.printPage();
-            sendData(response, writer.toString());
+            rsp.put("flag", true);
+            rsp.put("htmlString", writer.toString());
+            sendData(response, rsp);
         } catch (IOException e) {
             log.error(e.getMessage(),e);
         }

+ 23 - 5
Procedure/frontend/projectb/src/pages/product/report_form_config_reportcreater/reportFileShow.tsx

@@ -1,18 +1,36 @@
 import {
   downloadReportFile,
+  getReportFileHtml,
   ReportFileExportModel,
 } from '@/services/rwa/product/report_form_config_reportcreater/reportFile';
 import { SDButton, SDPage } from '@sundata/ui-frame';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
 
-const reportFileShow = (model: ReportFileExportModel) => {
+const ReportFileShow = (model: ReportFileExportModel) => {
   const dowloadFile = () => {
     downloadReportFile(model);
   };
-
   const [htmlStr, setHtmlStr] = useState();
 
-  return <SDPage footer={[<SDButton onClick={dowloadFile}>导出文件</SDButton>]}>{htmlStr}</SDPage>;
+  useEffect(() => {
+    getReportFileHtml(model).then((body) => {
+      if (body?.flag == 'false'){
+        return;
+      }
+      setHtmlStr(body.htmlString);
+    });
+  }, []);
+
+  const showHtml = (htmlContent: String) => {
+    return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
+  };
+
+  // @ts-ignore
+  return (
+    <SDPage footer={[<SDButton onClick={dowloadFile}>导出文件</SDButton>]}>
+      <div dangerouslySetInnerHTML={{ __html: htmlStr }} />
+    </SDPage>
+  );
 };
 
-export default reportFileShow;
+export default ReportFileShow;

+ 51 - 17
Procedure/frontend/projectb/src/pages/product/rwa/reportResult/G4B-1.tsx

@@ -1,33 +1,67 @@
-import { ProFormDatePicker, QueryFilter } from '@ant-design/pro-components';
+import ReportFileShow from '@/pages/product/report_form_config_reportcreater/reportFileShow';
 import { SDPage } from '@sundata/ui-frame';
+import { Button, DatePicker, Form, Layout } from 'antd';
 import React, { useRef, useState } from 'react';
-import {Button} from "antd";
+
+const { Header, Content, Footer } = Layout;
 
 const g4b_1: React.FC<any> = () => {
   const [visible, setVisible] = useState<boolean>(false); //弹窗是否显示
-  const [dataSource, setDataSource] = useState<any>();
+  const [monthStr, setMonthStr] = useState<any>();
   const monthRef = useRef();
+  // const monthRef02 = new Ref;
 
   const downloadReportExcel = () => {};
 
-  const showHtml = () =>{
-    console.log(monthRef.current)
-  }
+  const showHtml = () => {
+    console.log(monthRef.current);
+    // monthRef.current.value;
+  };
+
+  const [form] = Form.useForm();
 
+  // 自定义的提交方法
+  const handleSubmit = (values: any) => {
+    console.log('Received values of form: ', values.month.format('YYYYMM'));
+    setMonthStr(values.month.format('YYYYMM'));
+    // 在这里调用你自己的方法
+  };
 
   return (
     <SDPage>
-      <QueryFilter
-        defaultCollapsed
-        split
-        optionRender={(searchConfig) => [
-          <Button key="submit" onClick={() => showHtml} type="primary">
-            查询
-          </Button>,
-        ]}
-      >
-        <ProFormDatePicker.Month dataFormat={'YYYYMM'} fieldRef={monthRef} label={'期次'} />
-      </QueryFilter>
+      <Layout>
+        {/*<Header >*/}
+        <Form
+          layout={'inline'}
+          form={form}
+          name="basic"
+          initialValues={{ remember: true }}
+          // ref={monthRef}
+          onFinish={handleSubmit} // 使用自定义的提交方法
+          style={{ maxWidth: 'inline' }}
+        >
+          <Form.Item
+            label="期次"
+            name="month"
+            // labelCol={{ span: 8 }}
+            // wrapperCol={{ span: 16 }}
+            rules={[{ required: true, message: '请选择月份' }]}
+          >
+            {/*<Input />*/}
+            <DatePicker format="YYYY-MM" type={'month'} />
+          </Form.Item>
+          <Form.Item>
+            <Button type="primary" htmlType="submit">
+              查询
+            </Button>
+          </Form.Item>
+        </Form>
+
+        {/*</Header>*/}
+        <Content>
+          <ReportFileShow term={monthStr} reportNo="G4B_1" />
+        </Content>
+      </Layout>
     </SDPage>
   );
 };

+ 19 - 15
Procedure/frontend/projectb/src/pages/rdpMng/Template/Coding/components/G4B-1.tsx

@@ -7,11 +7,15 @@ import { SortOrder } from 'antd/es/table/interface';
 import { render } from '@/app';
 import { select } from '@/services/rwa/product_list';
 import Title from 'antd/es/typography/Title';
+
+/**
+ * 弃用
+ */
 type aaa = {
     onChangeVisible(visible: boolean, type: string): unknown;
     onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
     }
-    
+
 
 const g4b_1: React.FC<aaa>= (props:aaa) => {
     const [visible,setVisible] = useState<boolean>(false);//弹窗是否显示
@@ -20,7 +24,7 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
        return <div style={{background :'yellow'}}>{record}</div>
       };
 
-      
+
       var formDataList = new Array<G4B1>;
     const columns : ProColumns<G4B1>[]= [
         {
@@ -37,7 +41,7 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
              // align:'center',
              search: false,
                width:150,
-             ellipsis: true,    
+             ellipsis: true,
              render:()=>{
                 onclick=(()=>{
                setVisible(true)
@@ -541,7 +545,7 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
               width:150,
             // align:'center'
         },
-        
+
     ]
 
     const select =async(bpdy:any)=>{
@@ -549,11 +553,11 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
     }
 
     return(
-        
+
     <SDPage>
         <div style={{width:'100%' ,overflow:'auto'}}  >
         <ProTable rowKey={''}
-              scroll={{ x: 'max-content' }}   
+              scroll={{ x: 'max-content' }}
               title={() => (
                 <div>
         <Title style={{textAlign : 'center' ,fontSize:'600px'}}>G4B-1表内信用风险加权资产计算表(权重法)</Title>
@@ -567,11 +571,11 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
 
       )}
 
-                columns={columns}    
+                columns={columns}
                 request={async()=>{
                     return {data:[]};
                 }}
-                
+
                 toolBarRender={(_, { selectedRows }) => [
                     <SDButton
                       key="export"
@@ -583,9 +587,9 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
                     >
                       全部导出
                     </SDButton>,
-                  ]}  
+                  ]}
             />
-           </div> 
+           </div>
 
 
          {visible &&(
@@ -597,13 +601,13 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
                 //   columns={columns}
                    />
                  </SDLayout>
-                
+
             </SDModal>
-        
+
         )
-    
+
         }
-       
+
 
     </SDPage>
 
@@ -611,4 +615,4 @@ const g4b_1: React.FC<aaa>= (props:aaa) => {
 
     )
 }
-export default g4b_1;
+export default g4b_1;