Commit 78c783f3 authored by 邓超's avatar 邓超

fix: 节假日管理优化

parent 76515a30
Pipeline #65103 passed with stages
...@@ -30,7 +30,7 @@ const AddModal = props => { ...@@ -30,7 +30,7 @@ const AddModal = props => {
dayName: validate.dayName, dayName: validate.dayName,
startDate: validate.dayTime[0].format('YYYY-MM-DD'), startDate: validate.dayTime[0].format('YYYY-MM-DD'),
endDate: validate.dayTime[1].format('YYYY-MM-DD'), endDate: validate.dayTime[1].format('YYYY-MM-DD'),
dayType: validate.dayType, dayType: 1,
}).then(res => { }).then(res => {
if (res.code === 0) { if (res.code === 0) {
message.success('新增成功'); message.success('新增成功');
...@@ -63,12 +63,12 @@ const AddModal = props => { ...@@ -63,12 +63,12 @@ const AddModal = props => {
<Input placeholder="请输入假日名称" /> <Input placeholder="请输入假日名称" />
</Form.Item> </Form.Item>
<Form.Item label="节假日类型" name="dayType" initialValue={1}> {/* <Form.Item label="节假日类型" name="dayType" initialValue={1}>
<Radio.Group> <Radio.Group>
<Radio value={1}>休息</Radio> <Radio value={1}>休息</Radio>
<Radio value={3}>法定</Radio> <Radio value={3}>法定</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item> */}
<Form.Item <Form.Item
label="假期时间" label="假期时间"
name="dayTime" name="dayTime"
......
/* eslint-disable global-require */ /* eslint-disable global-require */
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import axios from 'axios';
import { import {
Calendar, Calendar,
Button, Button,
...@@ -20,6 +21,8 @@ import { ...@@ -20,6 +21,8 @@ import {
ExportOutlined, ExportOutlined,
PlusOutlined, PlusOutlined,
SyncOutlined, SyncOutlined,
LeftOutlined,
RightOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { import {
AddFlowHoliday, AddFlowHoliday,
...@@ -108,19 +111,21 @@ const Holidays = () => { ...@@ -108,19 +111,21 @@ const Holidays = () => {
const calendarHoliday = useRef(new Map()); // 日历上得假期 const calendarHoliday = useRef(new Map()); // 日历上得假期
const queryData = useRef({ year: new Date().getFullYear(), month: new Date().getMonth() + 1 }); const queryData = useRef({ year: new Date().getFullYear(), month: new Date().getMonth() + 1 });
const tableData = useRef([]); const tableData = useRef([]);
const [currentDate, setCurrentDate] = useState(''); const [currentDate, setCurrentDate] = useState(moment().format('YYYY-MM-DD'));
const [form] = Form.useForm(); const [form] = Form.useForm();
useEffect(() => { useEffect(() => {
document.querySelector('.ant-picker-content').setAttribute('border', 1); document.querySelector('.ant-picker-content').setAttribute('border', 1);
let year = new Date().getFullYear(); let year = new Date().getFullYear();
let month = new Date().getMonth() + 1; let month = new Date().getMonth() + 1;
getData(year, month); getData(year, month);
resizeListener();
window.addEventListener('resize', resizeListener); window.addEventListener('resize', resizeListener);
return () => { return () => {
window.removeEventListener('resize', resizeListener); window.removeEventListener('resize', resizeListener);
}; };
}, []); }, []);
const resizeListener = () => { const resizeListener = () => {
console.log(document.documentElement.clientWidth);
setSize({ setSize({
width: document.documentElement.clientWidth, width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight, height: document.documentElement.clientHeight,
...@@ -232,20 +237,27 @@ const Holidays = () => { ...@@ -232,20 +237,27 @@ const Holidays = () => {
initialValues={{ remember: true }} initialValues={{ remember: true }}
labelAlign="left" labelAlign="left"
> >
<Form.Item label="假期名称" name="dayName" style={{ margin: '10px 0 10px 0' }}> <Form.Item
label="假期名称"
name="dayName"
style={{
display: obj.nWeek === 6 || obj.nWeek === 7 ? 'none' : 'flex',
margin: '10px 0 0 0',
}}
>
<Input placeholder="请输入假日名称" /> <Input placeholder="请输入假日名称" />
</Form.Item> </Form.Item>
<Form.Item {/* <Form.Item
label="节假日类型" label="节假日类型"
name="dayType" name="dayType"
style={{ margin: '10px 0 0 0' }} style={{ margin: '10px 0 0 0' }}
initialValue={1} initialValue={1}
> >
<Radio.Group> <Radio.Group>
<Radio value={1}>休息</Radio> <Radio value={1}>调休</Radio>
<Radio value={3}>法定</Radio> <Radio value={3}>法定</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item> */}
</Form> </Form>
</div> </div>
), ),
...@@ -255,10 +267,18 @@ const Holidays = () => { ...@@ -255,10 +267,18 @@ const Holidays = () => {
onOk() { onOk() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate.dayName) { let name;
name = validate.dayName;
if (obj.nWeek === 6) {
name = '周六';
}
if (obj.nWeek === 7) {
name = '周日';
}
if (validate.dayName || obj.nWeek === 6 || obj.nWeek === 7) {
AddFlowHoliday({ AddFlowHoliday({
dayName: validate.dayName, dayName: name,
dayType: validate.dayType, dayType: obj.nWeek === 7 || obj.nWeek === 6 ? 2 : 1,
startDate: date, startDate: date,
endDate: date, endDate: date,
}).then(res => { }).then(res => {
...@@ -302,17 +322,24 @@ const Holidays = () => { ...@@ -302,17 +322,24 @@ const Holidays = () => {
[styles.otherMonthDay]: month != queryData.current.month, [styles.otherMonthDay]: month != queryData.current.month,
[styles.rest]: holidayMsg?.DayType === 1, [styles.rest]: holidayMsg?.DayType === 1,
[styles.holidays]: holidayMsg?.DayType === 3, [styles.holidays]: holidayMsg?.DayType === 3,
[styles.weekend]: (week === 0 || week === 6) && calendarHoliday.current.has(date), [styles.weekend]: week === 0 || week === 6,
[styles.choose]: date === currentDate, [styles.choose]: date === currentDate,
})} })}
onDoubleClick={() => onSelect(value, obj)} onDoubleClick={() => onSelect(value, obj)}
onClick={() => setCurrentDate(date)} onClick={e => {
setCurrentDate(date);
}}
> >
<div className={styles.tiemBox}> <div className={styles.tiemBox}>
<p> {time.getDate()}</p> <p> {time.getDate()}</p>
<p> {obj.festival || obj.Term || obj.IDayCn}</p> <p> {obj.lunarFestival || obj.festival || obj.Term || obj.IDayCn}</p>
</div>
<div
className={styles.tips}
style={{ display: week === 0 || week === 6 ? 'block' : 'none' }}
>
{calendarHoliday.current.has(date) ? '末' : '班'}
</div> </div>
<div <div
className={styles.icon} className={styles.icon}
style={{ display: calendarHoliday.current.has(date) ? 'block' : 'none' }} style={{ display: calendarHoliday.current.has(date) ? 'block' : 'none' }}
...@@ -328,6 +355,7 @@ const Holidays = () => { ...@@ -328,6 +355,7 @@ const Holidays = () => {
const current = value.clone(); const current = value.clone();
const localeData = value.localeData(); const localeData = value.localeData();
const months = []; const months = [];
for (let i = 0; i < 12; i++) { for (let i = 0; i < 12; i++) {
current.month(i); current.month(i);
months.push(localeData.monthsShort(current)); months.push(localeData.monthsShort(current));
...@@ -350,31 +378,80 @@ const Holidays = () => { ...@@ -350,31 +378,80 @@ const Holidays = () => {
</Select.Option>, </Select.Option>,
); );
} }
return ( return (
<div className={styles.calendarHeader}> <div className={styles.calendarHeader}>
<div className={styles.left}> <div className={styles.left}>
<LeftOutlined
onClick={() => {
let newYear = year - 1;
const now = value.clone().year(newYear);
onChange(now);
}}
/>
<Select <Select
style={{ marginRight: '5px' }} style={{ margin: '0 5px' }}
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
className="my-year-select" className="my-year-select"
value={year} value={year}
onChange={newYear => { onChange={newYear => {
console.log(newYear);
const now = value.clone().year(newYear); const now = value.clone().year(newYear);
onChange(now); onChange(now);
}} }}
> >
{options} {options}
</Select> </Select>
<RightOutlined
onClick={() => {
let newYear = year + 1;
const now = value.clone().year(newYear);
onChange(now);
}}
/>
<LeftOutlined
onClick={() => {
let val = value.clone();
let newMonth = month - 1;
let now;
if (newMonth < 1) {
let newYear = year - 1;
now = val.set({ year: newYear, month: 11 });
} else {
now = value.clone().month(newMonth);
}
console.log(now.format('YYYY-MM-DD'));
onChange(now);
}}
/>
<Select <Select
style={{ margin: '0 5px' }}
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
value={month} value={month}
onChange={newMonth => { onChange={newMonth => {
console.log(newMonth);
const now = value.clone().month(newMonth); const now = value.clone().month(newMonth);
onChange(now); onChange(now);
}} }}
> >
{monthOptions} {monthOptions}
</Select> </Select>
<RightOutlined
onClick={() => {
let val = value.clone();
let newMonth = month + 1;
let now;
if (newMonth > 12) {
newMonth = 1;
now = val.year(year + 1).month(newMonth);
} else {
now = value.clone().month(newMonth);
}
onChange(now);
}}
/>
</div> </div>
<div className={styles.right}> <div className={styles.right}>
<Upload showUploadList={false} accept=".json" beforeUpload={beforeUpload}> <Upload showUploadList={false} accept=".json" beforeUpload={beforeUpload}>
...@@ -414,6 +491,7 @@ const Holidays = () => { ...@@ -414,6 +491,7 @@ const Holidays = () => {
</div> </div>
); );
}; };
// 导出 // 导出
const hadelExport = () => { const hadelExport = () => {
window.location.href = DownLoadFlowHoliday({ window.location.href = DownLoadFlowHoliday({
...@@ -423,10 +501,10 @@ const Holidays = () => { ...@@ -423,10 +501,10 @@ const Holidays = () => {
// 提交上传文件 // 提交上传文件
const beforeUpload = val => { const beforeUpload = val => {
console.log(val); console.log(val);
if (!form.getFieldValue('fileName')) { // if (!form.getFieldValue('fileName')) {
message.info('请上传文件'); // message.info('请上传文件');
return; // return;
} // }
const formData = new FormData(); const formData = new FormData();
formData.append('_files', val); formData.append('_files', val);
...@@ -434,6 +512,7 @@ const Holidays = () => { ...@@ -434,6 +512,7 @@ const Holidays = () => {
.then(res => { .then(res => {
console.log(res); console.log(res);
if (res.code === 0) { if (res.code === 0) {
getData(queryData.current.year, queryData.current.month);
message.success('上传成功'); message.success('上传成功');
} else { } else {
message.error(res.msg); message.error(res.msg);
...@@ -464,18 +543,30 @@ const Holidays = () => { ...@@ -464,18 +543,30 @@ const Holidays = () => {
workTimeMsg.current = value; workTimeMsg.current = value;
setVisible({ ...visible, workTime: true }); setVisible({ ...visible, workTime: true });
}; };
const disabledDate = value => {
return (
value < moment(`${queryData.current.year}-${queryData.current.month}`).startOf('month') ||
value > moment(`${queryData.current.year}-${queryData.current.month}`).endOf('month')
);
};
return ( return (
<div className={styles.calendarPage} style={{ zoom: size.width / 1920 }}> <div
className={styles.calendarPage}
// style={{ transform: `scale(${size.width / 1920}, ${size.height / 960})` }}
style={{ zoom: size.width / 1920 }}
>
{/* 左侧日历 */} {/* 左侧日历 */}
<div className={styles.leftContent}> <div className={styles.leftContent}>
<div className={styles.calendarBox}> <div className={styles.calendarBox}>
<Calendar <Calendar
disabledDate={disabledDate}
prevFarthestDate={false}
locale={locale} locale={locale}
dateFullCellRender={dateCellRender} dateFullCellRender={dateCellRender}
onPanelChange={onPanelChange} onPanelChange={onPanelChange}
headerRender={headerRender} headerRender={headerRender}
// onSelect={onSelect} onSelect={() => {}}
/> />
</div> </div>
{/* 工作时间管理 */} {/* 工作时间管理 */}
...@@ -550,21 +641,34 @@ const Holidays = () => { ...@@ -550,21 +641,34 @@ const Holidays = () => {
{tableData.current.map((item, index) => ( {tableData.current.map((item, index) => (
<div className={styles.itemBox} key={index}> <div className={styles.itemBox} key={index}>
<div className={styles.header}> <div className={styles.header}>
<div className={styles.title}>{item.DayName}</div> <div className={styles.title}>
<div className={styles.del}> {item.DayName}({item.DayDate?.split(',').length}天)
</div>
<div
className={styles.del}
onClick={() => {
setTimeout(() => {
console.log(document.querySelectorAll('.ant-popconfirm'));
document.querySelectorAll('.ant-popconfirm').forEach(ele => {
ele.style.zoom = size.width / 1920;
});
}, 0);
}}
>
<Popconfirm <Popconfirm
title="是否删除该节假日?" title="是否删除该节假日?"
onConfirm={() => delRow(item)} onConfirm={() => delRow(item)}
onCancel={() => message.error('取消删除')} onCancel={() => message.error('取消删除')}
okText="是" okText="是"
cancelText="否" cancelText="否"
style={{ zoom: size.width / 1920 }}
> >
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} /> <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm> </Popconfirm>
</div> </div>
</div> </div>
<div className={styles.content}> <div className={styles.content}>
{item.DayDate?.split(',').map(ele => <span key={ele}>{ele}</span>)} {item.DayDate?.split(',').map((ele, i) => <span key={i}>{ele}</span>)}
</div> </div>
</div> </div>
))} ))}
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
.calendarCell { .calendarCell {
position: relative; position: relative;
width: 160px; width: 159px;
height: 88px; height: 88px;
.tiemBox { .tiemBox {
...@@ -97,6 +97,15 @@ ...@@ -97,6 +97,15 @@
background: #FFF2F2; background: #FFF2F2;
.tips {
position: absolute;
top: 5px;
right: 10px;
width: 10px;
height: 10px;
}
.tiemBox { .tiemBox {
p:nth-of-type(1) { p:nth-of-type(1) {
...@@ -157,6 +166,7 @@ ...@@ -157,6 +166,7 @@
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
} }
.right { .right {
...@@ -208,13 +218,14 @@ ...@@ -208,13 +218,14 @@
align-items: center; align-items: center;
.workTimeBox { .workTimeBox {
display: flex; display: flex;
align-items: center; align-items: center;
// justify-content: center; // justify-content: center;
width: 358px; width: 358px;
height: 123px; height: 123px;
transition: transform 0.5s;
cursor: pointer;
.left { .left {
margin-left: 38px; margin-left: 38px;
margin-right: 20px; margin-right: 20px;
...@@ -238,6 +249,10 @@ ...@@ -238,6 +249,10 @@
} }
} }
.workTimeBox:hover {
transform: scale(1.05);
}
.mor { .mor {
background: url("../../../../assets/images/holidays/mor.png"); background: url("../../../../assets/images/holidays/mor.png");
background-size: 100% 100%; background-size: 100% 100%;
......
...@@ -13,10 +13,12 @@ export const AddFlowHoliday = param => ...@@ -13,10 +13,12 @@ export const AddFlowHoliday = param =>
get(`${PUBLISH_SERVICE}/WorkDayManage/AddFlowHoliday`, param); get(`${PUBLISH_SERVICE}/WorkDayManage/AddFlowHoliday`, param);
// 导入节假日 // 导入节假日
export const ImportFlowHoliday = param => export const ImportFlowHoliday = param =>
get(`${PUBLISH_SERVICE}/WorkDayManage/ImportFlowHoliday`, param); post(`${PUBLISH_SERVICE}/WorkDayManage/ImportFlowHoliday`, param);
// 导出节假日 // 导出节假日
export const DownLoadFlowHoliday = query => export const DownLoadFlowHoliday = query =>
`${PUBLISH_SERVICE}/WorkDayManage/DownLoadFlowHoliday?year=${query.year}`; `${PUBLISH_SERVICE}/WorkDayManage/DownLoadFlowHoliday?year=${query.year}`;
// export const DownLoadFlowHoliday = param =>
// get(`${PUBLISH_SERVICE}/WorkDayManage/DownLoadFlowHoliday`, param);
// 初始化节假日 // 初始化节假日
export const InitializationFlowHoliday = param => export const InitializationFlowHoliday = param =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment