diff --git a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx index d104d77..552bc26 100644 --- a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx +++ b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx @@ -2,12 +2,12 @@ import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { Modal, Form, Button, Notification } from '@douyinfe/semi-ui'; +import { Modal, Form, Button, Notification,Toast } from '@douyinfe/semi-ui'; import { IconUpload } from '@douyinfe/semi-icons'; import XLSX from 'xlsx' //下载模板和上传文件读取 const ImportPerformanceSummaryModal = props => { - const { dispatch, actions, onCancel } = props; + const { dispatch, actions, onCancel,query } = props; const { businessManagement } = actions const [msg, setMsg] = useState(''); const [loading, setLoading] = useState(''); @@ -18,12 +18,11 @@ const ImportPerformanceSummaryModal = props => { const confirm = () => { if (postData.length) { setLoading(true) - console.log(postData,'-------------------') const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs dispatch(postAllPersonalTrainRecord(postData)).then(res => { if (res.success) { onCancel() - dispatch(getPersonalTrainRecord()) + dispatch(getPersonalTrainRecord(query)) } setLoading(false) }) @@ -32,24 +31,6 @@ const ImportPerformanceSummaryModal = props => { } } - const dldCsvMb = () => { - //表头 - let head = []; - Object.keys(personalTrainRecord).map(key => { - head.push(personalTrainRecord[key]); - }) - head = head.join(',') + "\n"; - //数据 - //let data = 1 + ',' + 2 + ',' + 3 + ',' + 4 + ',' + 5 - let templateCsv = "data:text/xlsx;charset=utf-8,\ufeff" + head; - //创建一个a标签 - let link = document.createElement("a"); - //为a标签设置属性 - link.setAttribute("href", templateCsv); - link.setAttribute("download", "个人培训记录表模板.xlsx"); - //点击a标签 - link.click(); - } const download = () => { const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数","考核形式","考核分数","总分"]]; let sheetName = '个人培训'; @@ -105,35 +86,12 @@ const ImportPerformanceSummaryModal = props => { request.send(); }) } - - - // const judgeNull = (value) => { - // return value ? String(value).trim().replace(/\s*/g, "") : null; - // } - - // const judgeNullTime = (v) => { - // //注意的点:xlsx将excel中的时间内容解析后,会小一天 - // //如2020/8/1,xlsx会解析成 Fri Jul 31 2020 23:59:17 GMT+0800 小了43秒 - // let a = new Date(v); - // a.setTime(a.getTime() + 43 * 1000); - // return v ? a : null; - // } - - const judgeTimeValid = (time) => { - let valid = true; - if (!time) { - return valid;//可以不填 - } - const ymd = /^((19|20)[0-9]{2})[\/\-]((0[1-9])|(1[0-2]))[\/\-]((0[1-9])|((1|2)[0-9])|(3[0-1]))$/;//年月日 - if (time instanceof Date) { - let timeStr = moment(time).format('YYYY/MM/DD'); - if (!ymd.test(timeStr)) { - valid = false; - } - } else { - valid = false; - } - return valid; + const changeTime = (v) => { + //注意的点:xlsx将excel中的时间内容解析后,会小一天 + //如2020/8/1,xlsx会解析成 Fri Jul 31 2020 23:59:17 GMT+0800 小了43秒 + let a = new Date(v); + a.setTime(a.getTime() + 43 * 1000); + return a; } return ( @@ -183,26 +141,55 @@ const ImportPerformanceSummaryModal = props => { obj[key] = d[personalTrainRecord[key]] || null; //} }) - // let tValid = judgeTimeValid(obj.recConDate); - // if (!tValid) { - // error(`第${i + 2}行【收到合同日期】错误,请填写yyyy/mm/dd格式`) - // return - // } - - // if (obj.isApproval && ['是', '否'].indexOf(obj.isApproval) == -1) { - // error(`第${i + 2}行【价格是否特批】错误,请填写是或否`) + if (!obj.personalName) { + Toast.error(`第${i + 2}行,姓名为空,请填写`) + return + } + if (!obj.departmentName) { + Toast.error(`第${i + 2}行,部门为空,请填写`) + return + } + if (!obj.trainingType) { + Toast.error(`第${i + 2}行,培训类型为空,请填写`) + return + } + if (!obj.topic) { + Toast.error(`第${i + 2}行,课程主题为空,请填写`) + return + } + if (!obj.trainer) { + Toast.error(`第${i + 2}行,培训讲师为空,请填写`) + return + } + if (!obj.trainDate) { + Toast.error(`第${i + 2}行,培训时间为空,请填写`) + return + } + if (!obj.trainTime) { + Toast.error(`第${i + 2}行,培训时长为空,请填写`) + return + } + if (!obj.trainMethod) { + Toast.error(`第${i + 2}行,培训方式为空,请填写`) + return + } + // if (!obj.attendanceScore) { + // error(`第${i + 2}考勤分数为空,请填写`) // return // } - // //复购次数 正整数 - // if (obj.repurchaseCount && !zzsPattern.test(obj.repurchaseCount)) { - // error(`第${i + 2}行【复购次数】填写错误,需要为非负整数`) + if (!obj.appraisalMethod) { + Toast.error(`第${i + 2}考核形式为空,请填写`) + return + } + // if (!obj.appraisalScore) { + // Toast.error(`第${i + 2}考核分数为空,请填写`) // return // } - - // if (obj.reproducible && ['是', '否'].indexOf(obj.reproducible) == -1) { - // error(`第${i + 2}行【是否可复制的业务路径】错误,请填写是或否`) + // if (!obj.totalScore) { + // Toast.error(`第${i + 2}总分为空,请填写`) // return // } + obj.trainDate = changeTime(obj.trainDate) postData.push(obj); } setPostData(postData) diff --git a/web/client/src/sections/humanAffairs/containers/personalTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/personalTrainRecord.jsx index 5fbb4a3..d8a916e 100644 --- a/web/client/src/sections/humanAffairs/containers/personalTrainRecord.jsx +++ b/web/client/src/sections/humanAffairs/containers/personalTrainRecord.jsx @@ -1,26 +1,21 @@ -import React, { useEffect, useState, useMemo } from 'react'; +import React, { useEffect, useState,useRef } from 'react'; import { connect } from 'react-redux'; import { Table, Pagination, Skeleton } from '@douyinfe/semi-ui'; import { SkeletonScreen } from "$components"; import '../style.less' import ImportPersonalTrainRecord from './importPersonalTrainRecord' +import moment from 'moment' const PersonalTrainRecord = (props) => { - const { dispatch, actions } = props + const { dispatch, actions ,personalTrainRecordList} = props const [limits, setLimits] = useState()//每页实际条数 const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [importModalV, setImportModalV] = useState(false); //页码信息 + const page = useRef(query.page); + const { getPersonalTrainRecord } = actions.humanAffairs useEffect(() => { - const { getPersonalTrainRecord } = actions.humanAffairs dispatch(getPersonalTrainRecord(query)) }, []); - - const [tableData, setTableData] = useState([{ id: 1, personalName: '张三', departmentName: '营销第一军团', trainingType: '内部培训', topic: '新员工入职培训', trainer: '李四', trainDate: '2022-12-30 18:30', trainTime: '1小时', trainMethod: '线下', attendanceScore: '95', appraisalMethod: '笔试', appraisalScore: '86', totalScore: '80' }, { id: 2, personalName: '张三', departmentName: '营销第一军团', trainingType: '内部培训', topic: '新员工入职培训', trainer: '李四', trainDate: '2022-12-30 18:30', trainTime: '1小时', trainMethod: '线下', attendanceScore: '95', appraisalMethod: '笔试', appraisalScore: '86', totalScore: '80' }, { id: 3, personalName: '张三', departmentName: '营销第一军团', trainingType: '内部培训', topic: '新员工入职培训', trainer: '李四', trainDate: '2022-12-30 18:30', trainTime: '1小时', trainMethod: '线下', attendanceScore: '95', appraisalMethod: '笔试', appraisalScore: '86', totalScore: '80' }, { id: 4, personalName: '张三', departmentName: '营销第一军团', trainingType: '内部培训', topic: '新员工入职培训', trainer: '李四', trainDate: '2022-12-30 18:30', trainTime: '1小时', trainMethod: '线下', attendanceScore: '95', appraisalMethod: '笔试', appraisalScore: '86', totalScore: '80' }]); - - useEffect(() => { - - }, []) - function handleRow(record, index) {// 给偶数行设置斑马纹 if (index % 2 === 0) { return { @@ -68,7 +63,8 @@ const PersonalTrainRecord = (props) => { title: '培训时间', dataIndex: 'trainDate', key: 'trainDate', - width: 200 + width: 200, + render: (text) => moment(text).format('YYYY-MM-DD HH:mm:ss') }, { title: '培训时长', dataIndex: 'trainTime', @@ -104,9 +100,6 @@ const PersonalTrainRecord = (props) => { dataIndex: 'action', width: 120 }]; - - - return ( <>