From ea09ca58aa4383ee8777844d295cd8ebcb0f5e36 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 24 Feb 2023 14:43:56 +0800 Subject: [PATCH] save cookie --- src/forge/Issues/Component/colorCard.jsx | 1 - src/forge/Issues/Component/datas.jsx | 1 - src/forge/Issues/Component/dropMenu.jsx | 172 +++++++++++++++++++++++ src/forge/Issues/Component/editMenus.jsx | 16 ++- src/forge/Issues/Component/newPanel.jsx | 2 - src/forge/Issues/Pages/details.jsx | 21 ++- src/forge/Issues/Pages/list.jsx | 35 +++-- src/forge/Issues/Pages/sign.jsx | 8 ++ src/forge/Issues/index.scss | 5 +- 9 files changed, 236 insertions(+), 25 deletions(-) create mode 100644 src/forge/Issues/Component/dropMenu.jsx diff --git a/src/forge/Issues/Component/colorCard.jsx b/src/forge/Issues/Component/colorCard.jsx index 38862a9e5..decb545f7 100644 --- a/src/forge/Issues/Component/colorCard.jsx +++ b/src/forge/Issues/Component/colorCard.jsx @@ -7,7 +7,6 @@ function ColorCard({getColor,defaultColor}){ const [ textcolor , setTextColor ] = useState("#F17013"); useEffect(()=>{ - console.log(defaultColor); defaultColor && setTextColor(defaultColor); },[defaultColor]) diff --git a/src/forge/Issues/Component/datas.jsx b/src/forge/Issues/Component/datas.jsx index 13e640ae4..61e7356f4 100644 --- a/src/forge/Issues/Component/datas.jsx +++ b/src/forge/Issues/Component/datas.jsx @@ -9,7 +9,6 @@ import Copy from '../Component/copy'; function Datas({checkbox ,item , projectsId,owner}){ let host = window.location.hostname === "localhost" ? "testforgeplus.trustie.net" : window.location.hostname; let protocol = window.location.protocol; - console.log("protocol:",protocol); function statusTag(name){ switch (name) { case "低": diff --git a/src/forge/Issues/Component/dropMenu.jsx b/src/forge/Issues/Component/dropMenu.jsx new file mode 100644 index 000000000..6d12418b9 --- /dev/null +++ b/src/forge/Issues/Component/dropMenu.jsx @@ -0,0 +1,172 @@ +import React ,{ useState , useEffect , useRef } from 'react'; +import { findDOMNode } from 'react-dom'; +import { Dropdown , Menu , Input , message} from 'antd'; +import { getImageUrl } from 'educoder'; + +const { Search } = Input; +/** + * + * @param {placeholder} placeholder:默认显示内容(为空时) + * @param {editFlag} editFlag:是否显示编辑按钮 + * @param {searchFlag} editFlag:是否显示搜索框 + * @param {selectValueList} selectValueList:将选中的list保存 + * @param {searchFunc} searchFunc:搜索方法 + * @param {onAdd} onAdd:标记管理 + * @param {headImg} headImg:是否显示头像 + * @param {menus} menus:下拉列表 + * @param {chooseFunc} chooseFunc:选择下拉列表 + * @param {double} double:undefined为单选,有值就是最多选的数量 + * @returns + */ +function DropMenu({ + placeholder ="未设置", + editFlag, + searchFlag, + selectValueList, + searchFunc, + onAdd, + headImg, + menus, + chooseFunc,double +}){ + const [ visible , setVisible ] = useState(false); + const [ searchValue , setSearchValue ]= useState(undefined); + const [ valuesId , setValuesId ] = useState([]); + const [ valuesName , setValuesName ] = useState([]); + + const refFa = useRef(null); + const refBox = useRef(null); + + // 根据选中的列表循环出id数组 + useEffect(()=>{ + if(selectValueList && selectValueList.length > 0 ){ + renderSelectList(selectValueList); + }else{ + setValuesId([]) + } + },[selectValueList]) + + function renderSelectList(list){ + console.log(list); + let a = list.map((i,k)=>{ + return i.id.toString() || i.name + }) + let n = list.map((i,k)=>{ + return i.name + }) + console.log("根据选中的列表循环出id数组:",a); + setValuesId(a); + setValuesName(n); + } + + useEffect(() => { + document.addEventListener('click', clickMe , false); + }, []) + + const clickMe = ({ target }) => { + // 查找父组件 + const faComponent = findDOMNode(refFa.current); + const boxComponent = findDOMNode(refBox.current); + if (faComponent && boxComponent) { + const isChild = faComponent.contains(target); + const isBox = boxComponent.contains(target); + if(!isChild && !isBox){ + setVisible(false); + } + } + } + // 搜索 + function changeSearchvalue(e){ + setSearchValue(e.target.value); + searchFunc(e.target.value); + } + + function chooseMenu(i){ + let list = selectValueList; + let re = []; + re = list && list.length > 0 ? list:[]; + let filter = list.filter(j=>j.id === i.id); + + if(filter && filter.length > 0){ + re = list.filter(j=>j.id !== i.id) ; + }else{ + if(double && (selectValueList && selectValueList.length >= double)){ + message.info(`最多只能添加${double}个${placeholder}`); + return; + } + re.push(i); + } + console.log("选择后:",re); + renderSelectList(re); + chooseFunc(re); + } + + function renderNames(nameArrs){ + return + { + nameArrs && nameArrs.length>0? + nameArrs.map((i,k)=>{ + return( +

{i}

+ ) + }) + :"" + } +
+ } + return( +
  • + + {placeholder} + {!editFlag && + setVisible(visible ? false : true)}> + + + } + + + { searchFunc && +
    + +
    + } + { + menus && menus.length >0? + + { + menus.map((i,k)=>{ + return( + chooseMenu(i)}> + { headImg && } + {i.color && } + {i.name} + + ) + }) + } + + : +
    +

    {searchValue ? 暂无{placeholder}“{searchValue}”: `暂无${placeholder}`}

    + { onAdd && {setVisible(false);onAdd()}}>标记管理} +
    + } + + }> +
    0 ? "operatevalue color-grey-3":"operatevalue"}>{renderNames(valuesName) || placeholder}
    +
    +
  • + ) +} +export default DropMenu; \ No newline at end of file diff --git a/src/forge/Issues/Component/editMenus.jsx b/src/forge/Issues/Component/editMenus.jsx index 09290a4ad..9de525488 100644 --- a/src/forge/Issues/Component/editMenus.jsx +++ b/src/forge/Issues/Component/editMenus.jsx @@ -110,6 +110,20 @@ function EditMenus({ searchFunc(e.target.value); } + function renderNames(nameArrs){ + return + { + nameArrs && nameArrs.length>0? + nameArrs.map((i,k)=>{ + return( +

    {i}

    + ) + }) + :"" + } +
    + } + return(
  • @@ -157,7 +171,7 @@ function EditMenus({ } }> -

    { (names && names.join(",")) || emptyName}

    +
    { names ? renderNames(names) : emptyName}
  • ) diff --git a/src/forge/Issues/Component/newPanel.jsx b/src/forge/Issues/Component/newPanel.jsx index 9bae37aba..f147d1ff4 100644 --- a/src/forge/Issues/Component/newPanel.jsx +++ b/src/forge/Issues/Component/newPanel.jsx @@ -43,7 +43,6 @@ function NewPanel(props,ref){ if(list && list.length>0 ){ arr = list.filter(i=>i.id !== id); } - console.log(arr.map(i=>{return i.id})); setFileList(arr.map(i=>{return i.id})); } @@ -56,7 +55,6 @@ function NewPanel(props,ref){ function sureFunc(){ validateFields((error,values)=>{ if (!error) { - console.log(fileList); createFunc(values,fileList,receivers_login,description); } }) diff --git a/src/forge/Issues/Pages/details.jsx b/src/forge/Issues/Pages/details.jsx index a5d4560c8..13b547d7b 100644 --- a/src/forge/Issues/Pages/details.jsx +++ b/src/forge/Issues/Pages/details.jsx @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom'; import { Box , LongWidth } from '../../Component/layout'; import RenderHtml from "../../../components/render-html"; import EditMenus from '../Component/editMenus'; +import DropMenu from '../Component/dropMenu'; import Add from '../Component/comments/add'; import NewPanel from '../Component/newPanel'; import Attachments from "../../Upload/attachment"; @@ -48,6 +49,8 @@ function Details(props){ const [ start_date, setStartDate ] = useState(""); const [ due_date, setDueDate ] = useState(""); + + const [ assigner_choose , setAssigner_choose ] = useState([]); const pathname = props.history.location.pathname; useEffect(()=>{ @@ -72,6 +75,9 @@ function Details(props){ if(result && result.data){ let data = result.data; setDetails(data); + + setAssigner_choose(data.assigners); + let cIds = data.assigners && data.assigners.length>0 ? data.assigners.map((i)=>{return i.id.toString();}):undefined; let cNames = data.assigners && data.assigners.length>0 ? data.assigners.map((i)=>{return i.name.toString();}):undefined; setCharegeId(cIds); @@ -84,10 +90,10 @@ function Details(props){ setBranchId(data.branch_name && [data.branch_name]); const n = { issue_priorities_name:data.priority ? [`${data.priority.name}`]:undefined, - issue_tag_name:tagNames && [tagNames], + issue_tag_name:tagNames, milestone_name:data.milestone ? [`${data.milestone.name}`]:undefined, status_name:data.status ? [`${data.status.name}`]:undefined, - assigner_name:cNames && [cNames] + assigner_name:cNames } setNames(n); data.start_date && setStartDate(moment(data.start_date).format('YYYY-MM-DD')); @@ -265,7 +271,6 @@ function Details(props){ }).catch(error=>{}) }else{ // 调用新建保存接口 - console.log(branchId,statusId,prioritiesId,millstoneId,tagId, charegeId); const url = `/v1/${owner}/${projectsId}/issues`; axios.post(url,{ ...params, @@ -374,6 +379,16 @@ function Details(props){ */}
    + {/* {setCharge(value)}} + headImg + selectValueList={assigner_choose} + chooseFunc={(list)=>{setAssigner_choose(list)}} + double={5} + /> */} + {saveForeach(ids);let copyname = { ...names,assigner_name:name};setNames(copyname);setCharegeId(ids);}} list={chargeList} value={charegeId} searchFlag searchFunc={(value)=>{setCharge(value)}} double={5} editFlag={details && !details.user_permission}/> {setStatusId(ids);saveForeach(undefined,ids);let copyname = { ...names,status_name:name};setNames(copyname);}} list={statusList} value={statusId} editFlag={details && !details.user_permission}/> {setPrioritiesId(ids);saveForeach(undefined,undefined,ids);let copyname = { ...names,issue_priorities_name:name};setNames(copyname);}} list={prioritiesList} value={prioritiesId} editFlag={details && !details.user_permission}/> diff --git a/src/forge/Issues/Pages/list.jsx b/src/forge/Issues/Pages/list.jsx index 5019f21c1..26e8d0afa 100644 --- a/src/forge/Issues/Pages/list.jsx +++ b/src/forge/Issues/Pages/list.jsx @@ -5,6 +5,7 @@ import issueEmp from '../Img/issue-big.png'; import create from '../Img/create.png'; import { Link } from "react-router-dom"; import AllMenus from '../Component/allMenus'; +import CheckProfile from '../../Component/ProfileModal/Profile' import Datas from '../Component/datas'; import DelBox from '../Component/delBox'; import axios from 'axios'; @@ -118,18 +119,17 @@ function List(props){ // 获取issue列表数据 function Init(params,p,names){ const url = `/v1/${owner}/${projectsId}/issues`; - let getParams ={ - participant_category:aboutMe, - keyword,category, - limit, - ...params, - page:p || page, - sort_direction:getDirection(params && params.sort_by), - sort_by:getBy(params && params.sort_by) - } - console.log(getParams); axios.get(url,{ - params:{...getParams,names:undefined} + params:{ + keyword, + participant_category:aboutMe, + category, + limit, + ...params, + page:p || page, + sort_direction:getDirection(params && params.sort_by), + sort_by:getBy(params && params.sort_by), + names:undefined} }).then(result=>{ if(result){ setIssueList(result.data.issues); @@ -141,7 +141,14 @@ function List(props){ setIssueTotal(result.data.total_issues_count); setHas_created_issues(result.data.has_created_issues); - let d={...getParams,names:{...names}} + let d={keyword, + participant_category:aboutMe, + category, + limit, + ...params, + page:p || page, + sort_direction:getDirection(params && params.sort_by), + sort_by:getBy(params && params.sort_by),names:{...names}} let inFifteenMinutes = new Date(new Date().getTime() + 24 * 3600 * 1000); cookie.save('states', {...d},{ expires: inFifteenMinutes,path:`/` }); } @@ -313,7 +320,7 @@ function List(props){ permission && permission !== "reporter" && 标记管理 } - 创建疑修 + {props.history.push(`/${owner}/${projectsId}/issues/new`)}} className="operateButton ml20">创建疑修
    @@ -358,7 +365,7 @@ function List(props){

    欢迎使用疑修(Issue)

    -

    疑修用于记录与跟踪待办事项、项目bug、功能需求等。在使用之前,请您先创建一个疑修

    +

    疑修用于记录与跟踪待办事项、项目bug、功能需求等。在使用之前,请您先{props.history.push(`/${owner}/${projectsId}/issues/new`)}} className="color-blue">创建一个疑修

    :
    diff --git a/src/forge/Issues/Pages/sign.jsx b/src/forge/Issues/Pages/sign.jsx index 228795294..75b2b4ba7 100644 --- a/src/forge/Issues/Pages/sign.jsx +++ b/src/forge/Issues/Pages/sign.jsx @@ -26,6 +26,14 @@ function Sign(props){ const [ key , setKey ] = useState("0"); const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; + const { projectDetail } = props; + + useEffect(()=>{ + if(projectDetail){ + const { author, name } = projectDetail; + document.title = `项目标记-${author.name}/${name}`; + } + },[projectDetail]) useEffect(()=>{ Init(); diff --git a/src/forge/Issues/index.scss b/src/forge/Issues/index.scss index 8c4012956..930d92973 100644 --- a/src/forge/Issues/index.scss +++ b/src/forge/Issues/index.scss @@ -416,7 +416,7 @@ padding-left: 50px; &>li{ border-bottom: 1px solid rgba(172, 176, 191, 0.17); - padding-bottom: 12px; + padding-bottom: 8px; margin-bottom: 22px!important; &>span{ font-size: 15px; @@ -434,8 +434,7 @@ } } .operatevalue{ - height: 20px; - line-height: 20px; + line-height: 24px; color: #acb0bf; margin-top: 10px; }