From 9ed440cb3913cb6b53a1495de2b3b722cf78682b Mon Sep 17 00:00:00 2001 From: Archer_cdm Date: Tue, 20 Dec 2022 09:03:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=EF=BC=88+=EF=BC=89=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=AE=B0=E5=BD=95=E8=A1=A8=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/personalTrain/index.js | 20 ++++++++++++++++++- api/app/lib/routes/personalTrain/index.js | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/personalTrain/index.js b/api/app/lib/controllers/personalTrain/index.js index 51d13a1..28d6182 100644 --- a/api/app/lib/controllers/personalTrain/index.js +++ b/api/app/lib/controllers/personalTrain/index.js @@ -18,6 +18,24 @@ async function getPersonalTrainRecordList(ctx) { } } +async function importPersonalTrainData(ctx) { + let errorMsg = { message: '导入个人培训记录信息失败' }; + const transaction = await ctx.fs.dc.orm.transaction(); + try { + const models = ctx.fs.dc.models; + const data = ctx.request.body; + await models.PersonalTraining.bulkCreate(data, { transaction }); + await transaction.commit(); + ctx.status = 204; + } catch (error) { + await transaction.rollback(); + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = errorMsg; + } +} + module.exports = { - getPersonalTrainRecordList + getPersonalTrainRecordList, + importPersonalTrainData } diff --git a/api/app/lib/routes/personalTrain/index.js b/api/app/lib/routes/personalTrain/index.js index 4779899..271466f 100644 --- a/api/app/lib/routes/personalTrain/index.js +++ b/api/app/lib/routes/personalTrain/index.js @@ -5,4 +5,7 @@ const personalTrain = require('../../controllers/personalTrain'); module.exports = function (app, router, opts) { app.fs.api.logAttr['GET/personal/train/record/list'] = { content: '查询个人培训记录列表', visible: true }; router.get('/personal/train/record/list', personalTrain.getPersonalTrainRecordList); + + app.fs.api.logAttr['POST/personal/train/record/bulk'] = { content: '导入个人培训记录信息', visible: true }; + router.post('/personal/train/record/bulk', personalTrain.importPersonalTrainData); }; \ No newline at end of file From 1fbf7acec4f54eab336fddd58366189c38030a03 Mon Sep 17 00:00:00 2001 From: ww664853070 Date: Tue, 20 Dec 2022 09:59:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?(*)=E5=AF=BC=E5=85=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sections/humanAffairs/actions/personalTrainRecord.js | 8 ++++---- .../humanAffairs/containers/importPersonalTrainRecord.jsx | 4 ++-- web/client/src/utils/webapi.js | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/client/src/sections/humanAffairs/actions/personalTrainRecord.js b/web/client/src/sections/humanAffairs/actions/personalTrainRecord.js index 277df99..d43fa83 100644 --- a/web/client/src/sections/humanAffairs/actions/personalTrainRecord.js +++ b/web/client/src/sections/humanAffairs/actions/personalTrainRecord.js @@ -2,14 +2,14 @@ import { ApiTable, basicAction } from '$utils' -export function personalTrainRecordAll(values) { +export function postAllPersonalTrainRecord(values) { return dispatch => basicAction({ type: 'post', dispatch: dispatch, - actionType: 'SALES_MEMBER_BULK_ADD', - url: ApiTable.addSalesMemberBulk, + actionType: 'POST_PERSONAL_TRAIN_RECORD_ALL', + url: ApiTable.postAllPersonalTrainRecord, data: values, - msg: { option: '导入销售人员信息' }, + msg: { option: '导入个人培训记录' }, }); } diff --git a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx index fa56b25..49e0a78 100644 --- a/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx +++ b/web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx @@ -39,12 +39,12 @@ const ImportPerformanceSummaryModal = props => { head = head.join(',') + "\n"; //数据 //let data = 1 + ',' + 2 + ',' + 3 + ',' + 4 + ',' + 5 - let templateCsv = "data:text/csv;charset=utf-8,\ufeff" + head; + let templateCsv = "data:text/xlsx;charset=utf-8,\ufeff" + head; //创建一个a标签 let link = document.createElement("a"); //为a标签设置属性 link.setAttribute("href", templateCsv); - link.setAttribute("download", "个人培训记录表模板.csv"); + link.setAttribute("download", "个人培训记录表模板.xlsx"); //点击a标签 link.click(); } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 7a8be15..fc60db4 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -46,6 +46,7 @@ export const ApiTable = { //个人培训记录 getPersonalTrainRecord: 'personal/train/record/list', + postAllPersonalTrainRecord: 'personal/train/record/list', //-培训资料库 getResourceClassify: 'train/trainFiles/resourceRepository/classify',