zhouna 3 лет назад
Родитель
Сommit
4be36e1db6

+ 212 - 0
src/components/MsgManage/index.js

@@ -0,0 +1,212 @@
+import { useEffect, useState } from 'react';
+import { useSelector } from 'react-redux'
+import { Table, Modal, message, Menu, Breadcrumb, Dropdown, Space, Form, Input, Button, Row, Col, Select } from 'antd';
+import { DownOutlined, PlusOutlined } from '@ant-design/icons';
+import './index.less';
+import apiObj from '@api/index';
+import utils from '@utils/index'
+const { pickCheckedTreeIds } = utils;
+const { post, api, xPost } = apiObj;
+const { Option } = Select;
+function MsgManage() {
+    useEffect(() => {
+        //刷新列表
+        getTableData();
+
+    }, []);
+
+    const [size, setSize] = useState(15);       //每页显示条数
+    const [total, setTotal] = useState(0);       //每页显示条数
+    const [dataSource, setDataSource] = useState([]);   //列表数据
+    const [visible, setVisible] = useState(false);   //弹窗查看
+    const [delVisible, setDelVisible] = useState(false);   //弹窗删除
+    const [delId,setDelId] = useState('');      //要删除的通知id
+    const [confirmLoading, setConfirmLoading] = useState(false);
+    const [msgDetail, setMsgDetail] = useState({});
+    //从state中取出状态、类型列表
+    const staticInfo = useSelector(state => {
+        return state.staticInfo;
+    });
+    const { msgTypeList, msgStatusList } = staticInfo;
+
+    //获取表格数据
+    function getTableData(param = {}) {
+        post(api.listPage, param).then((res) => {
+            if (res.data.code === 200) {
+                let data = res.data.data;
+                setTotal(data.total);
+                setDataSource(data.records);
+            }
+
+        })
+    }
+    //弹窗取消
+    function handleCancel() {
+        setVisible(false);
+    }
+    //新增子组织弹窗
+    function showMessage(id) {
+        getMsgDetail(id);
+        setVisible(true);
+    }
+    //删除消息
+    function delMessage(id){
+        setDelVisible(true);
+        setDelId(id);
+    }
+    //删除通知
+    function postDelMsg() {
+        xPost(api.deleteNoticeInfo, { id: delId}).then((res) => {
+            const { code } = res.data;
+            if (code === 200) {
+                getTableData();     //刷新列表
+                setDelVisible(false);
+                message.success(res.data.msg || '删除成功')
+            } else {
+                message.warning(res.data.msg || '删除失败,请重试')
+            }
+        });
+    }
+    //获取通知详情
+    function getMsgDetail(id) {     //type:1我的通知,0通知管理
+        xPost(api.getNoticeInfoById, { id: id, type: 0 }).then((res) => {
+            const { data, code } = res.data;
+            if (code === 200) {
+                setMsgDetail(data);
+            } else {
+                message.warning(res.data.msg || '获取详情失败')
+            }
+        });
+    }
+    //每页显示条数切换
+    function onSizeChange(){
+
+    }
+    //翻页
+    function onPageChange(){
+
+    }
+    //新增通知
+    function showAddMsg(){
+
+    }
+    //表格渲染
+    function RenderTable() {
+        const columns = [
+            { title: '标题', dataIndex: 'title', key: 'title' },
+            {
+                title: '类型', width: 150, dataIndex: 'typeName', key:'typeName'
+            },
+            { title: '发送者', dataIndex: 'sender', key: 'sender' },
+            { title: '发送时间', width: 240, dataIndex: 'gmtCreate', key: 'gmtCreate' },
+            {
+                title: '操作', key: 'operation', render: (row) => {
+                    return (<Space size="middle">
+                        <a onClick={() => showMessage(row.id)}>查看</a>
+                        <a className='delete' onClick={() => delMessage(row.id)}>删除</a>
+                    </Space>)
+                }
+            },
+        ];
+        return (
+            <Table
+                rowKey={record => record.id}
+                columns={columns}
+                dataSource={dataSource}
+                pagination={{
+                    showSizeChanger:true,
+                    pageSizeOptions:[15,30,60,120],
+                    defaultPageSize:size,
+                    pageNo: 1,
+                    size:'small',
+                    total: total,
+                    showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+                }}
+            />
+        )
+
+    }
+    //筛选项渲染
+    const [form] = Form.useForm();
+    const onFinish = (values: any) => {
+        getTableData(values);
+        console.log('筛选项:', values);
+    };
+    const onReset = () => {
+        form.resetFields();
+        getTableData();
+    };
+    return (
+        <div className='wrapper'>
+            <div className="filter-box">
+                <Form form={form} name="control-hooks" onFinish={onFinish}>
+                    <Row gutter={24}>
+                        <Col span={5} key={1}>
+                            <Form.Item name="type" label="通知类型">
+                                <Select
+                                    allowClear
+                                >
+                                    {msgTypeList.map((item) => {
+                                        return (
+                                            <Option value={item.name} key={item.name}>{item.val}</Option>
+                                        )
+                                    })}
+                                </Select>
+                            </Form.Item>
+                        </Col>
+                        <Col span={9} key={3}>
+                            <Form.Item>
+                                <Button type="primary" htmlType="submit">
+                                    查询
+                                </Button>
+                                <Button htmlType="button" onClick={onReset}>
+                                    重置
+                                </Button>
+                            </Form.Item>
+                        </Col>
+                    </Row>
+                </Form>
+            </div>
+            <div className="table">
+                <div className="table-header">
+                    <h2 className="table-title">通知管理</h2>
+                    <Button type="primary" icon={<PlusOutlined />} onClick={() => showAddMsg()}>新增通知</Button>
+                </div>
+                <RenderTable />
+            </div>
+            <Modal
+                title="查看通知"
+                footer={null}
+                width={724}
+                visible={visible}
+                onCancel={()=>setVisible(false)}
+                confirmLoading={confirmLoading}
+            >
+                <div className="message-box">
+                    <p className='msg-title'>{msgDetail.title}</p>
+                    <div className="msg-content">{msgDetail.content}</div>
+                    <div className="msg-footer">
+                        <span className="msg-type">类型:{msgDetail.typeName}</span>
+                        <span className="msg-sender">发送者:{msgDetail.creatorName}</span>
+                        <span className="msg-time">发送时间:{msgDetail.gmtCreate}</span>
+                    </div>
+                </div>
+                <p className='message-oper'><Button type='primary' onClick={handleCancel}>返回</Button></p>
+            </Modal>
+            <Modal
+                title="删除通知"
+                width={400}
+                visible={delVisible}
+                okText='确定'
+                cancelText='取消'
+                onOk={postDelMsg}
+                onCancel={()=>setDelVisible(false)}
+                confirmLoading={confirmLoading}
+            >
+                <p>确定要删除这条通知吗?</p>
+            </Modal>
+        </div>
+    )
+}
+
+export default MsgManage;

