From 84fa518cc6973c26d2e006b57d3e5570d4625075 Mon Sep 17 00:00:00 2001
From: liuwh <hugeinfo123>
Date: Mon, 06 Apr 2020 19:04:25 +0800
Subject: [PATCH] 修改

---
 src/components/page/AnnouncementPage/index.jsx |  225 +++++++++++---------------------------------
 src/index.js                                   |    2 
 /dev/null                                      |   12 --
 src/pages/index/System.jsx                     |    2 
 src/pages/index/workbench.jsx                  |    2 
 src/components/page/index/workbench/index.jsx  |    2 
 src/components/page/DocumentEditPage/index.jsx |   18 ++-
 src/components/page/index/rulesList/index.jsx  |    8 
 src/pages/index/Announcement.jsx               |    2 
 src/pages/document/DocumentEdit.jsx            |    6 
 src/components/common/NotifyList/index.jsx     |    6 +
 11 files changed, 88 insertions(+), 197 deletions(-)

diff --git a/src/components/common/NotifyList/index.jsx b/src/components/common/NotifyList/index.jsx
index 4c7b328..dd7f6be 100644
--- a/src/components/common/NotifyList/index.jsx
+++ b/src/components/common/NotifyList/index.jsx
@@ -23,10 +23,14 @@
 
   componentDidMount() { }
 
+  onClick = () => {
+    this.props.history.push({ pathname: "/index/workbench/announcement" });
+  }
+
   renderDom = () => {
     return <div className="notify-list-main-dom">
       <span className="notify-list-main-dom-msg">最新通知:公司本部从XX时间开始,调整省略很长很长的内容调整省略很长很长的内容公司本部从XX时间开始,调整省略很长很长的内容调整省略很长很长的内容公司本部从XX时间开始,调整省略很长很长的内容调整省略很长很长的内容</span>
-      <span className="notify-list-main-dom-fuc">[查看全部]</span>
+      <span className="notify-list-main-dom-fuc" onClick={this.onClick}>[查看全部]</span>
     </div>
   }
 
diff --git a/src/components/page/AnnouncementPage/index.jsx b/src/components/page/AnnouncementPage/index.jsx
index 56d9683..56d8695 100644
--- a/src/components/page/AnnouncementPage/index.jsx
+++ b/src/components/page/AnnouncementPage/index.jsx
@@ -1,199 +1,90 @@
 /* eslint-disable */
-/**liuwh
- * 4/6/2020, 12:33:28 PM
+/**柯礼钦
+ * 4/6/2020, 5:17:40 PM
  * doc comment for the file goes here
  */
 
-/** Happy Coding */
+/** 全部通知 */
 import React, { ReactNode, ReactEventHandler, Component } from 'react';
-// import { Link } from 'react-router-dom';
-import moment from 'moment'
-import { DatePicker, Table, Card, Row, Col, Icon, Form, Input, Button, Select, message } from 'antd';
+import TableView from '../../common/TableView';
+import SearchFormView from '../../common/SearchFormView';
+import moment from 'moment';
+
 import './index.scss';
 
