From 7cd6587d43dfda47b043c775ea9e67ee4c1bbd08 Mon Sep 17 00:00:00 2001 From: Mr Ke <kelq@hugeinfo.com.cn> Date: Tue, 14 Apr 2020 14:09:55 +0800 Subject: [PATCH] 跳转问题 --- src/components/page/DocumentEditPage/index.jsx | 49 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/components/page/DocumentEditPage/index.jsx b/src/components/page/DocumentEditPage/index.jsx index 051c78e..1e4bcc1 100644 --- a/src/components/page/DocumentEditPage/index.jsx +++ b/src/components/page/DocumentEditPage/index.jsx @@ -37,13 +37,14 @@ } loadData = () => { - const { id } = this.props; + const { id } = this.props.match.params; + console.log(this.props) console.log(id) let _this = this; _this.setState({ loading: true, disabled: id ? true : false - }) + }) fetch({ url: 'api/document/findDetail', params: { @@ -57,6 +58,7 @@ documentType: res.documentType || 'DT00002' }, loading: false, + fileList: res.attachmentList && res.attachmentList.map((a) => ({ ...a, key: a.id, uid: a.id, name: a.fileName + '.' + a.suffix})) || [] }); }); } @@ -75,11 +77,11 @@ const { savedate } = this.state; console.log(savedate) if (savedate.documentType == 'DT00001') { - if (!savedate.documentItle) { + if (!savedate.documentTitle) { return message.warning('规章制度标题不能为空') } } else { - if (!savedate.documentItle) { + if (!savedate.documentTitle) { return message.warning('通知标题不能为空') } else if (!savedate.documentContent) { return message.warning('通知内容不能为空') @@ -98,6 +100,9 @@ _this.setState({ iconLoading: false, }); + message.success("提交成功!"); + this.props.history.push("/index/rules") + // this.props.history.goBack() }); // Fetch.savePatrolCom(savedate) // .then(res => { @@ -111,13 +116,23 @@ } cancle = () => { - this.props.history.push("/index/workbench"); + // this.props.history.push("/index/workbench"); + const { id } = this.props.match.params; + if (id) { + this.props.history.goBack() + } else { + this.props.history.push("/index/workbench"); + } + // console.log(this.props) } render() { const { savedate, fileList, loading, disabled } = this.state; const props = { action: BASE_URL + `api/attachment/materials?associateId=${savedate.documentType == 'DT00002' ? 1001 : 1002}&entityId=` + savedate.id, + header: { + Authorization: window.localStorage.getItem('token') + }, onChange: ({ file, fileList }) => { if (file.status !== 'uploading') { console.log(file); @@ -127,6 +142,10 @@ this.setState({ fileList }); }, fileList: fileList, + onPreview: (file) => { + console.log(file) + }, + showUploadList: { showPreviewIcon: true, showDownloadIcon: true, showRemoveIcon: disabled ? false : true } // onDownload: (file) => { // console.log(file) // Fetch.attachmentDownload(file.uid) @@ -157,7 +176,7 @@ <Row gutter={16}> <Col className="gutter-row" > 文档类型: - </Col> + </Col> </Row> <Row gutter={16}> <Col className="gutter-row" style={{ margin: '12px 0' }} > @@ -176,7 +195,7 @@ <Row gutter={16} style={{ marginTop: '12px' }}> <Col className="gutter-row" style={{ marginTop: '12px' }}> 通知标题: - </Col> + </Col> </Row> } { @@ -184,12 +203,12 @@ <Row gutter={16} style={{ marginTop: '12px' }}> <Col className="gutter-row" style={{ marginTop: '12px' }}> 规章制度标题: - </Col> + </Col> </Row> } <Row gutter={16}> <Col className="gutter-row" style={{ margin: '12px 0' }} > - <Input disabled={disabled} style={{ width: '300px' }} name='documentItle' onChange={this.saveInputChange} value={savedate.documentItle || ""} /> + <Input disabled={disabled} style={{ width: '300px' }} name='documentTitle' onChange={this.saveInputChange} value={savedate.documentTitle || ""} /> </Col> </Row> @@ -198,7 +217,7 @@ <Row gutter={16}> <Col className="gutter-row" > 通知内容: - </Col> + </Col> </Row> } { @@ -220,8 +239,8 @@ {savedate.documentType == 'DT00001' && <Row gutter={16} > <Col className="gutter-row" > - <Upload disabled={disabled} {...props}> - <Button> + <Upload {...props} > + <Button disabled={disabled} style={{ display: disabled ? 'none' : 'inline-block' }}> <Icon type="upload" />上传文件</Button> </Upload> </Col> @@ -250,9 +269,9 @@ </Col> </Row> } - <Row gutter={16} style={{ marginTop: '12px' }}> - <Col span={2} className="gutter-row" ><Button disabled={disabled} style={{ marginRight: '15px', width: '100px' }} type="primary" loading={this.state.iconLoading} onClick={this.submit}>发布</Button></Col> - <Col span={2} className="gutter-row" ><Button style={{ marginLeft: '15px', width: '100px' }} onClick={this.cancle}>返回</Button></Col> + <Row type="flex" gutter={20} style={{ marginTop: '12px' }}> + <Col className="gutter-row" ><Button onClick={this.cancle}>返回</Button></Col> + <Col className="gutter-row" ><Button disabled={disabled} type="primary" loading={this.state.iconLoading} onClick={this.submit}>发布</Button></Col> </Row> </Card> </Spin> -- Gitblit v1.8.0