Browse Source

项目分配修改

dev
wenlele 2 years ago
parent
commit
6ea2d76424
  1. 5
      api/app/lib/controllers/project/index.js
  2. 2
      api/app/lib/utils/dataRange.js
  3. 12
      web/client/src/layout/components/header/index.jsx
  4. 3
      web/client/src/sections/problem/actions/problem.jsx
  5. 6
      web/client/src/sections/problem/components/inspection.jsx

5
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
}

2
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 }

12
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) => {
<Dropdown
onVisibleChange={(v) => {
setScrollbar(!Scrollbar)
setKeyword('')
}}
render={
<Dropdown.Menu style={{ minWidth: 270, maxWidth: 714, padding: 20, fontSize: 12 }}>
@ -106,7 +107,7 @@ const Header = (props) => {
{pomsList?.length > 0 ?
pomsList.filter(u => u.pepProjectName?.includes(keyword))?.map(v => {
return <Dropdown.Item
key={'pomsList' + v.id}
key={'pomsList' + v.pepProjectId}
style={{ width: 224, overflow: 'hidden', borderBottom: '', display: "inline-block", whiteSpace: 'nowrap', color: 'rgb(0, 90, 189)' }}>
{
@ -115,14 +116,13 @@ const Header = (props) => {
<div onClick={() => {
console.log(v.pepProjectId);
setPomsName(v.pepProjectName)
setPepProjectId(v.pepProjectId)
setPepProjectId(v.id)
}}>
{v.pepProjectName?.length > 15 ? `${v.pepProjectName?.substr(0, 15)}` : v.pepProjectName}
</div>
</div>
</Tooltip>
: <div onClick={() => {
console.log(v.pepProjectId);
setPomsName(v.pepProjectName)
setPepProjectId(v.pepProjectId)
}}>{v.pepProjectName}</div>

3
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: '获取已绑定项目' },

6
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)

Loading…
Cancel
Save