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, WeaInputNumber, WeaDropdown, } from "ecCom"; import { WeaTableNew } from "comsMobx"; const WeaTable = WeaTableNew.WeaTable; import { Modal, Row, Col, Button, Spin, Icon, Calendar, Tooltip, Timeline, } from "antd"; import "../style/newChecking.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"; import AbsenceDialog from "./absenceDetail/Dialog"; const getLabel = WeaLocaleProvider.getLabel; const toJS = mobx.toJS; let __this; const ButtonGroup = Button.Group; const { ButtonSelect } = WeaDropdown; const WorkInfo = (props) => { const { groupitem, onStsClick } = props; return (
{groupitem && groupitem.map((item) => { const { icon, value, title, color } = item; return (
onStsClick(item)}> {value}
{title}
); })}
); }; const LeaveInfo = (props) => { const { groupitem, onStsClick, hasBorder } = props; const datasLen = groupitem.length; let width; if (datasLen === 1) { width = "100%"; } else if (datasLen === 2) { width = "50%"; } else { width = "33.3%"; } return (
{groupitem && groupitem.map((item, index) => { const { value, title } = item; return (
onStsClick(item)}>{value} {title}
); })}
); }; const SignInfo = (props) => { const { groupitem, onStsClick } = props; return (
{groupitem && groupitem.map((d) => { const { value, title } = d; return (
onStsClick(d)}> {value} {title}
); })}
); }; const NoData = (props) => { const { tip, loading } = props; if (loading) { return null; } return (
{tip}
); }; @inject("hrmChecking") @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; } this.onStsClick.bind(this); __this = this; const { hrmChecking } = this.props; hrmChecking.init(); } componentDidMount() { const { hrmChecking, hrmCard } = this.props; hrmChecking.hrmId = this.props.params.hrmId || ""; this.getData(); hrmChecking.getHrmNewWorkflwList(); hrmChecking.getwfinfo(); if(hrmCard){ hrmCard.setTopButtons(this.getTopButtons.bind(this)); hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); hrmCard.setTopShowDropIcon(true); } //document.title = hrmChecking.title; } componentWillReceiveProps(nextProps) { const { hrmChecking } = this.props; if (this.props.location.key !== nextProps.location.key) { hrmChecking.init(); this.getData(); } } getData() { const { hrmChecking } = this.props; const { tabkey } = hrmChecking; hrmChecking.getData(() => { tabkey == 1 && this.refs.chart && this.refs.chart.paint(); }); } componentDidUpdate() { this.props.setParentRightMenu && this.props.setParentRightMenu(this.getRightMenu()); } getRightMenu() { const { hrmChecking } = this.props; let btns = []; btns.push({ key: "add", icon: , content: getLabel("385037", "新建考勤流程"), onClick: (key) => { this.addChecking(); }, }); return btns; } addChecking() { const { hrmChecking } = this.props; hrmChecking.updateNewVisible(true); } getTopButtons() { const { hrmChecking } = this.props; let btns = []; btns.push( ); return btns; } chooseUser(e) { const { hrmChecking } = this.props; let hrmId = "", hrmName = undefined; if (e.selected) { hrmId = e.node.props.id; hrmName = e.node.props.name; } if (hrmId) { hrmChecking.updateHrmId(hrmId); if (hrmName) hrmChecking.updateHrmName(hrmName); this.getData(); } } changeUserRoot(ids, names, datas) { const { hrmChecking } = this.props; hrmChecking.updateUserRoot(datas); } resetUserRoot() { const { hrmChecking } = this.props; hrmChecking.updateUserRoot(); hrmChecking.updateHrmId(); hrmChecking.updateHrmName(); this.getData(); } changeTab(key) { const { hrmChecking } = this.props; hrmChecking.changeTabHandler(key); this.getData(); } changeDateTab(key) { const { hrmChecking } = this.props; hrmChecking.changeDateTabHandler(key); this.getData(); } reFresh() { const { hrmChecking } = this.props; this.getData(); } changeDate(v) { const { hrmChecking } = this.props; const { dateTabkey } = hrmChecking; if (dateTabkey == "2") { v = new moment(v).format("YYYY-MM"); } else { v = new moment(v).format("YYYY"); } hrmChecking.changeDateHandler(v); this.getData(); } handlerStatusClick(item) { const { hrmChecking } = this.props; hrmChecking.handlerStatusClick(item.type); } renderLeft() { const { hrmChecking } = this.props; const { oHeight } = this.state; let { tabkey, leftTitle, userRoot } = hrmChecking; 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(/\>(.+) { return $('.e9theme-layout2-navbar').height() } renderDetail() { const { hrmChecking } = this.props; const { oHeight } = this.state; let { calendarCheckedDay, sData } = hrmChecking; if (calendarCheckedDay) { return (
{sData.date}  {getLabel("20080", "考勤情况")} {isEmpty(sData.signInfo) && (
{getLabel("386472", "当天没有考勤数据")}
)} {!isEmpty(sData.signInfo) && ( {sData.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}
*/}
{getLabel("506048", "时长")}: {data.count}
); } onMonthSelect(date) { const { hrmChecking } = this.props; let { dateTabkey, pDate } = hrmChecking; let select = new moment(date.time).format("YYYY-MM"); if (pDate.slice(0, 7) == select) { hrmChecking.updateCalendarCheckedDay(date.getDayOfMonth()); } } onyearMonthSelect(date) { const { hrmChecking } = this.props; let select = new moment(date.time).format("YYYY-MM"); hrmChecking.changeDateHandler(select); hrmChecking.updateDateTabkey("2"); this.getData(); } monthDateCellRender(date) { const { hrmChecking } = this.props; let { dateTabkey, pDate, calendarData, statusActiveType } = hrmChecking; 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]; const components = []; if ( data && (data.types.indexOf(statusActiveType) > -1 || statusActiveType == "ALL" || data.types.indexOf("NORMAL") > -1) ) { components.push(
{data.types && data.types.map((type, idx) => { if (idx > 4) return; const ic = Util.getIconColor(type); if (type == statusActiveType || statusActiveType == "ALL") { return ( ); } })} {data.tip} 0 ? 45 : 15} > {data.workflow && data.workflow.map((item, i) => { if ( item.workflowtype == statusActiveType || statusActiveType == "ALL" ) { const ic = Util.getIconColor(item.workflowtype); return (
); } })}
); } if (data && data.signInfo) { components.push( data.signInfo.map((info, i) => { const { title, signTime } = info; return ( {`${title}: ${signTime}`} ); }) ); } return components; } } yearDateCellRender(date) { const { hrmChecking } = this.props; let { dateTabkey, pDate, yearData, statusActiveType } = hrmChecking; 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 { hrmChecking } = this.props; let { dateTabkey, pDate, pDate1 } = hrmChecking; return (
{dateTabkey == "2" && ( )} {dateTabkey == "1" && ( )}
); } onStsClick(item) { const { hrmChecking } = this.props; const { id } = item; if (parseFloat(item.value) > 0) { hrmChecking.updateStsType(item.type); if (id === "leaveDays") { hrmChecking.openAbsenceDialog(); } else { const { type } = item; if (type === "OVERTIME") { hrmChecking.getOverTimeTabDatas().then(() => { hrmChecking.getTableData(); }); } else { hrmChecking.getTableData(); } hrmChecking.updateVisible(true); } } else { const content = getLabel("386474", "本月没有{params}数据!").replace( "{params}", item.title ); Modal.warning({ title: i18n.confirm.defaultTitle(), content, }); } } renderStatistics() { const { hrmChecking } = this.props; const { iWidth } = this.state; let { chartOptions, groupitem2, groupitem3, groupitem4, groupitem5, count, } = hrmChecking; chartOptions = toJS(chartOptions); groupitem4 = toJS(groupitem4); groupitem3 = toJS(groupitem3); groupitem2 = toJS(groupitem2); groupitem5 = toJS(groupitem5); const { hasLeaveInfo, loading } = hrmChecking; 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", "异常考勤汇总")}
this.onStsClick(d)} />
{getLabel("503887", "请假信息")}
{hasLeaveInfo ? ( this.onStsClick(d)} /> ) : ( )}
this.onStsClick(d)} hasBorder />
{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; } handleInputChange = (value) => { this.props.hrmChecking.setInputValue(value); }; handleButtonGroupClick = (bool) => { this.props.hrmChecking.setIsDay(bool); }; render() { const { hrmChecking } = this.props; const { getStatusList, statusActiveType, tabDatas, tabkey, dateTabDatas, dateTabkey, pDate, hasRight, leftTitle, hrmName, loading, newVisible, visible, table, setDialogHeight, kqDetailDialogHeight, stsType, overTimeTabDatas, overTimeTabkey, handleOverTimeTabClick, tofirstUpperCase, groupwfinfo } = hrmChecking; let { newWorklist } = hrmChecking; newWorklist = toJS(newWorklist); const statusList = getStatusList(); const { query } = this.props.location; const getMsg = (name) => { const content = getLabel( "386475", "您无权查看 {params} 的考勤数据!" ).replace("{params}", name); return content; }; let coms = [
} iconBgcolor="#217346" buttons={this.getTopButtons()} buttonSpace={10} showDropIcon={true} dropMenuDatas={this.getRightMenu()} />
, this.renderLeft(),
{leftTitle} :  {hrmName}
{[ { title: window.e9_locale.userLanguage == "8" ? "Year" : i18n.label.year(), key: "1", }, { title: i18n.label.month(), key: "2" }, ].map((item, i) => { return (
0 && window.e9_locale.userLanguage == "8" ? { margin: "0 10px" } : {} } className={`cursor-pointer date-item ${ item.key === dateTabkey ? "active" : "" }`} > {item.title}
); })}
{tabkey == "2" && (
{window.e9_locale.userLanguage != "8" ? statusList && statusList.map((item) => { return ( this.handlerStatusClick(item)} title={item.title} > {item.name} ); }) : statusList && ( { return { key: item.type, text: ( {item.name} ), show: ( {item.name} ), }; })} menuOnClick={(key, e) => this.handlerStatusClick({ type: key }) } /> )}
)}
{!hasRight && (
{getMsg(hrmName)}
)} {hasRight && (
{tabkey == "1" && this.renderStatistics()} {tabkey == "2" && this.renderCalendar()}
)}
]; if(!query.fromcard){ coms = ( {coms} ) } return (
hrmChecking.updateVisible(false)} closable style={{ width: 900, height: 500 }} title={getLabel("386477", "考勤明细")} icon="icon-coms-hrm" iconBgcolor="#217346" moreBtn={{ datas: [] }} onChangeHeight={(h) => setDialogHeight(h)} > {stsType === "OVERTIME" && ( )} hrmChecking.updateNewVisible(false)} closable style={{ width: 600, height: 400 }} title={getLabel("385037", "新建考勤流程")} icon="icon-portal-workflow" iconBgcolor="#0079de" hasScroll >
{ groupwfinfo && groupwfinfo.map(info => { const { img, color, typeName, wfs } = info; return (
{ `${typeName}(${wfs.length})` }
{ wfs.map(item => { return
{hrmChecking.handlerNewWorkflow(item)}}>{item.title}
}) }
) }) }
{coms}
); } } //窗口大小变化 jQuery(window).resize(function () { if (__this) { __this.setState({ iWidth: window.innerWidth, }); } }); export default main;