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 [msg, setMsg] = useState('');
const [loading, setLoading] = useState(''); const [loading, setLoading] = useState('');
const [postData, setPostData] = 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 = () => { const confirm = () => {
if (postData.length) { if (postData.length) {
setLoading(true) setLoading(true)
console.log(postData,'-------------------') console.log(postData,'-------------------')
// dispatch(businessManagement.importSalePerformance(postData)).then(res => { const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs
// if (res.success) { dispatch(postAllPersonalTrainRecord(postData)).then(res => {
// onCancel() if (res.success) {
// } onCancel()
// setLoading(false) dispatch(getPersonalTrainRecord())
// }) }
setLoading(false)
})
} else { } else {
Notification.warning({ content: '没有数据可以提交,请上传数据文件', duration: 2 }) Notification.warning({ content: '没有数据可以提交,请上传数据文件', duration: 2 })
} }
@ -49,10 +51,18 @@ const ImportPerformanceSummaryModal = props => {
link.click(); link.click();
} }
const download = () => { 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) => { const getFileBlob = (url) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -64,6 +74,7 @@ const ImportPerformanceSummaryModal = props => {
if (request.status == 200) { if (request.status == 200) {
if (window.FileReader) { if (window.FileReader) {
let reader = new FileReader(); let reader = new FileReader();
reader.readAsBinaryString(request.response); reader.readAsBinaryString(request.response);
reader.onload = event => { reader.onload = event => {
@ -72,7 +83,7 @@ const ImportPerformanceSummaryModal = props => {
// excel // excel
const workbook = XLSX.read(result, { const workbook = XLSX.read(result, {
type: "binary", type: "binary",
// cellDates: true,//true cellDates: true,//true
codepage: 936,// codepage: 936,//
}); });
let data = []; // let data = []; //
@ -172,7 +183,7 @@ const ImportPerformanceSummaryModal = props => {
obj[key] = d[personalTrainRecord[key]] || null; obj[key] = d[personalTrainRecord[key]] || null;
//} //}
}) })
let tValid = judgeTimeValid(obj.recConDate); // let tValid = judgeTimeValid(obj.recConDate);
// if (!tValid) { // if (!tValid) {
// error(`${i + 2}yyyy/mm/dd`) // error(`${i + 2}yyyy/mm/dd`)
// return // return

Loading…
Cancel
Save