wyq 3 years ago
parent
commit
dd861c1aed

+ 1 - 1
src/api/index.js

@@ -44,7 +44,7 @@ axios.interceptors.request.use(function (req) {
     const tokenStr = localStorage.getItem('token');
     if (tokenStr) {
         req.headers.Authorization = `Bearer ${tokenStr}`;
-        req.headers.hospitalId=1;
+        req.headers.hospitalId=1;//41
         return req;
     } else {
         return req;

+ 9 - 3
src/api/request.js

@@ -9,11 +9,17 @@ const request = {
     updateHospital:'/security-center/hospitalManage/updateHospital',   //修改
     getHospitalById:'/security-center/hospitalManage/getHospitalById', //获取详情
     getUserPage:'/security-center/userManage/getUserPage',//用户列表
-    resetPassword:'/security-center/hospitalManage/resetPassword',  //重置密码
+    addUser: '/security-center/userManage/addUser',//添加用户
+    getUserById: '/security-center/userManage/getUserById',//查看用户
+    getHospitalTree: '/security-center/userManage/getHospitalTree',//获取组织管理树
+    disableUser: '/security-center/userManage/disableUser',//禁用用户
+    getDataAuthPage: '/security-center/dataAuthManage/getDataAuthPage',//数据权限列表
+    getCreateRoles: '/security-center/roleManage/getCreateRoles',//获取当前登录用户角色列表
+    resetPassword: '/security-center/hospitalManage/resetPassword',  //重置密码
     //角色管理相关接口
-    getUserMenuResourceTree:'/security-center/roleManage/getUserMenuResourceTree',      //获取菜单权限树
+    getUserMenuResourceTree: '/security-center/roleManage/getUserMenuResourceTree',      //获取菜单权限树
 
     //用户管理相关接口
-    getHospitalTree:"/security-center/userManage/getHospitalTree",
+    getHospitalTree: "/security-center/userManage/getHospitalTree",
 };
 export default request;

+ 24 - 0
src/common/common.less

@@ -65,4 +65,28 @@
 }
 .ant-steps-item-icon, .ant-steps-item-content{
   vertical-align: unset;
+}
+//启用
+.Enable::before{
+  content: "";
+  width: 5px;
+  height: 5px;
+  display: block;
+  position: absolute;
+  left: 8px;
+  top: 24px;
+  background: #1690FF;
+  border-radius: 50%;
+}
+//禁用
+.Disable::before{
+  content: "";
+  width: 5px;
+  height: 5px;
+  display: block;
+  position: absolute;
+  left: 8px;
+  top: 24px;
+  background: #FE9748;
+  border-radius: 50%;
 }

+ 47 - 46
src/components/AMenu/index.js

@@ -1,61 +1,62 @@
-import {Menu} from 'antd';
-import { useDispatch,useSelector } from 'react-redux'
-import { add,active } from '../../store/reducers/tabPanes'
+import { Menu } from 'antd';
+import { useDispatch, useSelector } from 'react-redux'
+import { add, active } from '../../store/reducers/tabPanes'
 import OrgManager from "../OrgManager";
 import RoleManager from "../RoleManager";
 import UserManager from "../UserManager"
-
+import DataManager from "../DataManager"
 const { SubMenu } = Menu;
 const propTypes = {};
 const defaultProps = {};
 
 const pageMap = {
-    '组织管理':<OrgManager />,
-    '角色管理':<RoleManager />,
-    '用户管理': <UserManager />
+    '组织管理': <OrgManager />,
+    '角色管理': <RoleManager />,
+    '用户管理': <UserManager />,
+    '数据权限': <DataManager />
 }
 
-function AMenu (){
-        const dispatch = useDispatch();
-        //当前选中的菜单
-        const activeTab = useSelector(state => {
-            return state.tabPanes.activeTab
-        });
-        //已打开的tabs
-        const panes = useSelector(state => {
-            return state.tabPanes.panes
-        });
-        //切换菜单、增加tab
-        function changeMenu(val){
-            const item = panes.find((it)=>it.key===val.key);
-            //console.log(item);
-            if(item){   //已存在当前tab,则定位即可不增加
-                dispatch(active(val.key));
-                return;
-            }
-            dispatch(
-                add({ title: val.key, content: pageMap[val.key]||<OrgManager />, key:val.key },)
-            )
+function AMenu() {
+    const dispatch = useDispatch();
+    //当前选中的菜单
+    const activeTab = useSelector(state => {
+        return state.tabPanes.activeTab
+    });
+    //已打开的tabs
+    const panes = useSelector(state => {
+        return state.tabPanes.panes
+    });
+    //切换菜单、增加tab
+    function changeMenu(val) {
+        const item = panes.find((it) => it.key === val.key);
+        //console.log(item);
+        if (item) {   //已存在当前tab,则定位即可不增加
+            dispatch(active(val.key));
+            return;
         }
-        return (
-            <Menu
-                defaultSelectedKeys={['组织管理']}
-                defaultOpenKeys={['权限管理']}
-                selectedKeys={activeTab}
-                mode="inline"
-                onClick={changeMenu}
-            >
-                <SubMenu key="权限管理" title="权限管理">
-                    <Menu.Item key="组织管理">组织管理</Menu.Item>
-                    <Menu.Item key="角色管理">角色管理</Menu.Item>
-                    <Menu.Item key="用户管理">用户管理</Menu.Item>
-                    <Menu.Item key="数据管理">数据管理</Menu.Item>
-                </SubMenu>
-                <SubMenu key="系统管理" title="系统管理">
-                    <Menu.Item key="功能管理">功能管理</Menu.Item>
-                </SubMenu>
-            </Menu>
+        dispatch(
+            add({ title: val.key, content: pageMap[val.key] || <OrgManager />, key: val.key })
         )
+    }
+    return (
+        <Menu
+            defaultSelectedKeys={['组织管理']}
+            defaultOpenKeys={['权限管理']}
+            selectedKeys={activeTab}
+            mode="inline"
+            onClick={changeMenu}
+        >
+            <SubMenu key="权限管理" title="权限管理">
+                <Menu.Item key="组织管理">组织管理</Menu.Item>
+                <Menu.Item key="角色管理">角色管理</Menu.Item>
+                <Menu.Item key="用户管理">用户管理</Menu.Item>
+                <Menu.Item key="数据权限">数据权限</Menu.Item>
+            </SubMenu>
+            <SubMenu key="系统管理" title="系统管理">
+                <Menu.Item key="功能管理">功能管理</Menu.Item>
+            </SubMenu>
+        </Menu>
+    )
 }
 AMenu.propTypes = propTypes;
 AMenu.defaultProps = defaultProps;

+ 172 - 0
src/components/DataManager/index.js

@@ -0,0 +1,172 @@
+import React, { useState, useEffect } from 'react';
+import { Form, Input, Button, Table, Select, Pagination, Space, Modal } from 'antd';
+import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+// import NormalPlayer from './testComponent/testComponent'
+import '@common/common.less';
+import apiObj from '@api/index';
+const { post, api } = apiObj;
+const { Option } = Select;
+function UserManager() {
+  useEffect(() => {
+    getDataAuthPage();
+  }, []);
+  const [userList, setUserList] = useState([]);
+  const [title, setTitle] = useState("");
+  const [visible, setVisible] = useState(false);
+  const ChildrenChange = (val) => {//这个val就是子组件传来的
+    setVisible(false);
+  }
+  const showModal = (name, type) => {
+    setVisible(type);
+    setTitle(name);
+  }
+  function getDataAuthPage(param = {}) {
+    //const param = filterData;
+    post(api.getDataAuthPage, param).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        setUserList(data.records);
+      }
+    })
+  }
+  const disableUser = (userId, status) => {
+    let params = {
+      userId: userId,
+      status: status
+    }
+    post(api.disableUser, params).then((res) => {
+      if (res.data.code === 200) {
+        const data = res.data.data;
+        setUserList(data.records);
+      }
+    })
+  };
+  const [form] = Form.useForm();
+
+  const onFinish = (value) => {
+    getDataAuthPage(value);
+  };
+  const onReset = () => {
+    form.resetFields();
+    getDataAuthPage();
+  };
+
+  function confirm() {
+    Modal.confirm({
+      title: '提示',
+      icon: <ExclamationCircleOutlined />,
+      content: 'Bla bla ...',
+      okText: '确认',
+      cancelText: '取消',
+      onOk() {
+        console.log('OK');
+      },
+      onCancel() {
+        console.log('Cancel');
+      },
+    });
+  }
+  const columns = [
+    { title: '数据权限名称', dataIndex: 'key' },
+    { title: '所属角色', dataIndex: 'key' },
+    {
+      title: '状态', dataIndex: 'key', render: (text, record) => (
+        <Space size="middle">
+          {record.age == 1 ? (
+            <a>查看</a>
+          ) : (
+              <a >修改</a>
+            )}
+        </Space>
+      )
+    },
+    {
+      title: '操作', dataIndex: 'key', render: (text, record) => (
+        <Space size="middle">
+          <a>修改</a>
+          <a onClick={e => showModal('修改用户', true)} >禁用</a>
+          <a onClick={e => showModal('修改用户', true)} >删除</a>
+        </Space>
+      )
+    }
+  ]
+
+  const data = [];
+  for (let i = 0; i < 100; i++) {
+    data.push({
+      key: i,
+      name: 'John Brown',
+      age: i + 1,
+      street: 'Lake Park',
+      building: 'C',
+      number: 2035,
+      companyAddress: 'Lake Street 42',
+      companyName: 'SoftLake Co',
+      gender: 'M',
+    });
+  }
+  return (
+    <div className="wrapper">
+      <Form
+        form={form}
+        name="normal_login"
+        className="basic"
+        layout="inline"
+        onFinish={onFinish}
+        initialValues={{ status: '' }}
+      >
+        <div className="basic-left">
+          <Form.Item label="数据权限名称" name="username">
+            <Input placeholder="用户名" />
+          </Form.Item>
+          <Form.Item label="所属角色" name="name">
+            <Input placeholder="姓名" />
+          </Form.Item>
+          <Form.Item label="当前状态" name="status">
+            <Select
+              style={{ width: 200 }}
+              placeholder="Select a person"
+            >
+              <Option value="">全部</Option>
+              <Option value="1">启用</Option>
+              <Option value="0" >禁用</Option>
+            </Select>
+          </Form.Item>
+
+        </div>
+        <Form.Item>
+          <Space size="middle">
+            <Button onClick={onReset}>
+              重置
+          </Button>
+            <Button type="primary" htmlType="submit">
+              查询
+          </Button>
+          </Space>
+        </Form.Item>
+      </Form>
+
+      <div className="table">
+        <div className="table-header">
+          <span className="table-header-title">数据权限</span>
+          <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增用户', true)}>新增数据权限</Button>
+        </div>
+
+        <Table
+          columns={columns}
+          dataSource={data}
+          pagination={{
+            showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
+            pageSizeOptions: ['15', '30', '60', '120'],
+            pageSize: 5,
+          }} />
+      </div>
+      {/* <div>
+        <NormalPlayer changeData={ChildrenChange} title={title} visible={visible}></NormalPlayer>
+      </div> */}
+
+    </div >
+  )
+}
+
+export default UserManager;

+ 272 - 0
src/components/UserManager/addUser.js

@@ -0,0 +1,272 @@
+import React, {
+  useState, useEffect, useRef, useImperativeHandle, forwardRef
+} from 'react';
+import { Modal, Form, Input, Select, Button, Switch, TreeSelect, message } from 'antd';
+import apiObj from '@api/index';
+const { post, api } = apiObj;
+const { Option, OptGroup } = Select;
+const { SHOW_PARENT } = TreeSelect;
+
+const formItemLayout = {
+  labelCol: {
+    xs: { span: 36 },
+    sm: { span: 8 },
+  },
+  wrapperCol: {
+    xs: { span: 24 },
+    sm: { span: 16 },
+  },
+};
+const tailFormItemLayout = {
+  wrapperCol: {
+    xs: {
+      span: 24,
+      offset: 0,
+    },
+    sm: {
+      span: 16,
+      offset: 8,
+    },
+  },
+};
+function NormalPlayer(props, parentRef) {
+  const { title, visible, type } = props
+  const inputRef = useRef();
+  const [treeData, setTreeData] = useState([]);
+  const [treeRloe, setTreeRloe] = useState([]);
+  const [addHospitalTreeVO, setAddHospitalTreeVO] = useState({
+    depts: [],
+    hospitals: []
+  });
+  const [form] = Form.useForm();
+  useEffect(() => {
+    getHospitalTree();
+    getCreateRoles()
+  }, []);
+  // 父组件获取的值
+  useImperativeHandle(parentRef, () => {
+    return {
+      form: form.getFieldsValue(),
+      addHospitalTreeVO
+    }
+  })
+  const hideModal = () => {
+    form.resetFields();
+  };
+  //获取当前用户组织
+  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[0].children : []
+        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 getCreateRoles() {
+    post(api.getCreateRoles).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 swichChange(val) {
+    form.setFieldsValue({ status: val ? 1 : 0 })
+  }
+  // 判断元素存在格式
+  function getSameNum(val, arr) {
+    let processArr = arr.filter(function (value) {
+      return value == val;
+    })
+    return processArr.length;
+  }
+  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])
+      } 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])
+            })
+          }
+        })
+      }
+    })
+    setAddHospitalTreeVO(addHospitalTreeVO)
+  };
+  return (
+    <>
+      <Form
+        {...formItemLayout}
+        form={form}
+        name="register"
+        scrollToFirstError
+      >
+        <Form.Item
+          name="username"
+          label="用户名"
+
+          rules={[
+            {
+              required: true,
+              message: '请输入用户名',
+            },
+          ]}
+        >
+          <Input placeholder="用户名是组织中唯一标识,请勿重复" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="mobilePhone"
+          label="手机号码"
+          rules={[
+            {
+              required: true,
+              message: '请输入手机号码',
+            },
+          ]}
+        >
+          <Input placeholder="请输入手机号码" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="password"
+          label="初始密码"
+          rules={[
+            {
+              required: true,
+              message: '8-12位大小写字母、数字、特殊字符',
+            },
+          ]}
+          hasFeedback
+        >
+          <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="againpassword"
+          label="确认密码"
+          dependencies={['password']}
+          hasFeedback
+          rules={[
+            {
+              required: true,
+              message: '8-12位大小写字母、数字、特殊字符',
+            },
+            ({ getFieldValue }) => ({
+              validator(_, value) {
+                if (!value || getFieldValue('password') === value) {
+                  return Promise.resolve();
+                }
+                return Promise.reject(new Error('两次密码不一致,请确认密码'));
+              },
+            }),
+          ]}
+        >
+          <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="name"
+          label="姓名"
+          rules={[{ required: true, message: '请输入姓名', whitespace: true }]}
+        >
+          <Input placeholder="请输入姓名" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="idcard"
+          label="身份证号码"
+        >
+          <Input placeholder="请输入身份证号码" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="addHospitalTreeVO"
+          label="所属组织"
+          rules={[{ required: true, message: '请选择所属组织' }]}
+        >
+          <TreeSelect
+            showSearch={false}
+            treeData={organizationData(treeData)}
+            onChange={onChange}
+            treeCheckable
+            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}>
+            <Option value="male">Male</Option>
+            <Option value="female">Female</Option>
+            <Option value="other">Other</Option>
+          </Select>
+        </Form.Item>
+        <Form.Item
+          name="jobNo"
+          label="工号"
+        >
+          <Input placeholder="请输入工号" disabled={type == 3 ? true : false} />
+        </Form.Item>
+        <Form.Item
+          name="roles"
+          label="所属角色"
+          rules={[{ required: true, message: '请选择角色' }]}
+        >
+          <TreeSelect
+            showSearch={false}
+            treeData={treeRloe}
+            treeCheckable
+            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} />
+        </Form.Item>
+        <Form.Item
+          name="status"
+          valuePropName="checked"
+          label="当前状态"
+          rules={[{ required: true, message: '请选择状态' }]}
+        >
+          <Switch onChange={swichChange} disabled={type == 3 ? true : false} />
+        </Form.Item>
+      </Form>
+    </>
+  );
+}
+export default forwardRef(NormalPlayer);

