From b25f39a02f56b64c3675c6ec8bc7d78ea63c0653 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Tue, 8 Nov 2022 09:29:27 +0800 Subject: [PATCH] =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E9=A1=B9=E4=BC=81?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9C=A8=E6=98=A0=E5=B0=84=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=98=A0=E5=B0=84=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E6=97=B6=EF=BC=8C=E5=B7=B2=E8=A2=AB=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E8=BF=87=E7=9A=84PEP=E9=A1=B9=E7=9B=AE=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=86=8D=E8=A2=AB=E6=9F=A5=E7=9C=8B=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/index.js | 15 +- .../install/components/systemModal.jsx | 469 +++++++++--------- 2 files changed, 250 insertions(+), 234 deletions(-) diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index fdf0630..b40dbe0 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -129,11 +129,24 @@ async function projectAnxincloud (ctx) { async function projectPManage (ctx) { try { + const models = ctx.fs.dc.models; const { clickHouse } = ctx.app.fs const { includeDelete } = ctx.query const projectRes = await clickHouse.projectManage.query(`SELECT id, project_name, isdelete FROM t_pim_project WHERE isdelete=0 ${includeDelete == 1 ? 'OR isdelete=1' : ''} ORDER BY id DESC`).toPromise() + const bindedPRes = await models.ProjectCorrelation.findAll({ + where: { + pepProjectId: { $ne: null } + } + }) + + for (let p of projectRes) { + if (bindedPRes.some(bp => bp.pepProjectId == p.id)) { + p.binded = true + } + } + ctx.status = 200; ctx.body = projectRes } catch (error) { @@ -210,7 +223,7 @@ async function strucWithPomsProject (ctx) { WHERE project_state != -1 AND - t_project.id IN (${ bindRes.anxinProjectId.join(',')}) + t_project.id IN (${bindRes.anxinProjectId.join(',')}) ORDER BY strucId ` ).toPromise() : diff --git a/web/client/src/sections/install/components/systemModal.jsx b/web/client/src/sections/install/components/systemModal.jsx index 2ace1de..b485c8f 100644 --- a/web/client/src/sections/install/components/systemModal.jsx +++ b/web/client/src/sections/install/components/systemModal.jsx @@ -5,248 +5,251 @@ import { IconAlertCircle, IconAlertTriangle } from '@douyinfe/semi-icons'; function adminModal (props) { - const { - close, - cancel, - visible, - dispatch, - actions, - systemEdit,//是否是编辑 - peplist,//项企项目列表 - anxincloudList,//安心云项目列表 - appList,//应用列表 - pepProjectId,//已选择项企id - pepname,//修改时自定义项目名称 - anxincloudArr,//修改时已经选择的安心云列表 - anxinDelete,//修改时安心云项目有删除,显示提示信息 - appArr,//修改时添加应用 - bindId - } = props; - const { install } = actions; - const form = useRef();//表单 - const [custom, setCustom] = useState(false); //是否是自定义项目 - const [myprojectType, setMyprojectType] = useState('pep'); //是否是自定义项目 - //初始化 - useEffect(() => { - if (pepname) { - setCustom(true) - setMyprojectType('axy') - } - }, []); + const { + close, + cancel, + visible, + dispatch, + actions, + systemEdit,//是否是编辑 + peplist,//项企项目列表 + anxincloudList,//安心云项目列表 + appList,//应用列表 + pepProjectId,//已选择项企id + pepname,//修改时自定义项目名称 + anxincloudArr,//修改时已经选择的安心云列表 + anxinDelete,//修改时安心云项目有删除,显示提示信息 + appArr,//修改时添加应用 + bindId + } = props; + const { install } = actions; + const form = useRef();//表单 + const [custom, setCustom] = useState(false); //是否是自定义项目 + const [myprojectType, setMyprojectType] = useState('pep'); //是否是自定义项目 + //初始化 + useEffect(() => { + if (pepname) { + setCustom(true) + setMyprojectType('axy') + } + }, []); - function handleOk () { - //点击弹框确定 右边按钮 - form.current - .validate() - .then((values) => { - if (systemEdit) { - let appArr = [] - for (let i = 0; i < values.appId.length; i++) { - appArr.push(JSON.parse(values.appId[i]).id) - } - let bindObj = JSON.parse(JSON.stringify(values)) - bindObj.appId = appArr - dispatch(install.postProjectBind({ ...bindObj, bindId: bindId, msg: '修改映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 - if (res.success) { - close(); + function handleOk () { + //点击弹框确定 右边按钮 + form.current + .validate() + .then((values) => { + if (systemEdit) { + let appArr = [] + for (let i = 0; i < values.appId.length; i++) { + appArr.push(JSON.parse(values.appId[i]).id) + } + let bindObj = JSON.parse(JSON.stringify(values)) + bindObj.appId = appArr + dispatch(install.postProjectBind({ ...bindObj, bindId: bindId, msg: '修改映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 + if (res.success) { + close(); + } + }) + } + else { + let appArr = [] + for (let i = 0; i < values.appId.length; i++) { + appArr.push(JSON.parse(values.appId[i]).id) + } + let bindObj = JSON.parse(JSON.stringify(values)) + bindObj.appId = appArr + dispatch(install.postProjectBind({ ...bindObj, msg: '添加映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 + if (res.success) { + close(); + } + }) + } + }) + } + function handleCancel () { + cancel(); + //点击弹框取消 左边按钮 + } + const renderMultipleWithCustomTag = (optionNode, { onClose }) => { + const content = ( + + {JSON.parse(optionNode.value).name} + + ); + return { + isRenderInTag: false, + content + }; + } + return ( + <> + +
+
+
+
映射关系由项企立项项目与安心云项目关联产生,若项目未在项企中有记载,可选自定义项目,待项企立项项后再进行修改!
+
+
{ + for (var key in field) { + if (key == 'projectType') { + if (field.projectType == 'pep') { + setCustom(false) + } + else { + setCustom(true) + } } - }) - } - else { - let appArr = [] - for (let i = 0; i < values.appId.length; i++) { - appArr.push(JSON.parse(values.appId[i]).id) - } - let bindObj = JSON.parse(JSON.stringify(values)) - bindObj.appId = appArr - dispatch(install.postProjectBind({ ...bindObj, msg: '添加映射关系' })).then((res) => {//获取项企(PEP)全部部门及其下用户 - if (res.success) { - close(); + } + }} + getFormApi={(formApi) => (form.current = formApi)} + > +
+ + 项企项目 + 自定义项目(未在项企中立项的项目可选) + +
+ {custom ? ( +
+ +
+ ) : ( +
+ + { + peplist.reduce((arr, item) => { + if (!item.binded) { + arr.push( + + {item.project_name} + + ) + } + return arr + }, []) + } + +
+ )} +
+ + { + anxincloudList.map((item, index) => { + return ( + + {item.name} + + ) + }) } - }) - } - }) - } - function handleCancel () { - cancel(); - //点击弹框取消 左边按钮 - } - const renderMultipleWithCustomTag = (optionNode, { onClose }) => { - const content = ( - - {JSON.parse(optionNode.value).name} - - ); - return { - isRenderInTag: false, - content - }; - } - return ( - <> - -
-
-
-
映射关系由项企立项项目与安心云项目关联产生,若项目未在项企中有记载,可选自定义项目,待项企立项项后再进行修改!
-
- { - for (var key in field) { - if (key == 'projectType') { - if (field.projectType == 'pep') { - setCustom(false) - } - else { - setCustom(true) - } - } - } - }} - getFormApi={(formApi) => (form.current = formApi)} - > -
- - 项企项目 - 自定义项目(未在项企中立项的项目可选) - -
- {custom ? ( -
- -
- ) : ( -
- - { - peplist.map((item, index) => { - return ( - - {item.project_name} - - ) - }) - } - -
- )} -
- - { - anxincloudList.map((item, index) => { - return ( - - {item.name} - - ) - }) - } - + +
+ { + anxinDelete.length > 0 ? ( +
+
+ +
+
+ 确认关联后“{anxinDelete.join('、')}”将被系统移除映射关系,原因是项目已在【安心云】中被删除! +
+ ) : ('') + } +
+ { - anxinDelete.length > 0 ? ( -
-
- + appList.map((item, index) => { + return ( + +
+ {item.name} +
+
+ URL:{item.url} +
-
- 确认关联后“{anxinDelete.join('、')}”将被系统移除映射关系,原因是项目已在【安心云】中被删除! -
-
- ) : ('') + }> + + ) + }) } -
- - { - appList.map((item, index) => { - return ( - -
- {item.name} -
-
- URL:{item.url} -
-
- }> - - ) - }) - } -
-
- -
-
- - ); +
+
+ +
+
+ + ); } function mapStateToProps (state) { - const { auth, global, members } = state; - return { - // loading: members.isRequesting, - user: auth.user, - actions: global.actions, - // members: members.data, - }; + const { auth, global, members } = state; + return { + // loading: members.isRequesting, + user: auth.user, + actions: global.actions, + // members: members.data, + }; } export default connect(mapStateToProps)(adminModal);