weaver_trunk_cli/pc4mobx/hrm/stores/shift.js

96 lines
2.5 KiB
JavaScript

import { observable, action } from 'mobx';
import { WeaTools } from 'ecCom';
import moment from 'moment';
import * as API from '../apis/shift';
import * as Util from '../util/index';
import isEmpty from 'lodash/isEmpty';
import {i18n} from '../public/i18n';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
export class HrmShift {
title = () => getLabel('125798',"我的排班");
newChecking = () => getLabel('385037',"新建考勤流程");
leftTitle= () => getLabel('32997',"人员组织");
dateTabDatas = [
{title:'年',key:"1"},
{title:'月',key:"2"}
];
hrmId = undefined;
@observable yearData = {};
@observable calendarData = {};
@observable hrmName = WeaTools.ls.getJSONObj('theme-account') && WeaTools.ls.getJSONObj('theme-account').username || undefined;
@observable loading = false;
@observable dateTabkey = '2';
@observable userRoot = undefined;
@observable pDate = new moment().format('YYYY-MM');
@observable hasRight = true;
@observable canSearch = false;
@action
changeDateTabHandler(key) {
if (this.pDate) {
if (key == '1') {
this.pDate = new moment().format('YYYY');
} else {
this.pDate = new moment().format('YYYY-MM');
}
}
this.dateTabkey = key;
}
@action
updateDateTabkey(key) {
this.dateTabkey = key;
}
@action
changeDateHandler(v) {
this.pDate = v;
}
@action
init() {
this.dateTabkey = '2';
this.pDate = new moment().format('YYYY-MM');
this.hrmId = undefined;
this.hrmName = WeaTools.ls.getJSONObj('theme-account') && WeaTools.ls.getJSONObj('theme-account').username || undefined;
this.userRoot = undefined;
}
@action
updateUserRoot(data) {
this.userRoot = data;
}
@action
updateHrmId(v) {
this.hrmId = v;
}
@action
updateHrmName(v) {
this.hrmName = v || WeaTools.ls.getJSONObj('theme-account') && WeaTools.ls.getJSONObj('theme-account').username || undefined;
}
@action
getData(cb) {
let params = {};
if (this.hrmId) params.resourceId = this.hrmId;
if (this.pDate) params.typevalue = this.pDate;
params.loaddata = "1";
params.type = this.dateTabkey;
this.loading = true;
API.getKQCarendarReport(params).then((datas)=> {
if (datas.status == '1') {
if (this.dateTabkey == '1') {
this.yearData = datas.result;
} else {
this.calendarData = datas.result;
}
this.hasRight = true;
} else {
this.hasRight = false;
}
this.loading = false;
})
}
}