|
|
|
|
/**
|
|
|
|
|
* @see https://umijs.org/zh-CN/plugins/plugin-access
|
|
|
|
|
* */
|
|
|
|
|
export default function access(initialState: { currentUser?: API.PbcUsersVO | undefined }) {
|
|
|
|
|
const { currentUser } = initialState || {};
|
|
|
|
|
if (currentUser?.currentAuthority) {
|
|
|
|
|
console.log(currentUser.pbcUserRole)
|
|
|
|
|
const params: any = {
|
|
|
|
|
dashboard: false,
|
|
|
|
|
dashboardUser: currentUser.pbcUserMobile !== '13052023298',
|
|
|
|
|
isBusiness: currentUser.pbcUserRole === 2,
|
|
|
|
|
dashboardQuery: false,
|
|
|
|
|
operations: false,
|
|
|
|
|
operationsQuery: false,
|
|
|
|
|
user: false,
|
|
|
|
|
userQuery: false,
|
|
|
|
|
userSave: false,
|
|
|
|
|
userUpdateState: false,
|
|
|
|
|
userDelete: false,
|
|
|
|
|
role: false,
|
|
|
|
|
roleQuery: false,
|
|
|
|
|
roleSave: false,
|
|
|
|
|
roleDelete: false,
|
|
|
|
|
approval: false,
|
|
|
|
|
approvalQuery: false,
|
|
|
|
|
approvalSign: false,
|
|
|
|
|
business: false,
|
|
|
|
|
businessQuery: false,
|
|
|
|
|
businessSave: false,
|
|
|
|
|
businessAdd: false,
|
|
|
|
|
businessUpdateState: false,
|
|
|
|
|
member: false,
|
|
|
|
|
memberQuery: false,
|
|
|
|
|
memberUpdateState: false,
|
|
|
|
|
memberGrade: false,
|
|
|
|
|
memberGradeQuery: false,
|
|
|
|
|
memberGradeSave: false,
|
|
|
|
|
productCategory: false,
|
|
|
|
|
productCategoryQuery: false,
|
|
|
|
|
productCategorySave: false,
|
|
|
|
|
productCategoryUpdateState: false,
|
|
|
|
|
productCategoryDelete: false,
|
|
|
|
|
productLabel: false,
|
|
|
|
|
productLabelQuery: false,
|
|
|
|
|
productLabelSave: false,
|
|
|
|
|
productLabelDelete: false,
|
|
|
|
|
productLabelType: false,
|
|
|
|
|
productLabelTypeQuery: false,
|
|
|
|
|
productLabelTypeSave: false,
|
|
|
|
|
productLabelTypeDelete: false,
|
|
|
|
|
product: false,
|
|
|
|
|
productQuery: false,
|
|
|
|
|
productAdd: false,
|
|
|
|
|
productUpdateState: false,
|
|
|
|
|
productRemove: false,
|
|
|
|
|
content: false,
|
|
|
|
|
contentQuery: false,
|
|
|
|
|
contentSave: false,
|
|
|
|
|
message: false,
|
|
|
|
|
messageQuery: false,
|
|
|
|
|
messageDelete: false,
|
|
|
|
|
dictionary: false,
|
|
|
|
|
dictionaryQuery: false,
|
|
|
|
|
dictionaryAdd: false,
|
|
|
|
|
dictionaryUpdate: false,
|
|
|
|
|
adScreen: false,
|
|
|
|
|
adScreenQuery: false,
|
|
|
|
|
adScreenAdd: false,
|
|
|
|
|
adScreenUpdate: false,
|
|
|
|
|
adBanner: false,
|
|
|
|
|
adBannerQuery: false,
|
|
|
|
|
adBannerAdd: false,
|
|
|
|
|
adBannerUpdate: false,
|
|
|
|
|
purchaseAgent: false,
|
|
|
|
|
purchaseAgentQuery: false,
|
|
|
|
|
recommendPurchaseAgentQuery: false,
|
|
|
|
|
trainingClasses: false,
|
|
|
|
|
trainingClassesQuery: false,
|
|
|
|
|
trainingClassesCategoryQuery: false,
|
|
|
|
|
};
|
|
|
|
|
for (let i = 0; i < currentUser?.currentAuthority.length; i++) {
|
|
|
|
|
const element = currentUser?.currentAuthority[i];
|
|
|
|
|
params[element] = true;
|
|
|
|
|
}
|
|
|
|
|
params.product =
|
|
|
|
|
params.productCategoryQuery ||
|
|
|
|
|
params.productLabelQuery ||
|
|
|
|
|
params.productLabelTypeQuery ||
|
|
|
|
|
params.productQuery;
|
|
|
|
|
params.member =
|
|
|
|
|
params.memberQuery ||
|
|
|
|
|
params.memberGradeQuery;
|
|
|
|
|
params.purchaseAgent =
|
|
|
|
|
params.purchaseAgentQuery ||
|
|
|
|
|
params.recommendPurchaseAgentQuery;
|
|
|
|
|
params.business =
|
|
|
|
|
params.businessQuery ||
|
|
|
|
|
params.recommendBusinessQuery;
|
|
|
|
|
params.trainingClasses =
|
|
|
|
|
params.trainingClassesQuery ||
|
|
|
|
|
params.trainingClassesCategoryQuery;
|
|
|
|
|
return params;
|
|
|
|
|
}
|
|
|
|
|
return {};
|
|
|
|
|
}
|