From 55bae0a7edd9c47a007a5ec73cd8a7bc6bb1c6d9 Mon Sep 17 00:00:00 2001 From: CODE <1650192445@qq.com> Date: Thu, 7 Sep 2023 11:49:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=2013032=20=E6=95=B0=E6=8D=AE=E5=A4=A7?= =?UTF-8?q?=E5=B1=8F-=E5=A4=A7=E5=B1=8F=E5=90=8D=E7=A7=B0=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E5=B1=95=E7=A4=BA=E6=9C=AA=E6=A0=B9=E6=8D=AE=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=9B=86=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/group.js | 23 +++++++++++++++++++ api/app/lib/routes/project/index.js | 3 +++ .../sections/projectGroup/actions/group.js | 15 ++++++++++++ .../projectGroup/components/header.jsx | 6 ++--- .../projectGroup/containers/bigscreen.jsx | 10 ++++++-- web/client/src/utils/webapi.js | 1 + 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index 24bda85..9042255 100644 --- a/api/app/lib/controllers/project/group.js +++ b/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, diff --git a/api/app/lib/routes/project/index.js b/api/app/lib/routes/project/index.js index bb0ffa6..326a814 100644 --- a/api/app/lib/routes/project/index.js +++ b/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); diff --git a/web/client/src/sections/projectGroup/actions/group.js b/web/client/src/sections/projectGroup/actions/group.js index e994f1b..53149e0 100644 --- a/web/client/src/sections/projectGroup/actions/group.js +++ b/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", diff --git a/web/client/src/sections/projectGroup/components/header.jsx b/web/client/src/sections/projectGroup/components/header.jsx index aa2fb1c..a35e763 100644 --- a/web/client/src/sections/projectGroup/components/header.jsx +++ b/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' }}> - {match?.path == '/projectGroup/bigscreen' ? `${JSON.parse(localStorage.getItem('project_group'))?.find(v => v.userId == user?.id)?.name}数据统计大屏` : '运维中台大屏'} + {match?.path == '/projectGroup/bigscreen' ? `${groupDetail?.name}数据统计大屏` : '运维中台大屏'} { 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 (
-
+
diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 251429a..6f72db2 100644 --- a/web/client/src/utils/webapi.js +++ b/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', //获取已绑定项目