headergroup.js
952 Bytes
import { List } from 'immutable'
import { CLONE_ELEMENT, DELETE_LAST_ELEMENT, DELETE_ELEMENT } from '../constants/ActionTypes'
const init_state = List([
{ id: 1, name: "药库", initialPos: {x: 80, y: 70}, target_type: 'RegionalDesign::Repo' },
{ id: 2, name: "药架", initialPos: {x: 80, y: 70 + 60}, target_type: 'RegionalDesign::DrugRepo' },
{ id: 3, name: "药架格", initialPos: {x: 80, y: 70 + 60 * 2}, target_type: 'RegionalDesign::DrugBrandreth' }
])
const headergroup = (state = init_state, action) => {
switch (action.type) {
case CLONE_ELEMENT:
return [
...state,
action.element
]
case DELETE_LAST_ELEMENT:
return [
...state.slice(0, -1),
]
case DELETE_ELEMENT:
const index = state.indexOf(action.element)
return [
...state.slice(0, index),
...state.slice(index + 1)
]
default:
return state
}
}
export default headergroup