From 8d24b2559c9929814b31c0615bdcf915669350af Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Sat, 16 May 2020 13:49:11 +0800
Subject: [PATCH] 加入下载链接

---
 src/components/page/DocumentDetailPage/index.jsx |   98 ++++++++++++++++++++-----------------------------
 1 files changed, 40 insertions(+), 58 deletions(-)

diff --git a/src/components/page/DocumentDetailPage/index.jsx b/src/components/page/DocumentDetailPage/index.jsx
index d0e1fd2..834e778 100644
--- a/src/components/page/DocumentDetailPage/index.jsx
+++ b/src/components/page/DocumentDetailPage/index.jsx
@@ -13,7 +13,8 @@
 const { TextArea } = Input;
 
 import fetch from '../../../api/request';
-import { BASE_URL } from '../../../api/httpurl'
+import { BASE_URL } from '../../../api/httpurl';
+import moment from 'moment';
 
 const param = [{ value: 'DT00002', name: '通知公告' }, { value: 'DT00001', name: '规章制度' }]
 export default class DocumentDetailPage extends Component {
@@ -57,7 +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, })) || []
+        fileList: res.attachmentList && res.attachmentList.map((a) => ({ ...a, key: a.id, uid: a.id, name: a.fileName + '.' + a.suffix, status: 'done' })) || []
       });
     });
   }
@@ -135,6 +136,16 @@
       header: {
         Authorization: window.localStorage.getItem('token')
       },
+      showUploadList: {
+        showDownloadIcon: true,
+        showRemoveIcon: false,
+        showPreviewIcon: true
+      },
+      onDownload: (file) => {
+        // console.log('file', file)
+        window.open(file.downloadUrl);
+
+      },
       onChange: ({ file, fileList }) => {
         fileList = fileList.slice(-2);
         fileList = fileList.map(file => {
@@ -150,7 +161,6 @@
       onPreview: (file) => {
         window.open(file.url);
       },
-      showUploadList: { showPreviewIcon: true, showDownloadIcon: true, showRemoveIcon: false }
     };
 
     return (
@@ -158,55 +168,39 @@
         <Spin spinning={loading}>
 
           <Card style={{ border: 20, margin: 20, padding: 20 }}>
-            <Row gutter={16}>
-              <Col className="gutter-row marginTop flex-box-row" >
-                <div className="document-detail-page-main-label">
-                  文档类型:
-                </div>
-                <div className="document-detail-page-main-value">
-                  {
-                    saveData.documentType ? param.find(({ value }) => value == saveData.documentType).name : '无'
-                  }
-                </div>
-              </Col>
+            <Row className="document-detail-page-main-title">
+              {saveData.documentTitle || '无'}
             </Row>
 
-            <Row gutter={16} className="marginTop">
-              <Col className="gutter-row marginTop flex-box-row">
-                <div className="document-detail-page-main-label">
-                  {saveData.documentType && this.switchWordByType(saveData.documentType).title}标题:
-                </div>
-                <div className="document-detail-page-main-value">
-                  {saveData.documentTitle || '无'}
-                </div>
-              </Col>
+            <Row className="document-detail-page-main-documentType marginTop">
+              <div className="marginTop">
+                {
+                  saveData.documentType ? param.find(({ value }) => value == saveData.documentType).name : '无'
+                }
+              </div>
             </Row>
 
-            <Row gutter={16} className="marginTop">
-              <Col className="gutter-row marginTop flex-box-row flex-start">
-                <div className="document-detail-page-main-label">
-                  通知内容:
-                </div>
-                <div className="flex-1">
-                  {
-                    saveData.documentContent ? <div dangerouslySetInnerHTML={{
-                      __html: saveData.documentContent
-                    }} style={{ width: '70%' }} /> : <div className="document-detail-page-main-value">
-                        无
+            <Row className="document-detail-page-main-detail marginTop">
+              <Row gutter={16} type="flex" className="marginTop">
+                <Col>广州恒巨信息科技有限公司</Col>
+                <Col>{saveData.createTime && moment(saveData.createTime).format("YYYY-MM-DD HH:mm")}</Col>
+              </Row>
+              <Row className="marginTop">
+                {saveData.readNumber}人已读,{saveData.noticeNumber - saveData.readNumber}人未读
+              </Row>
+            </Row>
+
+            <Row className="marginTop">
+              <div>
+                {
+                  saveData.documentContent ? <div dangerouslySetInnerHTML={{
+                    __html: saveData.documentContent
+                  }} style={{ width: '70%' }} /> : <div className="document-detail-page-main-value">
+                      无
                   </div>
-                  }
-                </div>
-
-              </Col>
+                }
+              </div>
             </Row>
-
-            {/* 当有富文本内容的时候 -- 显示 */}
-            {/* {
-              saveData.documentContent &&
-              <div dangerouslySetInnerHTML={{
-                __html: saveData.documentContent
-              }} style={{ width: '70%' }} className="marginTB" />
-            } */}
 
             <Row gutter={16} className="marginTop">
               <Col className="gutter-row marginTop flex-box-row flex-start">
@@ -216,18 +210,6 @@
                 {
                   saveData.attachmentList && saveData.attachmentList.length > 0 ?
                     <div className="flex-1">
-                      <Upload {...props} >
-                        <Button disabled={disabled} style={{ display: disabled ? 'none' : 'inline-block' }}>
-                          <Icon type="upload" />上传文件</Button>
-                      </Upload>
-                      <Upload {...props} >
-                        <Button disabled={disabled} style={{ display: disabled ? 'none' : 'inline-block' }}>
-                          <Icon type="upload" />上传文件</Button>
-                      </Upload>
-                      <Upload {...props} >
-                        <Button disabled={disabled} style={{ display: disabled ? 'none' : 'inline-block' }}>
-                          <Icon type="upload" />上传文件</Button>
-                      </Upload>
                       <Upload {...props} >
                         <Button disabled={disabled} style={{ display: disabled ? 'none' : 'inline-block' }}>
                           <Icon type="upload" />上传文件</Button>

--
Gitblit v1.8.0