import React from 'react';
import { inject, observer} from 'mobx-react';
import {WeaTop, WeaTab, WeaOrgTree, WeaEchart, WeaYear, WeaDialog, WeaPopoverHrm,
WeaRightMenu,WeaTools,WeaErrorPage, WeaAlertPage, WeaDatePicker,WeaBrowser, WeaNewScroll
} from 'ecCom';
import {Modal, Row, Col, Button, Spin, Icon, Calendar, Tooltip, Timeline} from 'antd';
import '../style/checking.less';
import * as mobx from 'mobx';
import isEmpty from 'lodash/isEmpty';
import cloneDeep from 'lodash/cloneDeep';
import toString from 'lodash/toString';
import moment from 'moment';
import * as Util from '../util/index';
import {i18n} from '../public/i18n';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
const toJS = mobx.toJS;
@inject('hrmShift')
@observer
class main extends React.Component {
constructor(props) {
super(props);
const { hrmShift } = this.props;
hrmShift.init();
}
componentDidMount() {
this.getData();
const { hrmShift } = this.props;
//document.title = hrmShift.title;
}
componentWillReceiveProps(nextProps) {
if(this.props.location.key !== nextProps.location.key) {
const { hrmShift } = this.props;
hrmShift.init();
this.getData();
}
}
getData() {
const { hrmShift } = this.props;
hrmShift.getData();
}
getRightMenu(){
const {hrmShift} = this.props;
const {newChecking} = hrmShift;
let btns = [];
btns.push({
key: "search",
icon: ,
content: newChecking(),
onClick: key =>{
this.addChecking();
}
});
return btns;
}
addChecking() {
const {hrmShift} = this.props;
hrmShift.updateNewVisible(true);
}
chooseUser(e) {
const {hrmShift} = this.props;
let hrmId = '', hrmName = undefined;
if (e.selected) {
hrmId = e.node.props.id;
hrmName = e.node.props.name;
}
if (hrmId) {
hrmShift.updateHrmId(hrmId);
if (hrmName) hrmShift.updateHrmName(hrmName);
this.getData();
}
}
changeUserRoot(ids,names,datas) {
const {hrmShift} = this.props;
hrmShift.updateUserRoot(datas);
}
resetUserRoot() {
const {hrmShift} = this.props;
hrmShift.updateUserRoot();
hrmShift.updateHrmId();
hrmShift.updateHrmName();
this.getData();
}
changeDateTab(key) {
const {hrmShift} = this.props;
hrmShift.changeDateTabHandler(key);
this.getData();
}
reFresh() {
const {hrmShift} = this.props;
this.getData();
}
changeDate(v) {
const {hrmShift} = this.props;
const {dateTabkey} = hrmShift;
if (dateTabkey == '2') {
v = new moment(v).format('YYYY-MM');
} else {
v = new moment(v).format('YYYY');
}
hrmShift.changeDateHandler(v);
this.getData();
}
renderLeft() {
const {hrmShift} = this.props;
let {leftTitle, userRoot} = hrmShift;
userRoot = toJS(userRoot);
return
}
getLocale() {
return {
firstDayOfWeek: 0,
lang: {
format: {
eras: [getLabel(383357, "公元前"), getLabel(383358, "公元")],
months: [getLabel(1492, "一月"), getLabel(1493, "二月"), getLabel(383385, "三月"), getLabel(383387, "四月"), getLabel(1496, "五月"), getLabel(383392, "六月"),
getLabel(383393, "七月"), getLabel(383394, "八月"), getLabel(383395, "九月"), getLabel(383396, "十月"), getLabel(383397, "十一月"), getLabel(383398, "十二月")
],
shortMonths: [getLabel(1492, "一月"), getLabel(1493, "二月"), getLabel(383385, "三月"), getLabel(383387, "四月"), getLabel(1496, "五月"), getLabel(383392, "六月"),
getLabel(383393, "七月"), getLabel(383394, "八月"), getLabel(383395, "九月"), getLabel(383396, "十月"), getLabel(383397, "十一月"), getLabel(383398, "十二月")
],
weekdays: [getLabel(24626, "星期天"), getLabel(383399, "星期一"), getLabel(383400, "星期二"), getLabel(383402, "星期三"), getLabel(383403, "星期四"),
getLabel(383404, "星期五"), getLabel(383405, "星期六")
],
shortWeekdays: [getLabel(16106, "周日"), getLabel(16100, "周一"), getLabel(16101, "周二"), getLabel(16102, "周三"), getLabel(16103, "周四"), getLabel(16104, "周五"),
getLabel(16105, "周六")
],
veryShortWeekdays: [getLabel(16106, "周日"), getLabel(16100, "周一"), getLabel(16101, "周二"), getLabel(16102, "周三"), getLabel(16103, "周四"), getLabel(16104, "周五"), getLabel(16105, "周六")],
ampms: [getLabel(383408, "上午"), getLabel(383409, "下午")],
datePatterns: [`yyyy'${getLabel(383372,"年")}'M'${getLabel(383373,"月")}'d'${getLabel(383374,"日")}' EEEE`, `yyyy'${getLabel(383372,"年")}'M'${getLabel(383373,"月")}'d'${getLabel(383374,"日")}'`, "yyyy-M-d", "yy-M-d"],
timePatterns: [`ahh'${getLabel(383411,"时")}'mm'${getLabel(383412,"分")}'ss'${getLabel(383414,"秒")}' 'GMT'Z`, `ahh'${getLabel(383411,"时")}'mm'${getLabel(383412,"分")}'ss'${getLabel(383414,"秒")}'`, "H:mm:ss", "ah:mm"],
dateTimePattern: '{date} {time}'
}
},
}
}
onyearMonthSelect(date) {
const {hrmShift} = this.props;
let select = new moment(date.time).format('YYYY-MM');
hrmShift.changeDateHandler(select);
hrmShift.updateDateTabkey('2');
this.getData();
}
monthDateCellRender(date) {
const {hrmShift} = this.props;
let {dateTabkey, pDate, calendarData, statusActiveType} = hrmShift;
calendarData = toJS(calendarData);
let select = new moment(date.time).format('YYYY-MM');
if (pDate.slice(0,7) == select) {
let day = date.getDayOfMonth();
let data = calendarData[day];
if (data) {
return (
{data.tip}
{
data.items && data.items.map((item, i)=> {
return
{item.title}
})
}
)
}
}
}
renderYearCellBottom(items) {
if (!isEmpty(items)) {
return
{
items.map((item, i)=> {
return
})
}
}
}
yearDateCellRender(date) {
const {hrmShift} = this.props;
let {pDate, yearData} = hrmShift;
yearData = toJS(yearData);
const d = date.getDayOfMonth();
const m = date.getMonth() + 1;
let data = {};
if (yearData !== undefined && !isEmpty(yearData)) {
data = yearData[m][d];
}
let content =
{data.tip && {data.tip}}
{d}
{data.items && this.renderYearCellBottom(data.items)}
return
{content}
}
renderCalendar() {
const {hrmShift} = this.props;
let {dateTabkey, pDate} = hrmShift;
return
{dateTabkey == '2' &&
}
{dateTabkey == '1' &&
}
}
render() {
const {hrmShift} = this.props;
const {title,dateTabDatas, dateTabkey, pDate, hasRight, canSearch, leftTitle, hrmName, loading} = hrmShift;
const errorMsg = getLabel('386500',"您无权查看 {params} 的排班数据!").replace('{params}', hrmName);
return (
}
iconBgcolor='#217346'
buttons={[]}
buttonSpace={10}
showDropIcon={false}
// dropMenuDatas={this.getRightMenu()}
>
{canSearch && this.renderLeft()}
{leftTitle()} : {hrmName}
{[ {title:i18n.label.year(),key:"1"}, {title:i18n.label.month(),key:"2"}].map((item, i)=> {
return
{item.title}
}
)}
{!hasRight &&
{errorMsg}
}
{hasRight &&
{this.renderCalendar()}
}
)
}
}
export default main