From 4ed17d3d90e0a3dac6f38b9eac5d72c1a36a5271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=B8=8C=E9=87=8C?= Date: Sat, 30 Sep 2017 14:47:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=A4=8D=E7=8E=B0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=20undefined=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/controllers/interface.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/controllers/interface.js b/server/controllers/interface.js index 69090f18..d553146b 100755 --- a/server/controllers/interface.js +++ b/server/controllers/interface.js @@ -472,8 +472,8 @@ class interfaceController extends baseController { try { let result = await this.Model.up(id, data); let username = this.getUsername(); - if (params.catid) { - this.catModel.get(+params.catid).then((cate) => { + if (data.catid) { + this.catModel.get(+data.catid).then((cate) => { yapi.commons.saveLog({ content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`, type: 'project', From 326e84a033c9ae59f122a30bebbef6a1dacf7738 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Sat, 30 Sep 2017 20:34:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20tab=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/InterfaceCol/InterfaceCaseContent.js | 5 +---- .../Project/Interface/InterfaceCol/InterfaceColMenu.js | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceCaseContent.js b/client/containers/Project/Interface/InterfaceCol/InterfaceCaseContent.js index 4bf2cb3d..31176696 100755 --- a/client/containers/Project/Interface/InterfaceCol/InterfaceCaseContent.js +++ b/client/containers/Project/Interface/InterfaceCol/InterfaceCaseContent.js @@ -83,12 +83,9 @@ export default class InterfaceCaseContent extends Component { async componentWillReceiveProps(nextProps) { const oldCaseId = this.props.match.params.actionId const newCaseId = nextProps.match.params.actionId - const id = this.props.match.params.id; const { interfaceColList } = nextProps; let currColId = this.getColId(interfaceColList, newCaseId); - if(!currColId) { - this.props.history.push('/project/' + id + '/interface/col/' + interfaceColList[0]._id) - } else if (oldCaseId !== newCaseId) { + if (oldCaseId !== newCaseId) { await this.props.fetchCaseData(newCaseId); this.props.setColData({currCaseId: +newCaseId, currColId, isShowCol: false}) this.setState({editCasename: this.props.currCase.casename}) diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js index 09cf5c07..16dce076 100755 --- a/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js +++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColMenu.js @@ -171,6 +171,7 @@ export default class InterfaceColMenu extends Component { } showDelCaseConfirm = (caseId) => { let that = this; + const params = this.props.match.params; confirm({ title: '您确认删除此测试用例', content: '温馨提示:用例删除后无法恢复', @@ -178,7 +179,13 @@ export default class InterfaceColMenu extends Component { const res = await axios.get('/api/col/del_case?caseid=' + caseId) if (!res.data.errcode) { message.success('删除用例成功'); - await that.props.fetchInterfaceColList(that.props.match.params.id); + + // 如果删除当前选中 case,切换路由到集合 + if (+caseId === +that.props.currCaseId) { + that.props.history.push('/project/' + params.id + '/interface/col/') + } else { + that.props.fetchInterfaceColList(that.props.match.params.id); + } } else { message.error(res.data.errmsg); }