Browse Source

病区管理

wyq 3 years ago
parent
commit
5cb89601d0

+ 6 - 0
src/api/request.js

@@ -38,6 +38,12 @@ const request = {
     getDoctorPage: '/security-center/dataAuthManage/getDoctorPage',//医生列表
 
     //病区管理
+    getDeptList: '/security-center/regionManage/getDeptList',//关联科室
     getRegion: '/security-center/regionManage/getRegion',//病区管理列表
+    addRegion: '/security-center/regionManage/addRegion',//新增病区
+    checkSolveRegion: '/security-center/regionManage/checkSolveRegion',//禁用启用
+    deleteRegion: '/security-center/regionManage/deleteRegion',//删除病区
+    updateRegion: '/security-center/regionManage/updateRegion',//修改病区
 }
+
 export default request;

+ 3 - 0
src/common/common.less

@@ -52,6 +52,9 @@ body{
     }
   }
 }
+.ant-table-pagination-right{
+  justify-content: flex-start;
+}
 //面包屑样式覆盖
 .ant-breadcrumb{
   margin: 20px 0 30px 30px;

+ 2 - 0
src/components/AHeader/index.js

@@ -2,6 +2,7 @@ import { Layout, Dropdown ,Menu } from 'antd';
 import { withRouter } from 'react-router'
 import { useState, useEffect } from 'react';
 import { useSelector,useDispatch } from 'react-redux';
+import { panesNow } from '@reducers/tabPanes.js';
 import utils from '@utils/index';
 import logo from '@images/logo.png';
 import msg from '@images/msg.png';
@@ -30,6 +31,7 @@ function AHeader({ history,hideName }){
         localStorage.removeItem("token");
         localStorage.removeItem("systemId");
         localStorage.removeItem("hospitalId");
+        dispatch(panesNow());
         history.push('/login');
     }
     //获取组织列表

+ 72 - 73
src/components/DataManager/AddData.js

@@ -11,7 +11,7 @@ import DoctorList from "./doctorList"
 import Item from 'antd/lib/list/Item';
 const { post, api, xPost } = apiObj;
 const { SHOW_PARENT } = TreeSelect;
-const { unique } = utils;
+const { unique, organizationData } = utils;
 const { Step } = Steps;
 const { TabPane } = Tabs;
 function AddData(props) {
@@ -30,43 +30,13 @@ function AddData(props) {
   const [treeData, setTreeData] = useState([]);
   const [selectedKeys, setSelectedKeys] = useState([]);
   const [orgList, setOrgList] = useState([]);
-  const [selectedRowKey, setSelectedRowKey] = useState([]);
+  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
   const [autoExpandParent, setAutoExpandParent] = useState(true);
   const { save, detail } = useContext(DataContext);
   const staticInfo = useSelector(state => {
     return state.staticInfo;
   });
-  // const { dataList } = staticInfo;
-  const dataList = [
-    {
-      "name": "1",
-      "val": "全部组织"
-    },
-    {
-      "name": "2",
-      "val": "全部科室"
-    },
-    {
-      "name": "3",
-      "val": "全部科室除本科室外"
-    },
-    {
-      "name": "4",
-      "val": "本科室"
-    },
-    {
-      "name": "5",
-      "val": "本医疗组"
-    },
-    {
-      "name": "6",
-      "val": "本人"
-    },
-    {
-      "name": "7",
-      "val": "自定义"
-    }
-  ]
+  const { dataList } = staticInfo;
   const initialValues = detail || {
     status: '1',
   };
@@ -91,29 +61,43 @@ function AddData(props) {
     post(api.getHospitalTree).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data
-        let arr = data
-        arr = structureTreeData(arr)
+        let arr = structureTreeData(data)
         setTreeData(arr)
       }
     })
   }
   //数据转换为树形结构所需字段
   function structureTreeData(arr) {
-    let list = []
-    arr.forEach(it => {
-      it.key = it.hospitalId
-      it.title = it.hospitalName
-      list.push({
-        children: it.depts,
-        title: it.hospitalName,
-        key: it.parentId + '-' + it.hospitalId + '-' + it.hospitalName
-      })
-      it.depts.forEach(its => {
-        its.key = it.parentId + '-' + it.hospitalId + '-' + its.deptId + '-' + its.deptName
-      })
+    arr.forEach(item => {
+      item.key = item.hospitalId + '-' + item.hospitalName 
+      item.title = item.hospitalName
+      if (!item.children && item.depts) {
+        item.depts.forEach(it => {
+          it.key = item.parentId + '-' + it.deptId + '-' + it.deptName
+        })
+        item.children = JSON.parse(JSON.stringify(item.depts).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'key'))
+        return
+      }
+      if (item.children) {
+        structureTreeData(item.children)
+      }
     })
-    arr = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'key'))
     return arr
