فهرست منبع

用户管理查看样式修改

1178232204@qq.com 3 سال پیش
والد
کامیت
39c91affa1
3فایلهای تغییر یافته به همراه78 افزوده شده و 46 حذف شده
  1. 5 0
      src/common/common.less
  2. 50 45
      src/components/UserManager/addUser.js
  3. 23 1
      src/components/UserManager/index.js

+ 5 - 0
src/common/common.less

@@ -185,4 +185,9 @@ body{
     vertical-align: middle;
     text-align: center;
   }
+}
+.user{
+  .ant-form-item{
+    margin-bottom: 15px;
+  }
 }

+ 50 - 45
src/components/UserManager/addUser.js

@@ -1,7 +1,7 @@
 import React, {
   useState, useEffect, useContext
 } from 'react';
-import {  Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
+import { Form, Input, Select, Button, Switch, TreeSelect, message, Space } from 'antd';
 import apiObj from '@api/index';
 import { organizationData } from '@utils/index'
 import UserContext from './user-context';
@@ -28,7 +28,7 @@ function AddUser(props) {
   });
   const { titleList } = staticInfo;
   const initialValues = formData;
-  console.log(initialValues);
+  const hospitalName = formData.hospitalName ? formData.hospitalName.join(","):[]
   let addHospitalTreeVOs = {
     depts: [],
     hospitals: [],
@@ -61,8 +61,6 @@ function AddUser(props) {
     xPost(api.getCreateRoles, params).then((res) => {
       if (res.data.code === 200) {
         const data = res.data.data;
-        console.log(data);
-        
         let arr = JSON.parse(JSON.stringify(data).replace(/name/g, 'title').replace(/id/g, 'value'))
         setTreeRloe(arr)
       }
@@ -183,6 +181,7 @@ function AddUser(props) {
         name="register"
         onFinish={onFinish}
         initialValues={initialValues}
+        className='user'
       >
         <Form.Item
           name="username"
@@ -197,7 +196,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.username}</span>
             :
-            <Input placeholder="用户名是组织中唯一标识,请勿重复" autoComplete='off'/>
+            <Input placeholder="用户名是组织中唯一标识,请勿重复" autoComplete='off' />
           }
 
         </Form.Item>
@@ -214,7 +213,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.mobilePhone}</span>
             :
-            <Input placeholder="请输入手机号码" autoComplete='off'/>
+            <Input placeholder="请输入手机号码" autoComplete='off' />
           }
 
         </Form.Item>
@@ -225,7 +224,7 @@ function AddUser(props) {
             {
               required: true,
               message: '8-12位大小写字母、数字、特殊字符',
-            }, 
+            },
             {
               min: 8,
               message: '密码不能少于8个字符',
@@ -238,7 +237,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.password}</span>
             :
-            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" autoComplete='off' disabled={type == 2?true:false}/>
+            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" autoComplete='off' disabled={type == 2 ? true : false} />
           }
         </Form.Item>
         <Form.Item
@@ -263,7 +262,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.password}</span>
             :
-            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" autoComplete='off' disabled={type == 2?true:false}/>
+            <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" autoComplete='off' disabled={type == 2 ? true : false} />
           }
         </Form.Item>
         <Form.Item
@@ -274,7 +273,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.name}</span>
             :
-            <Input placeholder="请输入姓名" autoComplete='off'/>
+            <Input placeholder="请输入姓名" autoComplete='off' />
           }
 
         </Form.Item>
@@ -285,7 +284,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.idcard}</span>
             :
-            <Input placeholder="请输入身份证号码" autoComplete='off'/>
+            <Input placeholder="请输入身份证号码" autoComplete='off' />
           }
 
         </Form.Item>