-import fetch from '../../../api/request';
-const { MonthPicker, RangePicker } = DatePicker;
-const FormItem = Form.Item;
+
 export default class AnnouncementPage extends Component {
   constructor(props) {
     super(props);
     this.config = {
     };
     this.state = {
-      loading: true,
-      totalElements: 1,
-      size: 10,
-      page: 1,
-      resetKey: Date.now(),
-      formdata: {
+      formData: {
+        __key: Date.now(),
         type: '',
         title: '',
-        startTime: '',
-        endTime: ''
-      }
+        page: 1,
+        size: 10,
+      },
     };
   }
 
-
-
-
   componentWillMount() { }
 
-  componentDidMount() {
-    this.loadData(this.state.formdata, this.state.page, this.state.size);
+  componentDidMount() { }
+
+  cancle = (id) => {
+    console.log(id)
+    //   // this.props.history.push("/document/create?id=" + id);
+    this.props.history.push({ pathname: "/document/create/" + id });
   }
 
-  onShowSizeChange = (current, size) => {
-    console.log('pageSize', size)
-    this.setState({ size, page: 1 });
-    this.getData(this.state.formdata, this.state.page, this.state.size);
-  };
-
-  handleSubmit = (e) => {
-    e.preventDefault();
-    this.loadData(this.state.formdata, 1, this.state.size);
+  renderColumns = () => {
+    return [
+      { title: '标题', dataIndex: 'documentTitle' },
+      { title: '通知内容', dataIndex: 'documentContent' },
+      { title: '接受情况', dataIndex: 'groupType', render: (cur, item) => <span>{item.readNumber || 0}/{item.noticeNumber || 0}</span> },
+      { title: '通知时间', dataIndex: 'createTime', render: (cur, item) => cur !== "" && cur != null ? moment(cur).format("YYYY-MM-DD HH:mm") : "" },
+      { title: '操作', render: (text, record) => <a onClick={() => this.cancle(record.id)}>查看</a> }
+    ];
   }
 
-  loadData = (formdata, page, size) => {
-    console.log('111')
-    let _this = this;
-    _this.setState({
-      loading: true
-    })
-    fetch({
-      url: 'api/document/getNotice',
-      params: {
-        ...formdata,
-        page,
-        size
-      }
-    }).then(res => {
-      console.log(res)
-      _this.setState({
-        tableData: res.content,
-        loading: false,
-        totalElements: res.totalElements,
-        page
-      });
+  setFormData = data => {
+    console.log('form', data);
+    this.setState({
+      formData: data,
     });
   }
 
-  //查询
-  Seaech = () => {
-    const { formdata, page, size } = this.state;
-    if (formdata.areaId) {
-      formdata.areaId = parseInt(formdata.areaId[1]);
-    }
-    this.loadData(formdata, 1, size)
-  }
-
-  //重置
-  Reset = () => {
-    this.setState({
-      resetKey: Date.now(),
-      formdata: {},
-      page: 1,
-      size: 10
-    }, this.loadData({}, 1, this.state.size))
-  }
-
-  onInputChange = ({ target: { value, name } }) => {
-    this.setState(({ formdata }) => ({
-      formdata: {
-        ...formdata,
-        [name]: this.trim(value)
-      }
-    }))
-  }
-
-  onTimeChange = (value, dateString) => {
-    this.onChange('startTime', moment(dateString[0]).format('YYYY-MM-DD HH:mm'));
-    this.onChange('endTime', moment(dateString[1]).format('YYYY-MM-DD HH:mm'));
-  }
-
-  onChange = (field, value) => {
-    this.setState(({ formdata }) => ({
-      formdata: {
-        ...formdata,
-        [field]: value
-      }
-    }))
-  }
-
-  trim = (str) => {
-    str = str.replace(/^(\s|\u00A0)+/, '');
-    for (var i = str.length - 1; i >= 0; i--) {
-      if (/\S/.test(str.charAt(i))) {
-        str = str.substring(0, i + 1);
-        break;
-      }
-    }
-    return str;
-  }
-
-  getColumns = () => {
-    let obj = this;
-    return [
-      { title: '通知标题', className: "txt-c", dataIndex: 'documentItle;' },
-      { title: '通知内容', className: "txt-c", dataIndex: 'documentContent' },
-      // { title: '文档类型', className: "txt-c", dataIndex: 'documentType', render: (text, record) => text == "DT00001" ? "规章制度" : text == "DT00002" ? "通知公告" : text },
-      { title: '接受情况', className: "txt-c", dataIndex: 'groupType', render: (text, record) => <span>{readNumber || 0}/{noticeNumber || 0}</span> },
-      { title: '通知时间', className: "txt-c", dataIndex: 'createTime', render: (text, record) => text !== "" && text != null ? moment(text).format("YYYY-MM-DD HH:mm") : "" },
-      // {
-      //   title: '操作', className: "txt-c", key: 'operation', render: (text, record) => {
-      //     return <div>
-      //       <Link to={{ pathname: "/baseManage/groupDetail/" + record.id + '/Modify', query: { id: record.id } }}>修改</Link>
-      //       <span>&nbsp;|&nbsp;</span>
-      //       <a href="javascript:void(0);" onClick={() => this.delete(record.id)}>删除</a>
-      //     </div>
-      //   }
-      // }
-    ]
-  }
-
   render() {
-    const { resetKey, formdata } = this.state;
+    const { formData } = this.state;
+
+    let tableParams = {
+      url: `api/document/getNotice`,
+      formData,
+      key: formData.__key,
+      columns: this.renderColumns(),
+      extraFromData: {
+        type: '',
+      },
+      setFormData: this.setFormData
+    }
     return (
-      <div className="announcement-page-main">
-        <Card style={{ border: 20, margin: 20, padding: 20 }}>
-          <Row style={{ margin: '10px' }} key={resetKey}>
-            <Col span={1} style={{ display: 'flex', justifyContent: 'center', lineHeight: '28px' }}>标题:</Col>
-            <Col className="gutter-row" span={4}>
-              <Input placeholder="标题" name='name' onChange={this.onInputChange} />
-            </Col>
-            <Col span={2} style={{ display: 'flex', justifyContent: 'center', lineHeight: '28px' }}>工作时间:</Col>
-            <Col className="gutter-row" span={6}>
-              <RangePicker placeholder={['开始时间', '结束时间']} showTime format="YYYY-MM-DD HH:mm" onChange={this.onTimeChange} />
-            </Col>
-            <Col className="gutter-row" span={2}>
-              <Button type="primary" onClick={this.Seaech}>查询</Button>
-            </Col>
-            <Col className="gutter-row" span={2}>
-              <Button onClick={this.Reset}>重置</Button>
-            </Col>
-          </Row>
-          <Row>
-            <Table key={this.state.tableKey}
-              size="middle"
-              className="rowColor"
-              dataSource={this.state.tableData}
-              loading={{ spinning: this.state.loading }}
-              columns={this.getColumns()}
-              pagination={{
-                size: this.state.size,
-                onChange: this.pageChange,
-                total: this.state.totalElements,
-                showSizeChanger: true,
-                onShowSizeChange: this.onShowSizeChange,
-                showTotal: (total, range) => `共${total}条记录 `,
-                itemRender: this.itemRender,
-                showQuickJumper: true,
-                defaultCurrent: 1,
-                current: this.state.page
-              }}
-            />
-          </Row>
-        </Card>
+      <div className="rules-list-main">
+        <SearchFormView
+          formData={formData}
+          setFormData={this.setFormData}
+          data={[
+            { type: 'input', name: '标题', label: '标题', key: 'documentTitle' },
+            {
+              type: 'rangePicker',
+              label: '通知时间',
+              name: JSON.stringify(['开始时间', '结束时间']),
+              key: JSON.stringify(['startTime', 'endTime']),
+              keylistName: 'rangeTimelist',
+            },
+          ]} />
+        <TableView {...tableParams} />
       </div>
     )
   }
diff --git a/src/components/page/DocumentEditPage/index.jsx b/src/components/page/DocumentEditPage/index.jsx
index 051c78e..e5f073a 100644
--- a/src/components/page/DocumentEditPage/index.jsx
+++ b/src/components/page/DocumentEditPage/index.jsx
@@ -37,7 +37,8 @@
   }
 
   loadData = () => {
-    const { id } = this.props;
+    const { id } = this.props.match.params;
+    console.log(this.props)
     console.log(id)
     let _this = this;
     _this.setState({
@@ -75,11 +76,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('通知内容不能为空')
@@ -111,7 +112,14 @@
   }
 
   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() {
@@ -189,7 +197,7 @@
             }
             <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>
 
diff --git a/src/components/page/SystemPage/index.jsx b/src/components/page/SystemPage/index.jsx
deleted file mode 100644
index 12f5090..0000000
--- a/src/components/page/SystemPage/index.jsx
+++ /dev/null
@@ -1,199 +0,0 @@
-/* eslint-disable */
-/**liuwh
- * 4/6/2020, 12:33:28 PM
- * doc comment for the file goes here
- */
-
-/** Happy Coding */
-import React, { ReactNode, ReactEventHandler, Component } from 'react';
-import moment from 'moment'
-import { DatePicker, Table, Card, Row, Col, Icon, Form, Input, Button, Select, message } from 'antd';
-
-import './index.scss';
-
-import fetch from '../../../api/request';
-const { MonthPicker, RangePicker } = DatePicker;
-const FormItem = Form.Item;
-export default class SystemPage extends Component {
-  constructor(props) {
-    super(props);
-    this.config = {
-    };
-    this.state = {
-      loading: true,
-      totalElements: 1,
-      size: 10,
-      page: 1,
-      resetKey: Date.now(),
-      formdata: {
-        type: '',
-        title: '',
-        startTime: '',
-        endTime: ''
-      }
-    };
-  }
-
-  componentWillMount() { }
-
-  componentDidMount() {
-    this.loadData(this.state.formdata, this.state.page, this.state.size);
-  }
-
-  onShowSizeChange = (current, size) => {
-    console.log('pageSize', size)
-    this.setState({ size, page: 1 });
-    this.getData(this.state.formdata, this.state.page, this.state.size);
-  };
-
-  handleSubmit = (e) => {
-    e.preventDefault();
-    this.loadData(this.state.formdata, 1, this.state.size);
-  }
-
-  loadData = (formdata, page, size) => {
-    console.log('111')
-    let _this = this;
-    _this.setState({
-      loading: true
-    })
-    fetch({
-      url: 'api/document/getNotice',
-      params: {
-        ...formdata,
-        page,
-        size
-      }
-    }).then(res => {
-      console.log(res)
-      _this.setState({
-        tableData: res.content,
-        loading: false,
-        totalElements: res.totalElements,
-        page
-      });
-    });
-  }
-
-  //查询
-  Seaech = () => {
-    const { formdata, page, size } = this.state;
-    if (formdata.areaId) {
-      formdata.areaId = parseInt(formdata.areaId[1]);
-    }
-    this.loadData(formdata, 1, size)
-  }
-
-  //重置
-  Reset = () => {
-    this.setState({
-      resetKey: Date.now(),
-      formdata: {},
-      page: 1,
-      size: 10
-    }, this.loadData({}, 1, this.state.size))
-  }
-
-  onInputChange = ({ target: { value, name } }) => {
-    this.setState(({ formdata }) => ({
-      formdata: {
-        ...formdata,
-        [name]: this.trim(value)
-      }
-    }))
-  }
-
-  onTimeChange = (value, dateString) => {
-    this.onChange('startTime', moment(dateString[0]).format('YYYY-MM-DD HH:mm'));
-    this.onChange('endTime', moment(dateString[1]).format('YYYY-MM-DD HH:mm'));
-  }
-
-  onChange = (field, value) => {
-    this.setState(({ formdata }) => ({
-      formdata: {
-        ...formdata,
-        [field]: value
-      }
-    }))
-  }
-
-  trim = (str) => {
-    str = str.replace(/^(\s|\u00A0)+/, '');
-    for (var i = str.length - 1; i >= 0; i--) {
-      if (/\S/.test(str.charAt(i))) {
-        str = str.substring(0, i + 1);
-        break;
-      }
-    }
-    return str;
-  }
-
-  getColumns = () => {
-    let obj = this;
-    return [
-      { title: '通知标题', className: "txt-c", dataIndex: 'documentItle;' },
-      { title: '通知内容', className: "txt-c", dataIndex: 'documentContent' },
-      // { title: '文档类型', className: "txt-c", dataIndex: 'documentType', render: (text, record) => text == "DT00001" ? "规章制度" : text == "DT00002" ? "通知公告" : text },
-      { title: '接受情况', className: "txt-c", dataIndex: 'groupType', render: (text, record) => <span>{record.readNumber || 0}/{record.noticeNumber || 0}</span> },
-      { title: '通知时间', className: "txt-c", dataIndex: 'createTime', render: (text, record) => text !== "" && text != null ? moment(text).format("YYYY-MM-DD HH:mm") : "" },
-      // {
-      //   title: '操作', className: "txt-c", key: 'operation', render: (text, record) => {
-      //     return <div>
-      //       <Link to={{ pathname: "/baseManage/groupDetail/" + record.id + '/Modify', query: { id: record.id } }}>修改</Link>
-      //       <span>&nbsp;|&nbsp;</span>
-      //       <a href="javascript:void(0);" onClick={() => this.delete(record.id)}>删除</a>
-      //     </div>
-      //   }
-      // }
-    ]
-  }
-
-  render() {
-    const { resetKey, formdata } = this.state;
-    return (
-      <div className="announcement-page-main">
-        <Card style={{ border: 20, margin: 20, padding: 20 }}>
-          <Row style={{ margin: '10px' }} key={resetKey}>
-
-            <Col span={1} style={{ display: 'flex', justifyContent: 'center', lineHeight: '28px' }}>标题:</Col>
-            <Col className="gutter-row" span={4}>
-              <Input placeholder="标题" name='name' onChange={this.onInputChange} />
-            </Col>
-            <Col span={2} style={{ display: 'flex', justifyContent: 'center', lineHeight: '28px' }}>发布时间:</Col>
-            <Col className="gutter-row" span={6}>
-              <RangePicker placeholder={['开始时间', '结束时间']} showTime format="YYYY-MM-DD HH:mm" onChange={this.onTimeChange} />
-            </Col>
-            <Col className="gutter-row" span={2}>
-              <Button type="primary" onClick={this.Seaech}>查询</Button>
-            </Col>
-            <Col className="gutter-row" span={2}>
-              <Button onClick={this.Reset}>重置</Button>
-            </Col>
-          </Row>
-          <Row>
-            <Table key={this.state.tableKey}
-              size="middle"
-              className="rowColor"
-              dataSource={this.state.tableData}
-              loading={{ spinning: this.state.loading }}
-              columns={this.getColumns()}
-              pagination={{
-                size: this.state.size,
-                onChange: this.pageChange,
-                total: this.state.totalElements,
-                showSizeChanger: true,
-                onShowSizeChange: this.onShowSizeChange,
-                showTotal: (total, range) => `共${total}条记录 `,
-                itemRender: this.itemRender,
-                showQuickJumper: true,
-                defaultCurrent: 1,
-                current: this.state.page
-              }}
-            />
-          </Row>
-        </Card>
-      </div >
-    )
-  }
-}
-
diff --git a/src/components/page/SystemPage/index.scss b/src/components/page/SystemPage/index.scss
deleted file mode 100644
index b8341fa..0000000
--- a/src/components/page/SystemPage/index.scss
+++ /dev/null
@@ -1,12 +0,0 @@
-/* eslint-disable */
-/**liuwh
- * 4/6/2020, 3:25:59 PM
- * doc comment for the file goes here
- */
-
-/** Happy Coding */
-.system-page {
-  &-main {
-
-  }
-}
diff --git a/src/components/page/index/rulesList/index.jsx b/src/components/page/index/rulesList/index.jsx
index b465e0e..0b9bfb9 100644
--- a/src/components/page/index/rulesList/index.jsx
+++ b/src/components/page/index/rulesList/index.jsx
@@ -36,16 +36,16 @@
   cancle = (id) => {
     console.log(id)
   //   // this.props.history.push("/document/create?id=" + id);
-  this.props.history.push({ pathname: "/document/create" });
+  this.props.history.push({ pathname: "/document/create/"+id });
   }
 
   renderColumns = () => {
     return [
-      { title: '通知标题', dataIndex: 'documentTitle' },
+      { title: '标题', dataIndex: 'documentTitle' },
       { title: '通知内容', dataIndex: 'documentContent' },
       { title: '接受情况', dataIndex: 'groupType', render: (cur, item) => <span>{item.readNumber || 0}/{item.noticeNumber || 0}</span> },
-      { title: '通知时间', dataIndex: 'createTime', render: (cur, item) => cur !== "" && cur != null ? moment(cur).format("YYYY-MM-DD HH:mm") : "" },
-      { title: '操作', render: (text, record) => <a href="" onClick={() => this.cancle(record.id)}>查看</a> }
+      { title: '发布时间', dataIndex: 'createTime', render: (cur, item) => cur !== "" && cur != null ? moment(cur).format("YYYY-MM-DD HH:mm") : "" },
+      { title: '操作', render: (text, record) => <a >下载</a> }
     ];
   }
 
diff --git a/src/components/page/index/workbench/index.jsx b/src/components/page/index/workbench/index.jsx
index 4ffbf82..0098287 100644
--- a/src/components/page/index/workbench/index.jsx
+++ b/src/components/page/index/workbench/index.jsx
@@ -29,7 +29,7 @@
   render() {
     return (
       <div className="workbench-main">
-        <NotifyList />
+        <NotifyList {...this.props}/>
         <TopListTableView />
         <HotListTableView />
       </div>
diff --git a/src/index.js b/src/index.js
index 4fd9219..83c8587 100644
--- a/src/index.js
+++ b/src/index.js
@@ -49,7 +49,7 @@
           <Content>
             <Switch>
               {/* 新建文档 */}
-              <Route path="/document/create" component={DocumentEdit} />
+              <Route path="/document/create/:id?" component={DocumentEdit} />
 
               {/* 全部通知 */}
               <Route path="/index/workbench/announcement" component={Announcement} />
diff --git a/src/pages/document/DocumentEdit.jsx b/src/pages/document/DocumentEdit.jsx
index a9b9407..e2fc182 100644
--- a/src/pages/document/DocumentEdit.jsx
+++ b/src/pages/document/DocumentEdit.jsx
@@ -22,7 +22,9 @@
 
   componentWillMount() { }
 
-  componentDidMount() { }
+  componentDidMount() {
+    console.log()
+   }
 
   componentDidShow() { }
 
@@ -30,7 +32,7 @@
     return (
       <div className="document-edit-main">
         <BreadcrumbView data={[{ name: '新建文档' }]} />
-        <DocumentEditPage history={this.props.history}/>
+        <DocumentEditPage {...this.props}/>
       </div>
     )
   }
diff --git a/src/pages/index/Announcement.jsx b/src/pages/index/Announcement.jsx
index e2a408f..7b6fa38 100644
--- a/src/pages/index/Announcement.jsx
+++ b/src/pages/index/Announcement.jsx
@@ -28,7 +28,7 @@
     return (
       <div className="announcement-main">
         <BreadcrumbView data={[{ name: '工作台',url:'#/index/workbench' },{ name: '全部通知' }]} />
-        <AnnouncementPage />
+        <AnnouncementPage {...this.props}/>
       </div>
     )
   }
diff --git a/src/pages/index/System.jsx b/src/pages/index/System.jsx
index d526ecd..138f5b0 100644
--- a/src/pages/index/System.jsx
+++ b/src/pages/index/System.jsx
@@ -7,7 +7,6 @@
 /** Happy Coding */
 import React, { ReactNode, ReactEventHandler, Component } from 'react';
 import BreadcrumbView from '../../components/common/BreadcrumbView';
-import SystemPage from '../../components/page/SystemPage'
 import RulesList from '../../components/page/index/rulesList'
 
 export default class System extends Component {
@@ -29,7 +28,6 @@
     return (
       <div className="System-main">
         <BreadcrumbView data={[{ name: '规章制度' }]} />
-        {/* <SystemPage /> */}
         <RulesList {...this.props} />
       </div>
     )
diff --git a/src/pages/index/workbench.jsx b/src/pages/index/workbench.jsx
index a7661a3..a59e6c4 100644
--- a/src/pages/index/workbench.jsx
+++ b/src/pages/index/workbench.jsx
@@ -29,7 +29,7 @@
       <div className="workbench-page-main flex-box-column">
         <BreadcrumbView data={[{ name: '工作台' }]} />
         <div className="flex-1">
-          <WorkbenchPage />
+          <WorkbenchPage {...this.props}/>
         </div>
       </div>
     )

--
Gitblit v1.8.0