diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js index d19ef122d..ba6ee3ee3 100755 --- a/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceMenu.js @@ -104,9 +104,6 @@ class InterfaceMenu extends Component { async getList() { let r = await this.props.fetchInterfaceListMenu(this.props.projectId); - r.payload.data.data.forEach(item => { - item.parent_id = item.parent_id || 0 - }) this.setState({ list: r.payload.data.data }); @@ -676,7 +673,7 @@ class InterfaceMenu extends Component { return a.index - b.index;//从小到大排序 }); }); - const resultArray = temp.sort((a, b) => { + const resultArray = temp.filter(f => f.parent_id == 0).sort((a, b) => { return a.index - b.index;//从小到大排序 }); diff --git a/client/reducer/modules/interface.js b/client/reducer/modules/interface.js index 1bf8a77eb..10ac259e1 100755 --- a/client/reducer/modules/interface.js +++ b/client/reducer/modules/interface.js @@ -128,6 +128,9 @@ export async function fetchInterfaceData(interfaceId) { export async function fetchInterfaceListMenu(projectId) { let result = await axios.get('/api/interface/list_menu?project_id=' + projectId); + result.data.data.forEach(item => { + item.parent_id = item.parent_id || 0 + }) return { type: FETCH_INTERFACE_LIST_MENU, payload: result