+ 211 - 75
src/components/UserManager/index.js

@@ -1,79 +1,192 @@
-import React, { useState, useEffect } from 'react';
-import { Form, Input, Button, Table, Select, Pagination, Breadcrumb, Space, Menu, Dropdown } from 'antd';
-import { DownOutlined, PlusOutlined } from '@ant-design/icons';
-import NormalPlayer from './testComponent/testComponent'
+import React, { useState, useEffect, useRef } from 'react';
+import { Form, Input, Button, Table, Select, Pagination, Space, Menu, Dropdown, Modal, Breadcrumb, message } from 'antd';
+import { DownOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
+import NormalPlayer from './addUser'
 import '@common/common.less';
 import apiObj from '@api/index';
-const { post, api } = apiObj;
+const { post, api, xPost } = apiObj;
 const { Option } = Select;
 function UserManager() {
+  const parentRef = useRef();
   useEffect(() => {
     getUserPage();
   }, []);
   const [userList, setUserList] = useState([]);
   const [title, setTitle] = useState("");
   const [visible, setVisible] = useState(false);
-  const onFinish = (values) => {
-    console.log('Success:', values);
-  }
-  const ChildrenChange =(val)=> {//这个val就是子组件传来的
+  const [userId, setUserId] = useState("");
+  const [msvisible, setMsvisible] = useState(false);
+  const [modalType, setModalType] = useState("");
+  const [type, setType] = useState("");
+  const [form] = Form.useForm();
+  const tipText = {
+    1: '确定要删除该用户?',
+    2: '禁用后该用户将无法登录,确定要禁用该用户?',
+    3: '确定要重置该用户密码?',
+  };
+  const ChildrenChange = (val) => {
     setVisible(false);
+    getUserPage()
+  }
+  const getChildrenMsg = (result, msg) => {
+    // console.log(result, msg)
+    // 很奇怪这里的result就是子组件那bind的第一个参数this,msg是第二个参数
   }
-  const showModal = (name,type) => {
+  //新增弹窗
+  const showModal = (name, type, flag) => {
     setVisible(type);
     setTitle(name);
+    setType(flag)
+    if (flag == 3) {
+      getUserById()
+    }
   }
+  //表格数据
   function getUserPage(param = {}) {
     //const param = filterData;
     post(api.getUserPage, param).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
-        console.log(data)
         setUserList(data.records);
       }
     })
   }
-  const menu = (
-    <Menu>
-      <Menu.Item key="0">
-        <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com">
-          重置密码
-        </a>
-      </Menu.Item>
-      <Menu.Item key="1">
-        <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
-          禁用
-        </a>
-      </Menu.Item>
-      <Menu.Item key="2">
-        <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
-          删除
-        </a>
-      </Menu.Item>
-    </Menu>
-  )
+  //查看用户
+  function getUserById() {
+    xPost(api.getUserById, { userId: 39 }).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 disableUser(userId, status) {
+    const param = { userId: userId, status: status };
+    xPost(api.disableUser, param).then((res) => {
+      if (res.data.code === 200) {
+        getUserPage();
+        setMsvisible(false);
+        message.success((status ? '启用' : '禁用') + "成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      message.error("接口出错");
+    });
+  }
+  // 启用/禁用用户
+  function enable(userId, status) {
+    disableUser(userId, status)
+  }
+  //重置密码
+  function onResetPsd() {
+    // const param = { HospitalId: operId };
+    // xPost(api.disableHospital, param).then((res) => {
+    //   if (res.data.code === 200) {
+    //     getUserPage();
+    //     message.success("重置成功");
+    //   } else {
+    //     message.warning(res.data.msg || '操作失败');
+    //   }
+    // }).catch(() => {
+    //   message.error("接口出错");
+    // });
+  }
+  //删除
+  function onDelete() {
+    const param = { userId: userId };
+    xPost(api.deleteHospital, param).then((res) => {
+      if (res.data.code === 200) {
+        getUserPage();
+        message.success("删除成功");
+      } else {
+        message.warning(res.data.msg || '操作失败');
+      }
+    }).catch(() => {
+      message.error("接口出错");
+    });
+  }
+  // 确定按钮
+  function addUser(param = {}) {
+    //const param = filterData;
+    post(api.addUser, param).then((res) => {
+      if (res.data.code === 200) {
+        message.success(res.data.message);
+        form.resetFields();
+      }
+    })
+  }
+  const onFinish = (value) => {
+    getUserPage(value);
+  };
+  const onReset = () => {
+    form.resetFields();
+    getUserPage();
+  };
+  const messageBox = (type, id) => {
+    setMsvisible(true)
+    setUserId(id)
+    setModalType(type)
+  };
+  // 新增
+  const submit = () => {
+    console.log(parentRef.current)
+    form
+      .validateFields()
+      .then((values) => {
+        let params = parentRef.current.form
+        parentRef.current.addHospitalTreeVO.hospitals = unique(parentRef.current.addHospitalTreeVO.hospitals)
+        params.addHospitalTreeVO = parentRef.current.addHospitalTreeVO
+        addUser(params)
+      })
+      .catch((info) => {
+        console.log('Validate Failed:', info);
+      });
+  }
+  // 去重
+  function unique(arr) {
+    return arr.filter(function (item, index, arr) {
+      return arr.indexOf(item, 0) === index;
+    });
+  }
+  //提示框确认事件
+  function handleOk() {
+    if (modalType == 2) {
+      disableUser(userId, 0)
+    } else if (modalType == 2) {
+      disableUser(userId, 0)
+    } else if (modalType == 3) {
+      onResetPsd();
+    }
+  }
+  //提示框取消
+  function handleCancel() {
+    setMsvisible(false);
+  }
   const columns = [
-    { title: '用户名', dataIndex: 'key' },
-    { title: '姓名', dataIndex: 'key' },
-    { title: '所属组织', dataIndex: 'key' },
-    { title: '工号', dataIndex: 'key' },
+    { title: '用户名', dataIndex: 'username', key: 'index' },
+    { title: '姓名', dataIndex: 'name', key: 'index' },
+    { title: '所属组织', dataIndex: 'hospitalName', key: 'index' },
+    { title: '工号', dataIndex: 'jobNo', key: 'index' },
     {
-      title: '状态', dataIndex: 'key', render: (text, record) => (
+      title: '状态', dataIndex: 'status', key: 'status', render: (text, record) => (
         <Space size="middle">
-          {record.age == 1 ? (
-            <a>查看</a>
-          ) : (
-              <a >修改</a>
-            )}
+          {record.status == 1 ?
+            <span className="Enable">启用</span>
+            :
+            <span className="Disable">禁用</span>
+          }
         </Space>
       )
     },
     {
-      title: '操作', dataIndex: 'key', render: () => (
+      title: '操作', dataIndex: 'key', render: (text, record) => (
         <Space size="middle">
-          <a>查看</a>
-          <a onClick={e => showModal('修改用户', true)} >修改</a>
-          <Dropdown overlay={menu}>
+          <a onClick={e => showModal('查看用户', true, 3)}>查看</a>
+          <a onClick={e => showModal('修改用户', true, 2)} >修改</a>
+          <Dropdown overlay={menu.bind(this, record)} record={record}>
             <a className="ant-dropdown-link" onClick={e => e.preventDefault()}>
               更多 <DownOutlined />
             </a>
@@ -82,53 +195,57 @@ function UserManager() {
       )
     }
   ]
-  const data = [];
-  for (let i = 0; i < 100; i++) {
-    data.push({
-      key: i,
-      name: 'John Brown',
-      age: i + 1,
-      street: 'Lake Park',
-      building: 'C',
-      number: 2035,
-      companyAddress: 'Lake Street 42',
-      companyName: 'SoftLake Co',
-      gender: 'M',
-    });
+  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={() => enable(record.userId, 1)}>启用</a>)}
+        </Menu.Item>
+        <Menu.Item key="2">
+          <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
+            删除
+          </a>
+        </Menu.Item>
+      </Menu>
+    )
   }
   return (
     <div className="wrapper">
       <Form
+        form={form}
         name="normal_login"
-        className="login-form"
         className="basic"
         layout="inline"
-        initialValues={{ remember: true }}
         onFinish={onFinish}
+        initialValues={{ status: '' }}
       >
         <div className="basic-left">
-          <Form.Item label="用户名">
-            <Input placeholder="Basic usage" />
+          <Form.Item label="用户名" name="username">
+            <Input placeholder="用户名" />
           </Form.Item>
-          <Form.Item label="姓名">
-            <Input placeholder="Basic usage" />
+          <Form.Item label="姓名" name="name">
+            <Input placeholder="姓名" />
           </Form.Item>
-          <Form.Item label="当前状态">
+          <Form.Item label="当前状态" name="status">
             <Select
               style={{ width: 200 }}
               placeholder="Select a person"
-              defaultValue="全部"
             >
-              <Option value="全部">全部</Option>
-              <Option value="启用">启用</Option>
-              <Option value="禁用">禁用</Option>
+              <Option value="">全部</Option>
+              <Option value="1">启用</Option>
+              <Option value="0" >禁用</Option>
             </Select>
           </Form.Item>
 
         </div>
         <Form.Item>
           <Space size="middle">
-            <Button htmlType="submit">
+            <Button onClick={onReset}>
               重置
           </Button>
             <Button type="primary" htmlType="submit">
@@ -143,22 +260,41 @@ function UserManager() {
           <Breadcrumb>
             <Breadcrumb.Item>用户管理</Breadcrumb.Item>
           </Breadcrumb>
-          <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增用户', true)}>新增用户</Button>
+          <Button type="primary" icon={<PlusOutlined />} onClick={e => showModal('新增用户', true, 1)}>新增用户</Button>
         </div>
 
         <Table
           columns={columns}
-          dataSource={data}
+          dataSource={userList}
+          rowKey={record => record.userId}
           pagination={{
             showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条数据`,
             pageSizeOptions: ['15', '30', '60', '120'],
             pageSize: 5,
           }} />
       </div>
-      <div>
-        <NormalPlayer changeData={ChildrenChange} title={title}  visible={visible}></NormalPlayer>
-      </div>
-
+      <Modal
+        title="提示"
+        okText='确定'
+        cancelText='取消'
+        width={400}
+        visible={visible}
+        onOk={submit}
+        onCancel={handleCancel}
+      >
+        <NormalPlayer title={title} visible={visible} type={type} ref={parentRef}></NormalPlayer>
+      </Modal>
+      <Modal
+        title="提示"
+        okText='确定'
+        cancelText='取消'
+        width={400}
+        visible={msvisible}
+        onOk={handleOk}
+        onCancel={handleCancel}
+      >
+        <p>{tipText[modalType]}</p>
+      </Modal>
     </div >
   )
 }

+ 0 - 231
src/components/UserManager/testComponent/testComponent.js

@@ -1,231 +0,0 @@
-import React, { useState } from 'react';
-import { Modal, Form, Input, Select, Row, Col, Button, Switch  } from 'antd';
-
-const { Option } = Select;
-
-const formItemLayout = {
-  labelCol: {
-    xs: { span: 36 },
-    sm: { span: 8 },
-  },
-  wrapperCol: {
-    xs: { span: 24 },
-    sm: { span: 16 },
-  },
-};
-const tailFormItemLayout = {
-  wrapperCol: {
-    xs: {
-      span: 24,
-      offset: 0,
-    },
-    sm: {
-      span: 16,
-      offset: 8,
-    },
-  },
-};
-const state = {
-  phone: '123'
-}
-function NormalPlayer(props) {
-  console.log(state.phone)
-  const hideModal = () => {
-    form.resetFields();
-    props.changeData()
-  };
-  const submit = () => {
-    form
-      .validateFields()
-      .then((values) => {
-        form.resetFields();
-      })
-      .catch((info) => {
-        console.log('Validate Failed:', info);
-      });
-  }
-  const [form] = Form.useForm();
-  const handleMaxRestoreUp = (event) => {
-    console.log(event.target.value)
-  }
-  const onFinish = (values: any) => {
-    console.log('Received values of form: ', values);
-  };
-
-  const prefixSelector = (
-    <Form.Item name="prefix" noStyle>
-      <Select style={{ width: 70 }}>
-        <Option value="86">+86</Option>
-        <Option value="87">+87</Option>
-      </Select>
-    </Form.Item>
-  );
-
-  const [autoCompleteResult, setAutoCompleteResult] = useState([]);
-
-  const onWebsiteChange = (value: string) => {
-    if (!value) {
-      setAutoCompleteResult([]);
-    } else {
-      setAutoCompleteResult(['.com', '.org', '.net'].map(domain => `${value}${domain}`));
-    }
-  };
-
-  const websiteOptions = autoCompleteResult.map(website => ({
-    label: website,
-    value: website,
-  }));
-  return (
-    <>
-      <Modal
-        title={props.title}
-        visible={props.visible}
-        onOk={submit}
-        onCancel={hideModal}
-        okText="确认"
-        cancelText="取消">
-        <Form
-          {...formItemLayout}
-          form={form}
-          name="register"
-          onFinish={onFinish}
-          scrollToFirstError
-          initialValues={state}
-        >
-          <Form.Item
-            name="name"
-            label="用户名"
-            rules={[
-              {
-                required: true,
-                message: '请输入用户名',
-              },
-            ]}
-          >
-            <Input placeholder="用户名是组织中唯一标识,请勿重复" />
-          </Form.Item>
-
-          <Form.Item
-            name="phone"
-            label="手机号码"
-            rules={[
-              {
-                required: true,
-                message: '请输入手机号',
-              },
-            ]}
-          >
-            <Input />
-          </Form.Item>
-          <Form.Item
-            name="password"
-            label="初始密码"
-            rules={[
-              {
-                required: true,
-                message: '请输入初始密码',
-              },
-            ]}
-            hasFeedback
-          >
-            <Input.Password />
-          </Form.Item>
-          <Form.Item
-            name="confirm"
-            label="确认密码"
-            dependencies={['password']}
-            hasFeedback
-            rules={[
-              {
-                required: true,
-                message: '请输入确认密码',
-              },
-              ({ getFieldValue }) => ({
-                validator(_, value) {
-                  if (!value || getFieldValue('password') === value) {
-                    return Promise.resolve();
-                  }
-                  return Promise.reject(new Error('两次密码不一致,请确认密码'));
-                },
-              }),
-            ]}
-          >
-            <Input.Password />
-          </Form.Item>
-
-          <Form.Item
-            name="nickname"
-            label="姓名"
-            rules={[{ required: true, message: '请输入姓名', whitespace: true }]}
-          >
-            <Input />
-          </Form.Item>
-
-          <Form.Item
-            name="residence"
-            label="身份证号码"
-          >
-            <Input />
-          </Form.Item>
-
-          <Form.Item
-            name="phone"
-            label="所属组织"
-            rules={[{ required: true, message: 'Please input your phone number!' }]}
-          >
-            <Select placeholder="请选择组织">
-              <Option value="male">Male</Option>
-              <Option value="female">Female</Option>
-              <Option value="other">Other</Option>
-            </Select>
-          </Form.Item>
-
-          <Form.Item
-            name="website"
-            label="职称"
-          >
-            <Select placeholder="请选择职称">
-              <Option value="male">Male</Option>
-              <Option value="female">Female</Option>
-              <Option value="other">Other</Option>
-            </Select>
-          </Form.Item>
-
-          <Form.Item
-            name="gender"
-            label="工号"
-          >
-            <Input />
-          </Form.Item>
-
-          <Form.Item
-            name="captcha"
-            label="所属角色"
-            rules={[{ required: true, message: '请选择角色' }]}
-          >
-            <Select placeholder="请选择所属角色">
-              <Option value="male">Male</Option>
-              <Option value="female">Female</Option>
-              <Option value="other">Other</Option>
-            </Select>
-          </Form.Item>
-
-          <Form.Item
-            name="agreement"
-            label="排序"
-          >
-            <Input />
-          </Form.Item>
-          <Form.Item
-            name="agreement"
-            valuePropName="checked"
-            label="当前状态"
-          >
-            <Switch defaultChecked />
-          </Form.Item>
-        </Form>
-      </Modal>
-    </>
-  );
-}
-export default NormalPlayer;