Bläddra i källkod

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/components/AMenu/index.js
#	src/components/UserManager/index.js
zhouna 3 år sedan
förälder
incheckning
cd1902e8e2

+ 4 - 1
src/api/request.js

@@ -34,7 +34,10 @@ const request = {
 
     //数据权限相关接口
     getDataAuthPage: '/security-center/dataAuthManage/getDataAuthPage',//数据权限列表
-    disableAuth: '/security-center/dataAuthManage/disableAuth',//禁用
+    addAuth: '/security-center/dataAuthManage/addAuth',//禁用
     getDoctorPage: '/security-center/dataAuthManage/getDoctorPage',//医生列表
+
+    //病区管理
+    getRegion: '/security-center/regionManage/getRegion',//病区管理列表
 }
 export default request;

+ 3 - 1
src/components/AMenu/index.js

@@ -6,6 +6,7 @@ import OrgManager from "../OrgManager";
 import RoleManager from "../RoleManager";
 import UserManager from "../UserManager";
 import DataManager from "../DataManager";
+import InpaManager from "../InpaManager"
 import NullPage from "../NullPage";
 import apiObj from '@api/index';
 
@@ -18,7 +19,8 @@ const pageMap = {
     '组织管理': <OrgManager />,
     '角色管理': <RoleManager />,
     '用户管理': <UserManager />,
-    '数据权限': <DataManager />
+    '数据权限': <DataManager />,
+    '病区管理': <InpaManager />
 }
 
 function AMenu() {

+ 202 - 147
src/components/DataManager/AddData.js

@@ -1,136 +1,174 @@
 import { useEffect, useState, useContext } from 'react';
-import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag } from 'antd';
+import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag, Card, message } from 'antd';
 import './index.less';
 import DataContext from './data-context';
+import { useSelector } from 'react-redux'
 import apiObj from '@api/index';
+import utils from '@utils/index'
 import backIcon from "@images/back.png";
 import DoctorList from "./doctorList"
+import Item from 'antd/lib/list/Item';
 const { post, api, xPost } = apiObj;
 const { SHOW_PARENT } = TreeSelect;
