import * as Api from '../apis/basicImport';
import {
    observable,
    action
} from 'mobx';
import {
    message,
} from 'antd';
import {
    i18n
} from '../public/i18n';

export class HrmBasicDataImport {
    @observable title = i18n.module.basicInfoImport();
    @observable isMouseOver = false;
    @observable curIndex = '';
    @observable loading = true;
    @observable authorized = false;
    @observable cardConfig = []

    @action
    getRight = () => {
        this.loading = true;
        const params = {
            type: 'HrmBasicDataImport'
        }
        Api.getBasicDataImportHasRight(params).then(action(rs => {
            const {
                status,
                hasRight
            } = rs;

            if (status == '1') {
                if (hasRight) {
                    this.authorized = true;
                    if (rs.cardConfig) {
                        this.cardConfig = rs.cardConfig
                    } else {
                        this.authorized = false;
                    }
                }
                this.loading = false;
            } else {
                this.loading = false;
            }
        })).catch(error => {
            message.error(error);
        });
    }

    @action
    setMouseStatus = (index, bool) => {
        this.curIndex = index;
        this.isMouseOver = bool;
    }
}