瀏覽代碼

退出添加提示

wyq 3 年之前
父節點
當前提交
75639d7daa

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

@@ -139,7 +139,6 @@ function AHeader({ history, hideName }) {
                             name="password"
                             label="原密码"
                             required
-                            hasFeedback
                         >
                             <Input.Password placeholder="8-12位大小写字母、数字、特殊字符" />
                         </Form.Item>
@@ -147,7 +146,6 @@ function AHeader({ history, hideName }) {
                             name="modifyPassword"
                             label="新密码"
                             dependencies={['password']}
-                            hasFeedback
                             rules={[
                                 {
                                     required: true,
@@ -175,7 +173,6 @@ function AHeader({ history, hideName }) {
                             name="againnewpassword"
                             label="确认新密码"
                             dependencies={['password']}
-                            hasFeedback
                             rules={[
                                 {
                                     required: true,

+ 70 - 43
src/components/DataManager/AddData.js

@@ -1,5 +1,5 @@
 import { useEffect, useState, useContext } from 'react';
-import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag, Card, message } from 'antd';
+import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag, Card, message, Modal } from 'antd';
 import './index.less';
 import DataContext from './data-context';
 import MenuTree from './MenuTree';
@@ -25,6 +25,8 @@ function AddData(props) {
   }, []);
   const { back, } = props;
   const [form] = Form.useForm();
+  const [isChange, setIsChange] = useState(false);
+  const [visible, setVisible] = useState(false);
   const [value, setValue] = useState([]);
   const [key, setKey] = useState();
   const [index, setIndex] = useState('0');
@@ -44,7 +46,19 @@ function AddData(props) {
   const validateMessages = {
     required: '${label}不能为空',
   };
-
+  function handleOk() {
+    back()
+  }
+  function handleCancel() {
+    setVisible(false)
+  }
+  const goback = () => {
+    if (form.getFieldsValue().name != undefined || isChange) {
+      setVisible(true)
+    } else {
+      back()
+    }
+  };
   //获取当前用于所属角色
   function getCreateRoles() {
     const params = {
@@ -53,7 +67,7 @@ function AddData(props) {
     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'))
+        let arr = JSON.parse(JSON.stringify(data).replace(/name/g, 'title').replace(/id/g, 'value'))
         setTreeRloe(arr)
       }
     })
@@ -77,7 +91,7 @@ function AddData(props) {
         item.depts.forEach(it => {
           it.key = item.hospitalId + '-' + it.deptId + '-' + it.deptName
         })
-        item.children = JSON.parse(JSON.stringify(item.depts).replaceAll(/deptName/g, 'title').replaceAll(/deptId/g, 'key'))
+        item.children = JSON.parse(JSON.stringify(item.depts).replace(/deptName/g, 'title').replace(/deptId/g, 'key'))
         return
       }
       if (item.children) {
@@ -147,6 +161,7 @@ function AddData(props) {
     setTags([...tags])
     setValue([...val])
     setSelectedRowKeys([...selectedRowKeys])
+    setIsChange(true)
   };
   // 删除选择标签
   function delTag(type, id, i) {
@@ -187,6 +202,7 @@ function AddData(props) {
     form.setFieldsValue({
       softwareVOS: arr
     });
+    setIsChange(true)
   }
   // 去重
   function unique(arr) {
@@ -293,7 +309,7 @@ function AddData(props) {
   return (
     <>
       <Breadcrumb separator="">
-        <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={back} alt="返回上一页" /></Breadcrumb.Item>
+        <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={goback} alt="返回上一页" /></Breadcrumb.Item>
         <Breadcrumb.Item>数据权限</Breadcrumb.Item>
         <Breadcrumb.Separator />
         <Breadcrumb.Item>{type == 3 ? '修改' : '新增'}数据权限</Breadcrumb.Item>
@@ -373,53 +389,64 @@ function AddData(props) {
                 return (
                   <Form.Item
                     key={i}
-                    style={{ display:i == index ? 'block' : 'none'}}
+                    style={{ display: i == index ? 'block' : 'none' }}
                   >
-                  { index == i ?
-                  <Form.Item key={i + "b"}
-                    name={['softwareVOS', i, 'roles']}
-                    rules={[
-                      {
-                        required: true,
-                        message: '请选择所属角色',
-                      },
-                    ]}>
-                    <TreeSelect
-                      style={{ width: 300 }}
-                      showSearch={false}
-                      treeData={treeRloe}
-                      onChange={treeChange}
-                      maxTagCount={1}
-                      treeCheckable
-                      showCheckedStrategy={SHOW_PARENT}
-                      placeholder="请选择角色"
-                    />
-                  </Form.Item>
-                  : null}
+                    {index == i ?
+                      <Form.Item key={i + "b"}
+                        name={['softwareVOS', i, 'roles']}
+                        rules={[
+                          {
+                            required: true,
+                            message: '请选择所属角色',
+                          },
+                        ]}>
+                        <TreeSelect
+                          style={{ width: 300 }}
+                          showSearch={false}
+                          treeData={treeRloe}
+                          onChange={treeChange}
+                          maxTagCount={1}
+                          treeCheckable
+                          showCheckedStrategy={SHOW_PARENT}
+                          placeholder="请选择角色"
+                        />
+                      </Form.Item>
+                      : null}
 
-          </Form.Item>
+                  </Form.Item>
                 )
               })
             }
           </Form.Item>
-        <Form.Item
-          name="status"
-          valuePropName="checked"
-          label="当前状态"
-          rules={[{ required: true, message: '请选择状态' }]}
-        >
-          <Switch onChange={swichChange} />
-        </Form.Item>
-        <Form.Item wrapperCol={{ span: 6, offset: 21 }}>
-          <Button className='but' onClick={back}>
-            取消
+          <Form.Item
+            name="status"
+            valuePropName="checked"
+            label="当前状态"
+            rules={[{ required: true, message: '请选择状态' }]}
+          >
+            <Switch onChange={swichChange} />
+          </Form.Item>
+          <Form.Item wrapperCol={{ span: 6, offset: 20 }}>
+            <Button className='but' onClick={goback}>
+              取消
             </Button>
-          <Button type="primary" htmlType="submit">
-            保存
+            <Button type="primary" htmlType="submit">
+              保存
             </Button>
-        </Form.Item>
+          </Form.Item>
         </Form>
-    </div>
+        <Modal
+          title="提示"
+          okText='确定'
+          cancelText='取消'
+          width={400}
+          visible={visible}
+          onOk={handleOk}
+          onCancel={handleCancel}
+        >
+          <p>您还有内容未保存,确定要退出?</p>
+        </Modal>
+      </div>
     </>
   )
 }

+ 0 - 2
src/components/FuncManager/AddFunc.js

@@ -143,14 +143,12 @@ function AddUser(props) {
               message: '请填写功能名称',
             },
           ]}
-          hasFeedback
         >
           <Input placeholder="请填写功能名称" />
         </Form.Item>
         <Form.Item
           name="type"
           label="类型"
-          hasFeedback
           rules={[
             {
               required: true,

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

@@ -1,5 +1,5 @@
 import { useEffect, useState, useContext } from 'react';
-import { Form, Input, Checkbox, Button, Select, Steps, Tabs, InputNumber, Space, Switch, Breadcrumb } from 'antd';
+import { Form, Input, Checkbox, Button, Select, Steps, Tabs, InputNumber, Space, Switch, Breadcrumb, Modal } from 'antd';
 import MenuTree from './MenuTree';
 import './index.less';
 import OrgContext from './org-context';
@@ -12,8 +12,12 @@ const { Step } = Steps;
 const { TabPane } = Tabs;
 const { Option } = Select;
 function AddSubOrg(props) {
+    const [form] = Form.useForm();
     const [current, setCurrent] = useState(0);
-    const { back } = props;
+    const [isChange, setIsChange] = useState(false);
+    const [visible, setVisible] = useState(false);
+    
+    const { back } = props
     const steps = [
         {
             title: '基础信息',
@@ -31,14 +35,29 @@ function AddSubOrg(props) {
 
     const next = () => {
         setCurrent(current + 1);
+        setIsChange(true)
     };
     const pre = () => {
         setCurrent(current - 1);
     };
+    function handleOk(){
+        back()
+    }
+    function handleCancel(){
+        setVisible(false)
+    }
+    const goback = () => { 
+        if (form.getFieldsValue().name != undefined || form.getFieldsValue().type != undefined){
+            setVisible(true)
+        }else{
+            back()
+        }
+    };
+    
     return (
         <>
             <Breadcrumb separator="">
-                <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={back} alt="返回上一页" /></Breadcrumb.Item>
+                <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={goback} alt="返回上一页" /></Breadcrumb.Item>
                 <Breadcrumb.Item>组织管理</Breadcrumb.Item>
                 <Breadcrumb.Separator />
                 <Breadcrumb.Item>新增子组织</Breadcrumb.Item>
@@ -53,22 +72,34 @@ function AddSubOrg(props) {
                     <StepContent current={current}
                         pre={pre}
                         next={next}
+                        form={form}
                     />
                 </div>
+                <Modal
+                    title="提示"
+                    okText='确定'
+                    cancelText='取消'
+                    width={400}
+                    visible={visible}
+                    onOk={handleOk}
+                    onCancel={handleCancel}
+                >
+                    <p>您还有内容未保存,确定要退出?</p>
+                </Modal>
             </div>
         </>
     )
 }
 
 function StepContent(props) {
-    const [form] = Form.useForm();
+    
     const [treeDatas, setTreeDatas] = useState([]);
     const [tabDatas, setTabDatas] = useState([]);
     const [activeTab, setActiveTab] = useState('');
     const [sysCheckeds, setSysCheckeds] = useState([]);
     const [name, setName] = useState('');
     const { type, hisTypeList, save, detail } = useContext(OrgContext);
-    const { current, pre, next } = props;
+    const { current, pre, next, form } = props;
     const initialValues = detail
     const vilidateRules = {
         required: '${label}不能为空!',
@@ -77,7 +108,6 @@ function StepContent(props) {
             number: '${label} is not a valid number!',
         },
     };
-    
     //获取菜单数据
     function getTreeData() {
         xPost(api.getUserMenuResourceTree, { type: 0 }).then((res) => {
@@ -260,13 +290,14 @@ function StepContent(props) {
                     type="password"
                     hidden={current !== 1}
                     name={['addHospitalUserVO', 'password']}
-                    rules={[{ required: true }, ({ getFieldValue }) => ({
-                        validator(_, value) {
-                            if (value.length < 8 || value.length > 12) {
-                                return Promise.reject(new Error('密码长度8-12位'));
-                            }
+                    rules={[
+                        {
+                            required: true,
+                            message: '8-12位大小写字母、数字、特殊字符',
                         },
-                    })]}>
+
+                    ]}
+                    >
                     <Input placeholder='8-12位大小写字母、数字、特殊字符' autoComplete='off' disabled={type == 2 ? true : false} />
                 </Form.Item>
                 <Form.Item
@@ -282,7 +313,7 @@ function StepContent(props) {
                             }
                             return Promise.reject(new Error('两次密码输入不一致!'));
                         },
-                    }),]}>
+                    })]}>
                     <Input placeholder='8-12位大小写字母、数字、特殊字符' autoComplete='off' disabled={type == 2 ? true : false} />
                 </Form.Item>
                 <Form.Item
@@ -310,7 +341,7 @@ function StepContent(props) {
                         {
                             tabDatas.map((it, i) => {
                                 return (
-                                    <TabPane tab={it.title} key={it.title + '-' + it.key} forceRender={type==2?true:false}>
+                                    <TabPane tab={it.title} key={it.title + '-' + it.key} forceRender={type == 2 ? true : false}>
                                         <Form.Item key={i} name={['softwares', i, 'softwareMenuIds']} noStyle>
                                             <MenuTree data={it} checkeds={form.getFieldValue().softwares ? form.getFieldValue().softwares[i] : []} checkEv={(checkedKeys, sourceIds) => checkTreeEvent(i, checkedKeys, sourceIds)} />
                                         </Form.Item>

+ 1 - 0
src/components/OrgManager/index.js

@@ -51,6 +51,7 @@ function OrgManager() {
         3: '确定要禁用该组织?',
         4: '当前组织内可能包含子组织或其相关用户,禁用后所包含信息将一并被禁用',
         5: '确定要重置该组织密码?',
+        6: '您还有内容未保存,确定要退出?',
     };
 
     //获取表格数据

+ 32 - 6
src/components/RoleManager/AddRole.js

@@ -1,5 +1,5 @@
 import {useEffect,useState,useContext} from 'react';
-import { Form, Input, Checkbox, Button, Select,Tabs ,InputNumber,Space,Switch,Breadcrumb  } from 'antd';
+import { Form, Input, Checkbox, Button, Select, Tabs, InputNumber, Space, Switch, Breadcrumb, Modal  } from 'antd';
 import MenuTree  from './MenuTree';
 import './index.less';
 import RoleContext from './role-context';
@@ -11,31 +11,56 @@ const {post,api,xPost} = apiObj;
 const { TabPane } = Tabs;
 const { Option } = Select;
 function AddRole(props){
+    const [form] = Form.useForm();
     const { back } = props;
-
+    const [isChange, setIsChange] = useState(false);
+    const [visible, setVisible] = useState(false);
+    function handleOk() {
+        back()
+    }
+    function handleCancel() {
+        setVisible(false)
+    }
+    const goback = () => {
+        if (form.getFieldsValue().name != undefined || form.getFieldsValue().softwares != undefined) {
+            setVisible(true)
+        } else {
+            back()
+        }
+    };
     return (
         <>
             <Breadcrumb separator="">
-                <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={back} alt="返回上一页"/></Breadcrumb.Item>
+                <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={goback} alt="返回上一页"/></Breadcrumb.Item>
                 <Breadcrumb.Item>角色管理</Breadcrumb.Item>
                 <Breadcrumb.Separator />
                 <Breadcrumb.Item>新增角色</Breadcrumb.Item>
             </Breadcrumb>
             <div className="add-container">
-                <ContentForm back={back}></ContentForm>
+                <ContentForm back={goback} form={form}></ContentForm>
             </div>
+            <Modal
+                title="提示"
+                okText='确定'
+                cancelText='取消'
+                width={400}
+                visible={visible}
+                onOk={handleOk}
+                onCancel={handleCancel}
+            >
+                <p>您还有内容未保存,确定要退出?</p>
+            </Modal>
         </>
     )
 }
 
 function ContentForm(props){
-    const [form] = Form.useForm();
     const [treeDatas, setTreeDatas] = useState([]);
     const [tabDatas, setTabDatas] = useState([]);
     const [activeTab, setActiveTab] = useState('');
     const { save,detail }  = useContext(RoleContext);
     const [sysCheckeds, setSysCheckeds] = useState();
-    const { back } = props;
+    const { back,form } = props;
     const initialValues=detail||{
         status:'1'
     };
@@ -245,6 +270,7 @@ function ContentForm(props){
                 <Button onClick={back}>取消</Button>
             <Button onClick={handleSave} type='primary'>保存</Button>
         </div>
+        
         </>
     )
 }

+ 4 - 6
src/components/SysChoose/index.js

@@ -16,7 +16,7 @@ const { Step } = Steps;
 const {Option} = Select;
 function SysChoose({history}) {
     //const [current, setCurrent] = useState(1);
-    const [sysId, setSysId] = useState('');      //选中的系统id
+    const [sysId, setSysId] = useState(null);      //选中的系统id
     const [sysName, setSysName] = useState('');      //选中的系统名称
     const [subHisId, setSubHisId] = useState('');      //选中的子医院id
     const [showId, setShowId] = useState('');       //要显示子医院列表的医院id
@@ -56,7 +56,7 @@ function SysChoose({history}) {
                 
                 setTimeout(()=>{
                     if (data.jump) {
-                        getIn(software[0].hospitals[0].hospitalId)
+                        getIn(software[0].hospitals[0].hospitalId, software[0].id)
                     }
                 },500)
                 
@@ -66,11 +66,9 @@ function SysChoose({history}) {
         })
     }
     //点击进入
-    function getIn(id){
-        console.log(id);
-        
+    function getIn(id,sysid){
         dispatch(setSys({sysId,sysName,hisId:id}));
-        localStorage.setItem('systemId',sysId);
+        localStorage.setItem('systemId', sysId || sysid);
         localStorage.setItem('hospitalId',id);
         interceptors();
         history.push("/manage");

+ 3 - 3
src/components/UserManager/addUser.js

@@ -62,7 +62,9 @@ function AddUser(props) {
     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'))
+        console.log(data);
+        
+        let arr = JSON.parse(JSON.stringify(data).replace(/name/g, 'title').replace(/id/g, 'value'))
         setTreeRloe(arr)
       }
     })
@@ -233,7 +235,6 @@ function AddUser(props) {
               },
             }),
           ]}
-          hasFeedback
         >
           {type == 3 ?
             <span>{initialValues.password}</span>
@@ -245,7 +246,6 @@ function AddUser(props) {
           name="againpassword"
           label="确认密码"
           dependencies={['password']}
-          hasFeedback
           rules={[
             {
               required: true,

+ 1 - 1
src/utils/index.js

@@ -37,7 +37,7 @@ function organizationData(arr) {
             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'))
+            item.children = JSON.parse(JSON.stringify(item.depts).replace(/deptName/g, 'title').replace(/deptId/g, 'value'))
             return
         }
         if (item.children) {