mirror of
https://github.com/YMFE/yapi.git
synced 2025-02-05 13:29:43 +08:00
fix: 修改interfaceList 请求
This commit is contained in:
parent
9b3a2e6d51
commit
b00657f748
@ -6,7 +6,7 @@ import {
|
||||
Table, Button, Modal, message, Tooltip, Select
|
||||
} from 'antd';
|
||||
import AddInterfaceForm from './AddInterfaceForm';
|
||||
import { fetchInterfaceListMenu, fetchInterfaceList } from '../../../../reducer/modules/interface.js';
|
||||
import { fetchInterfaceListMenu, fetchInterfaceList, fetchInterfaceCatList } from '../../../../reducer/modules/interface.js';
|
||||
import { Link } from 'react-router-dom';
|
||||
import variable from '../../../../constants/variable';
|
||||
import './Edit.scss';
|
||||
@ -17,11 +17,14 @@ const Option = Select.Option;
|
||||
return {
|
||||
curData: state.inter.curdata,
|
||||
curProject: state.project.currProject,
|
||||
catList: state.inter.list
|
||||
catList: state.inter.list,
|
||||
totalTableList: state.inter.totalTableList,
|
||||
catTableList: state.inter.catTableList
|
||||
}
|
||||
}, {
|
||||
fetchInterfaceListMenu,
|
||||
fetchInterfaceList
|
||||
fetchInterfaceList,
|
||||
fetchInterfaceCatList
|
||||
})
|
||||
class InterfaceList extends Component {
|
||||
constructor(props) {
|
||||
@ -40,7 +43,8 @@ class InterfaceList extends Component {
|
||||
curProject: PropTypes.object,
|
||||
history: PropTypes.object,
|
||||
fetchInterfaceListMenu: PropTypes.func,
|
||||
fetchInterfaceList: PropTypes.func
|
||||
fetchInterfaceList: PropTypes.func,
|
||||
fetchInterfaceCatList: PropTypes.func
|
||||
}
|
||||
|
||||
handleRequest = async (props) => {
|
||||
@ -50,7 +54,7 @@ class InterfaceList extends Component {
|
||||
this.setState({
|
||||
catid: null
|
||||
})
|
||||
|
||||
|
||||
let r = await this.props.fetchInterfaceList(projectId);
|
||||
this.setState({
|
||||
data: r.payload.data.data
|
||||
@ -59,9 +63,9 @@ class InterfaceList extends Component {
|
||||
} else if (isNaN(params.actionId)) {
|
||||
let catid = params.actionId.substr(4)
|
||||
this.setState({ catid: +catid })
|
||||
let r = await axios.get('/api/interface/list_cat?catid=' + catid);
|
||||
let r = await this.props.fetchInterfaceCatList(catid);
|
||||
this.setState({
|
||||
data: r.data.data
|
||||
data: r.payload.data.data
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -84,9 +88,9 @@ class InterfaceList extends Component {
|
||||
if (this.actionId !== _actionId) {
|
||||
this.actionId = _actionId;
|
||||
this.handleRequest(nextProps)
|
||||
} else if( this.props.catList !== nextProps.catList){
|
||||
} else if (this.props.catList !== nextProps.catList) {
|
||||
this.handleRequest(nextProps)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,8 @@ const DELETE_INTERFACE_CAT_DATA = 'yapi/interface/DELETE_INTERFACE_CAT_DATA';
|
||||
const UPDATE_INTERFACE_DATA = 'yapi/interface/UPDATE_INTERFACE_DATA';
|
||||
const CHANGE_EDIT_STATUS = 'yapi/interface/CHANGE_EDIT_STATUS';
|
||||
const FETCH_INTERFACE_LIST = 'yapi/interface/FETCH_INTERFACE_LIST';
|
||||
const SAVE_IMPORT_DATA = 'yapi/interface/SAVE_IMPORT_DATA'
|
||||
const SAVE_IMPORT_DATA = 'yapi/interface/SAVE_IMPORT_DATA';
|
||||
const FETCH_INTERFACE_CAT_LIST = 'yapi/interface/FETCH_INTERFACE_CAT_LIST'
|
||||
// const SAVE_INTERFACE_PROJECT_ID = 'yapi/interface/SAVE_INTERFACE_PROJECT_ID';
|
||||
// const GET_INTERFACE_GROUP_LIST = 'yapi/interface/GET_INTERFACE_GROUP_LIST';
|
||||
|
||||
@ -16,8 +17,10 @@ const SAVE_IMPORT_DATA = 'yapi/interface/SAVE_IMPORT_DATA'
|
||||
const initialState = {
|
||||
curdata: {},
|
||||
list: [],
|
||||
editStatus: false // 记录编辑页面是否有编辑,
|
||||
|
||||
editStatus: false, // 记录编辑页面是否有编辑,
|
||||
totalTableList: [],
|
||||
catTableList: []
|
||||
|
||||
}
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
@ -25,7 +28,7 @@ export default (state = initialState, action) => {
|
||||
case INIT_INTERFACE_DATA:
|
||||
return initialState
|
||||
case UPDATE_INTERFACE_DATA:
|
||||
|
||||
|
||||
return {
|
||||
...state,
|
||||
curdata: Object.assign({}, state.curdata, action.updata)
|
||||
@ -46,6 +49,20 @@ export default (state = initialState, action) => {
|
||||
editStatus: action.status
|
||||
};
|
||||
}
|
||||
|
||||
case FETCH_INTERFACE_LIST: {
|
||||
return {
|
||||
...state,
|
||||
totalTableList: action.payload.data.data
|
||||
};
|
||||
}
|
||||
|
||||
case FETCH_INTERFACE_CAT_LIST: {
|
||||
return {
|
||||
...state,
|
||||
catTableList: action.payload.data.data
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
@ -87,7 +104,7 @@ export async function deleteInterfaceData(id) {
|
||||
export async function saveImportData(data) {
|
||||
let result = await axios.post('/api/interface/save', data)
|
||||
return {
|
||||
type:SAVE_IMPORT_DATA,
|
||||
type: SAVE_IMPORT_DATA,
|
||||
payload: result
|
||||
}
|
||||
}
|
||||
@ -125,3 +142,11 @@ export async function fetchInterfaceList(projectId) {
|
||||
payload: result
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchInterfaceCatList(catid) {
|
||||
let result = await axios.get('/api/interface/list_cat?catid=' + catid);
|
||||
return {
|
||||
type: FETCH_INTERFACE_CAT_LIST,
|
||||
payload: result
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user