+    // let list = []
+    // arr.forEach(it => {
+    //   it.key = it.hospitalId
+    //   it.title = it.hospitalName
+    //   list.push({
+    //     children: it.depts,
+    //     title: it.hospitalName,
+    //     key: it.parentId + '-' + it.hospitalId + '-' + it.hospitalName
+    //   })
+    //   it.depts.forEach(its => {
+    //     its.key = it.parentId + '-' + it.hospitalId + '-' + its.deptId + '-' + its.deptName
+    //   })
+    // })
+    // arr = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'key'))
+    // return arr
   }
   //获取组织列表
   function getOrgList() {
@@ -142,8 +126,8 @@ function AddData(props) {
     arr[i].id = key
     tags[index] = []
     setTags([...tags])
-    selectedRowKey[index] = []
-    setSelectedRowKey([...selectedRowKey])
+    selectedRowKeys[index] = []
+    setSelectedRowKeys([...selectedRowKeys])
     form.setFieldsValue({
       softwareVOS: arr
     });
@@ -188,7 +172,6 @@ function AddData(props) {
   //医生选中
   function checkDoctEvent(selectedRowKeys) {
     const formData = form.getFieldsValue();
-    let tag = []
     let arr = []
     selectedRowKeys.forEach(it => {
       arr.push({
@@ -196,37 +179,25 @@ function AddData(props) {
         detailId: it.split('-')[0],
         detailType: 3
       })
-      tag.push({
-        id: it.split('-')[0],
-        name: it.split('-')[1],
-        type: 3
-      })
     });
     formData.softwareVOS[index].dataAuthDetails = arr
     formData.softwareVOS[index].selectedRowKeys = selectedRowKeys
     form.setFieldsValue({
       softwareVOS: formData.softwareVOS
     });
-    tags[index] = unique(tag)
-    setTags([...tags])
+    getTags()
   }
   //树形结构选中事件
-  function checkTreeEvent(idsArr, sourceIds) {
+  function checkTreeEvent(idsArr) {
     const formData = form.getFieldsValue();
-    let tag = []
     let arr = []
-    let result = idsArr.find(ele => ele.split('-').length == 3)
+    let result = idsArr.find(ele => ele.split('-').length == 2)
     if (result) {
       arr.push({
         dataType: 7,
-        detailId: result.split('1')[1],
+        detailId: result.split('1')[0],
         detailType: 1
       })
-      tag.push({
-        id: result.split('-')[1],
-        name: result.split('-')[2],
-        type: 1
-      })
     } else {
       idsArr.forEach(it => {
         arr.push({
@@ -234,11 +205,6 @@ function AddData(props) {
           detailId: it.split('1')[2],
           detailType: 2
         })
-        tag.push({
-          id: it.split('-')[2],
-          name: it.split('-')[3],
-          type: 2
-        })
       })
     }
     formData.softwareVOS[index].dataAuthDetails = arr
@@ -246,7 +212,40 @@ function AddData(props) {
     form.setFieldsValue({
       softwareVOS: formData.softwareVOS
     });
-    tags[index] = unique(tag)
+    getTags()
+  }
+  //获取已选中标签
+  function getTags() {
+    const formData = form.getFieldsValue();
+    let tag = []
+    let softwareMenuIds = formData.softwareVOS[index].softwareMenuIds
+    let selectedRowKeys = formData.softwareVOS[index].selectedRowKeys
+    selectedRowKeys && selectedRowKeys.forEach(it => {
+      tag.push({
+        id: it.split('-')[0],
+        name: it.split('-')[1],
+        type: 3
+      })
+    });
+    if (softwareMenuIds) {
+      let result = softwareMenuIds.find(ele => ele.split('-').length == 2)
+      if (result) {
+        tag.push({
+          id: result.split('-')[0],
+          name: result.split('-')[1],
+          type: 1
+        })
+      } else {
+        softwareMenuIds.forEach(it => {
+          tag.push({
+            id: it.split('-')[1],
+            name: it.split('-')[2],
+            type: 2
+          })
+        })
+      }
+    }
+    tags[index] = tag
     setTags([...tags])
   }
   const onFinish = value => {

+ 2 - 7
src/components/DataManager/MenuTree.js

@@ -7,13 +7,8 @@ function MenuTree(props) {
 
 
   function onCheck(checkedKeys, e) {
-    const { checkedNodes } = e;
-    let sourceIds = e.node.key.split('-').length
-    // if (sourceIds == 3){
-    //   checkedKeys = []
-    //   checkedKeys.push(e.node.key)
-    // }
-    checkEv(checkedKeys, sourceIds)
+    console.log(e)
+    checkEv(checkedKeys)
   }
   function onSelect() {
 

+ 11 - 12
src/components/DataManager/doctorList.js

@@ -29,7 +29,6 @@ function DoctorList(props) {
     hospitals: []
   });
   const selectedRowKeys = checkeds.selectedRowKeys ? checkeds.selectedRowKeys.slice() : []
-  console.log(selectedRowKeys)
   //获取可看医生列表
   function getDoctorPage() {
     const param = {
@@ -89,19 +88,19 @@ function DoctorList(props) {
       hospitals: []
     }
     value.forEach(it => {
-      let arr = it.split('-')
+      let arr = JSON.stringify(it).split('-')
       let len = arr.length
-      if (len == 3) {
-        addHospitalTreeVO.depts.push(arr[2])
+      if (len == 2) {
+        addHospitalTreeVO.depts.push(arr[1])
       } else {
-        addHospitalTreeVO.hospitals.push(arr[1])
-        treeData.forEach(item => {
-          if (item.value.split('-')[1] == arr[1]) {
-            item.children.forEach(its => {
-              addHospitalTreeVO.depts.push(its.value.split('-')[2])
-            })
-          }
-        })
+        addHospitalTreeVO.hospitals.push(arr[0])
+        // treeData.forEach(item => {
+        //   if (item.value.split('-')[0] == arr[0]) {
+        //     item.children.forEach(its => {
+        //       addHospitalTreeVO.depts.push(its.value.split('-')[1])
+        //     })
+        //   }
+        // })
       }
     })
     setAddHospitalTreeVO(addHospitalTreeVO)

+ 27 - 29
src/components/DataManager/index.js

@@ -28,7 +28,7 @@ function DataManager() {
     2: '禁用后该用户将无法登录,确定要禁用该用户?',
   };
   console.log(addVisible);
-  
+
   const showModal = (name, type, flag) => {
     setaddVisible(true)
     // setVisible(type);
@@ -149,35 +149,33 @@ function DataManager() {
   if (addVisible) {
     return (
       <DataContext.Provider value={{ save: addData, detail: dataDetail }}>
-        <AddData back={goBack}/>
+        <AddData back={goBack} />
       </DataContext.Provider>
     )
   }
   return (
     <div className="wrapper">
-        <div className="filter-box">
+      <div className="filter-box">
         <Form
           form={form}
           name="normal_login"
-          className="basic"
           onFinish={onFinish}
           initialValues={{ status: '' }}
         >
-            <Row gutter={24}>
-                <Col span={6} key={0}>
-                  <Form.Item label="数据权限名称" name="username">
-                    <Input placeholder="用户名" />
-                  </Form.Item>
-                </Col>
-                <Col span={6} key={1}>
-                  <Form.Item label="所属角色" name="name">
-                    <Input placeholder="姓名" />
-                  </Form.Item>
-                </Col>
-                <Col span={8} key={2}>
+          <Row gutter={24}>
+            <Col span={5} key={0}>
+              <Form.Item label="数据权限名称" name="username">
+                <Input placeholder="用户名" />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={1}>
+              <Form.Item label="所属角色" name="name">
+                <Input placeholder="姓名" />
+              </Form.Item>
+            </Col>
+            <Col span={5} key={2}>
               <Form.Item label="当前状态" name="status">
                 <Select
-                  style={{ width: 200 }}
                   placeholder="Select a person"
                 >
                   <Option value="">全部</Option>
@@ -185,20 +183,20 @@ function DataManager() {
                   <Option value="0" >禁用</Option>
                 </Select>
               </Form.Item>
-                </Col>
-                <Col span={4} key={3}>
-          <Form.Item>
-            <Space size="middle">
-              <Button onClick={onReset}>
-                重置
+            </Col>
+            <Col span={6} key={3}>
+              <Form.Item>
+                <Space size="middle">
+                  <Button onClick={onReset}>
+                    重置
             </Button>
-              <Button type="primary" htmlType="submit">
-                查询
+                  <Button type="primary" htmlType="submit">
+                    查询
             </Button>
-            </Space>
-          </Form.Item>
-                </Col>
-            </Row>
+                </Space>
+              </Form.Item>
+            </Col>
+          </Row>
         </Form>
       </div>
       <div className="table">

+ 154 - 0
src/components/InpaManager/addInpa.js

@@ -0,0 +1,154 @@
+import React, {
+  useState, useEffect, useContext
+} from 'react';
+import { Modal, Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
+import apiObj from '@api/index';
+import utils from '@utils/index'
+import InpaContext from './inpa-context';
+import { useSelector } from 'react-redux'
+import Item from 'antd/lib/list/Item';
+const { post, api, xPost } = apiObj;
+const { organizationData } = utils;
+const { Option, OptGroup } = Select;
+const { SHOW_PARENT } = TreeSelect;
+function AddUser(props) {
+  const [form] = Form.useForm();
+  const { id, type, formData } = useContext(InpaContext);
+  
+  console.log(formData)
+  const initialValues = formData
+  function swichChange(val) {
+    form.setFieldsValue({ status: val ? 1 : 0 })
+  }
+  const onChangeRloe = value => {
+    form.setFieldsValue({ roles: value })
+  };
+  const onFinish = values => {
+    let params = values
+    if (type == 2) {
+      params.id = id
+      editRegion(params)
+    } else {
+      addRegion(params)
+    }
+
+  };
+  function addRegion(param) {
+    post(api.addRegion, param).then((res) => {
+      if (res.data.code === 200) {
+        props.userChange()
+        message.success(res.data.message);
+        form.resetFields();
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function editRegion(param) {
+    post(api.updateRegion, param).then((res) => {
+      if (res.data.code === 200) {
+        props.userChange()
+        message.success(res.data.message);
+        form.resetFields();
+      } else {
+        message.error(res.data.message);
+      }
+    })
+  }
+  function cancel() {
+    props.userChange()
+  }
+  return (
+    <>
+      <Form
+        labelCol={{ span: 7 }}
+        wrapperCol={{ span: 12 }}
+        form={form}
+        name="register"
+        onFinish={onFinish}
+        initialValues={initialValues}
+      >
+        <Form.Item
+          name="hospitalName"
+          label="上级组织"
+          required
+        >
+          <Input disabled />
+        </Form.Item>
+        <Form.Item
+          name="name"
+          label="病区名称"
+          rules={[
+            {
+              required: true,
+              message: '请输入病区名称',
+            },
+          ]}
+        >
+          <Input placeholder="请输入病区名称"/>
+        </Form.Item>
+        <Form.Item
+          name="code"
+          label="病区编码"
+        >
+          <Input placeholder="请输入病区编码" />
+        </Form.Item>
+        <Form.Item
+          name="liaison"
+          label="联系人"
+        >
+          <Input placeholder="请输入姓名" />
+        </Form.Item>
+        <Form.Item
+          name="phoneNumber"
+          label="手机号码"
+        >
+          <Input placeholder="请输入手机号码" />
+        </Form.Item>
+        <Form.Item
+          name="station"
+          label="类型"
+          required
+        >
+          <Input disabled/>
+        </Form.Item>
+       <Form.Item
+          name="orderNo"
+          label="排序"
+        >
+          <Input placeholder="大于0的整数" />
+        </Form.Item>
+        <Form.Item
+          name="status"
+          valuePropName="checked"
+          label="当前状态"
+          required
+        >
+          <Switch onChange={swichChange} />
+        </Form.Item>
+        {type == 3 ?
+          <Form.Item wrapperCol={{ offset: 10, span: 16 }}>
+            <Space size="middle">
+              <Button type="primary" htmlType="submit">
+                返回
+            </Button>
+            </Space>
+          </Form.Item>
+          :
+          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
+            <Space size="middle">
+              <Button htmlType="button" onClick={e => cancel()}>
+                取消
+            </Button>
+              <Button type="primary" htmlType="submit">
+                保存
+            </Button>
+            </Space>
+          </Form.Item>}
+
+      </Form>
+    </>
+  );
+}
+
+export default AddUser;

+ 150 - 118
src/components/InpaManager/index.js

@@ -1,9 +1,11 @@
 import React, { useState, useEffect, useRef } from 'react';
-import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Breadcrumb, message, Row, Col } from 'antd';
+import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Modal, message, Row, Col, Tooltip } from 'antd';
 import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
 import '@common/common.less';
+import AddInpa from './addInpa'
 import apiObj from '@api/index';
 import { useSelector } from 'react-redux'
+import InpaContext from './inpa-context';
 import utils from '@utils/index'
 const { post, api, xPost } = apiObj;
 const { organizationData } = utils;
@@ -11,89 +13,101 @@ const { Option } = Select;
 function InpaManager() {
   useEffect(() => {
     getRegion();
+    // getDeptList()
   }, []);
+  const [form] = Form.useForm();
   const [userList, setUserList] = useState([]);
+  const [deptList, setDeptList] = useState([]);
   const [title, setTitle] = useState("");
   const [visible, setVisible] = useState(false);
-  const [userId, setUserId] = useState("");
+  const [id, setId] = useState("");
   const [msvisible, setMsvisible] = useState(false);
   const [modalType, setModalType] = useState("");
   const [type, setType] = useState("");
   const [formData, setFormData] = useState(null);
   const [username, setUsername] = useState(null);
-
-  const [form] = Form.useForm();
+  const [total, setTotal] = useState(0);
+  const { user, sysName } = useSelector((state) => {
+    return state.userInfo;
+  });
+  let params = {
+    pages: 1,
+    current: 1,
+    size: 15
+  }
   const tipText = {
-    1: '确定要删除该用户?',
-    2: '禁用后该用户将无法登录,确定要禁用该用户?',
-    3: '确定要重置该用户密码?',
+    1: '确定要删除该病区?',
+    2: '确定要禁用该病区?',
   };
   const staticInfo = useSelector(state => {
     return state.staticInfo;
   });
   const { statusList } = staticInfo;
   //新增弹窗
-  const showModal = (name, type, flag, userId) => {
+  const showModal = (name, type, flag, id) => {
     setVisible(type);
     setTitle(name);
     setType(flag)
-    setUserId(userId)
+    setId(id)
     if (flag == 1) {
       setFormData({
-        status: '1'
+        hospitalName: user.name,
+        station: '病区',
+        status: 1
       })
     }
-    if (flag == 3 || flag == 2) {
-      getUserById(userId)
+    if (flag == 2) {
+      getRegionById(id)
     }
   }
   //表格数据
   function getRegion() {
-    let param = {
-      hospitalId:1
-    }
-    post(api.getRegion, param).then((res) => {
+    post(api.getRegion, params).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
         setUserList(data.records);
+        setTotal(data.total)
       }
     })
   }
+  //科室列表
+  // function getDeptList(param = {}) {
+  //   post(api.getDeptList, param).then((res) => {
+  //     if (res.data.code === 200) {
+  //       const data = res.data.data;
+  //       setDeptList(data);
+  //     }
+  //   })
+  // }
   //查看用户
-  function getUserById(userId) {
-    xPost(api.getUserById, { userId: userId }).then((res) => {
+  function getRegionById(id) {
+    post(api.updateRegion, { mark: 1, id: id }).then((res) => {
       if (res.data.code === 200) {
-        const data = res.data.data;
-        let roles = []
-        data.roles.forEach(item => {
-          roles.push(item.roleId)
-        })
+        const data = res.data.data.records[0];
+        console.log(data)
         const arr = {
-          username: data.username,
-          mobilePhone: data.mobilePhone,
-          password: data.password,
-          againpassword: data.password,
+          hospitalName: data.hospitalName,
           name: data.name,
-          idcard: data.idcard,
-          // addHospitalTreeVO: organizationData(data.hospitals[0].children[0].children),
-          titleId: data.titleId,
-          jobNo: data.jobNo,
-          roles: roles,
+          code: data.code,
+          liaison: data.liaison,
+          phoneNumber: data.phoneNumber,
+          station: '病区',
           orderNo: data.orderNo,
-          status: data.status,
+          status: data.status == '启用' ? '1' : '0',
         }
         setFormData(arr)
       }
     })
   }
   // 禁用/启用接口
-  function disableUser(userId, status) {
-    const param = { userId: userId, status: status };
-    xPost(api.disableUser, param).then((res) => {
+  function checkSolveRegion(id, mark) {
+    console.log(id)
+    const param = { id: id, mark: mark };
+    post(api.checkSolveRegion, param).then((res) => {
       if (res.data.code === 200) {
         getRegion();
         setMsvisible(false);
-        message.success((status ? '启用' : '禁用') + "成功");
+        message.success((mark == 2 ? '启用' : '禁用') + "成功");
       } else {
         message.warning(res.data.msg || '操作失败');
       }
@@ -101,26 +115,13 @@ function InpaManager() {
       message.error("接口出错");
     });
   }
-  //重置密码
-  function onResetPsd() {
-    // const param = { HospitalId: operId };
-    // xPost(api.disableHospital, param).then((res) => {
-    //   if (res.data.code === 200) {
-    //     getRegion();
-    //     message.success("重置成功");
-    //   } else {
-    //     message.warning(res.data.msg || '操作失败');
-    //   }
-    // }).catch(() => {
-    //   message.error("接口出错");
-    // });
-  }
   //删除
-  function deleteUser() {
-    const param = { userId: userId };
-    xPost(api.deleteUser, param).then((res) => {
+  function deleteRegion() {
+    const param = { id: id };
+    xPost(api.deleteRegion, param).then((res) => {
       if (res.data.code === 200) {
         getRegion();
+        setMsvisible(false)
         message.success("删除成功");
       } else {
         message.warning(res.data.msg || '操作失败');
@@ -129,9 +130,12 @@ function InpaManager() {
       message.error("接口出错");
     });
   }
-
   const onFinish = (value) => {
-    getRegion(value);
+    params = {
+      ...params,
+      ...value
+    }
+    getRegion();
   };
   const onReset = () => {
     form.resetFields();
@@ -139,18 +143,16 @@ function InpaManager() {
   };
   const messageBox = (type, id) => {
     setMsvisible(true)
-    setUserId(id)
+    setId(id)
     setModalType(type)
+    console.log(type)
   };
-
   //提示框确认事件
   function handleOk() {
     if (modalType == 1) {
-      deleteUser(userId)
+      deleteRegion(id)
     } else if (modalType == 2) {
-      disableUser(userId, 0)
-    } else if (modalType == 3) {
-      onResetPsd();
+      checkSolveRegion(id, 1)
     }
   }
   //提示框取消
@@ -163,16 +165,38 @@ function InpaManager() {
   }
   function userChange() {
     setVisible(false)
+    getRegion()
+  }
+  // function onSearch(val) {
+  //   getDeptList({ deptName: val })
+  // }
+  function changePage(page, pageSize) {
+    params.current = page
+    params.size = pageSize
+    getRegion()
   }
   const columns = [
-    { title: '用户名', dataIndex: 'username', key: 'index' },
-    { title: '姓名', dataIndex: 'name', key: 'index' },
-    { title: '所属组织', dataIndex: 'hospitalName', key: 'index' },
-    { title: '工号', dataIndex: 'jobNo', key: 'index' },
+    { title: '病区名称', dataIndex: 'name', key: 'index' },
+    {
+      title: '所属病区', dataIndex: 'hospitalName', key: 'index',
+      onCell: () => {
+        return {
+          style: {
+            maxWidth: 150,
+            overflow: 'hidden',
+            whiteSpace: 'nowrap',
+            textOverflow: 'ellipsis',
+            cursor: 'pointer'
+          }
+        }
+      },
+      render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
+    },
+    // { title: '关联科室', dataIndex: 'deptName', key: 'index' },
     {
       title: '状态', dataIndex: 'status', key: 'status', render: (text, record) => (
         <Space size="middle">
-          {record.status == 1 ?
+          {record.status == '启用' ?
             <span className="Enable">启用</span>
             :
             <span className="Disable">禁用</span>
@@ -180,83 +204,73 @@ function InpaManager() {
         </Space>
       )
     },
+    { title: '创建时间', dataIndex: 'gmtCreate', key: 'index' },
     {
       title: '操作', dataIndex: 'key', render: (text, record) => (
         <Space size="middle">
-          <a onClick={e => showModal('查看用户', true, 3, record.userId)}>查看</a>
-          <a onClick={e => showModal('修改用户', true, 2, record.userId)} >修改</a>
-          <Dropdown overlay={menu.bind(this, record)} record={record}>
-            <a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
-              更多 <DownOutlined />
-            </a>
-          </Dropdown>
+          <a onClick={e => showModal('修改用户', true, 2, record.id)} >修改</a>
+          {record.status === '启用' ? (<a onClick={() => messageBox(2, record.id)}>禁用</a>) : (<a onClick={() => checkSolveRegion(record.id, 2)}>启用</a>)}
+          <a target="_blank" onClick={() => messageBox(1, record.id)}>删除</a>
         </Space>
       )
     }
   ]
-  const menu = (record) => {
-    return (
-      <Menu>
-        <Menu.Item key="0">
-          <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com">
-            重置密码
-          </a>
-        </Menu.Item>
-        <Menu.Item key="1">
-          {record.status === '1' ? (<a onClick={() => messageBox(2, record.userId)}>禁用</a>) : (<a onClick={() => disableUser(record.userId, 1)}>启用</a>)}
-        </Menu.Item>
-        <Menu.Item key="2">
-          <a target="_blank" onClick={() => messageBox(1, record.userId)}>
-            删除
-          </a>
-        </Menu.Item>
-      </Menu>
-    )
-  }
+
   return (
     <div className="wrapper">
       <div className="filter-box">
         <Form
           form={form}
           name="normal_login"
-          className="basic"
           onFinish={onFinish}
           initialValues={{ status: '' }}
         >
           <Row gutter={24}>
-            <Col span={6} key={0}>
-              <Form.Item label="病区名称" name="username">
-                <Input placeholder="请求方式" />
+            <Col span={5} key={0}>
+              <Form.Item label="病区名称" name="name">
+                <Input placeholder="病区名称" />
               </Form.Item>
             </Col>
-            <Col span={6} key={1}>
-              <Form.Item label="管理科室" name="name">
-                <Input placeholder="IP地址" />
+            {/* <Col span={5} key={1}>
+              <Form.Item label="关联科室" name="deptName">
+                <Select
+                  allowClear
+                  showSearch
+                  placeholder="请选择"
+                  onSearch={onSearch}
+                  filterOption={(input, option) =>
+                    option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
+                  }
+                >
+                  {deptList.map(item => {
+                    return (
+                      <Option value={item.id} key={item.id}>{item.name}</Option>
+                    )
+                  })}
+                </Select>
               </Form.Item>
-            </Col>
-            <Col span={8} key={2}>
+            </Col> */}
+            <Col span={5} key={2}>
               <Form.Item name="status" label="当前状态">
                 <Select
                   allowClear
                 >
-                  {statusList.map((item) => {
+                  {statusList.map((item, index) => {
                     return (
-                      <Option value={item.name} key={item.name}>{item.val}</Option>
+                      <Option value={item.name} key={index}>{item.val}</Option>
                     )
                   })}
                 </Select>
               </Form.Item>
             </Col>
-            <Col span={4} key={3}>
+            <Col span={6} key={3}>
               <Form.Item>
-                <Space size="middle">
-                  <Button type="primary" htmlType="submit">
-                    查询
+                <Button type="primary" htmlType="submit">
+                  查询
                 </Button>
-                  <Button onClick={onReset}>
-                    重置
+                <Button onClick={onReset}>
+                  重置
                 </Button>
-                </Space>
               </Form.Item>
             </Col>
           </Row>
@@ -265,22 +279,40 @@ function InpaManager() {
 
       <div className="table">
         <div className="table-header">
-          <Breadcrumb>
-            <Breadcrumb.Item>异常日志</Breadcrumb.Item>
-          </Breadcrumb>
+          <h2 className="table-title">病区管理</h2>
+          <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增病区', true, 1)}>新增病区</Button>
         </div>
 
         <Table
           columns={columns}
           dataSource={userList}
-          rowKey={record => record.userId}
+          rowKey={record => record.id}
           pagination={{
-            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            pageNo: 1,
+            pageSize: 15,
             pageSizeOptions: ['15', '30', '60', '120'],
-            pageSize: 5,
+            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            onShowSizeChange: (current, pageSize) => this.pageSize = pageSize, // 改变每页数量时更新显示
+            onChange: (page, pageSize) => changePage(page, pageSize),//点击页码事件
+            total: total
           }} />
       </div>
-
+      {visible && formData ?
+        <Modal
+          title={title}
+          okText='确定'
+          cancelText='取消'
+          width={'35%'}
+          visible={visible}
+          onCancel={cancel}
+          footer={null}
+          forceRender={true}
+        >
+          <InpaContext.Provider value={{ id: id, type: type, formData: formData }}>
+            <AddInpa userChange={userChange} />
+          </InpaContext.Provider>
+        </Modal>
+        : ''}
       <Modal
         title="提示"
         okText='确定'

+ 4 - 0
src/components/InpaManager/inpa-context.js

@@ -0,0 +1,4 @@
+import { createContext } from 'react';
+const InpaContext = createContext(null);
+
+export default InpaContext;

+ 148 - 53
src/components/UserManager/addUser.js

@@ -8,8 +8,8 @@ import UserContext from './user-context';
 import { useSelector } from 'react-redux'
 import Item from 'antd/lib/list/Item';
 const { post, api, xPost } = apiObj;
-const { organizationData } = utils;
 const { Option, OptGroup } = Select;
+const { organizationData } = utils;
 const { SHOW_PARENT } = TreeSelect;
 function AddUser(props) {
   useEffect(() => {
@@ -17,7 +17,7 @@ function AddUser(props) {
     getCreateRoles()
   }, []);
   const [form] = Form.useForm();
-  const { userId, type, formData } = useContext(UserContext);
+  const { userId, type, formData, roleList } = useContext(UserContext);
   const [treeData, setTreeData] = useState([]);
   const [treeRloe, setTreeRloe] = useState([]);
   const [addHospitalTreeVO, setAddHospitalTreeVO] = useState({
@@ -29,17 +29,30 @@ function AddUser(props) {
   });
   const { titleList } = staticInfo;
   const initialValues = formData;
+  let addHospitalTreeVOs = {
+    depts: [],
+    hospitals: [],
+  }
   //获取当前用户组织
   function getHospitalTree() {
     post(api.getHospitalTree).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
-        let arr = data
-        arr = organizationData(arr)
-        setTreeData(arr)
+        const treeData = organizationData(data)
+        setTreeData(treeData)
       }
     })
   }
+  function addAttr(data) {
+    for (var j = 0; j < data.length; j++) {
+      data[j].title = data[j].name //添加title属性
+      data[j].key = data[j].code //添加key属性
+      if (data[j].children.length > 0) {
+        addAttr(data[j].children)
+      }
+    }
+    return data
+  }
   //获取当前用于所属角色
   function getCreateRoles() {
     const params = {
@@ -69,29 +82,54 @@ function AddUser(props) {
     })
     return processArr.length;
   }
+  //递归获取科室
+  function gethospitals(arr, val) {
+    arr.forEach(item => {
+      if (item.value == val) {
+        if (item.children) {
+          getdepts(item.children)
+        }
+        if (item.children && item.depts) {
+          item.children.forEach(item => {
+            addHospitalTreeVOs.depts.push(item.value.split('-')[1])
+          })
+        }
+      } else {
+        if (item.children) {
+          gethospitals(item.children, val)
+        }
+      }
+    })
+  }
+  //递归获取医院
+  function getdepts(arr) {
+    arr.forEach(item => {
+      if (JSON.stringify(item.value).indexOf('-') < 0) {
+        addHospitalTreeVOs.hospitals.push(item.value)
+      }
+      if (item.children && item.depts) {
+        item.children.forEach(it => {
+          addHospitalTreeVOs.depts.push(it.value.split('-')[1])
+        })
+        return
+      }
+      if (item.children) {
+
+        getdepts(item.children)
+      }
+    })
+  }
   const onChange = value => {
-    let addHospitalTreeVO = {
-      depts: [],
-      hospitals: []
-    }
     value.forEach(it => {
-      let arr = it.split('-')
-      let len = arr.length
-      if (len == 3) {
-        addHospitalTreeVO.depts.push(arr[2])
-        addHospitalTreeVO.hospitals.push(arr[1])
+      if (JSON.stringify(it).indexOf('-') > 0) {
+        addHospitalTreeVOs.depts.push(it.split('-')[1])
       } else {
-        addHospitalTreeVO.hospitals.push(arr[1])
-        organizationData(treeData).forEach(item => {
-          if (item.value.split('-')[1] == arr[1]) {
-            item.children.forEach(its => {
-              addHospitalTreeVO.depts.push(its.value.split('-')[2])
-            })
-          }
-        })
+        addHospitalTreeVOs.hospitals.push(it)
+        gethospitals(treeData, it)
       }
     })
-    setAddHospitalTreeVO(addHospitalTreeVO)
+    setAddHospitalTreeVO(addHospitalTreeVOs)
+    console.log(form.getFieldsValue())
   };
   const onChangeRloe = value => {
     form.setFieldsValue({ roles: value })
@@ -153,7 +191,12 @@ function AddUser(props) {
             },
           ]}
         >
-          <Input placeholder="用户名是组织中唯一标识,请勿重复" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.username}</span>
+            :
+            <Input placeholder="用户名是组织中唯一标识,请勿重复" />
+          }
+
         </Form.Item>
         <Form.Item
           name="mobilePhone"
@@ -165,7 +208,12 @@ function AddUser(props) {
             },
           ]}
         >
-          <Input placeholder="请输入手机号码" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.mobilePhone}</span>
+            :
+            <Input placeholder="请输入手机号码" />
+          }
+
         </Form.Item>
         <Form.Item
           name="password"
@@ -178,7 +226,11 @@ function AddUser(props) {
           ]}
           hasFeedback
         >
-          <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.password}</span>
+            :
+            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" />
+          }
         </Form.Item>
         <Form.Item
           name="againpassword"
@@ -200,20 +252,34 @@ function AddUser(props) {
             }),
           ]}
         >
-          <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.password}</span>
+            :
+            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" />
+          }
         </Form.Item>
         <Form.Item
           name="name"
           label="姓名"
           rules={[{ required: true, message: '请输入姓名', whitespace: true }]}
         >
-          <Input placeholder="请输入姓名" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.name}</span>
+            :
+            <Input placeholder="请输入姓名" />
+          }
+
         </Form.Item>
         <Form.Item
           name="idcard"
           label="身份证号码"
         >
-          <Input placeholder="请输入身份证号码" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.idcard}</span>
+            :
+            <Input placeholder="请输入身份证号码" />
+          }
+
         </Form.Item>
         <Form.Item
           name="addHospitalTreeVO"
@@ -229,48 +295,72 @@ function AddUser(props) {
             showCheckedStrategy={SHOW_PARENT}
             placeholder="请选择组织"
             style={{ width: '100%' }}
-            disabled={type == 3 ? true : false}
           />
         </Form.Item>
         <Form.Item
           name="titleId"
           label="职称"
         >
-          <Select placeholder="请选择职称" disabled={type == 3 ? true : false}>
-            {titleList.map((item) => {
-              return (
-                <Option value={item.name} key={item.name}>{item.val}</Option>
-              )
-            })}
-          </Select>
+          {type == 3 ?
+            <span>{initialValues.idcard}</span>
+            :
+            <Select placeholder="请选择职称">
+              {titleList.map((item) => {
+                return (
+                  <Option value={item.name} key={item.name}>{item.val}</Option>
+                )
+              })}
+            </Select>
+          }
+
         </Form.Item>
         <Form.Item
           name="jobNo"
           label="工号"
         >
-          <Input placeholder="请输入工号" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.jobNo}</span>
+            :
+            <Input placeholder="请输入工号" />
+          }
+
         </Form.Item>
         <Form.Item
           name="roles"
           label="所属角色"
           rules={[{ required: true, message: '请选择角色' }]}
         >
-          <TreeSelect
-            showSearch={false}
-            treeData={treeRloe}
-            treeCheckable
-            onChange={onChangeRloe}
-            showCheckedStrategy={SHOW_PARENT}
-            placeholder="请选择角色"
-            style={{ width: '100%' }}
-            disabled={type == 3 ? true : false}
-          />
+          {type == 3 ?
+            <div>
+              {roleList.map((it, i) => {
+                return (
+                  <span key={it.id}>{it.roleName}、</span>
+                );
+              })}
+            </div>
+            :
+            <TreeSelect
+              showSearch={false}
+              treeData={treeRloe}
+              treeCheckable
+              onChange={onChangeRloe}
+              showCheckedStrategy={SHOW_PARENT}
+              placeholder="请选择角色"
+              style={{ width: '100%' }}
+              disabled={type == 3 ? true : false}
+            />
+          }
         </Form.Item>
         <Form.Item
           name="orderNo"
           label="排序"
         >
-          <Input placeholder="大于0的整数" disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.orderNo}</span>
+            :
+            <Input placeholder="大于0的整数" />
+          }
+
         </Form.Item>
         <Form.Item
           name="status"
@@ -278,9 +368,14 @@ function AddUser(props) {
           label="当前状态"
           rules={[{ required: true, message: '请选择状态' }]}
         >
-          <Switch onChange={swichChange} disabled={type == 3 ? true : false} />
+          {type == 3 ?
+            <span>{initialValues.status == 1 ? '启用' : '禁用'}</span>
+            :
+            <Switch onChange={swichChange} />
+          }
+
         </Form.Item>
-        {type == 3  ?
+        {type == 3 ?
           <Form.Item wrapperCol={{ offset: 10, span: 16 }}>
             <Space size="middle">
               <Button type="primary" htmlType="submit">
@@ -288,7 +383,7 @@ function AddUser(props) {
             </Button>
             </Space>
           </Form.Item>
-          : 
+          :
           <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
             <Space size="middle">
               <Button htmlType="button" onClick={e => cancel()}>
@@ -299,7 +394,7 @@ function AddUser(props) {
             </Button>
             </Space>
           </Form.Item>}
-        
+
       </Form>
     </>
   );

+ 30 - 7
src/components/UserManager/index.js

@@ -5,10 +5,8 @@ import AddUser from './addUser'
 import '@common/common.less';
 import { useSelector } from 'react-redux'
 import apiObj from '@api/index';
-import utils from '@utils/index'
 import UserContext from './user-context';
 const { post, api, xPost } = apiObj;
-const { organizationData } = utils;
 const { Option } = Select;
 function UserManager() {
   useEffect(() => {
@@ -23,7 +21,7 @@ function UserManager() {
   const [type, setType] = useState("");
   const [formData, setFormData] = useState(null);
   const [username, setUsername] = useState(null);
-
+  const [roleList, setRoleList] = useState([]);
   const [form] = Form.useForm();
   const tipText = {
     1: '确定要删除该用户?',
@@ -33,6 +31,7 @@ function UserManager() {
   const staticInfo = useSelector(state => {
     return state.staticInfo;
   });
+  let list = []
   const { statusList } = staticInfo;
   //新增弹窗
   const showModal = (name, type, flag, userId) => {
@@ -74,17 +73,41 @@ function UserManager() {
           againpassword: data.password,
           name: data.name,
           idcard: data.idcard,
-          // addHospitalTreeVO: organizationData(data.hospitals[0].children[0].children),
+          addHospitalTreeVO: getHospitals(data.hospitals),
           titleId: data.titleId,
           jobNo: data.jobNo,
           roles: roles,
           orderNo: data.orderNo,
           status: data.status,
         }
+        setRoleList(data.roles)
         setFormData(arr)
       }
     })
   }
+  // 处理组织结构数据回显
+  function getHospitals(arr) {
+    arr.forEach((item, i, array) => {
+      item.value = item.hospitalId
+      item.title = item.hospitalName
+      if (!item.children && item.depts) {
+        item.depts.forEach(it => {
+          it.value = item.parentId + '-' + it.deptId
+          if (it.relation == 1) {
+            list.push(it.value)
+          }
+        })
+      }
+      if (item.type != 0 && item.relation == 1) {
+        list.push(item.value)
+        console.log(list)
+      }
+      if (item.children) {
+        getHospitals(item.children)
+      }
+    })
+    return list
+  }
   // 禁用/启用接口
   function disableUser(userId, status) {
     const param = { userId: userId, status: status };
@@ -120,6 +143,7 @@ function UserManager() {
     xPost(api.deleteUser, param).then((res) => {
       if (res.data.code === 200) {
         getUserPage();
+        setMsvisible(false);
         message.success("删除成功");
       } else {
         message.warning(res.data.msg || '操作失败');
@@ -232,7 +256,7 @@ function UserManager() {
                 <Input placeholder="姓名" />
               </Form.Item>
             </Col>
-            <Col span={6} key={2}>
+            <Col span={5} key={2}>
               <Form.Item name="status" label="当前状态">
                 <Select
                   allowClear
@@ -281,13 +305,12 @@ function UserManager() {
           okText='确定'
           cancelText='取消'
           width={'45%'}
-          height={'50%'}
           visible={visible}
           onCancel={cancel}
           footer={null}
           forceRender={true}
         >
-          <UserContext.Provider value={{ userId: userId, type: type, formData: formData }}>
+          <UserContext.Provider value={{ userId, type, formData, roleList }}>
             <AddUser userChange={userChange} />
           </UserContext.Provider>
 

+ 4 - 1
src/store/reducers/tabPanes.js

@@ -23,9 +23,12 @@ export const slice = createSlice({
         active:(state,action) => {       //切换tab
             state.activeTab = action.payload;
         },
+        panesNow: (state, action) => {       //切换tab
+            state.panes = [];
+        },
     },
 });
 
-export const { close, closeOther, active, add } = slice.actions;
+export const { close, closeOther, active, add, panesNow } = slice.actions;
 
 export default slice.reducer;

+ 18 - 16
src/utils/index.js

@@ -30,22 +30,24 @@ function pickCheckedTreeIds(data, menuIds = [], resourceIds = []) {
 }
 // 处理组织结构数据
 function organizationData(arr) {
-    let list = []
-    arr.forEach(it => {
-        it.value = it.hospitalId
-        it.title = it.hospitalName
-        list.push({
-            children: it.depts,
-            title: it.hospitalName,
-            value: it.parentId + '-' + it.hospitalId
-        })
-        it.depts.forEach(its => {
-            its.value = it.parentId + '-' + it.hospitalId + '-' + its.deptId
-        })
+    arr.forEach(item => {
+        item.value = item.hospitalId
+        item.title = item.hospitalName
+        if (!item.children && item.depts) {
+            item.depts.forEach(it => {
+                it.value = item.parentId + '-' + it.deptId
+            })
+            item.children = JSON.parse(JSON.stringify(item.depts).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'value'))
+            return
+        }
+        if (item.children) {
+            organizationData(item.children)
+        }
     })
-    arr = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'value'))
+    console.log()
     return arr
 }
+
 // 去重
 function unique(arr) {
     return arr.filter(function (item, index, arr) {
@@ -53,13 +55,13 @@ function unique(arr) {
     });
 }
 //时间获取
-function getTimeDetail(){
+function getTimeDetail() {
     const d = new Date();
-    const days = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
+    const days = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
     let sec = d.getSeconds()
     let min = d.getMinutes()
     let hour = d.getHours()
-    let str = `${d.getFullYear()}年${d.getMonth()+1}月${d.getDate()}日 / ${days[d.getDay()]} / ${hour>9?hour:'0'+hour}:${min>9?min:'0'+min}:${sec>9?sec:'0'+sec}`
+    let str = `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日 / ${days[d.getDay()]} / ${hour > 9 ? hour : '0' + hour}:${min > 9 ? min : '0' + min}:${sec > 9 ? sec : '0' + sec}`
     return str;
 }