diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js index 47c94ff1..93184f73 100644 --- a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js @@ -105,7 +105,6 @@ class InterfaceEditForm extends Component { values.req_headers = values.req_headers.filter((item)=> item.name !== '') values.req_body_form = values.req_body_form.filter((item)=> item.name !== '') values.req_params = values.req_params.filter(item=>item.name !== '') - this.props.onSubmit(values) } }); diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceList.js b/client/containers/Project/Interface/InterfaceList/InterfaceList.js index 5726e9b7..faa646a4 100644 --- a/client/containers/Project/Interface/InterfaceList/InterfaceList.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceList.js @@ -1,16 +1,17 @@ -import React,{Component} from 'react' +import React, { Component } from 'react' import PropTypes from 'prop-types' import axios from 'axios' import { - Table + Table, Tag } from 'antd'; -class InterfaceList extends Component{ - constructor(props){ +import { formatTime } from '../../../../common.js' +class InterfaceList extends Component { + constructor(props) { super(props) this.state = { - data : [], + data: [], sortedInfo: { - order: 'descend', + order: 'ascend', columnKey: 'title' } } @@ -20,15 +21,15 @@ class InterfaceList extends Component{ match: PropTypes.object } - handleRequest = async (props)=>{ - const {params} = props.match; - if(!params.actionId){ + handleRequest = async (props) => { + const { params } = props.match; + if (!params.actionId) { let projectId = params.id; let r = await axios.get('/api/interface/list?project_id=' + projectId); this.setState({ data: r.data.data }) - }else if(isNaN(params.actionId)){ + } else if (isNaN(params.actionId)) { let catid = params.actionId.substr(4) let r = await axios.get('/api/interface/list_cat?catid=' + catid); this.setState({ @@ -43,51 +44,76 @@ class InterfaceList extends Component{ }); } - componentWillMount(){ + componentWillMount() { this.actionId = this.props.match.params.actionId; this.handleRequest(this.props) } - componentWillReceiveProps(nextProps){ + componentWillReceiveProps(nextProps) { let _actionId = nextProps.match.params.actionId; - if(this.actionId !== _actionId){ - this.actionId = _actionId; + if (this.actionId !== _actionId) { + this.actionId = _actionId; this.handleRequest(nextProps) } } - render () { + render() { let { sortedInfo } = this.state; sortedInfo = sortedInfo || {}; const columns = [{ title: '接口名称', dataIndex: 'title', key: 'title', - sorter: (a, b) => b.title.length - a.title.length, + sorter: (a, b) => { + return a.title.localeCompare(b.title) === 1 + }, sortOrder: sortedInfo.columnKey === 'title' && sortedInfo.order - },{ + }, { title: '接口URL', dataIndex: 'path', key: 'path' - },{ + }, { title: '请求方式', dataIndex: 'method', key: 'method' - },{ + }, { + title: '状态', + dataIndex: 'status', + key: 'status', + render: (item) => { + return