|
@@ -6,19 +6,21 @@ import SelectedTag from '@common/SelectedTag.js';
|
|
|
import MyDeptStruct from '@common/MyDeptStruct.js';
|
|
|
import { useSelector } from 'react-redux'
|
|
|
import apiObj from '@api/index';
|
|
|
+import utils from '@utils/index';
|
|
|
import backIcon from "@images/back.png";
|
|
|
import DoctorList from "./doctorList"
|
|
|
const { api, xPost } = apiObj;
|
|
|
+const {filterIds }=utils;
|
|
|
const { SHOW_PARENT } = TreeSelect;
|
|
|
const { TabPane } = Tabs;
|
|
|
function AddData(props) {
|
|
|
useEffect(() => {
|
|
|
- getOrgList()
|
|
|
- if (type == 3) {
|
|
|
- setValue(val)
|
|
|
+ getOrgList();
|
|
|
+ if (isEdit) {
|
|
|
+ setEditData();
|
|
|
}
|
|
|
}, []);
|
|
|
- const { back, } = props;
|
|
|
+ const { back } = props;
|
|
|
const [form] = Form.useForm();
|
|
|
const [isChange, setIsChange] = useState(false);
|
|
|
const [visible, setVisible] = useState(false);
|
|
@@ -33,15 +35,17 @@ function AddData(props) {
|
|
|
const [value, setValue] = useState([]);
|
|
|
const [tabKey, setTabKey] = useState(); //权限范围选中的tab id
|
|
|
const [tabIndex, setTabIndex] = useState('0'); //权限范围选中的tab index
|
|
|
- const [treeRloe, setTreeRloe] = useState([]);
|
|
|
+ const [showCustom,setShowCustom]=useState(false); //是否显示自定义内容
|
|
|
+ const [treeRloe, setTreeRloe] = useState([]);
|
|
|
const [tags, setTags] = useState([[]]);
|
|
|
const [orgList, setOrgList] = useState([]);
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
- const { save, formData, type, val, tag } = useContext(DataContext);
|
|
|
+ const { save, formData, operType, val, tag,authChecksArr } = useContext(DataContext);
|
|
|
+ const isEdit = operType===3; //是否为编辑
|
|
|
const staticInfo = useSelector(state => {
|
|
|
return state.staticInfo;
|
|
|
});
|
|
|
- const { dataList } = staticInfo;
|
|
|
+ const { dataList } = staticInfo;console.log('formData:',formData)
|
|
|
const initialValues = formData
|
|
|
const validateMessages = {
|
|
|
required: '${label}不能为空',
|
|
@@ -53,12 +57,33 @@ function AddData(props) {
|
|
|
setVisible(false)
|
|
|
}
|
|
|
const goback = () => {
|
|
|
- if ((form.getFieldsValue().name != undefined || isChange) && type != 3) {
|
|
|
+ if ((form.getFieldsValue().name != undefined || isChange) && !isEdit) {
|
|
|
setVisible(true)
|
|
|
} else {
|
|
|
back()
|
|
|
}
|
|
|
};
|
|
|
+ //编辑数据填充
|
|
|
+ function setEditData(){
|
|
|
+ const data = authChecksArr[tabIndex]||{};
|
|
|
+ const sysObj = form.getFieldValue().softwareVOS[tabIndex]||{};
|
|
|
+ const dataType = sysObj.dataType;
|
|
|
+ const isCustom = dataType === '7';console.log(form.getFieldValue(),dataType,isCustom)
|
|
|
+ //判断权限范围类型,是否显示自定义内容
|
|
|
+ setShowCustom(isCustom);
|
|
|
+ if(!isCustom||!data){ //非自定义不处理
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const depts = data.depts||[];
|
|
|
+ const doctors = data.doctors||[];
|
|
|
+ const hospitals = data.hospitals||[];
|
|
|
+ setCheckedUser(doctors);
|
|
|
+ setCheckedUserIds(filterIds(doctors,'name'));
|
|
|
+ setCheckedHosIds(filterIds(hospitals,'name'));
|
|
|
+ //setHosArr(hospitals||[]);
|
|
|
+ setCheckedDepts([...hospitals,...depts]);
|
|
|
+ setCheckedDeptIds(filterIds((hospitals).concat(depts)));
|
|
|
+ }
|
|
|
//获取当前用于所属角色
|
|
|
function getCreateRoles(softwareId) {
|
|
|
const params = {
|
|
@@ -82,7 +107,7 @@ function AddData(props) {
|
|
|
setOrgList(software);
|
|
|
setTabKey(software[0].id)
|
|
|
getCreateRoles(software[0].id)
|
|
|
- if (type == 3) {
|
|
|
+ if (isEdit) {
|
|
|
software.forEach((it, index) => {
|
|
|
tag.forEach((item, i) => {
|
|
|
tags[index] = []
|
|
@@ -114,7 +139,7 @@ function AddData(props) {
|
|
|
arr[tabIndex].softwareMenuIds = []
|
|
|
arr[tabIndex].dataAuthDetails = []
|
|
|
arr[tabIndex].selectedRowKeys = []
|
|
|
- if (e.target.value != 7) {
|
|
|
+ if (e.target.value !== '7') {
|
|
|
arr[tabIndex].dataAuthDetails = [{
|
|
|
dataType: e.target.value
|
|
|
}]
|
|
@@ -132,9 +157,16 @@ function AddData(props) {
|
|
|
};
|
|
|
|
|
|
function callback(key) {
|
|
|
- setTabKey(key.split('-')[0])
|
|
|
- setTabIndex(key.split('-')[1])
|
|
|
- getCreateRoles(key.split('-')[0])
|
|
|
+ const ikey = key.split('-');
|
|
|
+ setTabKey(ikey[0])
|
|
|
+ setTabIndex(ikey[1])
|
|
|
+ const soft = form.getFieldValue().softwareVOS[ikey[1]];
|
|
|
+ if(soft){
|
|
|
+ setShowCustom(soft.dataType === '7');
|
|
|
+ }else{
|
|
|
+ setShowCustom(false);
|
|
|
+ }
|
|
|
+ getCreateRoles(ikey[0])
|
|
|
}
|
|
|
function treeChange(value) {
|
|
|
const formData = form.getFieldsValue();
|
|
@@ -167,7 +199,7 @@ function AddData(props) {
|
|
|
selectedRowKeys.forEach(it => {
|
|
|
arr.push({
|
|
|
id: it.split('-')[0],
|
|
|
- dataType: 7,
|
|
|
+ dataType: '7',
|
|
|
detailId: it.split('-')[0],
|
|
|
detailType: 3,
|
|
|
name: it.split('-')[1],
|
|
@@ -217,7 +249,7 @@ function AddData(props) {
|
|
|
if(it.pos==='0-0'){ //全选了平台,终止遍历
|
|
|
temp = tempKey.split("-");
|
|
|
//hosArr.push({key:tempKey});
|
|
|
- paramHos.push({id:temp[0],detailId:temp[0],detailType:1,name:temp[1],dataType:7,key:tempKey});
|
|
|
+ paramHos.push({id:temp[0],detailId:temp[0],detailType:1,name:temp[1],dataType:'7',key:tempKey});
|
|
|
hosIds.push(temp[0]);
|
|
|
setCheckedTreeItems([tempKey]);
|
|
|
return {hosIds:hosIds,deptIds:deptIds,deptObj:deptArr};
|
|
@@ -233,11 +265,11 @@ function AddData(props) {
|
|
|
//医院id存入sendHospitals,科室id存入sendDepts
|
|
|
if(len===2){
|
|
|
//hosArr.push({key:tempKey});
|
|
|
- paramHos.push({id:temp[0],detailId:temp[0],name:temp[1],detailType:1,dataType:7,key:tempKey});
|
|
|
+ paramHos.push({id:temp[0],detailId:temp[0],name:temp[1],detailType:1,dataType:'7',key:tempKey});
|
|
|
hosIds.push(temp[0]);
|
|
|
}else{
|
|
|
//deptArr.push({key:tempKey});
|
|
|
- paramDept.push({id:temp[2],detailId:temp[2],detailType:2,name:temp[1]+"-"+temp[3],dataType:7,key:tempKey});
|
|
|
+ paramDept.push({id:temp[2],detailId:temp[2],detailType:2,name:temp[1]+"-"+temp[3],dataType:'7',key:tempKey});
|
|
|
deptIds.push(temp[2]);
|
|
|
}
|
|
|
|
|
@@ -303,14 +335,13 @@ function AddData(props) {
|
|
|
function swichChange(val) {
|
|
|
form.setFieldsValue({ status: val ? 1 : 0 })
|
|
|
}
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
<Breadcrumb separator="">
|
|
|
<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>
|
|
|
+ <Breadcrumb.Item>{isEdit ? '修改' : '新增'}数据权限</Breadcrumb.Item>
|
|
|
</Breadcrumb>
|
|
|
<div className='form-center'>
|
|
|
<Form labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} form={form} name="nest-messages" onFinish={onFinish} initialValues={initialValues} validateMessages={validateMessages}>
|
|
@@ -322,7 +353,7 @@ function AddData(props) {
|
|
|
{
|
|
|
orgList.map((it, i) => {
|
|
|
return (
|
|
|
- <TabPane tab={it.name} key={it.id + "-" + i} forceRender={type == 3 && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
+ <TabPane tab={it.name} key={it.id + "-" + i} forceRender={isEdit && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
<Form.Item
|
|
|
key={i}
|
|
|
name={['softwareVOS', i, 'dataType']} noStyle>
|
|
@@ -346,26 +377,19 @@ function AddData(props) {
|
|
|
<Form.Item key={i + "e"} hidden={true} name={['softwareVOS', i, 'roles']} noStyle>
|
|
|
<Input />
|
|
|
</Form.Item>
|
|
|
- <Form.Item key={i + "c"} style={{ display: value[tabIndex] == 7 && it.id == tabKey ? 'block' : 'none' }}>
|
|
|
- {/*<Card title="已选中" extra={<span onClick={delAll} className='del-all'><img className='del-icon' src={del} />清空所有</span>} >
|
|
|
- {tags[index].map((tag, i) => {
|
|
|
- return (
|
|
|
- <Tag key={i} closable onClose={e => delTag(tag.type, tag.id, i)}>{tag.name}</Tag>
|
|
|
- );
|
|
|
- })}
|
|
|
- </Card>*/}
|
|
|
+ <Form.Item key={i + "c"} style={{ display: showCustom && it.id == tabKey ? 'block' : 'none' }}>
|
|
|
<SelectedTag userData={checkedUser} deptData={checkedDepts} delTag={handleTagDel}></SelectedTag>
|
|
|
</Form.Item>
|
|
|
- <Form.Item key={i + "d"} style={{ display: value[tabIndex] == 7 && it.id == tabKey ? 'block' : 'none' }}>
|
|
|
+ <Form.Item key={i + "d"} style={{ display: showCustom && it.id == tabKey ? 'block' : 'none' }}>
|
|
|
<Tabs defaultActiveKey="0" className='tab-content'>
|
|
|
- <TabPane tab="可看医生" key="0" forceRender={type == 3 && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
+ <TabPane tab="可看医生" key="0" forceRender={isEdit && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
<Form.Item
|
|
|
name={['softwareVOS', i, 'selectedRowKeys']}
|
|
|
>
|
|
|
<DoctorList checkeds={checkedUserIds} checkDoct={(selectedRowKeys) => checkDoctEvent(selectedRowKeys)} />
|
|
|
</Form.Item>
|
|
|
</TabPane>
|
|
|
- <TabPane tab="可看科室" key="1" forceRender={type == 3 && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
+ <TabPane tab="可看科室" key="1" forceRender={isEdit && form.getFieldValue().softwareVOS[i] ? true : false}>
|
|
|
<Form.Item
|
|
|
name={['softwareVOS', i, 'softwareMenuIds']}
|
|
|
>
|
|
@@ -380,7 +404,7 @@ function AddData(props) {
|
|
|
}
|
|
|
</Tabs>
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="所属角色" required >
|
|
|
+ <Form.Item label="所属角色" style={{marginLeft: '123px'}} required>
|
|
|
{
|
|
|
orgList.map((it, i) => {
|
|
|
return (
|