+ 93 - 0
src/components/MsgManage/index.less

@@ -0,0 +1,93 @@
+@import "@common/common.less";
+
+.ant-table-thead > tr > th{
+  background: @table-th-color;
+  color: @text-color;
+  border-bottom: 1px #D8D8D8 solid;
+}
+.ant-steps-item-title{
+  font-size: 14px;
+}
+.ant-tabs > .ant-tabs-nav, .ant-tabs > div > .ant-tabs-nav{
+  margin-bottom: 0;
+}
+.ant-tabs-content-holder{
+  border: 1px solid #f0f0f0;
+  border-top: none;
+}
+.button-box{
+  text-align: right;
+  .ant-btn-primary{
+    margin-left: 20px;
+  }
+}
+.filter-box{
+  .ant-btn-primary{
+    margin-right: 20px;
+  }
+}
+.add-container{
+  margin: 30px 165px;
+}
+.ant-breadcrumb{
+  .back-icon{
+    width: 14px;
+    height: 12px;
+    vertical-align: baseline;
+    margin-right: 4px;
+    cursor: pointer;
+  }
+}
+
+
+.table-header{
+  display: flex;
+  justify-content: space-between;
+  padding: 24px 0;
+  .ant-breadcrumb-link{
+    font-size: 16px;
+    font-weight: 500;
+    color: #333333;
+  }
+}
+
+/*******查看弹窗********/
+.message-box{
+  border:1px @border-color-base solid;
+  padding:0 15px;
+  height: 429px;
+  position: relative;
+  .msg-title{
+    color:@primary-color;
+    font-size: 16px;
+    line-height: 40px;
+    text-align: center;
+    border-bottom: 1px @border-color-base solid;
+  }
+  .msg-content{
+    height: 326px;
+    overflow-y: auto;
+  }
+  .msg-footer{
+    border-top:1px @border-color-base solid;
+    text-align: center;
+    line-height: 40px;
+    position: absolute;
+    bottom: 0;
+    width: calc(100% - 30px);
+  }
+  .msg-sender{
+    float: left;
+  }
+  .msg-time{
+    float: right;
+  }
+}
+.ant-modal-body{
+  padding: 14px 18px;
+}
+.message-oper{
+  text-align: center;
+  margin-top: 30px;
+
+}

+ 5 - 29
src/components/MyMessage/index.js

