|
|
@ -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);//json转excel |
|
|
|
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 |
|
|
|