From 6ea2d764248c2815652e2cabbe3add90ff98f995 Mon Sep 17 00:00:00 2001 From: wenlele Date: Fri, 14 Oct 2022 16:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=86=E9=85=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/index.js | 5 ++++- api/app/lib/utils/dataRange.js | 2 +- web/client/src/layout/components/header/index.jsx | 12 ++++++------ web/client/src/sections/problem/actions/problem.jsx | 3 ++- .../src/sections/problem/components/inspection.jsx | 6 ++---- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 6491184..49e27d3 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -23,7 +23,7 @@ async function pomsProject (ctx) { const models = ctx.fs.dc.models; const { clickHouse } = ctx.app.fs const { userId, pepUserId, userInfo, pepUserInfo } = ctx.fs.api - const { limit, page, global } = ctx.query + const { limit, page, global, pepId } = ctx.query let findOption = { where: { @@ -38,6 +38,9 @@ async function pomsProject (ctx) { if (global && !userInfo.role.includes('SuperAdmin') && !userInfo.role.includes('admin')) { findOption.where = { id: { $in: userInfo.correlationProject } } } + if (pepId) { + findOption.where.id = pepId + } if (limit) { findOption.limit = limit } diff --git a/api/app/lib/utils/dataRange.js b/api/app/lib/utils/dataRange.js index 0f79e19..cc0a332 100644 --- a/api/app/lib/utils/dataRange.js +++ b/api/app/lib/utils/dataRange.js @@ -28,7 +28,7 @@ module.exports = function (app, opts) { } if (pepProjectId) { // 有 特定的项目id 就按此查询 - findOption.where.pepProjectId = pepProjectId + findOption.where.id = pepProjectId } else if (!isSuper) { // 还不是超管或管理员就按关联的项目id的数据范围查 findOption.where.id = { $in: correlationProject } diff --git a/web/client/src/layout/components/header/index.jsx b/web/client/src/layout/components/header/index.jsx index 8371d1c..f75408c 100644 --- a/web/client/src/layout/components/header/index.jsx +++ b/web/client/src/layout/components/header/index.jsx @@ -32,12 +32,13 @@ const Header = (props) => { modalRole = headerItems?.filter(v => modal.includes(v.itemKey)) if (userRole?.includes('SuperAdmin') || userRole?.includes('admin')) modalRole = headerItems } - + useEffect(() => { if (JSON.parse(sessionStorage.getItem('pomsUser'))?.token) { dispatch(install.getProjectPoms({ global: 1 })).then((res) => { //获取已绑定项目 if (res.success) { - setPomsList(res.payload.data?.rows?.filter(v => v.pepProjectIsDelete == 0)) + let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name })) + setPomsList(data) } }) } @@ -57,7 +58,6 @@ const Header = (props) => { useEffect(() => { dispatch(pepProject(pepProjectId)) - console.log(); }, [pepProjectId]) @@ -95,6 +95,7 @@ const Header = (props) => { { setScrollbar(!Scrollbar) + setKeyword('') }} render={ @@ -106,7 +107,7 @@ const Header = (props) => { {pomsList?.length > 0 ? pomsList.filter(u => u.pepProjectName?.includes(keyword))?.map(v => { return { @@ -115,14 +116,13 @@ const Header = (props) => {
{ console.log(v.pepProjectId); setPomsName(v.pepProjectName) - setPepProjectId(v.pepProjectId) + setPepProjectId(v.id) }}> {v.pepProjectName?.length > 15 ? `${v.pepProjectName?.substr(0, 15)}` : v.pepProjectName}
:
{ - console.log(v.pepProjectId); setPomsName(v.pepProjectName) setPepProjectId(v.pepProjectId) }}>{v.pepProjectName}
diff --git a/web/client/src/sections/problem/actions/problem.jsx b/web/client/src/sections/problem/actions/problem.jsx index 329cca0..b8bf96e 100644 --- a/web/client/src/sections/problem/actions/problem.jsx +++ b/web/client/src/sections/problem/actions/problem.jsx @@ -2,10 +2,11 @@ import { ApiTable, basicAction } from '$utils' -export function getProjectPoms () { //获取已绑定项目 +export function getProjectPoms (query) { //获取已绑定项目 return dispatch => basicAction({ type: 'get', dispatch: dispatch, + query, actionType: 'GET_PROJECT_POMS', url: `${ApiTable.getProjectPoms}`, msg: { option: '获取已绑定项目' }, diff --git a/web/client/src/sections/problem/components/inspection.jsx b/web/client/src/sections/problem/components/inspection.jsx index 2c2013a..b1bbb2d 100644 --- a/web/client/src/sections/problem/components/inspection.jsx +++ b/web/client/src/sections/problem/components/inspection.jsx @@ -28,15 +28,13 @@ const Inspection = ({ dispatch, actions, user, route, statistic, pepProjectId }) useEffect(() => { - dispatch(problem.getProjectPoms({ global: 1 })).then((res) => { + dispatch(problem.getProjectPoms({ global: 1, pepId: pepProjectId })).then((res) => { if (res.success) { let project = [] let apply = [] res.payload.data?.rows?.map(v => { - if (!pepProjectId || v.pepProjectId == pepProjectId) { project.push({ name: v.pepProjectName || v.name || v.id, value: v.id }) - v.apps.map(app => apply.push({ name: app.name, value: app.id })) - } + v.apps.map(app => apply.push({ name: app.name, value: app.id })) }) setSelectProject(project) setApplyFilter(apply)