10 changed files with 703 additions and 355 deletions
After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,500 @@ |
|||||
|
import React, { useEffect, useState, useRef, useMemo } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import { Table, Button, Pagination, Skeleton, Form, Tooltip } from '@douyinfe/semi-ui'; |
||||
|
import { IconSearch } from '@douyinfe/semi-icons'; |
||||
|
import { SkeletonScreen } from "$components"; |
||||
|
import '../style.less' |
||||
|
import { Setup } from "$components"; |
||||
|
import moment from 'moment' |
||||
|
import { set } from 'nprogress'; |
||||
|
|
||||
|
const overtimeStatistics = (props) => { |
||||
|
const { dispatch, actions, history, user, loading, socket, xqMembers } = props |
||||
|
|
||||
|
const { humanAffairs } = actions; |
||||
|
|
||||
|
const form = useRef();//表单 |
||||
|
let [archivesList, setArchivesList] = useState([]);//人员列表 |
||||
|
// let [typeList, setTypeList] = useState([]);//请假类型列表 |
||||
|
|
||||
|
const [setup, setSetup] = useState(false);//表格设置是否显现 |
||||
|
const [setupp, setSetupp] = useState([]);//实际显示的表格列表 |
||||
|
const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 |
||||
|
const [order, setOrder] = useState({ orderBy: 'hiredate', orderDirection: 'DESC' }); //页码信息 |
||||
|
const [limits, setLimits] = useState()//每页实际条数 |
||||
|
const [downloadUrl, setDownloadUrl] = useState('')//下载pdf |
||||
|
const OVERTIMESTATISTICS = "overtimeStatistics"; |
||||
|
const page = useRef(query.page);//哪一页 |
||||
|
|
||||
|
const [tableList, setTableList] = useState([{ |
||||
|
title: '展示信息', |
||||
|
list: [ |
||||
|
{ name: "姓名", value: "userName" }, |
||||
|
{ name: "所属部门", value: "departmrnt" }, |
||||
|
{ name: "职位", value: "roleName" }, |
||||
|
{ name: "工作日-调休", value: "workdayChange" }, |
||||
|
{ name: "普假-调休", value: "dayoffChange" }, |
||||
|
{ name: "法定假-调休", value: "festivalsChange" }, |
||||
|
{ name: "工作日-折算", value: "workdayConversion" }, |
||||
|
{ name: "普假-折算", value: "dayoffConversion" }, |
||||
|
{ name: "法定假-折算", value: "festivalsConversion" }, |
||||
|
{ name: "合计调休加班时长", value: "overtimeTakeRestSum" }, |
||||
|
{ name: "合计折算加班时长", value: "overtimePaySum" }, |
||||
|
{ name: "合计加班次数", value: "overtimeCount" }, |
||||
|
{ name: "合计加班时长", value: "overtimeSum" }, |
||||
|
] |
||||
|
}]);//表格属性 |
||||
|
useEffect(() => { |
||||
|
localStorage.getItem(OVERTIMESTATISTICS) == null |
||||
|
? localStorage.setItem( |
||||
|
OVERTIMESTATISTICS, |
||||
|
JSON.stringify(['userName', 'departmrnt', 'roleName', 'overtimeCount', 'overtimeSum']) |
||||
|
) |
||||
|
: ""; |
||||
|
attribute(); |
||||
|
}, []) |
||||
|
useEffect(() => { |
||||
|
getAttendanceOvertimeList()//查询人员列表 |
||||
|
}, [query, order]) |
||||
|
|
||||
|
|
||||
|
function getAttendanceOvertimeList () {//查询人员列表 |
||||
|
let obj = form.current.getValues() |
||||
|
if (form.current.getValues().entryTime?.length > 1) { |
||||
|
obj.startDate = moment(form.current.getValues().entryTime[0]).format('YYYY-MM-DD') |
||||
|
obj.endDate = moment(form.current.getValues().entryTime[1]).format('YYYY-MM-DD') |
||||
|
} |
||||
|
else { |
||||
|
obj.startDate = '' |
||||
|
obj.endDate = '' |
||||
|
} |
||||
|
dispatch(humanAffairs.getAttendanceOvertime({ ...obj, ...query, ...order })).then((res) => {//查询人员列表 |
||||
|
if (res.success) { |
||||
|
setArchivesList(res.payload?.data?.rows) |
||||
|
setLimits(res.payload?.data?.count) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
const columns = [ |
||||
|
{ |
||||
|
title: ( |
||||
|
<span> |
||||
|
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 员工编号 |
||||
|
</span> |
||||
|
), |
||||
|
width: 200, |
||||
|
dataIndex: "userCode", |
||||
|
key: "userCode", |
||||
|
render: (_, r, index) => { |
||||
|
return (r.userCode ? r.userCode : '-'); |
||||
|
}, |
||||
|
}, |
||||
|
]; |
||||
|
//获取表格属性设置 |
||||
|
function attribute () { |
||||
|
const arr = localStorage.getItem(OVERTIMESTATISTICS) |
||||
|
? JSON.parse(localStorage.getItem(OVERTIMESTATISTICS)) |
||||
|
: []; |
||||
|
|
||||
|
let column = [ |
||||
|
{ |
||||
|
title: ( |
||||
|
<div> |
||||
|
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 姓名 |
||||
|
</div> |
||||
|
), |
||||
|
width: 100, |
||||
|
dataIndex: "userName", |
||||
|
key: "userName", |
||||
|
render: (_, r, index) => { |
||||
|
return (r.userName ? r.userName : '-'); |
||||
|
}, |
||||
|
}, { |
||||
|
title: ( |
||||
|
<div> |
||||
|
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 所属部门 |
||||
|
</div> |
||||
|
), |
||||
|
width: 200, |
||||
|
dataIndex: "departmrnt", |
||||
|
key: "departmrnt", |
||||
|
render: (_, r, index) => { |
||||
|
return ( |
||||
|
<div style={{ display: 'flex' }}> |
||||
|
{ |
||||
|
r.departmrnt.map((ite, idx) => { |
||||
|
let departmentsArr = [] |
||||
|
for (let i = 0; i < r.departmrnt.length; i++) { |
||||
|
departmentsArr.push(r.departmrnt[i].name) |
||||
|
} |
||||
|
return ( |
||||
|
<div key={idx} style={{ display: 'flex' }}> |
||||
|
{idx == 0 ? |
||||
|
(<div style={{ padding: '0px 4px 1px 4px ', color: '#FFFFFF', fontSize: 12, background: 'rgba(0,90,189,0.8)', borderRadius: 2, marginRight: 4 }}> |
||||
|
{ite.name} |
||||
|
</div>) : ('') |
||||
|
|
||||
|
} |
||||
|
{ |
||||
|
r.departmrnt.length > 1 && idx == 1 ? ( |
||||
|
<Tooltip content={departmentsArr.join(',')} trigger="click" style={{ lineHeight: 2 }}> |
||||
|
<div style={{ padding: '0px 4px 1px 4px ', color: '#FFFFFF', fontSize: 12, background: 'rgba(0,90,189,0.8)', borderRadius: 2, marginRight: 4, cursor: "pointer", }}> |
||||
|
... |
||||
|
</div> |
||||
|
</Tooltip> |
||||
|
) : ('') |
||||
|
} |
||||
|
</div> |
||||
|
) |
||||
|
}) |
||||
|
} |
||||
|
</div> |
||||
|
) |
||||
|
}, |
||||
|
}, { |
||||
|
title: ( |
||||
|
<div> |
||||
|
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 职位 |
||||
|
</div> |
||||
|
), |
||||
|
width: 150, |
||||
|
dataIndex: "roleName", |
||||
|
key: "roleName", |
||||
|
render: (_, r, index) => { |
||||
|
return (r.roleName ? r.roleName : '-'); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '工作日-调休/h', |
||||
|
width: 140, |
||||
|
dataIndex: "workdayChange", |
||||
|
key: "workdayChange", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'workday' && r.overtimeStatistic[i].compensate == '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '普假-调休/h', |
||||
|
width: 140, |
||||
|
dataIndex: "dayoffChange", |
||||
|
key: "dayoffChange", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'dayoff' && r.overtimeStatistic[i].compensate == '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '法定假-调休/h', |
||||
|
width: 140, |
||||
|
dataIndex: "festivalsChange", |
||||
|
key: "festivalsChange", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'festivals' && r.overtimeStatistic[i].compensate == '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '工作日-折算/h', |
||||
|
width: 140, |
||||
|
dataIndex: "workdayConversion", |
||||
|
key: "workdayConversion", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'workday' && r.overtimeStatistic[i].compensate !== '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '普假-折算/h', |
||||
|
width: 140, |
||||
|
dataIndex: "dayoffConversion", |
||||
|
key: "dayoffConversion", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'dayoff' && r.overtimeStatistic[i].compensate !== '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '法定假-折算/h', |
||||
|
width: 140, |
||||
|
dataIndex: "festivalsConversion", |
||||
|
key: "festivalsConversion", |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].dayType == 'festivals' && r.overtimeStatistic[i].compensate !== '调休') { |
||||
|
num = r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return (num); |
||||
|
}, |
||||
|
}, { |
||||
|
title: '合计调休加班时长/h', |
||||
|
width: 180, |
||||
|
dataIndex: "overtimeTakeRestSum", |
||||
|
key: "overtimeTakeRestSum", |
||||
|
sorter: (a, b) => { }, |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].compensate == '调休') { |
||||
|
num = num + r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return num; |
||||
|
}, |
||||
|
}, { |
||||
|
title: '合计折算加班时长/h', |
||||
|
width: 180, |
||||
|
dataIndex: "overtimePaySum", |
||||
|
key: "overtimePaySum", |
||||
|
sorter: (a, b) => { }, |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
if (r.overtimeStatistic[i].compensate !== '调休') { |
||||
|
num = num + r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
} |
||||
|
return num; |
||||
|
}, |
||||
|
}, { |
||||
|
title: '合计加班时长/h', |
||||
|
width: 160, |
||||
|
dataIndex: "overtimeSum", |
||||
|
key: "overtimeSum", |
||||
|
sorter: (a, b) => { }, |
||||
|
render: (_, r, index) => { |
||||
|
let num = 0 |
||||
|
for (let i = 0; i < r.overtimeStatistic.length; i++) { |
||||
|
num = num + r.overtimeStatistic[i].duration / 3600 |
||||
|
} |
||||
|
return num; |
||||
|
}, |
||||
|
}, { |
||||
|
title: '合计加班次数', |
||||
|
width: 140, |
||||
|
dataIndex: "overtimeCount", |
||||
|
key: "overtimeCount", |
||||
|
sorter: (a, b) => { }, |
||||
|
render: (_, r, index) => { |
||||
|
return (r.overtimeCount ? r.overtimeCount : '0'); |
||||
|
}, |
||||
|
}, |
||||
|
]; |
||||
|
for (let i = 0; i < arr.length; i++) { |
||||
|
let colum = column.filter((item) => { |
||||
|
return item.key === arr[i]; |
||||
|
}); |
||||
|
columns.splice(i + 2, 0, colum[0]); |
||||
|
} |
||||
|
setSetupp(columns); |
||||
|
} |
||||
|
function handleRow (record, index) {//斑马条纹 |
||||
|
// 给偶数行设置斑马纹 |
||||
|
if (index % 2 === 0) { |
||||
|
return { |
||||
|
style: { |
||||
|
background: '#FAFCFF', |
||||
|
} |
||||
|
}; |
||||
|
} else { |
||||
|
return {}; |
||||
|
} |
||||
|
} |
||||
|
const scroll = useMemo(() => ({}), []); |
||||
|
return ( |
||||
|
<> |
||||
|
<div style={{ padding: '0px 12px' }}> |
||||
|
<div style={{ display: 'flex' }}> |
||||
|
<div style={{ color: 'rgba(0,0,0,0.45)', fontSize: 14 }}>人事管理</div> |
||||
|
<div style={{ color: 'rgba(0,0,0,0.45)', fontSize: 14, margin: '0px 8px' }}>/</div> |
||||
|
<div style={{ color: 'rgba(0,0,0,0.45)', fontSize: 14 }}>档案中心</div> |
||||
|
<div style={{ color: '#033C9A', fontSize: 14, margin: '0px 8px' }}>/</div> |
||||
|
<div style={{ color: '#033C9A', fontSize: 14 }}>人员档案</div> |
||||
|
</div> |
||||
|
<div style={{ background: '#FFFFFF', boxShadow: '0px 0px 12px 2px rgba(220,222,224,0.2)', borderRadius: 2, padding: '20px 0px 20px 19px ', marginTop: 12 }}> |
||||
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}> |
||||
|
<div style={{ display: 'flex', alignItems: 'baseline' }}> |
||||
|
<div style={{ width: 0, height: 20, borderLeft: '3px solid #0F7EFB', borderTop: '3px solid transparent', borderBottom: '3px solid transparent' }}></div> |
||||
|
<div style={{ fontFamily: "YouSheBiaoTiHei", fontSize: 24, color: '#033C9A', marginLeft: 8 }}>员工信息</div> |
||||
|
<div style={{ marginLeft: 6, fontSize: 12, color: '#969799', fontFamily: "DINExp", }}>EMPLOYEE INFORMATION</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div style={{ marginRight: 20, marginTop: 18 }}> |
||||
|
<Form |
||||
|
labelPosition="left" |
||||
|
labelAlign="right" |
||||
|
labelWidth="80px" |
||||
|
onValueChange={(values, field) => { |
||||
|
console.log('values', values); |
||||
|
}} |
||||
|
getFormApi={(formApi) => (form.current = formApi)} |
||||
|
> |
||||
|
<div> |
||||
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}> |
||||
|
<div style={{ display: 'flex', alignItems: 'center' }}> |
||||
|
<Form.Select |
||||
|
pure |
||||
|
field="keywordTarget" |
||||
|
placeholder="请选择搜索类型" |
||||
|
style={{ width: 200 }} |
||||
|
initValue={"role"} |
||||
|
> |
||||
|
<Form.Select.Option value='role'>职位</Form.Select.Option> |
||||
|
<Form.Select.Option value='dep'>部门</Form.Select.Option> |
||||
|
<Form.Select.Option value='number'>编号</Form.Select.Option> |
||||
|
<Form.Select.Option value='name'>姓名</Form.Select.Option> |
||||
|
</Form.Select> |
||||
|
<Form.Input |
||||
|
suffix={<IconSearch />} |
||||
|
field="keyword" |
||||
|
pure |
||||
|
showClear |
||||
|
style={{ width: 346, marginLeft: 12, marginRight: 12 }} |
||||
|
placeholder="请输入或选择关键词" |
||||
|
/> |
||||
|
|
||||
|
<Form.DatePicker |
||||
|
label='时间范围:' |
||||
|
field='entryTime' type="dateRange" density="compact" showClear style={{ width: 370, color: "#F9F9F9" }} /> |
||||
|
|
||||
|
</div> |
||||
|
<div style={{ display: 'flex', alignItems: 'center' }}> |
||||
|
<div style={{ width: 20, height: 20, cursor: "pointer", marginRight: 15 }} |
||||
|
onClick={() => { |
||||
|
let obj = form.current.getValues() |
||||
|
if (form.current.getValues().entryTime?.length > 1) { |
||||
|
obj.startDate = moment(form.current.getValues().entryTime[0]).format('YYYY-MM-DD') |
||||
|
obj.endDate = moment(form.current.getValues().entryTime[1]).format('YYYY-MM-DD') |
||||
|
} |
||||
|
else { |
||||
|
obj.startDate = '' |
||||
|
obj.endDate = '' |
||||
|
} |
||||
|
setDownloadUrl(`attendance/overtime/export?token=${user.token}&keywordTarget=${obj.keywordTarget ? obj.keywordTarget : ''}&keyword=${obj.keyword ? obj.keyword : ''}&startDate=${obj.startDate}&endDate=${obj.endDate}&limit=${query.limit}&page=${query.page}}`) |
||||
|
}}> |
||||
|
<img src="/assets/images/hrImg/export.png" alt="" style={{ width: '100%', height: '100%' }} /> |
||||
|
{ |
||||
|
downloadUrl ? <iframe src={`/_api/${downloadUrl}`} style={{ display: 'none' }} /> : '' |
||||
|
} |
||||
|
</div> |
||||
|
<img src="/assets/images/hrImg/newsetup.png" alt="" style={{ width: 20, height: 20, cursor: "pointer", marginRight: 15 }} |
||||
|
onClick={() => setSetup(true)} |
||||
|
/> |
||||
|
<Button theme='solid' type='primary' style={{ width: 80, borderRadius: 2, height: 32, background: '#DBECFF', color: '#005ABD' }} |
||||
|
onClick={() => { |
||||
|
setQuery({ limit: 10, page: 0 }) |
||||
|
}}>查询</Button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</Form> |
||||
|
<div style={{ border: '1px solid #C7E1FF', background: '#F4F8FF', borderRadius: 2, height: 32, width: 669, padding: '8px 0px 7px 12px', display: 'flex', alignItems: 'center', color: '#0F7EFB', fontSize: 12 }}> |
||||
|
<img src="/assets/images/hrImg/!.png" alt="" style={{ width: 14, height: 14, marginRight: 8 }} /> |
||||
|
表格中带有认证标识" |
||||
|
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> |
||||
|
"信息的为系统基础数据,来源于项企PEP、钉钉等系统,其他数据均为导入或自定义数据 |
||||
|
</div> |
||||
|
<div style={{ marginTop: 20 }}> |
||||
|
<Skeleton |
||||
|
// loading={loading} |
||||
|
loading={false} |
||||
|
active={true} |
||||
|
placeholder={SkeletonScreen()} |
||||
|
> |
||||
|
<Table |
||||
|
columns={setupp.filter((s) => s)} |
||||
|
dataSource={archivesList} |
||||
|
bordered={false} |
||||
|
empty="暂无数据" |
||||
|
pagination={false} |
||||
|
onChange={({ sorter }) => { |
||||
|
if (sorter.sortOrder == 'descend') { |
||||
|
setOrder({ orderBy: sorter.key, orderDirection: 'DESC' }) |
||||
|
} else { |
||||
|
setOrder({ orderBy: sorter.key, orderDirection: 'ASC' }) |
||||
|
} |
||||
|
}} |
||||
|
onRow={handleRow} |
||||
|
scroll={scroll} |
||||
|
/> |
||||
|
</Skeleton> |
||||
|
<div |
||||
|
style={{ |
||||
|
display: "flex", |
||||
|
justifyContent: "space-between", |
||||
|
padding: "20px 20px", |
||||
|
}} |
||||
|
> |
||||
|
<div> |
||||
|
</div> |
||||
|
<div style={{ display: 'flex', }}> |
||||
|
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}> |
||||
|
共{limits}条信息 |
||||
|
</span> |
||||
|
<Pagination |
||||
|
className="22" |
||||
|
total={limits} |
||||
|
showSizeChanger |
||||
|
currentPage={query.page + 1} |
||||
|
pageSizeOpts={[10, 20, 30, 40]} |
||||
|
onChange={(currentPage, pageSize) => { |
||||
|
setQuery({ limit: pageSize, page: currentPage - 1 }); |
||||
|
page.current = currentPage - 1 |
||||
|
}} |
||||
|
/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{setup ? ( |
||||
|
<Setup |
||||
|
tableType={OVERTIMESTATISTICS} |
||||
|
tableList={tableList} |
||||
|
length={13} |
||||
|
close={() => { |
||||
|
setSetup(false); |
||||
|
attribute(); |
||||
|
}} |
||||
|
/> |
||||
|
) : ( |
||||
|
"" |
||||
|
)} |
||||
|
</> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { auth, global, MemberSearch, webSocket } = state; |
||||
|
return { |
||||
|
// loading: members.isRequesting, |
||||
|
user: auth.user, |
||||
|
actions: global.actions, |
||||
|
xqMembers: MemberSearch.data, |
||||
|
// socket: webSocket.socket |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
export default connect(mapStateToProps)(overtimeStatistics); |
Loading…
Reference in new issue