diff --git a/src/forge/Order/order_form.js b/src/forge/Order/order_form.js index 19a0eaeb0..2eb5e4299 100644 --- a/src/forge/Order/order_form.js +++ b/src/forge/Order/order_form.js @@ -47,25 +47,29 @@ 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=>{ + }; + + copyIssueAtWhoInit = (description) =>{ + if (description.indexOf("@") !== -1){ + this.setState({isSpin: true}); + const { projectsId, owner } = this.props.match.params; + axios.get(`/${owner}/${projectsId}/members.json`).then(response => { + this.setState({ isSpin: false}); if (response.data.total_count !== 0) { - allUser = response.data.users + const 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) }); + } } }) - 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({ @@ -97,6 +101,9 @@ class order_form extends Component { due_date: result.data.due_date, subject: result.data.subject, } + if (this.props.form_type === "copy" && result.data.description){ + this.copyIssueAtWhoInit(result.data.description); + } this.props.form.setFieldsValue({ ...data }); this.setState({ ...data }); } @@ -261,8 +268,10 @@ class order_form extends Component { //issue中at谁列表(存储:login) changeAtWhoLoginList = (loginList) =>{ + let list = new Set(this.state.atWhoLoginList); + loginList.map(item => list.add(item)); this.setState({ - atWhoLoginList:loginList, + atWhoLoginList: Array.from(list), }); }; @@ -374,7 +383,7 @@ class order_form extends Component { mdID={"order-new-description"} initValue={description} onChange={this.onContentChange} - isCanAtme = {form_type} + isCanAtme = {true} changeAtWhoLoginList = {this.changeAtWhoLoginList} owner = {owner} projectsId = {projectsId} diff --git a/src/modules/tpm/challengesnew/tpm-md-editor.js b/src/modules/tpm/challengesnew/tpm-md-editor.js index 9065c6c29..46c01ec37 100644 --- a/src/modules/tpm/challengesnew/tpm-md-editor.js +++ b/src/modules/tpm/challengesnew/tpm-md-editor.js @@ -106,20 +106,6 @@ 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) { @@ -211,7 +197,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla } useEffect(()=>{ - changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginList.current); + changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginListState); },[atWhoLoginListState]) const atWhoList = (