周沫沫历险记 2 years ago
parent
commit
cfd841139e
  1. 5
      api/app/lib/controllers/departmentTrain/index.js
  2. 17
      doc/scripts/3.2.0/schema/personal_training_create.sql
  3. 6
      web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx
  4. 3
      web/client/src/sections/humanAffairs/containers/departmentTrain/editModal.js
  5. 2
      web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js
  6. 33
      web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx
  7. 2
      web/client/src/utils/webapi.js

5
api/app/lib/controllers/departmentTrain/index.js

@ -1,4 +1,7 @@
'use strict';
const moment = require("moment/moment");
async function get(ctx) {
try {
const { limit, page } = ctx.query;
@ -45,7 +48,7 @@ async function modify(ctx) {
if (!existRes) {
throw '当前部门培训记录信息不存在';
}
await models.DeptTraining.update({ ...rest }, { where: { id: id } });
await models.DeptTraining.update({ updateDate: moment(), ...rest }, { where: { id: id } });
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);

17
doc/scripts/3.2.0/schema/personal_training_create.sql

@ -0,0 +1,17 @@
CREATE TABLE personal_training (
ID serial PRIMARY KEY NOT NULL,
personalName VARCHAR ( 255 ) NOT NULL,-- 姓名
departmentName VARCHAR ( 255 ) NOT NULL,-- 部门名称
trainingType VARCHAR ( 255 ) NOT NULL,-- 培训类型
topic VARCHAR ( 255 ) NOT NULL,-- 课程主题
trainer VARCHAR ( 255 ) NOT NULL,-- 培训讲师
trainDate TIMESTAMP NOT NULL,-- 培训时间
trainTime VARCHAR ( 255 ) NOT NULL,-- 培训时长
trainMethod VARCHAR ( 255 ) NOT NULL,-- 培训方式
attendanceScore VARCHAR ( 255 ),-- 考勤分数
appraisalMethod VARCHAR ( 255 ) NOT NULL,-- 考核形式
appraisalScore VARCHAR ( 255 ),-- 考核分数
totalScore VARCHAR ( 255 ),-- 总分
origin VARCHAR ( 255 ) --
);

6
web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx

@ -128,11 +128,7 @@ const DepartmentTrainRecord = (props) => {
render: (text, record) => {
if (record.origin === 'import')
return <div>
<span style={{ color: '#1890FF', cursor: 'pointer' }} onClick={() => onEdit(record)}>编辑</span>&nbsp;&nbsp;
{/* <Popconfirm
title='提示' content="确认删除该部门培训记录信息?" position='topLeft'
onConfirm={() => confirmDelete(record.id)} style={{ width: 330 }}
> <span style={{ color: '#1890FF', cursor: 'pointer' }}>删除</span></Popconfirm> */}
<span style={{ color: '#1890FF', cursor: 'pointer' }} onClick={() => onEdit(record)}>编辑</span>
</div>
else
return <span>-</span>

3
web/client/src/sections/humanAffairs/containers/departmentTrain/editModal.js

@ -82,7 +82,8 @@ const EditModal = (props) => {
return '';
}
};
//validate和validateContent写通用方法后,校验文本不提示了..奇怪
//validate和validateContent-暂不修改合并
const validateContent = (val, values) => {
if (!val) {
setValidateStatus('error');

2
web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js

@ -116,7 +116,7 @@ const ImportModal = props => {
<Form.Upload
label={'部门培训记录'} labelPosition='left'
action={'/'} accept={'.xlsx'}
maxSize={102400} limit={1}
maxSize={204800} limit={1}
onRemove={(currentFile, fileList, fileItem) => {
setMsg('');
setPostData([]);

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

2
web/client/src/utils/webapi.js

@ -46,7 +46,7 @@ export const ApiTable = {
//个人培训记录
getPersonalTrainRecord: 'personal/train/record/list',
postAllPersonalTrainRecord: 'personal/train/record/list',
postAllPersonalTrainRecord: 'personal/train/record/bulk',
//-培训资料库
getResourceClassify: 'train/trainFiles/resourceRepository/classify',

Loading…
Cancel
Save