Commit 0496cfe2 authored by Bill's avatar Bill

global.d.ts

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