Commit 78c7a4d8 authored by 前端-许佳敏's avatar 前端-许佳敏

feat:会员角色权限

parent 4ba1438a
export default {
'/api': {
'target': 'http://10.0.0.25:8100/',
'target': process.env.BACK_GATEWAY || 'http://10.0.0.25:8100/',
'changeOrigin': true,
'pathRewrite': { '^/api' : '' },
}
......
......@@ -54,6 +54,7 @@ const router = {
name: 'memberAuthManage',
component: '@/pages/ruleSettingManage/memberAuthManage',
},
// 设置会员角色
{
path: '/ruleSettingManager/memberAuthManage/detail',
name: 'memberAuthManageDetail',
......@@ -61,6 +62,14 @@ const router = {
hideInMenu: true,
hidePageHeader: true
},
// 查看会员角色
{
path: '/ruleSettingManager/memberAuthManage/preview',
name: 'memberAuthManageDetail',
component: '@/pages/ruleSettingManage/memberAuthManage/detail',
hideInMenu: true,
hidePageHeader: true
}
]
}
export default router
\ No newline at end of file
......@@ -84,8 +84,6 @@ export function render(oldRender:Function) {
* @param {*} { routes, matchedRoutes, location, action }
*/
export function onRouteChange({ routes, matchedRoutes, location, action }) {
console.log('onRouteChange')
if (isDev) {
console.log('dev')
return;
......
......@@ -104,8 +104,8 @@ export enum LAYOUT_TYPE {
}
// 本地环境跳过权限校验
// export const isDev = process.env.NODE_ENV === "development"
export const isDev = true
export const isDev = process.env.NODE_ENV === "development"
// export const isDev = false
export const STATUS_ENUM = [
{
......
......@@ -49,7 +49,7 @@ export interface ShopInfo {
type: number;
environment: number;
logoUrl: string;
describe?: any;
describe: string;
state: number;
url: string;
}
......
......@@ -24,11 +24,13 @@ export interface useTreeTabOptions {
// 右侧表单的实例操作方法
formActions?: ISchemaFormActions
// 删除菜单时调用的API
deleteMenu?: any
deleteMenu?: any,
menuDataKey?: string
}
export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const { selectCallback, fetchMenuData, fetchItemDetailData, resetDetail, treeActions, formActions, extendsToolsRender, deleteMenu } = options
const { selectCallback, fetchMenuData, fetchItemDetailData, resetDetail, treeActions, formActions, extendsToolsRender, deleteMenu, menuDataKey } = options
const [ treeExtraMaps, { set, get } ] = useMap<any, any>()
const [ treeData, setTreeData ] = useState<any[]>([])
const [ treeStatus, setTreeStatus ] = useState<FormState>(FormState.FREE)
......@@ -42,7 +44,7 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const resetMenu = async () => {
if (fetchMenuData) {
const res = await fetchMenuData()
setTreeData(res.data || [])
setTreeData(menuDataKey ? res.data[menuDataKey] : res.data || [])
}
}
......@@ -137,6 +139,8 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
...extendsToolsRender
}
return {
handleSelect,
treeStatus,
......
......@@ -11,7 +11,7 @@ import { MEMBER_ROLE_MAPS, MEMBER_TYPE_MAPS } from '@/constants';
import {history} from 'umi'
const fetchMenuData = async () => {
const res = await PublicApi.getMemberRoleAuthTree()
const res = await PublicApi.getMemberPlatformRoleAuthTree()
return res
}
......@@ -24,10 +24,25 @@ const SetMemberAuth: React.FC<{}> = () => {
} = usePageStatus()
const getMenuSelectData = async () => {
const res = await PublicApi.getMemberRoleAuthTreeCheck({memberRoleId: id})
const res = await PublicApi.getMemberPlatformRoleAuthTreeCheck({roleId: id})
return {
data: {
ids: res.data.checkIds
}
}
}
// 编辑和预览模式下需回显数据
const fetchRoleDetail = async () => {
// 10秒缓存
const res = await PublicApi.getMemberPlatformRoleAuthTree({roleId: id}, { useCache: true, ttl: 10 * 1000 })
return res
}
const fetchItemDetailData = async ({ id: menuId }) => {
return await PublicApi.getMemberPlatformRoleAuthButton({ roleId: id, menuId })
}
const {
treeData,
handleSelect,
......@@ -36,26 +51,20 @@ const SetMemberAuth: React.FC<{}> = () => {
setIsEditForm,
isEditForm
} = useTreeTabs({
fetchMenuData,
fetchItemDetailData: PublicApi.getMemberRoleAuthButton
fetchMenuData: fetchRoleDetail,
menuDataKey: 'auth',
fetchItemDetailData
})
const actionRef = useRef<any>({})
const formInitValue = nodeRecord ? getTreeMaps(nodeRecord.key) : null
const [formValue, setFormValue] = useState<any>(null)
// 编辑和预览模式下需回显数据
const fetchRoleDetail = async (id) => {
// 10秒缓存
const res = await PublicApi.getMemberRoleGet({memberRoleId: id}, { useCache: true, ttl: 10 * 1000 })
return res
}
// 储存的按钮数据
const [buttonInfos, setButtonInfos] = useState<any>([])
useEffect(() => {
if (!id) return ;
fetchRoleDetail(id).then(res => {
fetchRoleDetail().then(res => {
const { data } = res
setFormValue(data)
})
......@@ -63,18 +72,8 @@ const SetMemberAuth: React.FC<{}> = () => {
useEffect(() => {
if (formInitValue) {
// 显示右侧checkbox
setButtonInfos(formInitValue.buttons || [])
// 回显右侧checkbox的值
if (actionRef.current.setSelected) {
PublicApi.getMemberRoleAuthButtonCheck({
memberRoleId: id,
menuId: formInitValue.id
}).then(res => {
const { data } = res
actionRef.current.setSelected(data.checkIds)
})
}
actionRef.current.setSelected(formInitValue.checkIds)
}
}, [getTreeMaps])
......@@ -84,17 +83,16 @@ const SetMemberAuth: React.FC<{}> = () => {
// 右侧有编辑过,则需要调按钮提交接口
await PublicApi.postMemberRoleUpdate({
await PublicApi.postMemberPlatformRoleAuthUpdate({
menuIds: menuIds,
memberRoleId: id,
roleName: ''
roleId: id,
}, {
ctlType: isEditForm ? 'none' : 'message'
})
if (isEditForm) {
await PublicApi.postMemberRoleButtonUpsert({
await PublicApi.postMemberPlatformRoleButtonUpdate({
buttonIds: buttonIds,
memberRoleId: id,
roleId: id,
menuId: nodeRecord.id
})
}
......@@ -111,14 +109,14 @@ const SetMemberAuth: React.FC<{}> = () => {
<div>
<Row align='middle'>
<Col style={{marginRight: 24}}><ArrowLeftOutlined onClick={() => history.goBack()}/></Col>
<Col style={{marginRight: 24}} className={selfStyle.titleAvator}>{MEMBER_ROLE_MAPS[formValue.roleType][0]}</Col>
<div className={selfStyle.fontBold18}>{MEMBER_ROLE_MAPS[formValue.roleType]}</div>
<Col style={{marginRight: 24}} className={selfStyle.titleAvator}>{formValue.roleTypeName[0]}</Col>
<div className={selfStyle.fontBold18}>{formValue.roleTypeName}</div>
</Row>
</div>
<div>
<Row style={{marginTop: 24, fontSize: 12}}>
<Col span={10} offset={2}>会员类型:{MEMBER_TYPE_MAPS[formValue.memberType]}</Col>
<Col>会员角色:{formValue.name}</Col>
<Col span={10} offset={2}>会员类型:{formValue.memberTypeName}</Col>
<Col>会员角色:{formValue.roleName}</Col>
</Row>
</div>
</div>
......@@ -137,7 +135,7 @@ const SetMemberAuth: React.FC<{}> = () => {
<Col span={17} className={selfStyle['menu-role-tree']}>
<TabTree
title='菜单列表'
fetchData={params => fetchMenuData()}
fetchData={params => fetchRoleDetail()}
getMenuSelectData={getMenuSelectData}
customKey='id'
checkable
......
......@@ -12,11 +12,11 @@ import EyePreview from '@/components/EyePreview';
import DeleteItem from '@/components/DeleteItem';
const setInformation = (id) => {
history.push(`/memberManage/memberAuthManage/setMemberAuth?id=${id}`)
history.push(`/ruleSettingManager/memberAuthManage/detail?id=${id}`)
}
const fetchData = async (params:any) => {
const data = await PublicApi.getMemberRolePage(params)
const data = await PublicApi.getMemberPlatformRolePage(params)
return data.data
}
......@@ -26,44 +26,44 @@ const MemberRoleManage: React.FC<{}> = () => {
const columns: ColumnType<{}>[] = [
{
title: '会员角色ID',
dataIndex: 'id',
dataIndex: 'roleId',
align: 'center',
key: 'id',
key: 'roleId',
},
{
title: '会员角色',
dataIndex: 'name',
dataIndex: 'roleName',
align: 'center',
key: 'name',
key: 'roleName',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview handleClick={editMember.bind(null, record, '1')} type='button'>{text}</EyePreview>
render: (text: any, record: any) => <EyePreview url={`/ruleSettingManager/memberAuthManage/preview?id=${record.roleId}&preview=1`}>{text}</EyePreview>
},
{
title: '业务类型',
align: 'center',
dataIndex: 'serviceType',
key: 'serviceType'
dataIndex: 'businessTypeName',
key: 'businessTypeName'
},
{
title: '角色类型',
align: 'center',
dataIndex: 'roleType',
key: 'roleType',
render: (data) => findArrayItem(MEMBER_ROLE_LISTS, data).label
dataIndex: 'roleTypeName',
key: 'roleTypeName',
// render: (data) => findArrayItem(MEMBER_ROLE_LISTS, data).label
},
{
title: '会员类型',
align: 'center',
dataIndex: 'memberType',
key: 'memberType',
render: (data) => findArrayItem(MEMBER_TYPE_LISTS, data).label
dataIndex: 'memberTypeName',
key: 'memberTypeName',
// render: (data) => findArrayItem(MEMBER_TYPE_LISTS, data).label
},
{
title: '状态',
align: 'center',
dataIndex: 'state',
key: 'state',
render: (text: any, record:any) => <StatusSwitch handleCancel={cancel} handleConfirm={()=>handleModify(text, record)} record={record}></StatusSwitch>
dataIndex: 'status',
key: 'status',
render: (text: any, record:any) => <StatusSwitch handleCancel={cancel} fieldNames='status' handleConfirm={()=>handleModify(text, record)} record={record}></StatusSwitch>
},
{
title: '操作',
......@@ -72,51 +72,19 @@ const MemberRoleManage: React.FC<{}> = () => {
render: (text:any, record:any) => {
return (
<>
{ record.state===0 && <Button className='commonShow' type='link' onClick={editMember.bind(null, record, '0')}>修改</Button> }
{record.state === 0 && <DeleteItem confirm={() => deleteMember(record)}/>}
{ record.state === 1 && <Button className='commonShow' type='link' onClick={()=>setInformation(record.id)}>设置会员权限</Button> }
{ record.status === 1 && <Button className='commonShow' type='link' onClick={()=>setInformation(record.roleId)}>设置会员权限</Button> }
</>
)
}
}
];
const editMember = (memberInfo: any, preview?) => {
history.push({
pathname: '/memberManage/memberRoleManage/addMemberRole',
state: memberInfo,
query: {
id: 'custom',
preview
}
})
}
const deleteMember = (memberInfo: any) => {
PublicApi.postMemberRoleDelete({
memberRoleId: memberInfo.id
})
ref.current.reload()
}
const formSearch: ISchema = {
type: 'object',
properties: {
name: {
type: 'string',
"x-component-props": {
placeholder: '请输入会员角色'
}
}
}
}
const cancel = () => {
console.log('cancel')
}
const handleModify = async (text: number, record: any) => {
await PublicApi.postMemberRoleUpdatestatus({ id: record.id, status: text })
await PublicApi.postMemberPlatformRoleStatusUpdate({ roleId: record.roleId, status: text === 1 ? 0 : 1 })
ref.current.reload()
}
......@@ -125,6 +93,7 @@ const MemberRoleManage: React.FC<{}> = () => {
<StandardTable
columns={columns}
currentRef={ref}
rowKey='roleId'
fetchTableData={(params:any) => fetchData(params)}
formilyLayouts={{
justify: 'space-between'
......@@ -137,7 +106,7 @@ const MemberRoleManage: React.FC<{}> = () => {
schema: {
type: 'object',
properties: {
name: {
roleName: {
type: 'Search',
"x-component-props": {
placeholder: '请输入角色名称'
......
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