+const { organizationData } = utils;
 const { Step } = Steps;
 const { TabPane } = Tabs;
 function AddData(props) {
+  useEffect(() => {
+    getCreateRoles()
+    getHospitalTree()
+    getOrgList()
+  }, []);
   const { back } = props;
-  const [value, setValue] = useState('1');
-  const [treeRloe, setTreeRloe] = useState([]);
-  const [tags, setTags] = useState(['Unremovable', 'Tag 2', 'Tag 3']);
   const [form] = Form.useForm();
+  const [value, setValue] = useState(['','']);
+  const [key, setKey] = useState('0');
+  const [index, setIndex] = useState('0');
+  const [selectedId, setSelectedId] = useState(['48-胡能杰']);
+  const [treeRloe, setTreeRloe] = useState([]);
+  const [tags, setTags] = useState([]);
+  const [treeData, setTreeData] = useState([]);
   const layout = {
     labelCol: { span: 3 },
     wrapperCol: { span: 20 },
   };
-  const treeData = [
-    {
-      title: '0-0',
-      key: '0-0',
-      children: [
-        {
-          title: '0-0-0',
-          key: '0-0-0',
-          children: [
-            {
-              title: '0-0-0-0',
-              key: '0-0-0-0',
-            },
-            {
-              title: '0-0-0-1',
-              key: '0-0-0-1',
-            },
-            {
-              title: '0-0-0-2',
-              key: '0-0-0-2',
-            },
-          ],
-        },
-        {
-          title: '0-0-1',
-          key: '0-0-1',
-          children: [
-            {
-              title: '0-0-1-0',
-              key: '0-0-1-0',
-            },
-            {
-              title: '0-0-1-1',
-              key: '0-0-1-1',
-            },
-            {
-              title: '0-0-1-2',
-              key: '0-0-1-2',
-            },
-          ],
-        },
-        {
-          title: '0-0-2',
-          key: '0-0-2',
-        },
-      ],
-    },
-    {
-      title: '0-1',
-      key: '0-1',
-      children: [
-        {
-          title: '0-1-0-0',
-          key: '0-1-0-0',
-        },
-        {
-          title: '0-1-0-1',
-          key: '0-1-0-1',
-        },
-        {
-          title: '0-1-0-2',
-          key: '0-1-0-2',
-        },
-      ],
-    },
-    {
-      title: '0-2',
-      key: '0-2',
-    },
-  ];
   const [expandedKeys, setExpandedKeys] = useState(['0-0-0', '0-0-1']);
   const [checkedKeys, setCheckedKeys] = useState(['0-0-0']);
   const [selectedKeys, setSelectedKeys] = useState([]);
+  const [orgList, setOrgList] = 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 initialValues = detail || {
+    status: '1'
+  };
+  //获取当前用于所属角色
+  function getCreateRoles() {
+    const params = {
+      softwareId: ''
+    }
+    xPost(api.getCreateRoles, params).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        let arr = JSON.parse(JSON.stringify(data).replaceAll(/name/g, 'title').replaceAll(/id/g, 'value'))
+        setTreeRloe(arr)
+      }
+    })
+  }
+  //获取当前用户组织
+  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)
+      }
+    })
+  }
+  //获取组织列表
+  function getOrgList() {
+    xPost(api.getUserHospitals).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        const { software } = data;
+        setOrgList(software);
+        setKey(software[0].id)
+        // //默认显示第一个系统的组织
+        // setHisList(software[0] ? software[0].hospitals : []);
+      } else {
+        message.warning(res.data.msg || '获取医院列表失败');
+      }
+    }).catch(() => {
+      message.error("接口出错");
+    });
+  }
   const onExpand = (expandedKeysValue) => {
-    console.log('onExpand', expandedKeysValue); // if not set autoExpandParent to false, if children expanded, parent can not collapse.
+    //console.log('onExpand', expandedKeysValue); // if not set autoExpandParent to false, if children expanded, parent can not collapse.
     // or, you can remove all expanded children keys.
-
     setExpandedKeys(expandedKeysValue);
     setAutoExpandParent(false);
   };
 
   const onCheck = (checkedKeysValue) => {
-    console.log('onCheck', checkedKeysValue);
+    // console.log('onCheck', checkedKeysValue);
     setCheckedKeys(checkedKeysValue);
   };
 
   const onSelect = (selectedKeysValue, info) => {
-    console.log('onSelect', info);
     setSelectedKeys(selectedKeysValue);
   };
   const validateMessages = {
-    required: '${label} is required!',
-    types: {
-      email: '${label} is not a valid email!',
-      number: '${label} is not a valid number!',
-    },
-    number: {
-      range: '${label} must be between ${min} and ${max}',
-    },
+    required: '${label}不能为空',
   };
