Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wms
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wuhao
wms
Commits
c15bced2
Commit
c15bced2
authored
Aug 10, 2023
by
krysent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
f8200974
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
81 deletions
+88
-81
mtable.jsx
src/components/AutoTable/mtable.jsx
+19
-7
AvatarDropdown.jsx
src/components/RightContent/AvatarDropdown.jsx
+7
-7
index.jsx
src/components/TagView/Tags/index.jsx
+12
-25
index.jsx
src/components/TagView/index.jsx
+50
-42
No files found.
src/components/AutoTable/mtable.jsx
View file @
c15bced2
...
...
@@ -23,8 +23,6 @@ const Mtable = (props) => {
getDefaultSelected
,
//存在默认选中向上返回选中值
}
=
props
;
const
actionRefs
=
actionRef
??
useRef
(),
formRefs
=
formRef
??
useRef
(),
ifspagination
=
pagination
==
"false"
||
pagination
===
false
,
...
...
@@ -66,7 +64,6 @@ const Mtable = (props) => {
};
};
//更新 columns
useEffect
(()
=>
{
setcolumnes
((
s
)
=>
{
...
...
@@ -136,7 +133,15 @@ const Mtable = (props) => {
//初始化操作数据
const
initDrage
=
async
()
=>
{
console
.
log
(
valueColumns
);
if
(
!
path
)
return
;
if
(
Object
.
keys
(
valueColumns
).
length
!==
0
)
{
console
.
log
(
valueColumns
);
return
;
}
actionRefs
?.
current
?.
reset
();
let
res
=
await
doFetch
({
url
:
"/ngic-base-business/paFieldScene/queryContro"
,
params
:
{
...
...
@@ -148,6 +153,9 @@ const Mtable = (props) => {
},
});
if
(
res
.
code
==
"0000"
)
{
// if (res?.data?.dataList?.length == 0) {
// setvalueColumns({});
// }
//datalist:接口返回状态
let
datalist
=
{};
res
?.
data
?.
dataList
&&
...
...
@@ -184,17 +192,21 @@ const Mtable = (props) => {
});
setvalueColumns
(
allcol
);
}
actionRefs
?.
current
?.
reset
();
// actionRefs?.current?.clearSelected
();
// actionRefs?.current?.reload();
// actionRefs?.current?.clearSelected()
};
//调用重新渲染表格
useEffect
(
async
()
=>
{
// console.log(history?.location?.pathname);
await
initDrage
();
},
[
columns
,
extraparams
,
path
,
activeTabKey
,
refreshDep
]);
//
setvalueColumns
({});
},
[
extraparams
,
path
,
activeTabKey
,
refreshDep
]);
// useEffect(() => {
// actionRefs?.current?.reload();
// }, [columns]);
//
//缩放表格
const
handleResize
=
(
index
)
=>
...
...
src/components/RightContent/AvatarDropdown.jsx
View file @
c15bced2
...
...
@@ -17,14 +17,14 @@ import moment from "moment";
* 退出登录,并且将当前的 url 保存
*/
const
loginOut
=
async
()
=>
{
await
fakeAccountLoginOut
();
const
{
query
=
{}
}
=
history
.
location
;
const
{
redirect
}
=
query
;
// Note: There may be security issues, please note
//
await fakeAccountLoginOut();
//
const { query = {} } = history.location;
//
const { redirect } = query; // Note: There may be security issues, please note
if
(
window
.
location
.
pathname
!==
"/user/login"
&&
!
redirect
)
{
localStorage
.
clear
();
history
.
replace
(
"/user/login"
);
}
//
if (window.location.pathname !== "/user/login" && !redirect) {
//
localStorage.clear();
// }
history
.
replace
(
"/user/login"
);
};
const
AvatarDropdown
=
({
menu
})
=>
{
...
...
src/components/TagView/Tags/index.jsx
View file @
c15bced2
import
React
,
{
useState
,
useRef
,
useEffect
}
from
"react"
;
import
{
history
}
from
"umi"
;
import
{
Scrollbars
}
from
"react-custom-scrollbars"
;
import
{
CloseOutlined
}
from
"@ant-design/icons"
;
import
styles
from
"./index.less"
;
import
React
,
{
useState
,
useRef
,
useEffect
}
from
'react'
;
import
{
history
}
from
'umi'
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
import
{
CloseOutlined
}
from
'@ant-design/icons'
;
import
styles
from
'./index.less'
;
const
Tags
=
({
tagList
,
closeTag
,
closeAllTag
,
closeOtherTag
,
refreshTag
,
home
,
})
=>
{
const
Tags
=
({
tagList
,
closeTag
,
closeAllTag
,
closeOtherTag
,
refreshTag
,
home
})
=>
{
const
[
left
,
setLeft
]
=
useState
(
0
);
const
[
top
,
setTop
]
=
useState
(
0
);
const
[
menuVisible
,
setMenuVisible
]
=
useState
(
false
);
...
...
@@ -22,20 +15,18 @@ const Tags = ({
useEffect
(()
=>
{
return
()
=>
{
document
.
body
.
removeEventListener
(
"click"
,
handleClickOutside
);
document
.
body
.
removeEventListener
(
'click'
,
handleClickOutside
);
};
},
[]);
// 由于react的state不能及时穿透到 document.body.addEventListener去,需要在每次值发送改变时进行解绑和再次监听
useEffect
(()
=>
{
document
.
body
.
removeEventListener
(
"click"
,
handleClickOutside
);
document
.
body
.
addEventListener
(
"click"
,
handleClickOutside
);
document
.
body
.
removeEventListener
(
'click'
,
handleClickOutside
);
document
.
body
.
addEventListener
(
'click'
,
handleClickOutside
);
},
[
menuVisible
]);
const
handleClickOutside
=
(
event
)
=>
{
const
isOutside
=
!
(
contextMenuRef
.
current
&&
contextMenuRef
.
current
.
contains
(
event
.
target
)
);
const
isOutside
=
!
(
contextMenuRef
.
current
&&
contextMenuRef
.
current
.
contains
(
event
.
target
));
if
(
isOutside
&&
menuVisible
)
{
setMenuVisible
(
false
);
}
...
...
@@ -63,12 +54,8 @@ const Tags = ({
{
tagList
?.
map
?.((
item
,
i
)
=>
(
<
div
key=
{
item
.
path
}
className=
{
item
.
active
?
`${styles.item} ${styles.active}`
:
styles
.
item
}
onClick=
{
()
=>
history
.
push
({
pathname
:
item
.
path
,
query
:
item
.
query
})
}
className=
{
item
.
active
?
`${styles.item} ${styles.active}`
:
styles
.
item
}
onClick=
{
()
=>
history
.
push
({
pathname
:
item
.
path
,
query
:
item
.
query
})
}
onContextMenu=
{
(
e
)
=>
openContextMenu
(
e
,
item
)
}
>
<
span
>
{
item
.
title
}
</
span
>
...
...
src/components/TagView/index.jsx
View file @
c15bced2
import
React
,
{
useState
,
useEffect
,
useRef
}
from
"react"
;
import
{
RouteContext
}
from
"@ant-design/pro-layout"
;
import
{
history
,
FormattedMessage
}
from
"umi"
;
import
Tags
from
"./Tags"
;
import
styles
from
"./index.less"
;
/* eslint-disable react/jsx-key */
import
React
,
{
useState
,
useEffect
,
useRef
,
memo
}
from
'react'
;
import
{
RouteContext
}
from
'@ant-design/pro-layout'
;
import
{
history
}
from
'umi'
;
import
Tags
from
'./Tags'
;
import
styles
from
'./index.less'
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
// tree遍历
function
treeForeach
(
tree
,
func
)
{
tree
.
forEach
((
data
)
=>
{
func
(
data
);
data
.
children
&&
treeForeach
(
data
.
children
,
func
);
// 遍历子树
});
}
/**
* @component TagView 标签页组件
*/
const
TagView
=
({
children
,
home
})
=>
{
const
[
tagList
,
setTagList
]
=
useState
([]);
...
...
@@ -21,24 +27,23 @@ const TagView = ({ children, home }) => {
// 初始化 visitedViews,设置首页
const
initTags
=
(
routeContext
)
=>
{
// console.log(routeContext);
const
{
menuData
}
=
routeContext
;
if
(
tagList
.
length
===
0
&&
menuData
)
{
const
firstTag
=
menuData
.
filter
((
el
)
=>
el
.
path
===
home
)[
0
];
const
allarr
=
[];
treeForeach
(
menuData
,
(
node
)
=>
{
allarr
.
push
(
node
);
});
const
firstTag
=
allarr
.
filter
((
el
)
=>
el
.
path
===
location
?.
hash
?.
replace
(
'#'
,
''
))[
0
];
if
(
firstTag
)
{
const
title
=
(
<
FormattedMessage
key=
{
firstTag
.
name
}
id=
{
`menu.${firstTag.name}`
}
defaultMessage=
"首页"
/>
);
const
title
=
firstTag
.
name
;
const
path
=
firstTag
.
path
;
history
.
push
({
pathname
:
firstTag
.
path
,
query
:
firstTag
.
query
});
setTagList
([
{
title
,
path
,
children
:
firstTag
.
children
,
children
:
firstTag
.
element
,
refresh
:
0
,
active
:
true
,
key
:
firstTag
.
key
,
...
...
@@ -51,6 +56,7 @@ const TagView = ({ children, home }) => {
// 监听路由改变
const
handleOnChange
=
(
routeContext
)
=>
{
const
{
currentMenu
}
=
routeContext
;
// console.log(tagList);
// tags初始化
if
(
tagList
.
length
===
0
)
{
return
initTags
(
routeContext
);
...
...
@@ -60,9 +66,11 @@ const TagView = ({ children, home }) => {
if
(
currentMenu
.
path
)
{
const
tagsCopy
=
tagList
.
map
((
item
)
=>
{
if
(
currentMenu
?.
path
===
item
.
path
)
{
//console.log(item);
hasOpen
=
true
;
// 刷新浏览器时,重新覆盖当前 path 的 children
return
{
...
item
,
active
:
true
,
children
};
// console.log(item);
return
{
...
item
,
active
:
true
,
children
:
item
.
children
};
}
else
{
return
{
...
item
,
active
:
false
};
}
...
...
@@ -70,7 +78,7 @@ const TagView = ({ children, home }) => {
// 没有该tag时追加一个,并打开这个tag页面
if
(
!
hasOpen
)
{
const
title
=
routeContext
.
title
||
""
;
const
title
=
routeContext
.
title
||
''
;
const
path
=
currentMenu
?.
path
;
tagsCopy
.
push
({
title
,
...
...
@@ -80,6 +88,7 @@ const TagView = ({ children, home }) => {
active
:
true
,
});
}
return
setTagList
(
tagsCopy
);
}
};
...
...
@@ -89,7 +98,7 @@ const TagView = ({ children, home }) => {
const
tagsCopy
=
tagList
.
map
((
el
,
i
)
=>
({
...
el
}));
// 判断关闭标签是否处于打开状态
tagList
.
forEach
((
el
,
i
)
=>
{
tagList
.
forEach
?.
((
el
,
i
)
=>
{
if
(
el
.
path
===
tag
.
path
&&
tag
.
active
)
{
const
next
=
tagList
[
i
-
1
];
next
.
active
=
true
;
...
...
@@ -109,23 +118,24 @@ const TagView = ({ children, home }) => {
// 关闭其他标签
const
handleCloseOther
=
(
tag
)
=>
{
const
tagsCopy
=
tagList
.
filter
(
(
el
)
=>
el
.
path
===
home
||
el
.
path
===
tag
.
path
);
const
tagsCopy
=
tagList
.
filter
((
el
)
=>
el
.
path
===
home
||
el
.
path
===
tag
.
path
);
history
.
push
({
pathname
:
tag
?.
path
,
query
:
tag
?.
query
});
setTagList
(
tagsCopy
);
};
const
[
refresh
,
setrefresh
]
=
useState
(
true
);
// 刷新选择的标签
const
handleRefreshTag
=
(
tag
)
=>
{
const
tagsCopy
=
tagList
.
map
((
item
)
=>
{
if
(
item
.
path
===
tag
.
path
)
{
history
.
push
({
pathname
:
tag
?.
path
,
query
:
tag
?.
query
});
return
{
...
item
,
refresh
:
item
.
refresh
+
1
,
active
:
true
};
}
return
{
...
item
,
active
:
false
};
});
setTagList
(
tagsCopy
);
const
handleRefreshTag
=
async
(
tag
)
=>
{
// const tagsCopy = tagList.map((item) => {
// if (item.path === tag.path) {
// history.push({ pathname: tag?.path, query: tag?.query });
// return { ...item, refresh: item.refresh + 1, active: true };
// }
// return { ...item, active: false };
// });
// setTagList(tagsCopy);
await
setrefresh
(
false
);
setrefresh
(
true
);
};
return
(
...
...
@@ -153,16 +163,14 @@ const TagView = ({ children, home }) => {
</
div
>
<
div
className=
{
styles
.
child
}
>
<
div
className=
{
styles
.
contianbox
}
>
{
tagList
.
map
((
item
)
=>
{
return
(
<
div
key=
{
item
.
path
}
style=
{
{
display
:
item
.
active
?
"block"
:
"none"
}
}
>
<
div
key=
{
item
.
refresh
}
>
{
item
.
children
}
</
div
>
</
div
>
);
})
}
<
Scrollbars
thumbMinSize=
{
10
}
autoHide
style=
{
{
width
:
'100%'
,
height
:
'100%'
}
}
hideTracksWhenNotNeeded=
{
true
}
>
{
refresh
&&
children
}
</
Scrollbars
>
</
div
>
</
div
>
</>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment