import * as constants from './constants';
import React from 'react';
//锁定state不可修改，导致错误y
import { fromJS } from 'immutable';

const defaultState = fromJS({
	pagination:{
		current: 1,
		pageSize: 10,
		position:['bottomCenter'],
		showSizeChanger: false
	},
	dataSource:[],
	  columns:[
		{
			title: '锁号',
			dataIndex: 'companyname',
			key: 'companyname',
		  },
		  {
			title: '产品',
			dataIndex: 'nature',
			key: 'nature',
		  },
		  {
			title: '办事处',
			dataIndex: 'local',
			key: 'local',
		  },
		  {
			title: '出库时间',
			dataIndex: 'address',
			key: 'address',
		  },
		  {
			title: '销售/借出/赠送时间',
			dataIndex: 'ride',
			key: 'ride',
		  },
		  {
			title: '责任人',
			dataIndex: 'stay',
			key: 'stay',
		  },
		  {
			title: '状态',
			dataIndex: 'remarks',
			key: 'remarks',
		  },
		  {
			title: '联系人',
			dataIndex: 'webservice',
			key: 'webservice',
		  },
	  ],
});

export default (state = defaultState, action) => {
    switch(action.type) {
		case constants.CHANGE_LOCKSTORE_DATA:
			let pagination ={
				...action.pagination,
				total:action.recordsTotal,
			}
			// console.log(pagination);
			// return state.set('dataSource', action.data);
			return state.merge({
				pagination:fromJS(pagination),
				dataSource:fromJS(action.data),
			});
		default:
			return state;
	}
}
