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
{item === 'done' ? + 完成 + : + 未完成 + }
+ }, + filters: [{ + text: '完成', + value: 'done' + }, { + text: '未完成', + value: 'undone' + }], + onFilter: (value, record) => record.status.indexOf(value) === 0 + }, { title: '更新日期', dataIndex: 'add_time', - key: 'add_time' + key: 'add_time', + render: (item) => { + return {formatTime(item)} + } }] - const data = this.state.data.map(item=>{ + const data = this.state.data.map(item => { item.key = item._id; return item; }); - + return ( -
- - +
+

接口列表

+
+ ) } } diff --git a/server/controllers/interface.js b/server/controllers/interface.js index 1c8e4d4f..9423bcf3 100644 --- a/server/controllers/interface.js +++ b/server/controllers/interface.js @@ -311,6 +311,10 @@ class interfaceController extends baseController { data.res_body = params.res_body; } + if(params.status){ + data.status = params.status; + } + try { let result = await this.Model.up(id, data); ctx.body = yapi.commons.resReturn(result); diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js index e90259c3..39a0f8f8 100644 --- a/server_dist/controllers/interface.js +++ b/server_dist/controllers/interface.js @@ -622,29 +622,33 @@ var interfaceController = function (_baseController) { data.res_body = params.res_body; } - _context6.prev = 32; - _context6.next = 35; + if (params.status) { + data.status = params.status; + } + + _context6.prev = 33; + _context6.next = 36; return this.Model.up(id, data); - case 35: + case 36: result = _context6.sent; ctx.body = _yapi2.default.commons.resReturn(result); - _context6.next = 42; + _context6.next = 43; break; - case 39: - _context6.prev = 39; - _context6.t0 = _context6['catch'](32); + case 40: + _context6.prev = 40; + _context6.t0 = _context6['catch'](33); ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message); - case 42: + case 43: case 'end': return _context6.stop(); } } - }, _callee6, this, [[32, 39]]); + }, _callee6, this, [[33, 40]]); })); function up(_x6) {