Commit 1eca8ec0 authored by xiexiuxing's avatar xiexiuxing

🐞 fix: 修改bug

parent 8257523a
...@@ -3,7 +3,6 @@ import { Space } from 'antd'; ...@@ -3,7 +3,6 @@ import { Space } from 'antd';
import { getIntl } from 'umi'; import { getIntl } from 'umi';
const intl = getIntl(); const intl = getIntl();
const CustomStatus = props => { const CustomStatus = props => {
console.log(props);
return ( return (
<> <>
<Space> <Space>
......
...@@ -79,8 +79,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -79,8 +79,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const isHome = location.pathname === '/memberCenter/home' const isHome = location.pathname === '/memberCenter/home'
const handleMenuCollapse = (payload: boolean): void => { const handleMenuCollapse = (payload: boolean): void => {
if(DEFAULT_COLLAPSED_LIST.includes(location.pathname)) { if (DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
return ; return;
} }
setCollapsed(payload) setCollapsed(payload)
if (payload) { if (payload) {
...@@ -139,7 +139,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -139,7 +139,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
}, [currentRouter, collapsed]) }, [currentRouter, collapsed])
useLayoutEffect(() => { useLayoutEffect(() => {
if(DEFAULT_COLLAPSED_LIST.includes(location.pathname)) { if (DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
setCollapsed(true) setCollapsed(true)
} else { } else {
setCollapsed(false); setCollapsed(false);
...@@ -148,11 +148,11 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -148,11 +148,11 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const prolayoutStyle = isHome const prolayoutStyle = isHome
? { ? {
minHeight: '100vh', minHeight: '100vh',
minWidth: '1280px', minWidth: '1280px',
} }
: {} : {}
console.log(currentRouter) // console.log(currentRouter)
return currentRouter?.noLayout ? props.children : ( return currentRouter?.noLayout ? props.children : (
<ProLayout <ProLayout
pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href} pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href}
...@@ -167,7 +167,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => { ...@@ -167,7 +167,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
</Link> </Link>
)} )}
collapsed={collapsed} collapsed={collapsed}
collapsedButtonRender={(flag) => (DEFAULT_COLLAPSED_LIST.includes(location.pathname) ? null : flag ? <MenuUnfoldOutlined /> : <MenuFoldOutlined/>) } collapsedButtonRender={(flag) => (DEFAULT_COLLAPSED_LIST.includes(location.pathname) ? null : flag ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />)}
onCollapse={handleMenuCollapse} onCollapse={handleMenuCollapse}
disableContentMargin={currentRouter?.noMargin !== undefined} disableContentMargin={currentRouter?.noMargin !== undefined}
breadcrumbRender={(routers = []) => [ breadcrumbRender={(routers = []) => [
......
...@@ -28,7 +28,7 @@ import TabTree, { ...@@ -28,7 +28,7 @@ import TabTree, {
useTreeActions, useTreeActions,
createTreeActions, createTreeActions,
} from '@/components/TabTree'; } from '@/components/TabTree';
import { getMemberRoleAuthTree, getMemberOrgTree, postMemberRoleAdd, postMemberRoleUpdate, getMemberRoleGet, getMemberRoleAuthButton, getMemberRoleAuthButtonCheck, } from '@/services/MemberV2Api'; import { getMemberRoleAuthTree, getMemberOrgTree, postMemberRoleAdd, postMemberRoleUpdate, getMemberRoleGet, getMemberRoleAuthButton, getMemberRoleAuthButtonCheck, } from '@/services/MemberV2Api';
import styled from './index.less'; import styled from './index.less';
import CheckboxTree from '@/components/CheckBoxTree'; import CheckboxTree from '@/components/CheckBoxTree';
import { useTreeData } from '@/hooks/useTreeData'; import { useTreeData } from '@/hooks/useTreeData';
...@@ -42,8 +42,9 @@ import FieldHeader from '@/components/FieldHeader'; ...@@ -42,8 +42,9 @@ import FieldHeader from '@/components/FieldHeader';
import OrgModal from './orgModal'; import OrgModal from './orgModal';
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { useTreeTabs } from '@/hooks/useTreeTabs'; import { useTreeTabs } from '@/hooks/useTreeTabs';
import { concat } from 'lodash';
const intl = getIntl(); const intl = getIntl();
const pageTitles = [`${intl.formatMessage({ id: 'authConfig.add'})}`, `${intl.formatMessage({ id: 'authConfig.edit'})}`, `${intl.formatMessage({ id: 'authConfig.previewLook'})}`]; const pageTitles = [`${intl.formatMessage({ id: 'authConfig.add' })}`, `${intl.formatMessage({ id: 'authConfig.edit' })}`, `${intl.formatMessage({ id: 'authConfig.previewLook' })}`];
const TabFormErrors = props => { const TabFormErrors = props => {
return ( return (
...@@ -125,6 +126,9 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -125,6 +126,9 @@ const MemberDetail: React.FC<{}> = () => {
const [buttonInfos, setButtonInfos] = useState<any>([]); const [buttonInfos, setButtonInfos] = useState<any>([]);
// 储存的数据权限选项 // 储存的数据权限选项
const [authInfos, setAuthInfos] = useState<any>({}); const [authInfos, setAuthInfos] = useState<any>({});
// 存储默认勾选的id
const [checkIds, setcheckIds] = useState<any>({});
const modalRef = useRef<any>({}) const modalRef = useRef<any>({})
const disabledCheckAuthConfig = useMemo(() => { const disabledCheckAuthConfig = useMemo(() => {
...@@ -171,12 +175,13 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -171,12 +175,13 @@ const MemberDetail: React.FC<{}> = () => {
); );
const [setEditForm, validateEditForm] = useLeavePage({ const [setEditForm, validateEditForm] = useLeavePage({
onSave: () => {}, onSave: () => { },
onModalOk: () => {}, onModalOk: () => { },
onModalCancel: () => {}, onModalCancel: () => { },
}); });
const handleNodeSelected = async (selectKey, selectNode) => { const handleNodeSelected = async (selectKey, selectNode) => {
// console.log(selectKey, 'selectKey', selectNode, 'selectNode')
try { try {
const { node } = await handleSelect(selectKey, selectNode); const { node } = await handleSelect(selectKey, selectNode);
if (nodeRecord) { if (nodeRecord) {
...@@ -199,7 +204,7 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -199,7 +204,7 @@ const MemberDetail: React.FC<{}> = () => {
setNodeRecord(node); setNodeRecord(node);
fetchItemDetailData(node); fetchItemDetailData(node);
} }
} catch (error) {} } catch (error) { }
}; };
// 编辑和预览模式下需回显数据 // 编辑和预览模式下需回显数据
...@@ -233,6 +238,8 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -233,6 +238,8 @@ const MemberDetail: React.FC<{}> = () => {
} }
}, [getButtonAuth, nodeRecord]); }, [getButtonAuth, nodeRecord]);
// 提交
const handleSubmit = () => { const handleSubmit = () => {
menuActions menuActions
.submit() .submit()
...@@ -241,19 +248,61 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -241,19 +248,61 @@ const MemberDetail: React.FC<{}> = () => {
// 如果未点击过操作权限tab, 则无法获取到actionRef实例, 需补充手动补充回显的ids, 新增的时候如果未设置按钮,则返回空数组 // 如果未点击过操作权限tab, 则无法获取到actionRef实例, 需补充手动补充回显的ids, 新增的时候如果未设置按钮,则返回空数组
const buttonCheckIds = const buttonCheckIds =
actionRef.current.selected || (formValue && formValue.ids) || []; actionRef.current.selected || (formValue && formValue.ids) || [];
// 获取选中的树状 id
const treeCheckIds = treeActions.getSelectKeys(); const treeCheckIds = treeActions.getSelectKeys();
// 把后台返回的数据处理成一个数组
const cheIds = [];
for (let i in checkIds) {
cheIds.push(checkIds[i]);
}
// 1 获取勾选中的id 和 后台返回勾选的id 进行对比
const publicarr = [];
// 判断选中的数组是否存在 后台返回的数据里面
for (let i = 0; i < treeCheckIds.length; i++) {
if (cheIds.indexOf(treeCheckIds[i]) === -1) {
publicarr.push({
menuId: treeCheckIds[i],
checked: true
})
}
}
// 根据后台返回的勾选中 进去匹配
const CheckIds = [];
for (let i in checkIds) {
if (treeCheckIds.indexOf(checkIds[i]))
CheckIds.push({
menuId: checkIds[i],
checked: treeCheckIds.includes(checkIds[i])
})
}
// 把两个数组合并成一个数组
let list = []
list = CheckIds.concat(publicarr)
const publicParams = { const publicParams = {
...values, ...values,
imFlag: !!values.imFlag, imFlag: !!values.imFlag,
auth: treeCheckIds.map(v => ({ checked: treeCheckIds,
menuId: v, auth: list.map(v => ({
menuId: v.menuId,
// @todo 暂时写死为空 // @todo 暂时写死为空
buttonIds: [], buttonIds: [],
hasDataAuth: authInfos[v]?.hasDataAuth, checked: v.checked,
orgIds: authInfos[v]?.orgIds hasDataAuth: authInfos[v.menuId]?.hasDataAuth,
})), orgIds: authInfos[v.menuId]?.orgIds
}))
// auth: treeCheckIds.map(v => ({
// menuId: v,
// // @todo 暂时写死为空
// buttonIds: [],
// checked: true,
// hasDataAuth: authInfos[v]?.hasDataAuth,
// orgIds: authInfos[v]?.orgIds
// })),
}; };
delete publicParams.checkIds
console.log(publicParams, '请求参数', treeCheckIds)
// return;
if (pageStatus === PageStatus.EDIT) { if (pageStatus === PageStatus.EDIT) {
await postMemberRoleUpdate({ await postMemberRoleUpdate({
memberRoleId: id, memberRoleId: id,
...@@ -280,6 +329,7 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -280,6 +329,7 @@ const MemberDetail: React.FC<{}> = () => {
const { data } = res; const { data } = res;
// 获取菜单id选中的集合 // 获取菜单id选中的集合
const { checkIds, ...reset } = data; const { checkIds, ...reset } = data;
setcheckIds({ ...checkIds })
treeActions.setSelectKeys(checkIds); treeActions.setSelectKeys(checkIds);
}); });
} }
...@@ -424,8 +474,8 @@ const MemberDetail: React.FC<{}> = () => { ...@@ -424,8 +474,8 @@ const MemberDetail: React.FC<{}> = () => {
> >
{intl.formatMessage({ id: 'authConfig.ifHasDataAccess' })} {intl.formatMessage({ id: 'authConfig.ifHasDataAccess' })}
</Checkbox> </Checkbox>
<div style={{marginTop: 16}}> <div style={{ marginTop: 16 }}>
<p style={{color: '#909399'}}>{intl.formatMessage({ id: 'authConfig.OrganizationAuthorization' })}</p> <p style={{ color: '#909399' }}>{intl.formatMessage({ id: 'authConfig.OrganizationAuthorization' })}</p>
{disabledCheckAuthConfig.orgIds.map(v => { {disabledCheckAuthConfig.orgIds.map(v => {
const node = getTreeNode(plateformTreeData, v); const node = getTreeNode(plateformTreeData, v);
if (!node || !node.id) return null; if (!node || !node.id) return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment