feat: 更新用例

This commit is contained in:
zwjamnsss 2017-08-24 11:11:38 +08:00
parent cd68abf810
commit f7b945ba08
3 changed files with 40 additions and 36 deletions

View File

@ -2,6 +2,8 @@ import React, { Component } from 'react'
import { connect } from 'react-redux';
import PropTypes from 'prop-types'
import { withRouter } from 'react-router'
import axios from 'axios'
import { message } from 'antd'
import { fetchInterfaceColList, setColData, fetchCaseData } from '../../../../reducer/modules/interfaceCol'
import { Postman } from '../../../../components'
@ -77,39 +79,41 @@ export default class InterfaceCaseContent extends Component {
}
}
updateCase = () => {
// const project_id = this.props.match.params.id;
// const {
// currDomain: domain,
// pathname: path,
// method,
// pathParam: req_params,
// query: req_query,
// headers: req_headers,
// bodyType: req_body_type,
// bodyForm: req_body_form,
// bodyOther: req_body_other
// } = this.postman.state;
// const res = await axios.post('/api/col/add_case', {
// casename: caseName,
// col_id: colId,
// project_id,
// domain,
// path,
// method,
// req_params,
// req_query,
// req_headers,
// req_body_type,
// req_body_form,
// req_body_other
// });
// if (res.data.errcode) {
// message.error(res.data.errmsg)
// } else {
// message.success('添加成功')
// this.setState({saveCaseModalVisible: false})
// }
savePostmanRef = (postman) => {
this.postman = postman;
}
updateCase = async () => {
const {
currDomain: domain,
pathname: path,
method,
pathParam: req_params,
query: req_query,
headers: req_headers,
bodyType: req_body_type,
bodyForm: req_body_form,
bodyOther: req_body_other
} = this.postman.state;
const {_id: id, casename} = this.props.currCase;
const res = await axios.post('/api/col/up_case', {
id,
casename,
domain,
path,
method,
req_params,
req_query,
req_headers,
req_body_type,
req_body_form,
req_body_other
});
if (res.data.errcode) {
message.error(res.data.errmsg)
} else {
message.success('更新成功')
}
}
render() {
@ -119,7 +123,7 @@ export default class InterfaceCaseContent extends Component {
<div>
<h1 style={{marginLeft: 8}}>{currCase.casename}</h1>
<div>
<Postman data={data} type="case" saveTip="更新保存修改" save={this.updateCase} />
<Postman data={data} type="case" saveTip="更新保存修改" save={this.updateCase} ref={this.savePostmanRef} />
</div>
</div>
)

View File

@ -199,7 +199,7 @@ class interfaceColController extends baseController{
params.uid = this.getUid();
let result = await this.caseModel.up(params);
let result = await this.caseModel.up(params.id, params);
ctx.body = yapi.commons.resReturn(result);

View File

@ -435,7 +435,7 @@ var interfaceColController = function (_baseController) {
params.uid = this.getUid();
_context5.next = 10;
return this.caseModel.up(params);
return this.caseModel.up(params.id, params);
case 10:
result = _context5.sent;