diff --git a/src/forge/Order/order_form.js b/src/forge/Order/order_form.js index 2b6ba2d77..19a0eaeb0 100644 --- a/src/forge/Order/order_form.js +++ b/src/forge/Order/order_form.js @@ -47,7 +47,26 @@ class order_form extends Component { } componentDidMount = () => { this.getSelectList(); + //如果是复制issue则需要将原内容中的@谁录入 @列表中 (在tpm-md-editor.js中其实有处理,但是当用户点击【复制】按钮之后迅速创建issue会有延迟导致@失效) + if (this.state.form_type === "copy"){ + let allUser = undefined; + axios.get(`/${owner}/${projectsId}/members.json`).then(response=>{ + if (response.data.total_count !== 0) { + allUser = response.data.users + } + }) + if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) { + const list = new Set(); + allUser.map(item => { + if (description.indexOf(`[@${item.username}](/${item.login})`) !== -1) { + list.add(item.login); + } + }) + this.setState({ atWhoLoginList: Array.from(list)}); + } + } }; + get_detail = () => { this.setState({ isSpin:true diff --git a/src/modules/tpm/challengesnew/tpm-md-editor.js b/src/modules/tpm/challengesnew/tpm-md-editor.js index 030a05e0d..9065c6c29 100644 --- a/src/modules/tpm/challengesnew/tpm-md-editor.js +++ b/src/modules/tpm/challengesnew/tpm-md-editor.js @@ -90,7 +90,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla const containerId = `mdEditor_${mdID}`; const editorBodyId = `mdEditors_${mdID}`; const tipId = `e_tips_mdEditor_${mdID}`; - const [init, setInit] = useState(true); useEffect(()=>{ //请求members接口获取全部可@列表 @@ -107,6 +106,20 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla }) },[]) + useEffect(()=>{ + //如果是复制issue则需要将原内容中的@谁录入 @列表中 + if (isCanAtme === "copy" && initValue && initValue.indexOf("@") !== -1) { + allUsers.map(item=>{ + if (initValue.indexOf(`[@${item.username}](/${item.login})`) !== -1) { + const list = new Set(atWhoLoginList.current); + list.add(item.login); + atWhoLoginList.current = Array.from(list); + setAtWhoLoginListState(Array.from(list)); + } + }) + } + }, [initValue]) + function onLayout() { let ro; if (editorEl.current) { @@ -198,7 +211,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla } useEffect(()=>{ - changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginListState); + changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginList.current); },[atWhoLoginListState]) const atWhoList = ( @@ -296,17 +309,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla const cmEl = editorInstance && editorInstance.cm - useEffect(() => { - //如果是复制issue则需要将原内容中的@谁录入 @列表中 - if (init && cmEl && initValue && isCanAtme === "copy" && initValue.indexOf("@") !== -1) { - allUsers.map(item => { - initValue.indexOf(`[@${item.username}](/${item.login})`) !== -1 && selectAtWho(item.username); - }) - setInit(false); - console.log('复制issue atWhoLoginList.current', atWhoLoginList.current, 'atWhoLoginListState', atWhoLoginListState); - } - }, [initValue]) - useEffect(()=>{ if(atWhoVisibleRef.current){ // 添加上下键、enter键监听事件