周沫沫历险记 2 years ago
parent
commit
1c0c82f204
  1. 20
      api/app/lib/controllers/personalTrain/index.js
  2. 3
      api/app/lib/routes/personalTrain/index.js
  3. 8
      web/client/src/sections/humanAffairs/actions/personalTrainRecord.js
  4. 4
      web/client/src/sections/humanAffairs/containers/importPersonalTrainRecord.jsx
  5. 1
      web/client/src/utils/webapi.js

20
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
}

3
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);
};

8
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: '导入个人培训记录' },
});
}

4
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();
}

1
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',

Loading…
Cancel
Save