Browse Source

(*)导入数据联调

master
ww664853070 2 years ago
parent
commit
1ede7b34d7
  1. 117
      web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx
  2. 33
      web/client/src/sections/humanAffairs/containers/personalTrainRecord.jsx

117
web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx

@ -2,12 +2,12 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import moment from 'moment'; 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 { IconUpload } from '@douyinfe/semi-icons';
import XLSX from 'xlsx' import XLSX from 'xlsx'
// //
const ImportPerformanceSummaryModal = props => { const ImportPerformanceSummaryModal = props => {
const { dispatch, actions, onCancel } = props; const { dispatch, actions, onCancel,query } = props;
const { businessManagement } = actions const { businessManagement } = actions
const [msg, setMsg] = useState(''); const [msg, setMsg] = useState('');
const [loading, setLoading] = useState(''); const [loading, setLoading] = useState('');
@ -18,12 +18,11 @@ const ImportPerformanceSummaryModal = props => {
const confirm = () => { const confirm = () => {
if (postData.length) { if (postData.length) {
setLoading(true) setLoading(true)
console.log(postData,'-------------------')
const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs
dispatch(postAllPersonalTrainRecord(postData)).then(res => { dispatch(postAllPersonalTrainRecord(postData)).then(res => {
if (res.success) { if (res.success) {
onCancel() onCancel()
dispatch(getPersonalTrainRecord()) dispatch(getPersonalTrainRecord(query))
} }
setLoading(false) 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 download = () => {
const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数","考核形式","考核分数","总分"]]; const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数","考核形式","考核分数","总分"]];
let sheetName = '个人培训'; let sheetName = '个人培训';
@ -105,35 +86,12 @@ const ImportPerformanceSummaryModal = props => {
request.send(); request.send();
}) })
} }
const changeTime = (v) => {
//xlsxexcel
// const judgeNull = (value) => { //2020/8/1xlsx Fri Jul 31 2020 23:59:17 GMT+0800 43
// return value ? String(value).trim().replace(/\s*/g, "") : null; let a = new Date(v);
// } a.setTime(a.getTime() + 43 * 1000);
return a;
// const judgeNullTime = (v) => {
// //xlsxexcel
// //2020/8/1xlsx 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;
} }
return ( return (
@ -183,26 +141,55 @@ const ImportPerformanceSummaryModal = props => {
obj[key] = d[personalTrainRecord[key]] || null; obj[key] = d[personalTrainRecord[key]] || null;
//} //}
}) })
// let tValid = judgeTimeValid(obj.recConDate); if (!obj.personalName) {
// if (!tValid) { Toast.error(`${i + 2}行,姓名为空,请填写`)
// error(`${i + 2}yyyy/mm/dd`) return
// return }
// } if (!obj.departmentName) {
Toast.error(`${i + 2}行,部门为空,请填写`)
// if (obj.isApproval && ['', ''].indexOf(obj.isApproval) == -1) { return
// error(`${i + 2}`) }
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 // return
// } // }
// // if (!obj.appraisalMethod) {
// if (obj.repurchaseCount && !zzsPattern.test(obj.repurchaseCount)) { Toast.error(`${i + 2}考核形式为空,请填写`)
// error(`${i + 2}`) return
}
// if (!obj.appraisalScore) {
// Toast.error(`${i + 2}`)
// return // return
// } // }
// if (!obj.totalScore) {
// if (obj.reproducible && ['', ''].indexOf(obj.reproducible) == -1) { // Toast.error(`${i + 2}`)
// error(`${i + 2}`)
// return // return
// } // }
obj.trainDate = changeTime(obj.trainDate)
postData.push(obj); postData.push(obj);
} }
setPostData(postData) setPostData(postData)

