Merge pull request '更新' (#482) from durian/forgeplus-react:pre_dev_military into pre_dev_military

This commit is contained in:
tongChong 2022-12-02 10:20:38 +08:00
commit e7c71d35de
4 changed files with 52 additions and 20 deletions

View File

@ -25,7 +25,7 @@ if (isDev) {
}
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' :
window.location.search.indexOf('debug=a') !== -1 ? 'a' : parsed.debug || 'admin'
window.location.search.indexOf('debug=a') !== -1 ? 'a' : parsed.debug || ''
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {

View File

@ -139,6 +139,16 @@ const GatheringList = Loadable({
})
const Managements = (propsF) => {
useEffect(()=>{
const {current_user, history} = propsF;
if(current_user && current_user.login){
if(!current_user.admin){
history.push('/403')
}
}else{
propsF.showLoginDialog();
}
},[])
return (
<div className="newMain clearfix managementMain">

View File

@ -31,6 +31,8 @@ export default Form.create()(({form}) => {
const [selectedMenuFa, setSelectedMenuFa] = useState(undefined);
//
let oneTree = [];
//
let twoTree = [];
const helper = useCallback(
(label, name, rules, widget, initialValue) => (
@ -216,7 +218,9 @@ export default Form.create()(({form}) => {
listMenu(roleId).then(response=>{
if(response && response.message=='success'){
//
const keys = response.data.map(item=>{return oneTree.indexOf(item.key.toString()) === -1 ? item.key.toString() : null});
const keys = response.data.map(item=>{
return (oneTree.indexOf(item.key.toString()) !== -1 || twoTree.indexOf(item.key.toString()) !== -1) ? null : item.key.toString()
});
setSelectedMenu(keys);
setRoleId(roleId);
setMenuModal(true);
@ -239,7 +243,17 @@ export default Form.create()(({form}) => {
useEffect(()=>{
treeList().then(response=>{
if(response && response.message=='success'){
oneTree = response.data.map(item=>{return item.key.toString()});
// antd tree checkedKeys
response.data.map(item=>{
oneTree.push(item.key.toString())
if(item.children && item.children.length){
item.children.map(i =>{
if(i.children && i.children.length){
twoTree.push(i.key.toString());
}
})
}
})
setMenuTreeData(response.data);
}
}).finally(()=>{

View File

@ -165,27 +165,35 @@ const Competition = (props) => {
// 关注和取消关注
function follow1(){
follow({
id: competitionId,
target_type: 'competition_info'
}).then(res=>{
if(res && res.status === 200){
message.success('关注成功');
setReloadDetail(Math.random());
}
})
if(current_user && current_user.login){
follow({
id: competitionId,
target_type: 'competition_info'
}).then(res=>{
if(res && res.status === 200){
message.success('关注成功');
setReloadDetail(Math.random());
}
})
}else{
props.showLoginDialog();
}
}
function unfollow(){
unFollow({
id: competitionId,
target_type: 'competition_info'
}).then(res=>{
if(res && res.status === 200){
message.success('取消关注成功');
setReloadDetail(Math.random());
if(current_user && current_user.login){
unFollow({
id: competitionId,
target_type: 'competition_info'
}).then(res=>{
if(res && res.status === 200){
message.success('取消关注成功');
setReloadDetail(Math.random());
}
})
}else{
props.showLoginDialog();
}
})
}
const is_local = qzDetail && qzDetail.is_local;