import React from 'react'; import { inject, observer } from 'mobx-react'; import { WeaTop, WeaTab, WeaOrgTree, WeaLeftRightLayout, WeaEchart, WeaYear, WeaDialog, WeaPopoverHrm, WeaRightMenu, WeaTools, WeaErrorPage, WeaAlertPage, WeaDatePicker, WeaBrowser, WeaNewScroll } from 'ecCom'; import { WeaTableNew } from 'comsMobx'; const WeaTable = WeaTableNew.WeaTable; 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 debounce from 'lodash/debounce' import * as Util from '../util/index'; import { win32 } from 'path'; import { i18n } from '../public/i18n'; import { WeaLocaleProvider } from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; const toJS = mobx.toJS; @inject('hrmOldChecking') @observer class main extends React.Component { constructor(props) { super(props); this.state = { iWidth: window.innerWidth, oHeight: 300 } if (window.innerHeight > 850) { this.state.oHeight = 450; } else if (window.innerHeight > 600) { this.state.oHeight = window.innerHeight / 2 - 100; } else { this.state.oHeight = 200; } const { hrmOldChecking } = this.props; hrmOldChecking.init(); } componentDidMount() { const { hrmOldChecking } = this.props; hrmOldChecking.hrmId = this.props.params.hrmId || ''; this.getData(); hrmOldChecking.getHrmNewWorkflwList(); //document.title = hrmOldChecking.title; //窗口大小变化 jQuery(window).resize(() => { this.setState({ iWidth: window.innerWidth }) }); } componentWillReceiveProps(nextProps) { const { hrmOldChecking } = this.props; if (this.props.location.key !== nextProps.location.key) { hrmOldChecking.init(); this.getData(); } } getData = () => { const { hrmOldChecking } = this.props; const { tabkey } = hrmOldChecking; hrmOldChecking.getData(() => { tabkey == 1 && this.refs.chart && this.refs.chart.paint(); }); } getRightMenu = () => { const { hrmOldChecking } = this.props; let btns = []; btns.push({ key: "add", icon: , content: getLabel('385037', "新建考勤流程"), onClick: key => { this.addChecking(); } }); return btns; } addChecking = () => { const { hrmOldChecking } = this.props; hrmOldChecking.updateNewVisible(true); } getTopButtons = () => { const { hrmOldChecking } = this.props; let btns = []; btns.push( ); return btns; } chooseUser = (e) => { const { hrmOldChecking } = this.props; let hrmId = '', hrmName = undefined; if (e.selected) { hrmId = e.node.props.id; hrmName = e.node.props.name; } if (hrmId) { hrmOldChecking.updateHrmId(hrmId); if (hrmName) hrmOldChecking.updateHrmName(hrmName); this.getData(); } } changeUserRoot = (ids, names, datas) => { const { hrmOldChecking } = this.props; hrmOldChecking.updateUserRoot(datas); } resetUserRoot = () => { const { hrmOldChecking } = this.props; hrmOldChecking.updateUserRoot(); hrmOldChecking.updateHrmId(); hrmOldChecking.updateHrmName(); this.getData(); } changeTab = (key) => { const { hrmOldChecking } = this.props; hrmOldChecking.changeTabHandler(key); this.getData(); } changeDateTab = (key) => { const { hrmOldChecking } = this.props; hrmOldChecking.changeDateTabHandler(key); this.getData(); } reFresh = () => { const { hrmOldChecking } = this.props; this.getData(); } changeDate = (v) => { const { hrmOldChecking } = this.props; const { dateTabkey } = hrmOldChecking; if (dateTabkey == '2') { v = new moment(v).format('YYYY-MM'); } else { v = new moment(v).format('YYYY'); } hrmOldChecking.changeDateHandler(v); this.getData(); } handlerStatusClick = (item) => { const { hrmOldChecking } = this.props; hrmOldChecking.handlerStatusClick(item.type); } renderLeft = () => { const { hrmOldChecking } = this.props; const { oHeight } = this.state; let { tabkey, leftTitle, userRoot } = hrmOldChecking; userRoot = toJS(userRoot); const hrmId = this.props.params.hrmId || ''; let org = return
{getLabel('32997',"人员组织")}
{ tabkey === '1'?
{org}
: {org} } { tabkey === '2' && this.renderDetail() }
} // 截取很magic的a标签数据 sliceA = (str) => { if (str.indexOf('a>') > -1 && str.indexOf(' -1) { str = str.match(/\>(.+) { const { hrmOldChecking } = this.props; const { oHeight } = this.state; let { calendarCheckedDay, calendarData } = hrmOldChecking; calendarData = toJS(calendarData); if (calendarCheckedDay) { let data = calendarData[calendarCheckedDay]; return
{data.date}  {getLabel('20080',"考勤情况")} {isEmpty(data.signInfo) &&
{getLabel('386472',"当天没有考勤数据")}
} {!isEmpty(data.signInfo) && { data.signInfo.map((i, index) => { return { i.item && i.item.map((d)=> { return
{d.title} :  {this.sliceA(d.value)}
}) }
}) }
}
} return
{getLabel('386473',"点击日历查看每天考勤情况")}
} 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}' } }, } } getTipText = (data) => { return
{getLabel('24979',"开始时间")}: {data.start}
{getLabel('743',"结束时间")}: {data.end}
{data.type &&
{getLabel('500401',"类型")}: {data.type}
}
{data.workflowtype=='OVERTIME'?getLabel('132055',"时长(小时)"):getLabel('132014',"时长(天)")}: {data.count}
} onMonthSelect = (date) => { const { hrmOldChecking } = this.props; let { dateTabkey, pDate } = hrmOldChecking; let select = new moment(date.time).format('YYYY-MM'); if (pDate.slice(0, 7) == select) { hrmOldChecking.updateCalendarCheckedDay(date.getDayOfMonth()); } } onyearMonthSelect = (date) => { const { hrmOldChecking } = this.props; let select = new moment(date.time).format('YYYY-MM'); hrmOldChecking.changeDateHandler(select); hrmOldChecking.updateDateTabkey('2'); this.getData(); } monthDateCellRender = (date) => { const { hrmOldChecking } = this.props; let { dateTabkey, pDate, calendarData, statusActiveType } = hrmOldChecking; calendarData = toJS(calendarData); let select = new moment(date.time).format('YYYY-MM'); if (pDate.slice(0, 7) == select) { let day = date.getDayOfMonth(); const data = calendarData[day]; if (data && (data.types.indexOf(statusActiveType) > -1 || statusActiveType == 'ALL' || data.types.indexOf('NORMAL') > -1)) { return (
{ data.types && data.types.map((type, idx)=> { if (idx > 4) return; const ic = Util.getIconColor(type); if (type == statusActiveType || statusActiveType == 'ALL') { return } }) } {data.tip} { data.workflow && data.workflow.map((item, index)=> { if (item.workflowtype == statusActiveType || statusActiveType == 'ALL') { const ic = Util.getIconColor(item.workflowtype); return
} }) }
) } } } yearDateCellRender = (date) => { const { hrmOldChecking } = this.props; let { dateTabkey, pDate, yearData, statusActiveType } = hrmOldChecking; yearData = toJS(yearData); const d = date.getDayOfMonth(); const m = date.getMonth() + 1; let data = {}, ic = undefined; if (yearData !== undefined && !isEmpty(yearData)) { data = yearData[m][d]; try { if (data.type !== 'NORMAL') ic = Util.getIconColor(data.type); } catch (e) { return
{d}
} } let content; if (ic && (statusActiveType == data.type || statusActiveType == 'ALL')) { content = {data.tip && {data.tip}} } else { content = {data.tip && {data.tip}} {d} } return
{content}
} renderCalendar = () => { const { hrmOldChecking } = this.props; let { dateTabkey, pDate, pDate1 } = hrmOldChecking; return
{dateTabkey == '2' && } {dateTabkey == '1' && }
} onStsClick = (item) => { const { hrmOldChecking } = this.props; if (parseFloat(item.value) > 0) { hrmOldChecking.updateStsType(item.type); hrmOldChecking.getTableData(); hrmOldChecking.updateVisible(true); } else { const content = getLabel('386474', "本月没有{params}数据!").replace('{params}', item.title); Modal.warning({ title: i18n.confirm.defaultTitle(), content, }); } } renderStatistics = () => { const { hrmOldChecking } = this.props; const { iWidth } = this.state; let { chartOptions, groupitem2, groupitem3, groupitem4, count } = hrmOldChecking; chartOptions = toJS(chartOptions); groupitem4 = toJS(groupitem4); groupitem3 = toJS(groupitem3); groupitem2 = toJS(groupitem2); return (
{getLabel('16732',"出勤统计")}
this.onStsClick(chartOptions.series[0].data[1])}>{!isEmpty(chartOptions.series[0].data) && chartOptions.series[0].data[1].value} this.onStsClick(chartOptions.series[0].data[0])}>{!isEmpty(chartOptions.series[0].data) && chartOptions.series[0].data[0].value} {!isEmpty(chartOptions.series[0].data) && chartOptions.series[0].data[1].name}({i18n.label.day()}) {!isEmpty(chartOptions.series[0].data) && chartOptions.series[0].data[0].name}({i18n.label.day()})
{getLabel('132057',"异常考勤汇总")}
= 1684? 40: 10}}> { groupitem2 && groupitem2.map((d, i)=> { return
this.onStsClick(d)}>
{d.value}
{d.title}{d.type=="OVERTIME"?`(${i18n.label.hour()})`:`(${i18n.label.day()})`}
}) } { groupitem3 && groupitem3.map((d, i)=> { return this.onStsClick(d)}> {d.value} {d.title} }) }
{ groupitem4 && groupitem4.map((d, i)=> { return {d.title}
{ d.item.map((i, index)=> { return {i.title} {i.value} }) }
}) }
) } onOperatesClick = (record, index, operate, flag, argumentString) => { if (toJS(operate) && toJS(operate).href.indexOf('addChecking') > -1) { this.addChecking(); } } getBtns = () => { let btns = []; return btns; } render() { const { hrmOldChecking } = this.props; const { getStatusList, statusActiveType, tabDatas, tabkey, dateTabDatas, dateTabkey, pDate, hasRight, leftTitle, hrmName, loading, newVisible, visible, table } = hrmOldChecking; let { newWorklist } = hrmOldChecking; newWorklist = toJS(newWorklist); const statusList = getStatusList(); const { query } = this.props.location; const getMsg = (name) => { const content = getLabel('386475', "您无权查看 {params} 的考勤数据!").replace('{params}', name); return content; } return (
hrmOldChecking.updateVisible(false)} closable style={{width: 900, height: window.innerHeight-250>500?500:window.innerHeight-250}} title = {getLabel('386477',"考勤明细")} icon="icon-coms-hrm" iconBgcolor='#217346' moreBtn={{datas:[]}} > 500?500:window.innerHeight-250} ref="scrollBar"> hrmOldChecking.updateNewVisible(false)} closable style={{width: 600, height: 400}} title = {getLabel('385037',"新建考勤流程")} icon="icon-portal-workflow" iconBgcolor='#0079de' >
{getLabel('15882',"人事管理")}({newWorklist.length})
{ !isEmpty(newWorklist) && newWorklist.map((item)=> { return
{hrmOldChecking.handlerNewWorkflow(item)}}>{item.title}
}) }
} iconBgcolor='#217346' buttons={this.getTopButtons()} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} />
{this.renderLeft()}
{leftTitle} :  {hrmName}
{[{title: i18n.label.year(),key:"1"}, {title: i18n.label.month() ,key:"2"}].map((item)=> { return
{item.title}
} )} { tabkey == '2' &&
{ statusList && statusList.map((item)=> { return this.handlerStatusClick(item)} title={item.title}> {item.name} }) }
}
{!hasRight &&
{getMsg(hrmName)}
} { hasRight &&
{tabkey == '1' && this.renderStatistics()} {tabkey == '2' && this.renderCalendar()}
}
) } } export default main