import {
	observable,
	action,
	computed
} from 'mobx';
import {
	message
} from 'antd';
import HrmBaseStore from './baseStore';
import * as api from '../apis/resourceIndex';
import {
	i18n
} from '../public/i18n';
import {
	chunk
} from 'lodash';

export class HrmResourceIndex extends HrmBaseStore {
	/********************* unobservable list *********************/
	/********************* unobservable list *********************/

	/********************* dialog info setting *********************/

	/********************* dialog info setting *********************/

	/********************* observable list *********************/
	@observable result = [];
	/********************* observable list *********************/

	/********************* computed list *********************/
	/********************* computed list *********************/

	/********************* action list *********************/
	initData = () => {
		this.loadData({loadData: 0}, () => this.loadData({loadData: 1}));
		// api.getIndexInfo().then(data => {
		// 	if(data.status === '1'){
		// 		this.result = chunk(data.result, 2);
		// 	}else{
		// 		message.error(data.message);
		// 	}
		// }, error => {})
	}

	@action loadData = (params, callback) => {
		api.getIndexInfo(params).then(data => {
			if(data.status === '1'){
				this.result = chunk(data.result, 2);
				callback && callback();
			}else{
				message.error(data.message);
			}
		}, error => {})
	}
	/********************* action list *********************/
}

export const hrmResourceIndex = new HrmResourceIndex();