Browse Source

(*)导入

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

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

@ -12,19 +12,21 @@ const ImportPerformanceSummaryModal = props => {
const [msg, setMsg] = useState('');
const [loading, setLoading] = useState('');
const [postData, setPostData] = useState([]);
let personalTrainRecord = { index: '序号', personalName: '姓名', departmentName: '部门', trainingType: '培训类型', topic: '课程主题', trainer: '培训讲师', trainDate: '培训时间', trainTime: '培训时长', trainMethod: '培训方式', attendanceScore: '考勤分数', appraisalMethod: '考核形式', appraisalScore: '考核分数', totalScore: '总分' }
let personalTrainRecord = { personalName: '姓名', departmentName: '部门', trainingType: '培训类型', topic: '课程主题', trainer: '培训讲师', trainDate: '培训时间', trainTime: '培训时长', trainMethod: '培训方式', attendanceScore: '考勤分数', appraisalMethod: '考核形式', appraisalScore: '考核分数', totalScore: '总分' }
//
const confirm = () => {
if (postData.length) {
setLoading(true)
console.log(postData,'-------------------')
// dispatch(businessManagement.importSalePerformance(postData)).then(res => {
// if (res.success) {
// onCancel()
// }
// setLoading(false)
// })
const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs
dispatch(postAllPersonalTrainRecord(postData)).then(res => {
if (res.success) {
onCancel()
dispatch(getPersonalTrainRecord())
}
setLoading(false)
})
} else {
Notification.warning({ content: '没有数据可以提交,请上传数据文件', duration: 2 })
}
@ -49,10 +51,18 @@ const ImportPerformanceSummaryModal = props => {
link.click();
}
const download = () => {
dldCsvMb();
const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数","考核形式","考核分数","总分"]];
let sheetName = '个人培训';
let workbook = { SheetNames: [sheetName], Sheets: {} };
workbook.Sheets[sheetName] = XLSX.utils.aoa_to_sheet(head);//jsonexcel
workbook.Sheets[sheetName]['!cols'] = [
{ wch: 12 }, { wch: 12 }, { wch: 15 }, { wch: 20 }, { wch: 12 },
{ wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 10 }];
let wopts = { bookType: 'xlsx', type: 'buffer' };// excel
XLSX.writeFile(workbook, '个人培训记录导入模板.xlsx', wopts);
}
const fileLimit = '.csv';
const fileLimit = '.xlsx';
const getFileBlob = (url) => {
return new Promise((resolve, reject) => {
@ -64,6 +74,7 @@ const ImportPerformanceSummaryModal = props => {
if (request.status == 200) {
if (window.FileReader) {
let reader = new FileReader();
reader.readAsBinaryString(request.response);
reader.onload = event => {
@ -72,7 +83,7 @@ const ImportPerformanceSummaryModal = props => {
// excel
const workbook = XLSX.read(result, {
type: "binary",
// cellDates: true,//true
cellDates: true,//true
codepage: 936,//
});
let data = []; //
@ -172,7 +183,7 @@ const ImportPerformanceSummaryModal = props => {
obj[key] = d[personalTrainRecord[key]] || null;
//}
})
let tValid = judgeTimeValid(obj.recConDate);
// let tValid = judgeTimeValid(obj.recConDate);
// if (!tValid) {
// error(`${i + 2}yyyy/mm/dd`)
// return

Loading…
Cancel
Save