@@ -10,29 +10,17 @@ const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function MyMessage() {
     useEffect(() => {
-        //监听resize事件
-        // setTableHt(window.innerHeight - 260);
-        // window.addEventListener('resize', () => {
-        //     setTableHt(window.innerHeight - 260);
-        // });
         //刷新列表
-        setOrgType(localStorage.getItem('type'))
         getTableData();
-        //解绑事件
-        // return function clear() {
-        //     window.removeEventListener("resize");
-        // }
 
     }, []);
 
     const [size, setSize] = useState(15);       //每页显示条数
     const [total, setTotal] = useState(0);       //每页显示条数
     const [dataSource, setDataSource] = useState([]);   //列表数据
-    // const [tableHt, setTableHt] = useState(300);   //表格滚动高度
     const [visible, setVisible] = useState(false);   //弹窗查看
     const [confirmLoading, setConfirmLoading] = useState(false);
     const [msgDetail, setMsgDetail] = useState({});
-    const [orgType, setOrgType] = useState(localStorage.getItem('type'));
     //从state中取出状态、类型列表
     const staticInfo = useSelector(state => {
         return state.staticInfo;
@@ -41,7 +29,7 @@ function MyMessage() {
 
     //获取表格数据
     function getTableData(param = {}) {
-        post(api.listPage, param).then((res) => {
+        post(api.listManagePage, param).then((res) => {
             if (res.data.code === 200) {
                 let data = res.data.data;
                 setTotal(data.total);
@@ -56,10 +44,10 @@ function MyMessage() {
     }
     //新增子组织弹窗
     function showMessage(id) {
-        getOrgDetail(id);
+        getMsgDetail(id);
         setVisible(true);
     }
-    function getOrgDetail(id) {     //type:1我的通知,0通知管理
+    function getMsgDetail(id) {     //type:1我的通知,0通知管理
         xPost(api.getNoticeInfoById, { id: id, type: 1 }).then((res) => {
             const { data, code } = res.data;
             if (code === 200) {
@@ -69,19 +57,6 @@ function MyMessage() {
             }
         });
     }
-    function structDetail(data) {
-        const content = JSON.parse(JSON.stringify(data).replace(/getHospitalUserDTO/g, "addHospitalUserVO"));
-        const menuData = content.getRoleDTO ? content.getRoleDTO.loginUserMenuResourceTree : [];
-        content.confirmPsd = content.addHospitalUserVO.password
-        let softwares = [], sids = [];
-        for (let i = 0; i < menuData.length; i++) {
-            const obj = pickCheckedTreeIds(menuData[i]);
-            softwares.push(obj);
-            sids.push(obj.id);
-        }
-        const fData = Object.assign({}, content, { softwares, sids });
-        setMsgDetail(fData);
-    }
     //每页显示条数切换
     function onSizeChange(){
 
@@ -100,7 +75,7 @@ function MyMessage() {
                 { title: '发送者', dataIndex: 'sender', key: 'sender' },
                 { title: '发送时间', width: 240, dataIndex: 'gmtCreate', key: 'gmtCreate' },
                 {
-                    title: '发送状态', key: 'statusName', dataIndex:'statusName'
+                    title: '阅读状态', key: 'statusName', dataIndex:'statusName'
                 },
                 {
                     title: '操作', key: 'operation', render: (row) => {
@@ -194,6 +169,7 @@ function MyMessage() {
                 width={724}
                 visible={visible}
                 confirmLoading={confirmLoading}
+                onCancel={()=>setVisible(false)}
             >
                 <div className="message-box">
                     <p className='msg-title'>{msgDetail.title}</p>

+ 2 - 2
src/components/OrgManager/index.js

@@ -286,7 +286,7 @@ function OrgManager() {
                         );
                         return (<Space size="middle">
                             <a onClick={() => editSubOrg(row.hospitalId, row.type, row.deptId)}>修改</a>
-                            {row.status === '1' ? (<a onClick={() => showModal(row.hasUserFlag || row.hasHospitalFlag ? 4 : 3, row.hospitalId, row.type)}>禁用</a>) : (<a onClick={() => enable(1, row.hospitalId, row.type)}>启用</a>)}
+                            {row.status === '1' ? (<a className='disable' onClick={() => showModal(row.hasUserFlag || row.hasHospitalFlag ? 4 : 3, row.hospitalId, row.type)}>禁用</a>) : (<a onClick={() => enable(1, row.hospitalId, row.type)}>启用</a>)}
                             <Dropdown overlay={menu} trigger={['click']}>
                                 <a className="ant-dropdown-link">
                                     更多 <DownOutlined />
@@ -341,7 +341,7 @@ function OrgManager() {
                         );
                         return (<Space size="middle">
                             <a onClick={() => editSubOrg(row.hospitalId, row.type)}>修改</a>
-                            {row.status === '1' ? (<a onClick={() => showModal(row.hasUserFlag || row.hasHospitalFlag ? 4 : 3, row.hospitalId, row.type)}>禁用</a>) : (<a onClick={() => enable(1, row.hospitalId, row.type)}>启用</a>)}
+                            {row.status === '1' ? (<a className='disable' onClick={() => showModal(row.hasUserFlag || row.hasHospitalFlag ? 4 : 3, row.hospitalId, row.type)}>禁用</a>) : (<a onClick={() => enable(1, row.hospitalId, row.type)}>启用</a>)}
                             <Dropdown overlay={menu} trigger={['click']}>
                                 <a className="ant-dropdown-link">
                                     更多 <DownOutlined />