Browse Source

修改组织用户名重复bug

wyq 3 years ago
parent
commit
a78231f7c3
2 changed files with 45 additions and 23 deletions
  1. 14 4
      src/components/OrgManager/AddSubOrg.js
  2. 31 19
      src/components/OrgManager/index.js

+ 14 - 4
src/components/OrgManager/AddSubOrg.js

@@ -18,6 +18,7 @@ function AddSubOrg(props) {
     const [visible, setVisible] = useState(false);
 
     const { back } = props
+    const { type } = useContext(OrgContext);
     const steps = [
         {
             title: '基础信息',
@@ -36,6 +37,8 @@ function AddSubOrg(props) {
     const next = () => {
         setCurrent(current + 1);
         setIsChange(true)
+        console.log(form.getFieldsValue());
+        
     };
     const pre = () => {
         setCurrent(current - 1);
@@ -47,7 +50,7 @@ function AddSubOrg(props) {
         setVisible(false)
     }
     const goback = () => {
-        if (form.getFieldsValue().name != undefined || form.getFieldsValue().type != undefined) {
+        if ((form.getFieldsValue().name != undefined || form.getFieldsValue().type != undefined) && type!=2) {
             setVisible(true)
         } else {
             back()
@@ -110,6 +113,7 @@ function StepContent(props) {
             number: '${label} is not a valid number!',
         },
     };
+    
     //获取菜单数据
     function getTreeData() {
         xPost(api.getUserMenuResourceTree, { type: 0 }).then((res) => {
@@ -307,11 +311,17 @@ function StepContent(props) {
                     name='orderNo'>
                     <InputNumber placeholder='大于0的整数' min={0} />
                 </Form.Item>
+                <Form.Item
+                    label="用户名"
+                    hidden
+                    name={type == 2?['addHospitalUserVO', 'id']:''}>
+                    <Input placeholder='用户名是组织中唯一标识,请勿重复' autoComplete='off' disabled={type == 2 ? true : false} />
+                </Form.Item>
                 <Form.Item
                     label="用户名"
                     hidden={current !== 1}
                     name={['addHospitalUserVO', 'username']}
-                    rules={[{ required: true }]}>
+                    rules={type != 2 ? [{ required: true }]:null}>
                     <Input placeholder='用户名是组织中唯一标识,请勿重复' autoComplete='off' disabled={type == 2 ? true : false} />
                 </Form.Item>
                 <Form.Item
@@ -334,14 +344,14 @@ function StepContent(props) {
                     name='confirmPsd'
                     dependencies={['addHospitalUserVO', 'password']}
                     hidden={current !== 1}
-                    rules={[{ required: true }, ({ getFieldValue }) => ({
+                    rules={type != 2 ? [{ required: true }, ({ getFieldValue }) => ({
                         validator(_, value) {
                             if (!value || getFieldValue(['addHospitalUserVO', 'password']) === value) {
                                 return Promise.resolve();
                             }
                             return Promise.reject(new Error('两次密码输入不一致!'));
                         },
-                    })]}>
+                    })]:null}>
                     <Input placeholder='8-12位大小写字母、数字、特殊字符' autoComplete='off' disabled={type == 2 ? true : false} />
                 </Form.Item>
                 <Form.Item

+ 31 - 19
src/components/OrgManager/index.js

@@ -154,11 +154,11 @@ function OrgManager() {
             parentId: orgId,
             parentName: orgName,
             status: 1,
-            type: orgType==4?'科室':''
+            type: orgType == 4 ? '科室' : ''
         })
     }
     function getOrgDetail(id, type) {
-        xPost(api.getHospitalById, { HospitalId: id, type:type }).then((res) => {
+        xPost(api.getHospitalById, { HospitalId: id, type: type }).then((res) => {
             const { data, code } = res.data;
             if (code === 200) {
                 structDetail(data);
@@ -170,7 +170,7 @@ function OrgManager() {
     }
     function structDetail(data) {
         const content = JSON.parse(JSON.stringify(data).replace(/getHospitalUserDTO/g, "addHospitalUserVO"));
-        const menuData = content.getRoleDTO?content.getRoleDTO.loginUserMenuResourceTree:[];
+        const menuData = content.getRoleDTO ? content.getRoleDTO.loginUserMenuResourceTree : [];
         content.confirmPsd = content.addHospitalUserVO.password
         let softwares = [], sids = [];
         for (let i = 0; i < menuData.length; i++) {
@@ -182,8 +182,12 @@ function OrgManager() {
         setOrgDetail(fData);
     }
     //修改子组织
-    function editSubOrg(id, type) {
-        getOrgDetail(id, type);
+    function editSubOrg(id, type, deptId) {
+        if (orgType == 4) {
+            getOrgDetail(deptId, type);
+        } else {
+            getOrgDetail(id, type);
+        }
         setAddVisible(true);
         setType(2)
         setOperId(id);
@@ -197,14 +201,12 @@ function OrgManager() {
                 return it;
             }
         });
-        if (orgType == 4){
+        if (orgType == 4) {
             param.type = 4
         }
         if (type == 2) {
             url = api.updateHospital
             param.id = operId
-            delete param.addHospitalUserVO
-            delete param.confirmPsd
         }
         formData.softwares = arr;
         post(url, param).then((res) => {
@@ -240,7 +242,7 @@ function OrgManager() {
                         }
                     }
                 },
-                { title: '类型', width: 150, key: 'type', dataIndex: 'typeName'},
+                { title: '类型', width: 150, key: 'type', dataIndex: 'typeName' },
                 {
                     title: '状态', width: 120, key: 'status', render: (row) => {
                         if (row.children) {
@@ -264,7 +266,7 @@ function OrgManager() {
                             </Menu>
                         );
                         return (<Space size="middle">
-                            <a onClick={() => editSubOrg(row.hospitalId, row.type)}>修改</a>
+                            <a onClick={() => editSubOrg(row.hospitalId, row.type, row.deptId)}>修改</a>
                             {row.status === '1' ? (<a onClick={() => showModal(row.hasUserFlag || row.hasHospitalFlag ? 4 : 3, row.hospitalId, row.type)}>禁用</a>) : (<a onClick={() => enable(1, row.hospitalId, row.type)}>启用</a>)}
                             <Dropdown overlay={menu} trigger={['click']}>
                                 <a className="ant-dropdown-link">
@@ -275,6 +277,15 @@ function OrgManager() {
                     }
                 },
             ];
+            return (
+                <Table
+                    pagination={false}
+                    className="components-table-demo-nested"
+                    rowKey={record => record.deptId}
+                    columns={columns}
+                    dataSource={dataSource}
+                />
+            )
         } else {
             columns = [
                 { title: '组织机构层级', dataIndex: 'hospitalName', key: 'hospitalName' },
@@ -321,16 +332,17 @@ function OrgManager() {
                     }
                 },
             ];
+            return (
+                <Table
+                    pagination={false}
+                    className="components-table-demo-nested"
+                    rowKey={record => record.hospitalId}
+                    columns={columns}
+                    dataSource={dataSource}
+                />
+            )
         }
-        return (
-            <Table
-                pagination={false}
-                className="components-table-demo-nested"
-                rowKey={record => record.hospitalId + record.deptId}
-                columns={columns}
-                dataSource={dataSource}
-            />
-        )
+        
     }
     //筛选项渲染
     const [form] = Form.useForm();