@@ -294,34 +293,40 @@ function AddUser(props) {
           label="所属组织"
           rules={[{ required: true, message: '请选择所属组织' }]}
         >
-          <TreeSelect
-            showSearch={false}
-            treeData={treeData}
-            onChange={onChange}
-            maxTagCount={1}
-            treeCheckable
-            showCheckedStrategy={SHOW_PARENT}
-            placeholder="请选择"
-            style={{ width: '100%' }}
-          />
+
+          {type == 3 ?
+            <span>{hospitalName}</span>
+            :
+            <TreeSelect
+              showSearch={false}
+              treeData={treeData}
+              onChange={onChange}
+              maxTagCount={1}
+              treeCheckable
+              showCheckedStrategy={SHOW_PARENT}
+              placeholder="请选择"
+              style={{ width: '100%' }}
+            />
+          }
+
         </Form.Item>
-		<Form.Item
-			name="titleId"
-			label="医疗组"
-		>
-		  {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
+          name="titleId"
+          label="医疗组"
+        >
+          {type == 3 ?
+            <span>{initialValues.idcard}</span>
+            :
+            <Select placeholder="请选择">
+              {titleList.map((item, i) => {
+                return (
+                  <Option value={item.name} key={i}>{item.val}</Option>
+                )
+              })}
+            </Select>
+          }
 
-		</Form.Item>
+        </Form.Item>
         <Form.Item
           name="titleId"
           label="职称"
@@ -330,9 +335,9 @@ function AddUser(props) {
             <span>{initialValues.idcard}</span>
             :
             <Select placeholder="请选择职称">
-              {titleList.map((item) => {
+              {titleList.map((item, i) => {
                 return (
-                  <Option value={item.name} key={item.name}>{item.val}</Option>
+                  <Option value={item.name} key={i}>{item.val}</Option>
                 )
               })}
             </Select>
@@ -346,7 +351,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.jobNo}</span>
             :
-            <Input placeholder="请输入工号" autoComplete='off'/>
+            <Input placeholder="请输入工号" autoComplete='off' />
           }
 
         </Form.Item>
@@ -359,7 +364,7 @@ function AddUser(props) {
             <div>
               {roleList.map((it, i) => {
                 return (
-                  <span key={it.id}>{it.roleName}、</span>
+                  <span key={i}>{it.roleName}、</span>
                 );
               })}
             </div>
@@ -383,7 +388,7 @@ function AddUser(props) {
           {type == 3 ?
             <span>{initialValues.orderNo}</span>
             :
-            <Input placeholder="大于0的整数" autoComplete='off'/>
+            <Input placeholder="大于0的整数" autoComplete='off' />
           }
 
         </Form.Item>
@@ -405,7 +410,7 @@ function AddUser(props) {
             <Space size="middle">
               <Button type="primary" onClick={e => cancel()}>
                 返回
-            </Button>
+              </Button>
             </Space>
           </Form.Item>
           :
@@ -413,10 +418,10 @@ function AddUser(props) {
             <Space size="middle">
               <Button htmlType="button" onClick={e => cancel()}>
                 取消
-            </Button>
+              </Button>
               <Button type="primary" htmlType="submit">
                 保存
-            </Button>
+              </Button>
             </Space>
           </Form.Item>}
 

+ 23 - 1
src/components/UserManager/index.js

@@ -7,6 +7,7 @@ import { useSelector } from 'react-redux'
 import apiObj from '@api/index';
 import UserContext from './user-context';
 import { getValueFromEvent } from '@utils/index'
+import { logDOM } from '@testing-library/react';
 
 const { post, api, xPost } = apiObj;
 const { Option } = Select;
@@ -41,6 +42,7 @@ function UserManager() {
     return state.staticInfo;
   });
   let list = []
+  let listName = []
   let data = {
     pages: 1,
     current: 1,
@@ -94,7 +96,9 @@ function UserManager() {
           roles: roles,
           orderNo: data.orderNo,
           status: data.status,
+          hospitalName:getHospitalsName(data.hospitals)
         }
+        console.log(arr);
         setRoleList(data.roles)
         setFormData(arr)
       }
@@ -115,7 +119,6 @@ function UserManager() {
       }
       if (item.type != 0 && item.relation == 1) {
         list.push(item.value)
-        console.log(list)
       }
       if (item.children) {
         getHospitals(item.children)
@@ -123,6 +126,25 @@ function UserManager() {
     })
     return list
   }
+  // 处理组织结构数据回显
+  function getHospitalsName(arr) {
+    arr.forEach((item, i, array) => {
+      if (!item.children && item.depts) {
+        item.depts.forEach(it => {
+          if (it.relation == 1) {
+            listName.push(it.deptName)
+          }
+        })
+      }
+      if (item.type != 0 && item.relation == 1) {
+        listName.push(item.hospitalName)
+      }
+      if (item.children) {
+        getHospitalsName(item.children)
+      }
+    })
+    return listName
+  }
   // 禁用/启用接口
   function disableUser(userId, status) {
     const param = { userId: userId, status: status };