diff --git a/api/app/lib/controllers/departmentTrain/index.js b/api/app/lib/controllers/departmentTrain/index.js index 02f14b8..f14bd62 100644 --- a/api/app/lib/controllers/departmentTrain/index.js +++ b/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}`); diff --git a/doc/scripts/3.2.0/schema/personal_training_create.sql b/doc/scripts/3.2.0/schema/personal_training_create.sql new file mode 100644 index 0000000..e81e4ba --- /dev/null +++ b/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 ) --来源 + +); \ No newline at end of file diff --git a/web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx index 12c2a73..9790ff7 100644 --- a/web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx +++ b/web/client/src/sections/humanAffairs/containers/departmentTrain/departmentTrainRecord.jsx @@ -128,11 +128,7 @@ const DepartmentTrainRecord = (props) => { render: (text, record) => { if (record.origin === 'import') return
- onEdit(record)}>编辑   - {/* confirmDelete(record.id)} style={{ width: 330 }} - > 删除 */} + onEdit(record)}>编辑
else return - diff --git a/web/client/src/sections/humanAffairs/containers/departmentTrain/editModal.js b/web/client/src/sections/humanAffairs/containers/departmentTrain/editModal.js index 90019f8..8589533 100644 --- a/web/client/src/sections/humanAffairs/containers/departmentTrain/editModal.js +++ b/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'); diff --git a/web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js b/web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js index 4f8b2a0..a02b69c 100644 --- a/web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js +++ b/web/client/src/sections/humanAffairs/containers/departmentTrain/importModal.js @@ -116,7 +116,7 @@ const ImportModal = props => { { setMsg(''); setPostData([]); diff --git a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx index 49e0a78..d104d77 100644 --- a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx +++ b/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);//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 diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index d27794f..5e43749 100644 --- a/web/client/src/utils/webapi.js +++ b/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',