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 { 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) => {
// //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;
const changeTime = (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 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)

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 { 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 (
<>
<div style={{ padding: '0px 12px' }}>
@ -145,7 +138,7 @@ const PersonalTrainRecord = (props) => {
>
<Table
columns={columns}
dataSource={tableData}
dataSource={personalTrainRecordList.rows}
bordered={false}
empty="暂无数据"
pagination={false}
@ -161,15 +154,16 @@ const PersonalTrainRecord = (props) => {
<div></div>
<div style={{ display: 'flex', }}>
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}>
{limits}条信息
{personalTrainRecordList.count}条信息
</span>
<Pagination
total={limits}
total={personalTrainRecordList.count}
showSizeChanger
currentPage={query.page + 1}
pageSizeOpts={[10, 20, 30, 40]}
onChange={(currentPage, pageSize) => {
setQuery({ limit: pageSize, page: currentPage - 1 });
dispatch(getPersonalTrainRecord({ limit: pageSize, page: currentPage - 1 }));
page.current = currentPage - 1
}}
/>
@ -179,7 +173,7 @@ const PersonalTrainRecord = (props) => {
</div>
</div>
{
importModalV ? <ImportPersonalTrainRecord
importModalV ? <ImportPersonalTrainRecord query={query}
onCancel={() => {
setImportModalV(false);
}} /> : ''
@ -190,10 +184,11 @@ const PersonalTrainRecord = (props) => {
}
function mapStateToProps(state) {
const { auth, global } = state;
const { auth, global,personalTrainRecordList } = state;
return {
user: auth.user,
actions: global.actions,
personalTrainRecordList:personalTrainRecordList.data || {}
};
}

Loading…
Cancel
Save