-  const onChange = e => {
-    console.log('radio checked', e.target.value);
-    setValue(e.target.value)
+  const onChange = (e, i) => {
+    let val = value
+    const formData = form.getFieldsValue();
+    let arr = formData.softwareVOS;
+    arr[i] = {
+      id: key,
+      dataAuthDetails: arr[i].dataAuthDetails,
+    };
+    console.log(arr)
+    form.setFieldsValue({
+      softwareVOS: arr
+    });
+    console.log(form.getFieldsValue())
+    val[i] = e.target.value
+    setValue([...val])
+
   };
+  // 删除选择标签
+  function delTag(i){
+    console.log(i);
+    console.log(tags);
+    tags.splice(i)
+    selectedRowKeys.splice(i)
+    setTags([...tags])
+    setSelectedRowKeys([...selectedRowKeys])
+    // setDelIndex(i)
+    // DoctorList.alertEvevnt();
+  }
   function callback(key) {
-    console.log(key);
+    setKey(key.split('-')[0])
+    setIndex(key.split('-')[1])
+  }
+  function callbacks(keys) {
+    
   }
-  const onFinish = (values: any) => {
-    console.log(values);
+  function checkDoctEvent(selectedRowKeys){
+    console.log(selectedRowKeys);
+    
+    const formData = form.getFieldsValue();
+    let arr = []
+    let tag = []
+    let ids = []
+    selectedRowKeys.forEach(it => {
+      arr.push({
+        dataType:7,
+        detailId:it.split('-')[0],
+        detailType:3
+      })
+      tag.push(it.split('-')[1])
+      ids.push(it.split('-')[0])
+    });
+    
+    formData.dataAuthDetails[index] = arr
+    form.setFieldsValue({
+      dataAuthDetails: formData.dataAuthDetails
+    });
+    setSelectedId([...ids])
+    console.log(selectedId);
+    
+    setTags([...tag])
+  }
+  const onFinish = value => {
+    console.log(form.getFieldsValue())
+    save(form.getFieldsValue())
   };
   function swichChange(val) {
     form.setFieldsValue({ status: val ? 1 : 0 })
@@ -143,73 +181,90 @@ function AddData(props) {
         <Breadcrumb.Separator />
         <Breadcrumb.Item>新增子组织</Breadcrumb.Item>
       </Breadcrumb>
-      <Form {...layout} name="nest-messages" onFinish={onFinish} validateMessages={validateMessages}>
-        <Form.Item name={['user', 'name']} label="数据权限名称" rules={[{ required: true }]}>
+      <Form {...layout} form={form} name="nest-messages" onFinish={onFinish} initialValues={initialValues} validateMessages={validateMessages}>
+        <Form.Item name="name" label="数据权限名称" rules={[{ required: true }]}>
           <Input placeholder="请填写数据权限名称" />
         </Form.Item>
-        <Form.Item name={['user', 'email']} label="权限范围" rules={[{ type: 'email' }]}>
-          <Tabs defaultActiveKey="1" onChange={callback} >
-            <TabPane tab="AI终末质控系统" key="1">
-              <Radio.Group onChange={onChange} value={value} className="radio">
-                <Space direction="vertical">
-                  <Radio value={1}>全部组织</Radio>
-                  <Radio value={2}>全部科室</Radio>
-                  <Radio value={3}>全部科室除本科室外</Radio>
-                  <Radio value={4}>本科室</Radio>
-                  <Radio value={5}>本医疗组</Radio>
-                  <Radio value={6}>本人</Radio>
-                  <Radio value={7}>自定义</Radio>
-                </Space>
-              </Radio.Group>
-            </TabPane>
-            <TabPane tab="AI终末质控系统" key="2">
-              Content of Tab Pane 2
-            </TabPane>
+        <Form.Item label="权限范围" required >
+          <Tabs type="card" onChange={callback} >
+            {
+              orgList.map((it, i) => {
+                return (
+                  <TabPane tab={it.name} key={it.id+"-"+i}>
+                    <Form.Item
+                      key={i}
+                      name={['dataAuthDetails', i, 'dataType']} noStyle>
+                      <Radio.Group onChange={e => { onChange(e, i) }} value={value[i]} className="radio">
+                        <Space direction="vertical">
+                          {dataList.map((Item) => {
+                            return (
+                              <Radio value={Item.name}>{Item.val}</Radio>
+                            )
+                          })
+                          }
+                        </Space>
+                      </Radio.Group>
+                    </Form.Item>
+                    <Form.Item key={i + "a"} hidden={true} name={['softwareVOS', i, 'id']} noStyle>
+                      <Input />
+                    </Form.Item>
+                  </TabPane>
+                )
+              })
+            }
           </Tabs>
         </Form.Item>
-        <Form.Item>
-          {tags.map((tag, index) => {
-            return (
-              <Tag>{tag}</Tag>
-            );
-          }
-          )
-          }
-        </Form.Item>
+        {value[index] == 7 ?
+          <Form.Item wrapperCol={{ offset: 3, span: 20 }} name={['dataAuthDetails', key, 'dataType']}>
+            <Card title="已选中" extra={<a href="#">More</a>} >
+              {tags.map((tag, i) => {
+                return (
+                  <Tag closable  onClose={e=>delTag(i)}>{tag}</Tag>
+                );
+              })}
+            </Card>
+          </Form.Item>
+          :
+          null}
+
+        {value[index] == 7 ?
+          <Form.Item
+            name={['softwareVOS', index, 'dataAuthDetails', index, 'detailId']}
+            wrapperCol={{ offset: 3, span: 20 }}
+          >
+            <Tabs defaultActiveKey="0" onChange={callbacks} >
+              <TabPane tab="可看医生" key="0">
+                <DoctorList data={selectedId} checkDoct={(selectedRowKeys) => checkDoctEvent(selectedRowKeys)}/>
+              </TabPane>
+              <TabPane tab="可看科室" key="1">
+                <Tree
+                  checkable
+                  onExpand={onExpand}
+                  expandedKeys={expandedKeys}
+                  autoExpandParent={autoExpandParent}
+                  onCheck={onCheck}
+                  checkedKeys={checkedKeys}
+                  onSelect={onSelect}
+                  selectedKeys={selectedKeys}
+                  treeData={treeData}
+                />
+              </TabPane>
+            </Tabs>
+          </Form.Item>
+          :
+          null}
 
         <Form.Item
           name="roles"
           label="所属角色"
-        >
-          <Tabs defaultActiveKey="1" onChange={callback} >
-            <TabPane tab="AI终末质控系统" key="1">
-              <DoctorList />
-            </TabPane>
-            <TabPane tab="AI终末质控系统" key="2">
-              <Tree
-                checkable
-                onExpand={onExpand}
-                expandedKeys={expandedKeys}
-                autoExpandParent={autoExpandParent}
-                onCheck={onCheck}
-                checkedKeys={checkedKeys}
-                onSelect={onSelect}
-                selectedKeys={selectedKeys}
-                treeData={treeData}
-              />
-            </TabPane>
-          </Tabs>
-        </Form.Item>
-        <Form.Item
-          name="roles"
-          label="所属角色"
+          rules={[{ required: true }]}
         >
           <TreeSelect
             showSearch={false}
             treeData={treeRloe}
             treeCheckable
             showCheckedStrategy={SHOW_PARENT}
-            placeholder="请选择组织"
+            placeholder="请选择角色"
             style={{ width: '100%' }}
           />
         </Form.Item>

+ 25 - 22
src/components/DataManager/doctorList.js

@@ -2,26 +2,35 @@ import React, { useState, useEffect } from 'react';
 import { Form, Input, Button, Table, Select, Pagination, Space, TreeSelect, Tag } from 'antd';
 import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
 import apiObj from '@api/index';
+import { useSelector } from 'react-redux'
+import utils from '@utils/index'
+import { getOverflowOptions } from 'antd/lib/tooltip/placements';
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
 const { SHOW_PARENT } = TreeSelect;
-function DoctorList() {
+const { organizationData } = utils;
+function DoctorList(props) {
   useEffect(() => {
     getDoctorPage();
     getHospitalTree()
   }, []);
+  
+  const { data,checkDoct} = props;
+  const [form] = Form.useForm();
   const [doctorList, setDoctorList] = useState([]);
   const [name, setName] = useState("");
   const [phone, setPhone] = useState("");
   const [pages, setPages] = useState("1");
   const [current, setCurrent] = useState("5");
   const [treeData, setTreeData] = useState([]);
+  // const [selectedRowKeys, setSelectedRowKeys] = useState([]);
   const [addHospitalTreeVO, setAddHospitalTreeVO] = useState({
     depts: [],
     hospitals: []
   });
-  const [form] = Form.useForm();
+  const selectedRowKeys = data
 
+  
   //获取可看医生列表
   function getDoctorPage() {
     const param = {
@@ -44,27 +53,12 @@ function DoctorList() {
     post(api.getHospitalTree).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
-        let arr = data[0].children ? data[0].children[0].children : []
+        let arr = data ? data : []
+        arr = organizationData(arr)
         setTreeData(arr)
       }
     })
   }
-  // 处理组织结构数据
-  function organizationData(arr) {
-    let list = []
-    arr.forEach(item => {
-      list.push({
-        children: item.depts,
-        title: item.hospitalName,
-        value: item.parentId + '-' + item.hospitalId
-      })
-      item.depts.forEach(its => {
-        its.value = item.parentId + '-' + item.hospitalId + '-' + its.deptId
-      })
-    })
-    arr = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'value'))
-    return arr
-  }
   // 去重
   function unique(arr) {
     return arr.filter(function (item, index, arr) {
@@ -102,7 +96,7 @@ function DoctorList() {
         addHospitalTreeVO.depts.push(arr[2])
       } else {
         addHospitalTreeVO.hospitals.push(arr[1])
-        organizationData(treeData).forEach(item => {
+        treeData.forEach(item => {
           if (item.value.split('-')[1] == arr[1]) {
             item.children.forEach(its => {
               addHospitalTreeVO.depts.push(its.value.split('-')[2])
@@ -113,6 +107,11 @@ function DoctorList() {
     })
     setAddHospitalTreeVO(addHospitalTreeVO)
   };
+  function onSelectChange(selectedRowKeys){
+    console.log(selectedRowKeys);
+    
+    checkDoct(selectedRowKeys)
+  }
   function submit(){
     getDoctorPage()
   }
@@ -130,7 +129,7 @@ function DoctorList() {
             所属组织:
             <TreeSelect
               showSearch={false}
-              treeData={organizationData(treeData)}
+              treeData={treeData}
               onChange={onChange}
               treeCheckable
               maxTagCount={1}
@@ -158,9 +157,13 @@ function DoctorList() {
         </div>
 
         <Table
+          rowSelection={{
+            selectedRowKeys,
+            onChange: onSelectChange,
+          }}
           columns={columns}
           dataSource={doctorList}
-          rowKey={record => record.id}
+          rowKey={record => record.id +'-'+ record.name}
           pagination={{
             showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
             pageSizeOptions: ['15', '30', '60', '120'],

+ 40 - 21
src/components/DataManager/index.js

@@ -21,6 +21,7 @@ function DataManager() {
   const [msvisible, setMsvisible] = useState(false);
   const [type, setType] = useState("");
   const [addVisible, setaddVisible] = useState("false");
+  const [dataDetail, setDataDetail] = useState(null);
   const [form] = Form.useForm();
   const tipText = {
     1: '确定要删除该数据权限?',
@@ -28,9 +29,10 @@ function DataManager() {
   };
 
   const showModal = (name, type, flag) => {
-    setVisible(type);
-    setTitle(name);
-    setType(flag)
+    setaddVisible(true)
+    // setVisible(type);
+    // setTitle(name);
+    // setType(flag)
   }
   function getDataAuthPage(param = {}) {
     //const param = filterData;
@@ -57,7 +59,38 @@ function DataManager() {
       }
     })
   };
-
+  //保存
+  function addData(formData) {
+    let url = api.addAuth;
+    console.log(formData)
+    
+    // const arr = formData.softwares.filter((it) => {
+    //   if (Object.keys(it).length && it.softwareMenuIds && it.softwareMenuIds.length) {
+    //     return it;
+    //   }
+    // });
+    // if (roleDetail) {     //修改角色
+    //   formData.id = roleDetail.id;
+    //   url = api.updateRole;
+    // }
+    let roles = formData.roles
+    delete formData.roles
+    let param = {
+      addDataAuthVO: formData,
+      roles: roles
+    }
+    post(url, param).then((res) => {
+      if (res.data.code === 200) {
+        getDataAuthPage();
+        setaddVisible(false)
+        message.success("添加成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      message.error("接口出错");
+    });
+  }
   const onFinish = (value) => {
     getDataAuthPage(value);
   };
@@ -97,22 +130,7 @@ function DataManager() {
   function showAddData() {
     setaddVisible(true)
   }
-  //保存
-  function addSubOrg(formData) {
-    console.log('保存参数:', formData);
-    const param = formData;
-    post(api.addHospital, param).then((res) => {
-      if (res.data.code === 200) {
-        // getTableData();
-        // setAddVisible(false);
-        message.success("添加成功");
-      } else {
-        message.warning(res.data.msg || '操作失败');
-      }
-    }).catch(() => {
-      message.error("接口出错");
-    });
-  }
+
   //提示框确认事件
   function handleOk() {
     if (modalType == 2) {
@@ -130,7 +148,7 @@ function DataManager() {
   }
   if (addVisible) {
     return (
-      <DataContext.Provider value={{ save: addSubOrg }}>
+      <DataContext.Provider value={{ save: addData, detail: dataDetail }}>
         <AddData back={goBack} />
       </DataContext.Provider>
     )
@@ -192,6 +210,7 @@ function DataManager() {
         <Table
           columns={columns}
           dataSource={userList}
+          rowKey={record => record.id}
           pagination={{
             showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
             pageSizeOptions: ['15', '30', '60', '120'],

+ 4 - 0
src/components/DataManager/index.less

@@ -16,3 +16,7 @@
     font-size: 16px;
   }
 }
+.ant-tree-list-holder-inner{
+  height: 500px;
+  overflow-y: auto;
+}

+ 299 - 0
src/components/InpaManager/index.js

@@ -0,0 +1,299 @@
+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 { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+import '@common/common.less';
+import apiObj from '@api/index';
+import { useSelector } from 'react-redux'
+import utils from '@utils/index'
+const { post, api, xPost } = apiObj;
+const { organizationData } = utils;
+const { Option } = Select;
+function InpaManager() {
+  useEffect(() => {
+    getRegion();
+  }, []);
+  const [userList, setUserList] = useState([]);
+  const [title, setTitle] = useState("");
+  const [visible, setVisible] = useState(false);
+  const [userId, setUserId] = 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 tipText = {
+    1: '确定要删除该用户?',
+    2: '禁用后该用户将无法登录,确定要禁用该用户?',
+    3: '确定要重置该用户密码?',
+  };
+  const staticInfo = useSelector(state => {
+    return state.staticInfo;
+  });
+  const { statusList } = staticInfo;
+  //新增弹窗
+  const showModal = (name, type, flag, userId) => {
+    setVisible(type);
+    setTitle(name);
+    setType(flag)
+    setUserId(userId)
+    if (flag == 1) {
+      setFormData({
+        status: '1'
+      })
+    }
+    if (flag == 3 || flag == 2) {
+      getUserById(userId)
+    }
+  }
+  //表格数据
+  function getRegion() {
+    let param = {
+      hospitalId:1
+    }
+    post(api.getRegion, param).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        setUserList(data.records);
+      }
+    })
+  }
+  //查看用户
+  function getUserById(userId) {
+    xPost(api.getUserById, { userId: userId }).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        let roles = []
+        data.roles.forEach(item => {
+          roles.push(item.roleId)
+        })
+        const arr = {
+          username: data.username,
+          mobilePhone: data.mobilePhone,
+          password: data.password,
+          againpassword: data.password,
+          name: data.name,
+          idcard: data.idcard,
+          // addHospitalTreeVO: organizationData(data.hospitals[0].children[0].children),
+          titleId: data.titleId,
+          jobNo: data.jobNo,
+          roles: roles,
+          orderNo: data.orderNo,
+          status: data.status,
+        }
+        setFormData(arr)
+      }
+    })
+  }
+  // 禁用/启用接口
+  function disableUser(userId, status) {
+    const param = { userId: userId, status: status };
+    xPost(api.disableUser, param).then((res) => {
+      if (res.data.code === 200) {
+        getRegion();
+        setMsvisible(false);
+        message.success((status ? '启用' : '禁用') + "成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      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) => {
+      if (res.data.code === 200) {
+        getRegion();
+        message.success("删除成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      message.error("接口出错");
+    });
+  }
+
+  const onFinish = (value) => {
+    getRegion(value);
+  };
+  const onReset = () => {
+    form.resetFields();
+    getRegion();
+  };
+  const messageBox = (type, id) => {
+    setMsvisible(true)
+    setUserId(id)
+    setModalType(type)
+  };
+
+  //提示框确认事件
+  function handleOk() {
+    if (modalType == 1) {
+      deleteUser(userId)
+    } else if (modalType == 2) {
+      disableUser(userId, 0)
+    } else if (modalType == 3) {
+      onResetPsd();
+    }
+  }
+  //提示框取消
+  function handleCancel() {
+    setMsvisible(false);
+  }
+  function cancel() {
+    setVisible(false)
+    setFormData(null)
+  }
+  function userChange() {
+    setVisible(false)
+  }
+  const columns = [
+    { title: '用户名', dataIndex: 'username', key: 'index' },
+    { title: '姓名', dataIndex: 'name', key: 'index' },
+    { title: '所属组织', dataIndex: 'hospitalName', key: 'index' },
+    { title: '工号', dataIndex: 'jobNo', key: 'index' },
+    {
+      title: '状态', dataIndex: 'status', key: 'status', render: (text, record) => (
+        <Space size="middle">
+          {record.status == 1 ?
+            <span className="Enable">启用</span>
+            :
+            <span className="Disable">禁用</span>
+          }
+        </Space>
+      )
+    },
+    {
+      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>
+        </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="请求方式" />
+              </Form.Item>
+            </Col>
+            <Col span={6} key={1}>
+              <Form.Item label="管理科室" name="name">
+                <Input placeholder="IP地址" />
+              </Form.Item>
+            </Col>
+            <Col span={8} key={2}>
+              <Form.Item name="status" label="当前状态">
+                <Select
+                  allowClear
+                >
+                  {statusList.map((item) => {
+                    return (
+                      <Option value={item.name} key={item.name}>{item.val}</Option>
+                    )
+                  })}
+                </Select>
+              </Form.Item>
+            </Col>
+            <Col span={4} key={3}>
+              <Form.Item>
+                <Space size="middle">
+                  <Button type="primary" htmlType="submit">
+                    查询
+                </Button>
+                  <Button onClick={onReset}>
+                    重置
+                </Button>
+                </Space>
+              </Form.Item>
+            </Col>
+          </Row>
+        </Form>
+      </div>
+
+      <div className="table">
+        <div className="table-header">
+          <Breadcrumb>
+            <Breadcrumb.Item>异常日志</Breadcrumb.Item>
+          </Breadcrumb>
+        </div>
+
+        <Table
+          columns={columns}
+          dataSource={userList}
+          rowKey={record => record.userId}
+          pagination={{
+            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            pageSizeOptions: ['15', '30', '60', '120'],
+            pageSize: 5,
+          }} />
+      </div>
+
+      <Modal
+        title="提示"
+        okText='确定'
+        cancelText='取消'
+        width={400}
+        visible={msvisible}
+        onOk={handleOk}
+        onCancel={handleCancel}
+      >
+        <p>{tipText[modalType]}</p>
+      </Modal>
+    </div >
+  )
+}
+
+export default InpaManager;

+ 31 - 38
src/components/UserManager/addUser.js

@@ -29,19 +29,17 @@ function AddUser(props) {
   });
   const { titleList } = staticInfo;
   const initialValues = formData;
-  console.log(initialValues)
   //获取当前用户组织
   function getHospitalTree() {
     post(api.getHospitalTree).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
-        let arr = data[0].children ? data[0].children : []
+        let arr = data
         arr = organizationData(arr)
         setTreeData(arr)
       }
     })
   }
-
   //获取当前用于所属角色
   function getCreateRoles() {
     const params = {
@@ -76,34 +74,19 @@ function AddUser(props) {
       depts: [],
       hospitals: []
     }
+    console.log(value)
     value.forEach(it => {
-      if (JSON.stringify(it).indexOf("-") != -1) {
-        let arr = it.split('-')
-        let len = arr.length
-        if (len == 3) {
-          addHospitalTreeVO.depts.push(arr[2])
-          addHospitalTreeVO.hospitals.push(arr[1])
-        } else {
-          addHospitalTreeVO.hospitals.push(arr[1])
-          treeData.forEach(item => {
-            item.children && item.children.forEach(tit => {
-              if (tit.value.split('-')[1] == arr[1]) {
-                tit.children.forEach(its => {
-                  addHospitalTreeVO.depts.push(its.value.split('-')[2])
-                })
-              }
-            })
-          })
-        }
+      let arr = it.split('-')
+      let len = arr.length
+      if (len == 3) {
+        addHospitalTreeVO.depts.push(arr[2])
+        addHospitalTreeVO.hospitals.push(arr[1])
       } else {
-        addHospitalTreeVO.hospitals.push(it)
-        treeData.forEach(item => { 
-          if (item.value == it){
-            item.children && item.children.forEach(its => {
-              addHospitalTreeVO.hospitals.push(its.value.split('-')[1])
-              its.children && its.children.forEach(lit => {
-                addHospitalTreeVO.depts.push(lit.value.split('-')[2])
-              })
+        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])
             })
           }
         })
@@ -171,7 +154,6 @@ function AddUser(props) {
             },
           ]}
         >
-
           <Input placeholder="用户名是组织中唯一标识,请勿重复" disabled={type == 3 ? true : false} />
         </Form.Item>
         <Form.Item
@@ -243,6 +225,7 @@ function AddUser(props) {
             showSearch={false}
             treeData={treeData}
             onChange={onChange}
+            maxTagCount={1}
             treeCheckable
             showCheckedStrategy={SHOW_PARENT}
             placeholder="请选择组织"
@@ -298,16 +281,26 @@ function AddUser(props) {
         >
           <Switch onChange={swichChange} disabled={type == 3 ? true : false} />
         </Form.Item>
-        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
-          <Space size="middle">
-            <Button htmlType="button" onClick={e => cancel()}>
-              取消
+        {type == 3  ?
+          <Form.Item wrapperCol={{ offset: 10, span: 16 }}>
+            <Space size="middle">
+              <Button type="primary" htmlType="submit">
+                返回
             </Button>
-            <Button type="primary" htmlType="submit">
-              保存
+            </Space>
+          </Form.Item>
+          : 
+          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
+            <Space size="middle">
+              <Button htmlType="button" onClick={e => cancel()}>
+                取消
             </Button>
-          </Space>
-        </Form.Item>
+              <Button type="primary" htmlType="submit">
+                保存
+            </Button>
+            </Space>
+          </Form.Item>}
+        
       </Form>
     </>
   );

+ 12 - 5
src/components/UserManager/index.js

@@ -3,6 +3,7 @@ import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown,
 import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
 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';
@@ -29,6 +30,10 @@ function UserManager() {
     2: '禁用后该用户将无法登录,确定要禁用该用户?',
     3: '确定要重置该用户密码?',
   };
+  const staticInfo = useSelector(state => {
+    return state.staticInfo;
+  });
+  const { statusList } = staticInfo;
   //新增弹窗
   const showModal = (name, type, flag, userId) => {
     setVisible(type);
@@ -228,13 +233,15 @@ function UserManager() {
               </Form.Item>
             </Col>
             <Col span={6} key={2}>
-              <Form.Item label="当前状态" name="status">
+              <Form.Item name="status" label="当前状态">
                 <Select
-                  placeholder="Select a person"
+                  allowClear
                 >
-                  <Option value="">全部</Option>
-                  <Option value="1">启用</Option>
-                  <Option value="0" >禁用</Option>
+                  {statusList.map((item) => {
+                    return (
+                      <Option value={item.name} key={item.name}>{item.val}</Option>
+                    )
+                  })}
                 </Select>
               </Form.Item>
             </Col>

+ 8 - 10
src/utils/index.js

@@ -34,18 +34,16 @@ function organizationData(arr) {
     arr.forEach(it => {
         it.value = it.hospitalId
         it.title = it.hospitalName
-        it.children && it.children.forEach(item => {
-            list.push({
-                children: item.depts,
-                title: item.hospitalName,
-                value: item.parentId + '-' + item.hospitalId
-            })
-            item.depts.forEach(its => {
-                its.value = item.parentId + '-' + item.hospitalId + '-' + its.deptId
-            })
-            it.children = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'value'))
+        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 = JSON.parse(JSON.stringify(list).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'value'))
     return arr
 }