From 8be1a93b13a440f1395104d7789857d900231302 Mon Sep 17 00:00:00 2001 From: Archer_cdm Date: Wed, 21 Dec 2022 12:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=88Fixed=20issue=20#=EF=BC=897466=20?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=9F=B9=E8=AE=AD=E8=AE=B0=E5=BD=95-?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=96=87=E6=A1=A3=E5=A7=93=E5=90=8D=E5=92=8C?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=81=9A=E6=95=B0=E6=8D=AE=E6=BA=90=E5=8C=B9?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../containers/importPersonalTrainRecord.jsx | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx index 552bc26..06b5d3e 100644 --- a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx +++ b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx @@ -2,23 +2,23 @@ import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { Modal, Form, Button, Notification,Toast } 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,query } = props; + const { dispatch, actions, onCancel, query, user } = props; const { businessManagement } = actions const [msg, setMsg] = useState(''); const [loading, setLoading] = useState(''); const [postData, setPostData] = useState([]); let personalTrainRecord = { personalName: '姓名', departmentName: '部门', trainingType: '培训类型', topic: '课程主题', trainer: '培训讲师', trainDate: '培训时间', trainTime: '培训时长', trainMethod: '培训方式', attendanceScore: '考勤分数', appraisalMethod: '考核形式', appraisalScore: '考核分数', totalScore: '总分' } //初始化 - + const confirm = () => { if (postData.length) { setLoading(true) - const { postAllPersonalTrainRecord,getPersonalTrainRecord } = actions.humanAffairs + const { postAllPersonalTrainRecord, getPersonalTrainRecord } = actions.humanAffairs dispatch(postAllPersonalTrainRecord(postData)).then(res => { if (res.success) { onCancel() @@ -32,7 +32,7 @@ const ImportPerformanceSummaryModal = props => { } const download = () => { - const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数","考核形式","考核分数","总分"]]; + const head = [["姓名", "部门", "培训类型", "课程主题", "培训讲师", "培训时间", "培训时长", "培训方式", "考勤分数", "考核形式", "考核分数", "总分"]]; let sheetName = '个人培训'; let workbook = { SheetNames: [sheetName], Sheets: {} }; workbook.Sheets[sheetName] = XLSX.utils.aoa_to_sheet(head);//json转excel @@ -55,9 +55,9 @@ const ImportPerformanceSummaryModal = props => { if (request.status == 200) { if (window.FileReader) { let reader = new FileReader(); - + reader.readAsBinaryString(request.response); - + reader.onload = event => { try { const { result } = event.target; @@ -149,6 +149,21 @@ const ImportPerformanceSummaryModal = props => { Toast.error(`第${i + 2}行,部门为空,请填写`) return } + if (user.allDepartment && user.allDepartment.departments) { + let dept = user.allDepartment.departments.find(d => !d.delete && d.name === obj.departmentName); + let personal = dept && dept.departmentUsers.find(e => e.user.name === obj.personalName); + if (dept) { + obj.departmentName = dept.name; + } else if (!dept) { + Toast.error(`第${i + 2}行【部门】数据有误,请确认后重新填写`) + return + } else if (personal) { + obj.personalName = personal.user.name; + } else if (!personal) { + Toast.error(`第${i + 2}行【姓名】数据有误,请确认后重新填写`) + return + } + } if (!obj.trainingType) { Toast.error(`第${i + 2}行,培训类型为空,请填写`) return