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