33
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 { connect } from 'react-redux';
import { Table, Pagination, Skeleton } from '@douyinfe/semi-ui'; import { Table, Pagination, Skeleton } from '@douyinfe/semi-ui';
import { SkeletonScreen } from "$components"; import { SkeletonScreen } from "$components";
import '../style.less' import '../style.less'
import ImportPersonalTrainRecord from './importPersonalTrainRecord' import ImportPersonalTrainRecord from './importPersonalTrainRecord'
import moment from 'moment'
const PersonalTrainRecord = (props) => { const PersonalTrainRecord = (props) => {
const { dispatch, actions } = props const { dispatch, actions ,personalTrainRecordList} = props
const [limits, setLimits] = useState()// const [limits, setLimits] = useState()//
const [query, setQuery] = useState({ limit: 10, page: 0 }); // const [query, setQuery] = useState({ limit: 10, page: 0 }); //
const [importModalV, setImportModalV] = useState(false); // const [importModalV, setImportModalV] = useState(false); //
const page = useRef(query.page);
const { getPersonalTrainRecord } = actions.humanAffairs
useEffect(() => { useEffect(() => {
const { getPersonalTrainRecord } = actions.humanAffairs
dispatch(getPersonalTrainRecord(query)) 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) {// function handleRow(record, index) {//
if (index % 2 === 0) { if (index % 2 === 0) {
return { return {
@ -68,7 +63,8 @@ const PersonalTrainRecord = (props) => {
title: '培训时间', title: '培训时间',
dataIndex: 'trainDate', dataIndex: 'trainDate',
key: 'trainDate', key: 'trainDate',
width: 200 width: 200,
render: (text) => moment(text).format('YYYY-MM-DD HH:mm:ss')
}, { }, {
title: '培训时长', title: '培训时长',
dataIndex: 'trainTime', dataIndex: 'trainTime',
@ -104,9 +100,6 @@ const PersonalTrainRecord = (props) => {
dataIndex: 'action', dataIndex: 'action',
width: 120 width: 120
}]; }];
return ( return (
<> <>
<div style={{ padding: '0px 12px' }}> <div style={{ padding: '0px 12px' }}>
@ -145,7 +138,7 @@ const PersonalTrainRecord = (props) => {
> >
<Table <Table
columns={columns} columns={columns}
dataSource={tableData} dataSource={personalTrainRecordList.rows}
bordered={false} bordered={false}
empty="暂无数据" empty="暂无数据"
pagination={false} pagination={false}
@ -161,15 +154,16 @@ const PersonalTrainRecord = (props) => {
<div></div> <div></div>
<div style={{ display: 'flex', }}> <div style={{ display: 'flex', }}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}> <span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{limits}条信息 {personalTrainRecordList.count}条信息
</span> </span>
<Pagination <Pagination
total={limits} total={personalTrainRecordList.count}
showSizeChanger showSizeChanger
currentPage={query.page + 1} currentPage={query.page + 1}
pageSizeOpts={[10, 20, 30, 40]} pageSizeOpts={[10, 20, 30, 40]}
onChange={(currentPage, pageSize) => { onChange={(currentPage, pageSize) => {
setQuery({ limit: pageSize, page: currentPage - 1 }); setQuery({ limit: pageSize, page: currentPage - 1 });
dispatch(getPersonalTrainRecord({ limit: pageSize, page: currentPage - 1 }));
page.current = currentPage - 1 page.current = currentPage - 1
}} }}
/> />
@ -179,7 +173,7 @@ const PersonalTrainRecord = (props) => {
</div> </div>
</div> </div>
{ {
importModalV ? <ImportPersonalTrainRecord importModalV ? <ImportPersonalTrainRecord query={query}
onCancel={() => { onCancel={() => {
setImportModalV(false); setImportModalV(false);
}} /> : '' }} /> : ''
@ -190,10 +184,11 @@ const PersonalTrainRecord = (props) => {
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { auth, global } = state; const { auth, global,personalTrainRecordList } = state;
return { return {
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
personalTrainRecordList:personalTrainRecordList.data || {}
}; };
} }

Loading…
Cancel
Save