Browse Source

(*)岗位评级:1. 列表查询评级时间倒序;2. 导入模板增加姓名

3. 员工信息【技术职级等级】替换真实数据
master
周沫沫历险记 2 years ago
parent
commit
bb14f7e38d
  1. 41
      api/app/lib/controllers/member/index.js
  2. 13
      web/client/src/sections/humanAffairs/components/importPositionRating.jsx
  3. 2
      web/client/src/sections/humanAffairs/containers/employeeInformation.jsx
  4. 2
      web/client/src/sections/humanAffairs/containers/positionRating.jsx

41
api/app/lib/controllers/member/index.js

@ -707,7 +707,9 @@ async function getPositionRating(ctx) {
const { models } = ctx.fs.dc;
const { limit, page } = ctx.query;
const findObj = {};
const findObj = {
order: [["ratingTime", "desc"]]
};
if (Number(limit) > 0 && Number(page) >= 0) {
findObj.limit = Number(limit);
findObj.offset = Number(page) * Number(limit);
@ -786,25 +788,23 @@ async function postPositionRating(ctx) {
//处理新增的
if (data) {
if (data.length) {
const dataToSave = [];
const dataToUpdate = [];
if (data.length) {
data.map((item) => {
const { pepUserId, technicalGrade } = item;
dataToUpdate.push({ pepUserId, technicalGrade });
})
await models.PositionRating.bulkCreate(data, { transaction });
for (let item in dataToUpdate) {
await models.Member.update({ technicalGrade: dataToUpdate[item].technicalGrade },
{ where: { pepUserId: dataToUpdate[item].pepUserId }, transaction });
}
}
else {
await models.PositionRating.create(data, { transaction });
await models.Member.update({ technicalGrade: data.technicalGrade },
{ where: { pepUserId: data.pepUserId }, transaction });
dataToUpdate.push({ pepUserId: data.pepUserId, technicalGtechnicalGrade: data.technicalGraderade });
}
for (let item in dataToUpdate) {
await models.Member.update({ technicalGrade: dataToUpdate[item].technicalGrade },
{ where: { pepUserId: dataToUpdate[item].pepUserId }, transaction });
}
//更新member表字段
}
await transaction.commit();
@ -824,11 +824,30 @@ async function delPositionRating(ctx) {
const oldData = await models.PositionRating.findOne({ where: { id: id } });
if (oldData) {
//todo 更新memeber技术等级字段
const positionRating = await models.PositionRating.findAll({
where: {
pepUserId: oldData.pepUserId,
id: { $not: oldData.id }
},
attributes: ["technicalGrade"],
order: [["ratingTime", "desc"]]
});
//更新员工信息中的技术等级
const technicalGrade = positionRating.length ? positionRating[0].technicalGrade : undefined;
await models.Member.update({ technicalGrade: technicalGrade },
{
where: { pepUserId: oldData.pepUserId, del: false },
transaction
});
await models.PositionRating.destroy({ where: { id: id }, transaction });
}
transaction.commit();
ctx.status = 204;
} catch (error) {
transaction.rollback();
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {

13
web/client/src/sections/humanAffairs/components/importPositionRating.jsx

@ -32,11 +32,12 @@ const ImportPositionRatingModal = props => {
}
const download = () => {
const head = [Object.keys(IMPORT_FIELD).map(key => IMPORT_FIELD[key].label)];
const head = Object.keys(IMPORT_FIELD).map(key => IMPORT_FIELD[key].label);
head.unshift("姓名");
let workbook = { SheetNames: [SHEETNAME], Sheets: {} };
workbook.Sheets[SHEETNAME] = XLSX.utils.aoa_to_sheet(head);//jsonexcel
workbook.Sheets[SHEETNAME] = XLSX.utils.aoa_to_sheet([head]);//jsonexcel
workbook.Sheets[SHEETNAME]['!cols'] = [
{ wch: 13 }, { wch: 12 }, { wch: 18 }, { wch: 30 }, { wch: 11 },
{ wch: 13 }, { wch: 13 }, { wch: 12 }, { wch: 18 }, { wch: 30 }, { wch: 11 },
{ wch: 30 }, { wch: 13 }];
let wopts = { bookType: 'xlsx', type: 'buffer' };// excel
XLSX.writeFile(workbook, `${SHEETNAME}导入模板.xlsx`, wopts);
@ -152,9 +153,9 @@ const ImportPositionRatingModal = props => {
if (!member) {
errmsg = `${i + 2}行【${IMPORT_FIELD[item].label}${obj.userCode}未匹配到数据,请检查该员工是否添加`;
break;
} else if (postData.find(m => m.userCode == obj.userCode)) {
errmsg = `${i + 2}行【${IMPORT_FIELD[item].label}${obj.userCode}已存在,请检查`;
break;
// } else if (postData.find(m => m.userCode == obj.userCode)) {
// errmsg = `${i + 2}${IMPORT_FIELD[item].label}${obj.userCode},`;
// break;
} else {
obj.pepUserId = member.pepUserId;
}

2
web/client/src/sections/humanAffairs/containers/employeeInformation.jsx

@ -263,7 +263,7 @@ const employeeInformation = (props) => {
width: 150,
dataIndex: "technicalGrade",
key: "technicalGrade",
render: (_, r, index) => <span>-</span>,
// render: (_, r, index) => <span>-</span>,
}, {
title: '证件号',
width: 180,

2
web/client/src/sections/humanAffairs/containers/positionRating.jsx

@ -93,7 +93,7 @@ const PositionRating = (props) => {
}, {
title: (
<div>
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 现在职岗位
<img src="/assets/images/hrImg/V.png" alt="" style={{ width: 14, height: 14 }} /> 岗位
</div>
),
width: 120,

Loading…
Cancel
Save