2017-08-14 17:32:17 +08:00
|
|
|
import axios from 'axios'
|
|
|
|
// Actions
|
|
|
|
const FETCH_INTERFACE_COL_LIST = 'yapi/interfaceCol/FETCH_INTERFACE_COL_LIST';
|
2017-08-18 17:31:48 +08:00
|
|
|
const FETCH_CASE_DATA = 'yapi/interfaceCol/FETCH_CASE_DATA';
|
|
|
|
const FETCH_CASE_LIST = 'yapi/interfaceCol/FETCH_CASE_LIST';
|
2017-08-17 20:24:07 +08:00
|
|
|
const SET_COL_DATA = 'yapi/interfaceCol/SET_COL_DATA';
|
2017-08-14 17:32:17 +08:00
|
|
|
|
|
|
|
// Reducer
|
|
|
|
const initialState = {
|
|
|
|
interfaceColList: [{
|
|
|
|
_id: 0,
|
|
|
|
name: '',
|
|
|
|
uid: 0,
|
|
|
|
project_id: 0,
|
|
|
|
desc: '',
|
|
|
|
add_time: 0,
|
|
|
|
up_time: 0,
|
2017-08-17 20:24:07 +08:00
|
|
|
caseList: [
|
2017-08-14 17:32:17 +08:00
|
|
|
{}
|
|
|
|
]
|
|
|
|
}],
|
|
|
|
isShowCol: true,
|
2017-11-07 16:39:27 +08:00
|
|
|
isRender:false,
|
2017-08-17 20:24:07 +08:00
|
|
|
currColId: 0,
|
2017-08-18 17:31:48 +08:00
|
|
|
currCaseId: 0,
|
|
|
|
currCase: {},
|
|
|
|
currCaseList: []
|
2017-08-14 17:32:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default (state = initialState, action) => {
|
|
|
|
switch (action.type) {
|
2017-08-18 17:31:48 +08:00
|
|
|
case FETCH_INTERFACE_COL_LIST:{
|
2017-08-14 17:32:17 +08:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
interfaceColList: action.payload.data.data
|
|
|
|
}
|
2017-08-18 17:31:48 +08:00
|
|
|
}
|
|
|
|
case FETCH_CASE_DATA: {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
currCase: action.payload.data.data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case FETCH_CASE_LIST: {
|
2017-08-14 17:32:17 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2017-08-18 17:31:48 +08:00
|
|
|
currCaseList: action.payload.data.data
|
2017-08-17 20:24:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case SET_COL_DATA: {
|
|
|
|
return {
|
|
|
|
...state,
|
2017-08-18 11:33:37 +08:00
|
|
|
...action.payload
|
2017-08-14 17:32:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Action Creators
|
|
|
|
export function fetchInterfaceColList (projectId) {
|
|
|
|
return {
|
|
|
|
type: FETCH_INTERFACE_COL_LIST,
|
|
|
|
payload: axios.get('/api/col/list?project_id=' + projectId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-18 17:31:48 +08:00
|
|
|
export function fetchCaseData(caseId){
|
|
|
|
return {
|
|
|
|
type: FETCH_CASE_DATA,
|
|
|
|
payload: axios.get('/api/col/case?caseid=' + caseId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchCaseList(colId) {
|
2017-08-14 17:32:17 +08:00
|
|
|
return {
|
2017-08-18 17:31:48 +08:00
|
|
|
type: FETCH_CASE_LIST,
|
2017-08-18 17:56:26 +08:00
|
|
|
payload: axios.get('/api/col/case_list/?col_id=' + colId)
|
2017-08-14 17:32:17 +08:00
|
|
|
}
|
|
|
|
}
|
2017-08-17 20:24:07 +08:00
|
|
|
|
|
|
|
export function setColData(data){
|
|
|
|
return {
|
|
|
|
type: SET_COL_DATA,
|
|
|
|
payload: data
|
|
|
|
}
|
|
|
|
}
|