Commit 1eca8ec0 authored by xiexiuxing's avatar xiexiuxing

🐞 fix: 修改bug

parent 8257523a
......@@ -3,7 +3,6 @@ import { Space } from 'antd';
import { getIntl } from 'umi';
const intl = getIntl();
const CustomStatus = props => {
console.log(props);
return (
<>
<Space>
......
......@@ -79,8 +79,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const isHome = location.pathname === '/memberCenter/home'
const handleMenuCollapse = (payload: boolean): void => {
if(DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
return ;
if (DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
return;
}
setCollapsed(payload)
if (payload) {
......@@ -139,7 +139,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
}, [currentRouter, collapsed])
useLayoutEffect(() => {
if(DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
if (DEFAULT_COLLAPSED_LIST.includes(location.pathname)) {
setCollapsed(true)
} else {
setCollapsed(false);
......@@ -148,11 +148,11 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const prolayoutStyle = isHome
? {
minHeight: '100vh',
minWidth: '1280px',
}
minHeight: '100vh',
minWidth: '1280px',
}
: {}
console.log(currentRouter)
// console.log(currentRouter)
return currentRouter?.noLayout ? props.children : (
<ProLayout
pageTitleRender={() => currentRouter ? currentRouter.name : window.location.href}
......@@ -167,7 +167,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
</Link>
)}
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}
disableContentMargin={currentRouter?.noMargin !== undefined}
breadcrumbRender={(routers = []) => [
......
......@@ -28,7 +28,7 @@ import TabTree, {
useTreeActions,
createTreeActions,
} 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 CheckboxTree from '@/components/CheckBoxTree';
import { useTreeData } from '@/hooks/useTreeData';
......@@ -42,8 +42,9 @@ import FieldHeader from '@/components/FieldHeader';
import OrgModal from './orgModal';
import { PlusOutlined } from '@ant-design/icons';
import { useTreeTabs } from '@/hooks/useTreeTabs';
import { concat } from 'lodash';
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 => {
return (
......@@ -125,6 +126,9 @@ const MemberDetail: React.FC<{}> = () => {
const [buttonInfos, setButtonInfos] = useState<any>([]);
// 储存的数据权限选项
const [authInfos, setAuthInfos] = useState<any>({});
// 存储默认勾选的id
const [checkIds, setcheckIds] = useState<any>({});
const modalRef = useRef<any>({})
const disabledCheckAuthConfig = useMemo(() => {
......@@ -171,12 +175,13 @@ const MemberDetail: React.FC<{}> = () => {
);
const [setEditForm, validateEditForm] = useLeavePage({
onSave: () => {},
onModalOk: () => {},
onModalCancel: () => {},
onSave: () => { },
onModalOk: () => { },
onModalCancel: () => { },
});
const handleNodeSelected = async (selectKey, selectNode) => {
// console.log(selectKey, 'selectKey', selectNode, 'selectNode')
try {
const { node } = await handleSelect(selectKey, selectNode);
if (nodeRecord) {
......@@ -199,7 +204,7 @@ const MemberDetail: React.FC<{}> = () => {
setNodeRecord(node);
fetchItemDetailData(node);
}
} catch (error) {}
} catch (error) { }
};
// 编辑和预览模式下需回显数据
......@@ -233,6 +238,8 @@ const MemberDetail: React.FC<{}> = () => {
}
}, [getButtonAuth, nodeRecord]);
// 提交
const handleSubmit = () => {
menuActions
.submit()
......@@ -241,19 +248,61 @@ const MemberDetail: React.FC<{}> = () => {
// 如果未点击过操作权限tab, 则无法获取到actionRef实例, 需补充手动补充回显的ids, 新增的时候如果未设置按钮,则返回空数组
const buttonCheckIds =
actionRef.current.selected || (formValue && formValue.ids) || [];
// 获取选中的树状 id
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 = {
...values,
imFlag: !!values.imFlag,
auth: treeCheckIds.map(v => ({
menuId: v,
checked: treeCheckIds,
auth: list.map(v => ({
menuId: v.menuId,
// @todo 暂时写死为空
buttonIds: [],
hasDataAuth: authInfos[v]?.hasDataAuth,
orgIds: authInfos[v]?.orgIds
})),
checked: v.checked,
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) {
await postMemberRoleUpdate({
memberRoleId: id,
......@@ -280,6 +329,7 @@ const MemberDetail: React.FC<{}> = () => {
const { data } = res;
// 获取菜单id选中的集合
const { checkIds, ...reset } = data;
setcheckIds({ ...checkIds })
treeActions.setSelectKeys(checkIds);
});
}
......@@ -424,8 +474,8 @@ const MemberDetail: React.FC<{}> = () => {
>
{intl.formatMessage({ id: 'authConfig.ifHasDataAccess' })}
</Checkbox>
<div style={{marginTop: 16}}>
<p style={{color: '#909399'}}>{intl.formatMessage({ id: 'authConfig.OrganizationAuthorization' })}</p>
<div style={{ marginTop: 16 }}>
<p style={{ color: '#909399' }}>{intl.formatMessage({ id: 'authConfig.OrganizationAuthorization' })}</p>
{disabledCheckAuthConfig.orgIds.map(v => {
const node = getTreeNode(plateformTreeData, v);
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