Browse Source

fix 13032 数据大屏-大屏名称标题展示未根据项目集变化

dev
CODE 1 year ago
parent
commit
55bae0a7ed
  1. 23
      api/app/lib/controllers/project/group.js
  2. 3
      api/app/lib/routes/project/index.js
  3. 15
      web/client/src/sections/projectGroup/actions/group.js
  4. 6
      web/client/src/sections/projectGroup/components/header.jsx
  5. 10
      web/client/src/sections/projectGroup/containers/bigscreen.jsx
  6. 1
      web/client/src/utils/webapi.js

23
api/app/lib/controllers/project/group.js

@ -23,6 +23,28 @@ async function groupList (ctx) {
}
}
async function groupDetail (ctx) {
try {
const { models } = ctx.fs.dc;
const { groupId } = ctx.params
const res = await models.ProjectGroup.findOne({
where: {
id: groupId
}
})
ctx.status = 200;
ctx.body = res
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function editGroup (ctx) {
try {
const { models } = ctx.fs.dc;
@ -566,6 +588,7 @@ async function groupProject (ctx) {
module.exports = {
groupList,
groupDetail,
editGroup,
delGroup,
groupStatistic,

3
api/app/lib/routes/project/index.js

@ -34,6 +34,9 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/project/group'] = { content: '获取项目分组', visible: true };
router.get('/project/group', projectGroup.groupList);
app.fs.api.logAttr['GET/project/group/:groupId'] = { content: '获取项目分组详情', visible: true };
router.get('/project/group/:groupId', projectGroup.groupDetail);
app.fs.api.logAttr['PUT/project/group'] = { content: '编辑项目分组', visible: true };
router.put('/project/group', projectGroup.editGroup);

15
web/client/src/sections/projectGroup/actions/group.js

@ -13,6 +13,21 @@ export function getProjectGroup () {
});
}
export function getProjectGroupDetail (groupId) {
return (dispatch) => basicAction({
type: "get",
dispatch: dispatch,
actionType: "GET_PROJECT_GROPUP_DETAIL",
url: `${ApiTable.groupProjectDetail.replace(':groupId', groupId)}`,
msg: { error: "获取项目分组详情失败" },
reducer: {
name: "projectGroupDetail", params: {
// noClear: true
}
},
});
}
export function editProjectGroup (data) {
return (dispatch) => basicAction({
type: "put",

6
web/client/src/sections/projectGroup/components/header.jsx

@ -5,7 +5,7 @@ import { push } from 'react-router-redux';
import moment from "moment";
const Header = (props) => {
const { dispatch, actions, user, match, weatherRealtime, history } = props
const { dispatch, actions, user, match, weatherRealtime, history, groupDetail } = props
const [queryUserId, setQueryUserId] = useState('')
const [date, setDate] = useState(moment());
const dayMap = { 0: '日', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六' }
@ -25,11 +25,9 @@ const Header = (props) => {
dispatch(actions.auth.getWeatherRealtime())
}
useEffect(() => {
console.log(props?.location);
let search = props?.location?.search || '';
let params = new URLSearchParams(search);
let userId = params.get('pomsU')
console.log(userId);
setQueryUserId(userId)
const setTime = () => {
@ -81,7 +79,7 @@ const Header = (props) => {
display: 'flex', alignItems: 'center', justifyContent: 'space-between'
}}>
<span style={{ fontSize: 'xx-large', fontWeight: 'bolder' }}>
{match?.path == '/projectGroup/bigscreen' ? `${JSON.parse(localStorage.getItem('project_group'))?.find(v => v.userId == user?.id)?.name}数据统计大屏` : '运维中台大屏'}
{match?.path == '/projectGroup/bigscreen' ? `${groupDetail?.name}数据统计大屏` : '运维中台大屏'}
</span>
<span style={{
display: 'flex', alignItems: 'center', flexDirection: 'row'

10
web/client/src/sections/projectGroup/containers/bigscreen.jsx

@ -24,7 +24,7 @@ const Bigscreen = (props) => {
const [groupProject, setGroupProject] = useState([])
const [proportion, setProportion] = useState([])
const [formatter, setFormatter] = useState({})
const [groupDetail, setGroupDetail] = useState({})
const [alarmData, setAlarmData] = useState()//
const [biggest, setBiggest] = useState()//
@ -63,6 +63,12 @@ const Bigscreen = (props) => {
}
})
dispatch(actions.projectGroup.getProjectGroupDetail(groupId_)).then(res => {
if (res.success) {
setGroupDetail(res.payload.data)
}
})
const interruptDom = document.getElementById("interrupt");
if (interruptDom) {
interrupt = new PerfectScrollbar("#interrupt", {
@ -195,7 +201,7 @@ const Bigscreen = (props) => {
return (
<div className='project-group'>
<Header match={match} history={history} {...props} />
<Header match={match} history={history} {...props} groupDetail={groupDetail} />
<Body>
<div style={{ width: "100%", height: '100%' }}>
<div style={{ width: '100%', height: "45%", display: 'flex' }}>

1
web/client/src/utils/webapi.js

@ -42,6 +42,7 @@ export const ApiTable = {
groupStatisticOnline: 'project/group/statistic/online',
groupStatisticAlarm: 'project/group/statistic/alarm',
groupProject: "project/group/list",
groupProjectDetail: "project/group/:groupId",
//告警
getProjectPoms: 'project/poms', //获取已绑定项目

Loading…
Cancel
Save