This commit is contained in:
xuyucheng 2022-01-25 16:17:14 +08:00
parent ae5e3bb194
commit 13a064bbfb
4 changed files with 25 additions and 10 deletions

View File

@ -75,12 +75,12 @@ const api = {
});
});
},
BlobGet: function (path = '', data = {}) {
BlobGet: function (path = '') {
return new Promise(function (resolve, reject) {
axios.get(
path, { params: data }, { responseType: 'blob' })
path, { responseType: 'blob' })
.then(function (response) {
const blob = new Blob([response.data],{ type: 'application/pdf;charset=UTF-8' });
const blob = new Blob([response.data],{ type: 'application/pdf' });
resolve(window.URL.createObjectURL(blob));
})
.catch(function (error) {
@ -93,8 +93,8 @@ const api = {
axios.post(
path, data, { responseType: 'blob' })
.then(function (response) {
const blob = new Blob([response.data]);
resolve(URL.createObjectURL(blob));
const blob = new Blob([response.data],{type:"application/pdf"});
resolve(window.URL.createObjectURL(blob));
})
.catch(function (error) {
reject(error);

View File

@ -37,12 +37,12 @@ class RateResult extends Component {
if (typeof val[key][child] !== 'object') {
return <Descriptions.Item label={child} key={n}>{val[key][child]}</Descriptions.Item >
} else {
return <p>{child}
return <Tag>{child}
{Object.keys(val[key][child]).map((ele, j) => {
return <span className="block">{ele}:{val[key][child][ele]}</span>
// return <Descriptions.Item label={ele} key={j}>{val[key][child][ele]}</Descriptions.Item>
})}
</p>
</Tag>
}
})}</Descriptions></React.Fragment>
}

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Input, Button, Modal, Space } from 'antd'
import { Input, Button, Modal, Space, Row } from 'antd'
import { LeftOutlined, RightOutlined } from '@ant-design/icons';
import FeTable from '@/components/table'
import api from "@/api/request"
@ -101,6 +101,17 @@ class ManageRate extends Component {
})
}
downLoad() {
const filename = "文件.pdf";
const downloadElement = document.createElement("a");
downloadElement.href = this.state.file;
[downloadElement.download] = [filename];
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(this.state.file);
}
callback(value) {
if (!this.isJump) {
const newPanes = [...this.props.panes]
@ -122,7 +133,10 @@ class ManageRate extends Component {
onCancel={this.onCancel}
onOk={this.onConfirm}
footer={[
<p ><Space><LeftOutlined style={{ fontSize: '16px' }} onClick={this.prePage} /><span style={{ fontSize: '16px' }}>{this.state.page} of {this.state.numPages} </span><RightOutlined style={{ fontSize: '16px' }} onClick={this.nextPage} /></Space></p>
<Row justify="space-between">
<Space><LeftOutlined style={{ fontSize: '16px' }} onClick={this.prePage} /><span style={{ fontSize: '16px' }}>{this.state.page} of {this.state.numPages} </span><RightOutlined style={{ fontSize: '16px' }} onClick={this.nextPage} /></Space>
<Button type='primary' onClick={this.downLoad.bind(this)}> </Button>
</Row>
]}
>
<Document
@ -130,6 +144,7 @@ class ManageRate extends Component {
onLoadSuccess={this.onDocumentLoadSuccess} //成功加载文档后调用
onLoadError={console.error} //加载失败时调用
loading="正在努力加载中" //加载时提示语句
renderMode="canvas"
>
<Page pageNumber={this.state.page} />
</Document>

View File

@ -95,7 +95,7 @@ class UserSet extends Component {
</Form.Item>
<Form.Item name="duty" label="duty" rules={[{ required: true, message: 'Please input duty!' }]}>
<Select>
<Option value="developers">developers</Option>
<Option value="developers">developer</Option>
<Option value="analysts">analysts</Option>
<Option value="manager">manager</Option>
</Select>