Commit b43fdad0 by zhaochengxiang

spreadjs

parent f1aefb60
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal, Form, Button, Space, Input, Checkbox, Row, Col, Typography, Spin } from 'antd'; import { Modal, Form, Button, Space, Input, Checkbox, Row, Col, Typography, Spin, InputNumber } from 'antd';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
import { showMessage } from '../../../../util'; import { showMessage } from '../../../../util';
...@@ -80,11 +80,11 @@ const WorksheetModal = (props) => { ...@@ -80,11 +80,11 @@ const WorksheetModal = (props) => {
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 3 }, sm: { span: 4 },
}, },
wrapperCol: { wrapperCol: {
xs: { span: 24 }, xs: { span: 24 },
sm: { span: 21 }, sm: { span: 20 },
}, },
}; };
...@@ -93,7 +93,7 @@ const WorksheetModal = (props) => { ...@@ -93,7 +93,7 @@ const WorksheetModal = (props) => {
forceRender forceRender
title={`${report?.name}工作簿信息`} title={`${report?.name}工作簿信息`}
visible={ visible } visible={ visible }
width={ 600 } width={ 800 }
onCancel={() => { onCancel={() => {
reset(); reset();
onCancel && onCancel(); onCancel && onCancel();
...@@ -117,6 +117,15 @@ const WorksheetModal = (props) => { ...@@ -117,6 +117,15 @@ const WorksheetModal = (props) => {
> >
<Input /> <Input />
</Form.Item> </Form.Item>
{
(report?.code === 'SpreadJS') && <Form.Item
label="最大加载行数"
name="limit"
rules={[{ required: true, message: '请选择最大加载行数!' }]}
>
<InputNumber min={0} />
</Form.Item>
}
<Form.Item <Form.Item
label="字段" label="字段"
name="columns" name="columns"
......
...@@ -6,23 +6,30 @@ import { getQueryParam } from '../../../../util'; ...@@ -6,23 +6,30 @@ import { getQueryParam } from '../../../../util';
const ts = Date.now() const ts = Date.now()
const FC = (props) => { const FC = (props) => {
const ref = React.useRef()
const url = getQueryParam('downloadurl', props.location?.search); const url = getQueryParam('downloadurl', props.location?.search);
React.useEffect(() => { React.useEffect(() => {
axios.request({ window.addEventListener('message', download)
method: 'GET',
url, return () => {
responseType: 'blob' window?.removeEventListener("message", download);
}).then((resp) => { }
var iframe = document.getElementById('myIframe');
setTimeout(() => {
iframe.contentWindow.postMessage({ data: resp.data, type: "preview.excel.file" }, "*");
}, 5000)
})
}, []) }, [])
const download = (e) => {
console.log('type', e.data?.type)
if (e.data?.type === 'excel.mount') {
axios.request({
method: 'GET',
url,
responseType: 'blob'
}).then((resp) => {
var iframe = document.getElementById('myIframe');
iframe.contentWindow.postMessage({ data: resp.data, type: "preview.excel.file" }, "*");
});
}
}
return ( return (
<iframe <iframe
id='myIframe' id='myIframe'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment