Browse Source

管理员设置和信息功能完成

yee 8 years ago
parent
commit
c75ed3bc49

+ 6 - 17
js/component/account/services/patent.jsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { Icon, Alert, Button, Input, Select, Spin, Table, message } from 'antd';
+import { Icon, Button, Input, Select, Spin, Table, message } from 'antd';
 import { patentTypeList, patentStateList } from '../../dataDic.js';
 import { getPatentType, getPatentState, getTime, setUserContactsList } from '../../tools.js';
 import ajax from 'jquery/src/ajax/xhr.js'
@@ -15,11 +15,11 @@ const Patent = React.createClass({
             loading: true
         });
         let page = pageNo || 1,
-        pageSize = this.state.pagination.pageSize,
-        patentNumber = this.state.searchNum || '',
-        patentName = this.state.searchName || '',
-        patentCatagory = this.state.searchType || '',
-        patentState = this.state.searchState || '';
+            pageSize = this.state.pagination.pageSize,
+            patentNumber = this.state.searchNum || '',
+            patentName = this.state.searchName || '',
+            patentCatagory = this.state.searchType || '',
+            patentState = this.state.searchState || '';
         $.ajax({
             method: "get",
             dataType: "json",
@@ -84,8 +84,6 @@ const Patent = React.createClass({
     },
     getInitialState() {
         return {
-            warningText: 'warning text! warning text! warning text!',
-            AlertDis: 'block',
             patentTypeOption: [],
             patentStateOption: [],
             data: [],
@@ -152,9 +150,6 @@ const Patent = React.createClass({
         this.loadData();
         this.state.contactsOption = setUserContactsList();
     },
-    alertClose(e) {
-        console.log(e);
-    },
     tableRowClick(record, index) {
         this.state.RowData = record;
         this.setState({
@@ -188,12 +183,6 @@ const Patent = React.createClass({
                     <span>专利申请管理</span>
                     {userData.type == '0' ? <span></span> : <PatentAdd ButtonDisabled={this.state.ButtonDisabled} closeDesc={this.closeDesc} />}
                 </div>
-                <Alert style={{ display: this.state.AlertDis }} className="patent-alert" message={this.state.warningText}
-                    type="info"
-                    showIcon={true}
-                    closable
-                    onClose={this.alertClose}
-                />
                 <div className="patent-query">
                     <Input placeholder="专利号" value={this.state.searchNum} onChange={(e) => { this.setState({ searchNum: e.target.value }); }} />
                     <Input placeholder="专利名称" value={this.state.searchName} onChange={(e) => { this.setState({ searchName: e.target.value }); }} />

+ 1 - 0
js/component/manageCenter/servicesManage/highTech/fosterDesc/finance.jsx

@@ -326,6 +326,7 @@ const Finance = React.createClass({
                 message.warning(data.error[0].message);
                 return;
             };
+            this.state.data = [];
             for (let i = 0; i < data.data.list.length; i++) {
                 let thisdata = data.data.list[i];
                 this.state.data.push({

+ 0 - 1
js/component/manageCenter/servicesManage/patent/comprehensive.jsx

@@ -168,7 +168,6 @@ const Patent = React.createClass({
             endTime: [],
             startTime: [],
             author: '',
-            AlertDis: 'block',
             patentTypeOption: [],
             patentStateOption: [],
             companyOption: [],

+ 389 - 3
js/component/manageCenter/topTab.jsx

@@ -1,5 +1,7 @@
 import React from 'react';
-import { Row, Col } from 'antd';
+import { Row, Col, Icon, Modal, Button, Spin, Select, Input, message, Badge, Table, Tabs } from 'antd';
+import { provinceArr } from '../dataDic.js';
+import { companySearch } from '../tools.js';
 import './topTab.less';
 import ajax from 'jquery/src/ajax/xhr.js'
 import $ from 'jquery/src/ajax';
@@ -7,10 +9,343 @@ import $ from 'jquery/src/ajax';
 
 import logo from '../../../image/acc-logo.png';
 
+const MessageModal = React.createClass({
+    getInitialState() {
+        return {
+            visible: false,
+            loading: false,
+            pagination: {
+                defaultCurrent: 1,
+                defaultPageSize: 10,
+                showQuickJumper: true,
+                pageSize: 10,
+                onChange: function (page) {
+                    this.loadReaded(page);
+                }.bind(this),
+                showTotal: function (total) {
+                    return '共' + total + '条数据';
+                }
+            },
+            columns: [
+                {
+                    title: '编号',
+                    dataIndex: 'key',
+                    key: 'key'
+                }, {
+                    title: '类型',
+                    dataIndex: 'noticeType',
+                    key: 'noticeType',
+                    render: (text) => {
+                        switch (text) {
+                            case 1:
+                                return <a href={globalConfig.context + "/admin/servicesManage/patent.html#comprehensive"}> 专利申请管理 </a>;
+                            case 3:
+                                return <a href={globalConfig.context + "/admin/servicesManage/copyright.html#copyright"}> 软著申请管理 </a>;
+                            case 2:
+                                return <a href={globalConfig.context + "/admin/servicesManage/highTech.html#highTechApply"}> 高企认定管理 </a>;
+                            case 4:
+                                return <a href={globalConfig.context + "/admin/servicesManage/technology.html#applyManage"}> 科技项目申报管理 </a>;
+                        }
+                    }
+                }, {
+                    title: '时间',
+                    dataIndex: 'createTimeFormattedDate',
+                    key: 'createTimeFormattedDate'
+                }, {
+                    title: '内容',
+                    dataIndex: 'content',
+                    key: 'content',
+                }
+            ],
+            data: []
+        };
+    },
+    loadReaded(pageNo) {
+        this.state.data = [];
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/notice/readed",
+            data: {
+                pageNo: pageNo || 1,
+                pageSize: this.state.pagination.pageSize,
+            }
+        }).done((data) => {
+            if (!data.data) {
+                if (data.error && data.error.length) {
+                    message.warning(data.error[0].message);
+                    return;
+                };
+            };
+            this.state.data = [];
+            for (let i = 0; i < data.data.list.length; i++) {
+                let thisdata = data.data.list[i];
+                this.state.data.push({
+                    key: i + 1,
+                    id: thisdata.id,
+                    aid: thisdata.aid,
+                    noticeType: thisdata.noticeType,
+                    content: thisdata.content,
+                    createTime: thisdata.createTime,
+                    createTimeFormattedDate: thisdata.createTimeFormattedDate,
+                });
+            };
+            this.state.pagination.current = data.data.pageNo;
+            this.state.pagination.total = data.data.totalCount;
+            this.setState({
+                dataSource: this.state.data,
+                pagination: this.state.pagination
+            });
+        }).always(function () {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+    loadUnread() {
+        this.state.data = [];
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/notice/unread",
+            // data: {
+            //     pageNo: pageNo || 1,
+            //     pageSize: this.state.pagination.pageSize,
+            // }
+        }).done((data) => {
+            if (!data.data) {
+                if (data.error && data.error.length) {
+                    message.warning(data.error[0].message);
+                    return;
+                };
+            };
+            this.state.data = [];
+            for (let i = 0; i < data.data.list.length; i++) {
+                let thisdata = data.data.list[i];
+                this.state.data.push({
+                    key: i + 1,
+                    id: thisdata.id,
+                    aid: thisdata.aid,
+                    noticeType: thisdata.noticeType,
+                    content: thisdata.content,
+                    createTime: thisdata.createTime,
+                    createTimeFormattedDate: thisdata.createTimeFormattedDate,
+                });
+            };
+            this.setState({
+                unreadData: this.state.data
+            });
+            // this.state.pagination.current = data.data.pageNo;
+            // this.state.pagination.total = data.data.totalCount;
+            // this.setState({
+            //     dataSource: this.state.data,
+            //     pagination: this.state.pagination
+            // });
+        }).always(function () {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+    componentWillReceiveProps(nextProps) {
+        if (!this.state.visible && nextProps.showDesc) {
+            this.loadReaded();
+            this.loadUnread();
+        };
+        this.state.visible = nextProps.showDesc
+    },
+    handleOk() {
+        this.setState({
+            visible: false,
+        });
+        this.props.closeDesc(false, true);
+    },
+    handleCancel(e) {
+        this.setState({
+            visible: false,
+        });
+        this.props.closeDesc(false, true);
+    },
+    render() {
+        return (
+            <div className="topTab-modal">
+                <Spin spinning={this.state.loading} className='spin-box'>
+                    <Modal title="信息中心" visible={this.state.visible}
+                        onOk={this.handleOk} onCancel={this.handleCancel}
+                        width='600px' footer={
+                            <Button key="back" onClick={this.handleCancel}>返回</Button>
+                        }
+                    >
+                        <Tabs defaultActiveKey="1">
+                            <Tabs.TabPane tab="新信息" key="1">
+                                <Table columns={this.state.columns}
+                                    dataSource={this.state.unreadData}
+                                    pagination={false} />
+                            </Tabs.TabPane>
+                            <Tabs.TabPane tab="已读信息" key="2">
+                                <Table columns={this.state.columns}
+                                    dataSource={this.state.dataSource}
+                                    pagination={this.state.pagination} />
+                            </Tabs.TabPane>
+                        </Tabs>
+                    </Modal>
+                </Spin>
+            </div>
+        );
+    }
+});
+
+const UserModal = React.createClass({
+    getInitialState() {
+        return {
+            visible: false,
+            loading: false,
+            provinceOption: []
+        };
+    },
+    componentWillMount() {
+        let _me = this;
+        provinceArr.map(function (item) {
+            _me.state.provinceOption.push(
+                <Select.Option value={item} key={item}>{item}</Select.Option>
+            )
+        });
+    },
+    loadData() {
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/adminInfo",
+            success: function (data) {
+                if (!data.data) {
+                    if (data.error[0] && data.error[0]) {
+                        message.warning(data.error[0].message);
+                    };
+                    return;
+                };
+                this.setState({
+                    id: data.data.id,
+                    mobile: data.data.mobile,
+                    name: data.data.name,
+                    email: data.data.email,
+                    createTime: data.data.createTime,
+                    number: data.data.number,
+                    province: data.data.province,
+                    createTimeFormattedDate: data.data.createTimeFormattedDate
+                });
+            }.bind(this),
+        }).always(function (data) {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+    componentWillReceiveProps(nextProps) {
+        if (!this.state.visible && nextProps.showDesc) {
+            this.loadData();
+        };
+        this.state.visible = nextProps.showDesc
+    },
+    handleOk() {
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "post",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/updateAdminInfo",
+            data: {
+                id: this.state.id,
+                mobile: this.state.mobile,
+                name: this.state.name,
+                email: this.state.email,
+                province: this.state.province,
+                password: this.state.password,
+                pwd: this.state.pwd
+            }
+        }).always(function (data) {
+            if (data.error && data.error.length) {
+                message.warning(data.error[0].message);
+                this.setState({
+                    loading: false
+                });
+            } else {
+                message.success('保存成功!');
+                this.props.closeDesc(false, true);
+            };
+        }.bind(this));
+    },
+    handleCancel(e) {
+        this.setState({
+            visible: false,
+        });
+        this.props.closeDesc(false);
+    },
+    render() {
+        return (
+            <div className="topTab-modal">
+                <Spin spinning={this.state.loading} className='spin-box'>
+                    <Modal title="用户设置" visible={this.state.visible}
+                        onOk={this.handleOk} onCancel={this.handleCancel}
+                        width='380px'
+                    >
+                        <ul className="modal-content">
+                            <li>
+                                <span className='modal-text'>名字</span>
+                                <Input value={this.state.name} onChange={(e) => { this.state.name = e.target.value; this.setState({ name: this.state.name }); }} />
+                            </li>
+                            <li>
+                                <span className='modal-text'>登录账号</span>
+                                <Input value={this.state.mobile} onChange={(e) => { this.state.mobile = e.target.value; this.setState({ mobile: this.state.mobile }); }} />
+                            </li>
+                            <li>
+                                <span className='modal-text'>省份</span>
+                                <Select placeholder="选择省份"
+                                    style={{ width: 200 }}
+                                    value={this.state.province}
+                                    showSearch
+                                    filterOption={companySearch}
+                                    onChange={(e) => { this.setState({ province: e }) }}>
+                                    {this.state.provinceOption}
+                                </Select>
+                            </li>
+                            <li>
+                                <span className='modal-text'>邮箱</span>
+                                <Input value={this.state.email} onChange={(e) => { this.state.email = e.target.value; this.setState({ email: this.state.email }); }} />
+                            </li>
+                            <li>
+                                <span className='modal-text'>密码</span>
+                                <Input value={this.state.password} onChange={(e) => { this.state.password = e.target.value; this.setState({ password: this.state.password }); }} />
+                            </li>
+                            <li>
+                                <span className='modal-text'>原密码</span>
+                                <Input value={this.state.pwd} onChange={(e) => { this.state.pwd = e.target.value; this.setState({ pwd: this.state.pwd }); }} />
+                            </li>
+                        </ul>
+                    </Modal>
+                </Spin>
+            </div>
+        );
+    }
+});
+
 const TopTab = React.createClass({
     getInitialState() {
         return {
-            username: 'username',
+            username: '请登录!',
         };
     },
     logOut() {
@@ -23,12 +358,61 @@ const TopTab = React.createClass({
             window.location.href = globalConfig.context + "/admin/login.html"
         });
     },
+    componentWillMount() {
+        this.loadData();
+    },
+    loadData() {
+        this.setState({
+            loading: true
+        });
+        $.ajax({
+            method: "get",
+            dataType: "json",
+            crossDomain: false,
+            url: globalConfig.context + "/api/admin/notice/unreadCount",
+            success: function (data) {
+                if (!data.data) {
+                    if (data.error[0] && data.error[0]) {
+                        message.warning(data.error[0].message);
+                        return;
+                    };
+                };
+                this.setState({
+                    badge: data.data,
+                });
+            }.bind(this),
+        }).always(function (data) {
+            this.setState({
+                loading: false
+            });
+        }.bind(this));
+    },
+    closeUserModal(e, s) {
+        this.state.userModalShow = e;
+        if (s) {
+            this.loadData();
+        };
+    },
+    closeMessageModal(e, s) {
+        this.state.messageModalShow = e;
+        if (s) {
+            this.loadData();
+        };
+    },
     render() {
         return (
             <div className="account-top" >
                 <div className="acc-top-user">
-                    <span className="acc-top-user-name">欢迎您, {adminData.name || adminData.mobile || this.state.username} <a onClick={this.logOut}>[ 退出 ]</a></span>
+                    <span className="acc-top-user-name">欢迎您 , {adminData.name || adminData.mobile ? <a onClick={() => { this.setState({ userModalShow: true }); }}> {adminData.name || adminData.mobile} </a> : <a onClick={this.logOut}>{this.state.username}</a>} <a onClick={this.logOut}>[ 退出 ]</a></span>
                     <span className="acc-top-user-toindex"><a href={globalConfig.context + "/admin/index.html"}>返回首页</a></span>
+                    <a onClick={() => { this.setState({ messageModalShow: true }); }} className="user-badge">
+                        <Icon type="mail" />
+                        {(() => {
+                            if (this.state.badge) {
+                                return <Badge status="processing" />
+                            }
+                        })()}
+                    </a>
                 </div>
                 <div className="acc-index">
                     <div className="acc-index-imgbox">
@@ -46,6 +430,8 @@ const TopTab = React.createClass({
                         <Col style={{ display: window.showSystem ? 'block' : 'none' }} className={this.props.active === 'system' ? 'active' : ''} span={3}><a href={globalConfig.context + "/admin/set.html"}>系统设置</a></Col>
                     </Row>
                 </div>
+                <UserModal showDesc={this.state.userModalShow} closeDesc={this.closeUserModal} />
+                <MessageModal showDesc={this.state.messageModalShow} closeDesc={this.closeMessageModal} />
             </div >
         )
     }

+ 41 - 5
js/component/manageCenter/topTab.less

@@ -11,12 +11,34 @@
             height: 34px;
             line-height: 34px;
             background: #f8f8f8;
+            font-size: 14px;
             .acc-top-user-name {
                 margin-left: 10px;
+                line-height: 34px;
+                vertical-align: middle;
             }
             .acc-top-user-toindex {
                 float: right;
                 margin-right: 10px;
+                line-height: 34px;
+                vertical-align: middle;
+            }
+            .user-badge {
+                margin-left: 12px;
+                font-size: 18px;
+                color: #58a3ff;
+                position: relative;
+                line-height: 34px;
+                vertical-align: middle;
+                .ant-badge {
+                    position: absolute;
+                    right: -10px;
+                    top: 0;
+                    line-height: 0px;
+                    .ant-badge-status-processing {
+                        background-color: red
+                    }
+                }
             }
         }
         .acc-index {
@@ -27,8 +49,8 @@
             left: 0;
             color: #fff;
             background: #4665bf;
-            padding:27px 10px;
-            .acc-index-imgbox{
+            padding: 27px 10px;
+            .acc-index-imgbox {
                 width: 36px;
                 height: 36px;
                 padding-top: 36px;
@@ -48,7 +70,7 @@
                 font-size: 20px;
                 line-height: 36px;
                 a {
-                    color:#fff;
+                    color: #fff;
                 }
             }
         }
@@ -65,9 +87,9 @@
                 padding-left: 20px;
                 border-left: 1px solid #6b84cc;
                 div {
-                    margin:0 10px;
+                    margin: 0 10px;
                     a {
-                        color:#fff;
+                        color: #fff;
                     }
                 }
                 .active {
@@ -85,4 +107,18 @@
                 }
             }
         }
+    }
+
+    .modal-content {
+        >li {
+            margin-bottom: 20px;
+            >span {
+                display: inline-block;
+                width: 60px;
+                margin-right: 10px;
+            }
+            >input {
+                width: 200px;
+            }
+        }
     }