|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2022-01-13 15:22:48
|
|
|
- * @LastEditTime: 2023-03-22 14:00:06
|
|
|
+ * @LastEditTime: 2023-03-23 15:55:50
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/hospManage/index.tsx
|
|
@@ -22,7 +22,7 @@ import { KCInput } from '@/components/KCInput';
|
|
|
import { createFromIconfontCN, DownOutlined } from '@ant-design/icons';
|
|
|
import { DrawerForm } from '@ant-design/pro-form';
|
|
|
import { DataNode } from 'antd/es/tree';
|
|
|
-
|
|
|
+import { getTreeData, getTreeDataRespType } from '../systemNavMana/service';
|
|
|
|
|
|
import expandedIcon from '../../../../../public/images/treenode_open.png';
|
|
|
import closeIcon from '../../../../../public/images/treenode_collapse.png';
|
|
@@ -170,7 +170,9 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
|
const [drawerTableDataFilterParams, set_drawerTableDataFilterParams] = useState<any | undefined>();
|
|
|
|
|
|
- const [checkBoxCodes, set_checkBoxCodes] = useState<any[]>([]);
|
|
|
+ const [checkBoxCodes, set_checkBoxCodes] = useState<any[]>([]); //勾选的菜单
|
|
|
+
|
|
|
+ const [needCancelCheckedMenus, set_needCancelCheckedMenus] = useState<any[]>([]);
|
|
|
|
|
|
|
|
|
const [drawerTableDataSearchKeywords, set_drawerTableDataSearchKeywords] = useState<string>('');
|
|
@@ -397,10 +399,24 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
}
|
|
|
|
|
|
const saveResult = async () => {
|
|
|
- const result = checkBoxCodes.map((item: any) => ({ ...item, hospId: record.id }))
|
|
|
- const resp = await saveHospMenuApiPerm(result);
|
|
|
+
|
|
|
+ const needCancelMenus = needCancelCheckedMenus.map(a => ({ hospId: record.id, systemId: currentSelectedTreeNode.code, function: [], menuId: a }))
|
|
|
+ const result = checkBoxCodes.map((item: any) => ({ ...item, hospId: record.id,systemId: currentSelectedTreeNode.code }));
|
|
|
+
|
|
|
+ const data = [...result, ...needCancelMenus];
|
|
|
+
|
|
|
+ function uniqueFunc(arr:any[], uniId:string){
|
|
|
+ const res = new Map();
|
|
|
+ return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ const resp = await saveHospMenuApiPerm(result.length == 0 ? [{ hospId: record.id, systemId: currentSelectedTreeNode.code }] :uniqueFunc(data,'menuId') );
|
|
|
+
|
|
|
if (resp) {
|
|
|
set_drawerTablereload(true);
|
|
|
+ set_checkBoxCodes([]);
|
|
|
+ set_checkedTableMenuIds([]);
|
|
|
+ set_needCancelCheckedMenus([]);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -419,17 +435,17 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
}
|
|
|
|
|
|
|
|
|
- const oneKeySetReadOnly = (bool:boolean)=>{
|
|
|
-
|
|
|
- if(bool){
|
|
|
- const _temp = checkBoxCodes.map((item:any)=>{
|
|
|
- const needed = item.function.filter((a:any)=>a.code == 'search');
|
|
|
- return {...item,function:needed}
|
|
|
- })
|
|
|
- set_checkBoxCodes([..._temp]);
|
|
|
- }
|
|
|
+ // const oneKeySetReadOnly = (bool: boolean) => {
|
|
|
|
|
|
- }
|
|
|
+ // if (bool) {
|
|
|
+ // const _temp = checkBoxCodes.map((item: any) => {
|
|
|
+ // const needed = item.function.filter((a: any) => a.code == 'search');
|
|
|
+ // return { ...item, function: needed }
|
|
|
+ // })
|
|
|
+ // set_checkBoxCodes([..._temp]);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -440,6 +456,7 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
//切换系统清空数据
|
|
|
set_checkBoxCodes([]);
|
|
|
set_checkedTableMenuIds([]);
|
|
|
+ set_needCancelCheckedMenus([]);
|
|
|
|
|
|
}, [currentSelectedTreeNode]);
|
|
|
|
|
@@ -580,7 +597,7 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
</div>
|
|
|
|
|
|
<div className={'btnGroup'}>
|
|
|
- {/* <a style={{color: '#17181A'}}><Switch style={{position:'relative',marginRight:4}} size='small' onChange={(bool)=>oneKeySetReadOnly(bool)} />只读</a> */}
|
|
|
+ {/* <a style={{color: '#17181A'}}><Switch style={{position:'relative',marginRight:4}} size='small' onChange={(bool)=>oneKeySetReadOnly(bool)} />只读</a> */}
|
|
|
{/* <UpDataActBtn key={'act'} record={undefined} type='ADD' /> */}
|
|
|
</div>
|
|
|
|
|
@@ -604,6 +621,7 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
onSelect: (record, selected, selectedRows, nativeEvent) => {
|
|
|
//console.log({ record, selected, selectedRows, nativeEvent });
|
|
|
let checkedData = checkBoxCodes;
|
|
|
+ let needCancel = needCancelCheckedMenus;
|
|
|
if (selected) {
|
|
|
//选中
|
|
|
selectedRows.forEach(a => {
|
|
@@ -611,8 +629,9 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
checkedData.push({
|
|
|
menuId: a.menuId,
|
|
|
function: a.functionList
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
+ needCancel.splice(needCancel.findIndex(id => id == a.menuId), 1);
|
|
|
});
|
|
|
//更新表格row选中状态
|
|
|
if (record.type == 0) {
|
|
@@ -626,11 +645,13 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
+ let needCancelCheckedRow = []; //需要取消勾选的表格行
|
|
|
if (record.type == 0) {
|
|
|
//目录
|
|
|
if (record.children) {
|
|
|
record.children.forEach((element: any) => {
|
|
|
const index = checkedData.findIndex((item) => item.menuId == record.menuId);
|
|
|
+ needCancelCheckedRow.push(record.menuId);
|
|
|
checkedData.splice(index, 1);
|
|
|
});
|
|
|
}
|
|
@@ -641,17 +662,20 @@ const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
|
|
|
|
|
|
} else if (record.type == 1) {
|
|
|
//菜单
|
|
|
+ needCancelCheckedRow.push(record.menuId);
|
|
|
const temp = checkedTableMenuIds;
|
|
|
const index = checkedData.findIndex((item) => item.menuId == record.menuId);
|
|
|
const menuIdIndex = checkedTableMenuIds.findIndex((item) => item == record.menuId);
|
|
|
checkedData.splice(index, 1);
|
|
|
temp.splice(menuIdIndex, 1);
|
|
|
set_checkedTableMenuIds([...temp]);
|
|
|
+
|
|
|
+ set_needCancelCheckedMenus([...needCancelCheckedMenus, ...needCancelCheckedRow]);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//console.log({ checkedData });
|
|
|
-
|
|
|
set_checkBoxCodes([...checkedData]);
|
|
|
}
|
|
|
}}
|