Commit f5bdc007 authored by lxd's avatar lxd

feat: 文件上传

parent 13fcdac8
...@@ -12,12 +12,12 @@ export function renderModal() { ...@@ -12,12 +12,12 @@ export function renderModal() {
]; ];
} }
export function detailsModal() { export function detailsModal(filePath) {
return [ return [
<Button type="primary" key="cancel" onClick={() => this.handleCancel()}> <Button type="primary" key="cancel" onClick={() => this.handleCancel()}>
取消 取消
</Button>, </Button>,
<Button type="primary" onClick={() => this.handleDownload()} key="down"> <Button type="primary" href={filePath} target="_blank" key="down">
下载 下载
</Button>, </Button>,
]; ];
......
...@@ -42,13 +42,6 @@ class toExamine extends Component { ...@@ -42,13 +42,6 @@ class toExamine extends Component {
}); });
}; };
handleDownload = () => {
const {
toExamineData: { url },
} = this.props;
window.open(url);
};
render() { render() {
const { const {
form: { getFieldDecorator }, form: { getFieldDecorator },
...@@ -63,7 +56,7 @@ class toExamine extends Component { ...@@ -63,7 +56,7 @@ class toExamine extends Component {
title={status === 1 ? '上传发票' : '查看发票'} title={status === 1 ? '上传发票' : '查看发票'}
visible={visible} visible={visible}
onCancel={() => this.handleCancel()} onCancel={() => this.handleCancel()}
footer={status === 1 ? renderModal.call(this) : detailsModal.call(this)} footer={status === 1 ? renderModal.call(this) : detailsModal.call(this, filePath)}
className={styles.textArea} className={styles.textArea}
> >
<Form className="login-form" {...formItemLayout}> <Form className="login-form" {...formItemLayout}>
......
...@@ -54,7 +54,8 @@ class PicturesWall extends React.Component { ...@@ -54,7 +54,8 @@ class PicturesWall extends React.Component {
return; return;
} }
const vm = this; const vm = this;
const observable = qiniu.upload(file, null, token); const name = file.name + file.uid;
const observable = qiniu.upload(file, file.name, token);
const observer = { const observer = {
next() { next() {
// ... // ...
...@@ -65,7 +66,7 @@ class PicturesWall extends React.Component { ...@@ -65,7 +66,7 @@ class PicturesWall extends React.Component {
}, },
complete(res) { complete(res) {
const comFile = file; const comFile = file;
const url = `${qiniuHost}/${res.hash}`; const url = `${qiniuHost}/${res.key}`;
comFile.url = url; comFile.url = url;
const list = vm.state.fileList; const list = vm.state.fileList;
list.push({ list.push({
......
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