Commit 2b6692e3 by 钟乾明

u: 同步项目经历,优化考核结果年份数据合并

parent 6b84b8cc
......@@ -217,7 +217,10 @@ span {
.item_header-img-jobhistory {
background: url('../images/jobhistory.svg') no-repeat;
}
.item_header-img-project_history{
background: url('../images/project_history.png') no-repeat;
background-size: 100%;
}
.item_header-img-base {
background: url('../images/base.svg') no-repeat;
}
......
......@@ -9,6 +9,7 @@ const RENDER_TYPE = {
F: Symbol('F'),
G: Symbol('G'),
H: Symbol('H'),
I: Symbol('I')
};
let config = {
identifier: cube.identifier,
......@@ -71,7 +72,16 @@ let config = {
note: ['jobstarttime', 'jobendtime'],
},
},
projectExpVOList: {
name: '项目经历',
type: RENDER_TYPE.I,
img: 'project_history',
list: {
title: 'projectName',
subTitle: ['roleName'],
note: ['startTime', 'endTime'],
}
},
mergeCheckResult:{
name: '考核结果',
type: RENDER_TYPE.H,
......@@ -92,6 +102,7 @@ let config = {
}
},
cadreEvaluationVoList: {
name: '干部考核',
type: RENDER_TYPE.G,
......
......@@ -477,7 +477,8 @@ function render(data) {
jobVoList: configuration.renderItem.jobVoList,
// 历史任职
jobHistoryVoList: configuration.renderItem.jobHistoryVoList,
// 项目经历
projectExpVOList: configuration.renderItem.projectExpVOList,
// 工作经历
workVoList: configuration.renderItem.workVoList,
// 教育经历
......@@ -508,6 +509,8 @@ function render(data) {
resumeBaseVo: configuration.renderItem.resumeBaseVo,
jobVoList: configuration.renderItem.jobVoList,
jobHistoryVoList: configuration.renderItem.jobHistoryVoList,
// 项目经历
projectExpVOList: configuration.renderItem.projectExpVOList,
assessVoList: configuration.renderItem.assessVoList,
rewardPunishVoList: configuration.renderItem.rewardPunishVoList
};
......@@ -531,6 +534,9 @@ function render(data) {
jobVoList: configuration.renderItem.jobVoList,
// 历史任职
jobHistoryVoList: configuration.renderItem.jobHistoryVoList,
// 项目经历
projectExpVOList: configuration.renderItem.projectExpVOList,
// 工作经历
workVoList: configuration.renderItem.workVoList,
// 教育经历
......@@ -695,7 +701,10 @@ function filterData(item, data, isAssessNew) {
//兼容多条没有年度数据的情况
for (let i = 0; i < objKeys.length; i++) {
if (!dataYears.includes(objKeys[ i ])) {
noYearData.push({ assyear: objKeys[ i ], assgrade: '' });
noYearData.push({
assyear: objKeys[ i ],
assgrade: ''
});
}
}
}
......@@ -744,7 +753,10 @@ function filterData(item, data, isAssessNew) {
console.log('干部考核数据处理 后>>', assessData);
assessData.forEach(item => {
if (item.checkTypeName === '年度') {
arr.push({ ...item, halfArr: [] });
arr.push({
...item,
halfArr: []
});
} else if (item.checkTypeName === '半年度') {
let idx = arr.findIndex(i => item.year === i.year);
if (idx === -1) {
......@@ -766,12 +778,19 @@ function filterData(item, data, isAssessNew) {
}
//------------合并考核结果数据--------------
if (item === 'mergeCheckResult') {
console.log('mergeCheckResult 元数据>>', data);
assessData = [];
let ygResult = [];
let gbResult = [];
const ygArr = data.filter(i => i.dataType === 'yg');
const gbArr = data.filter(i => i.dataType === 'gb');
// 合并数据
console.log('ygArr>>', ygArr);
console.log('gbArr>>', gbArr);
// 处理员工考核
if (ygArr.length) {
if (isAssessNew) {
......@@ -813,7 +832,12 @@ function filterData(item, data, isAssessNew) {
//兼容多条没有年度数据的情况
for (let i = 0; i < objKeys.length; i++) {
if (!dataYears.includes(objKeys[ i ])) {
noYearData.push({ assyear: objKeys[ i ], assgrade: '', dataType: 'yg' });
noYearData.push({
assyear: objKeys[ i ],
assgrade: '',
dataType: 'yg',
year: objKeys[ i ]
});
}
}
}
......@@ -862,7 +886,10 @@ function filterData(item, data, isAssessNew) {
console.log('干部考核数据处理 后>>', gbResult);
gbResult.forEach(item => {
if (item.checkTypeName === '年度') {
arr.push({ ...item, halfArr: [] });
arr.push({
...item,
halfArr: []
});
} else if (item.checkTypeName === '半年度') {
let idx = arr.findIndex(i => item.year === i.year);
if (idx === -1) {
......@@ -885,13 +912,83 @@ function filterData(item, data, isAssessNew) {
gbResult = [];
}
assessData = ygResult.concat(gbResult).sort((a, b) => b.year - a.year);
const origData = ygResult.concat(gbResult).sort((a, b) => b.year - a.year);
console.log('合并月份前的数据 origData>>', origData);
// 去重年份及合并数据
assessData = mergeByYear(origData)
console.log('过滤后的数据---------->>', item, assessData);
}
console.log('过滤后的数据>>', item, assessData);
return assessData;
}
/**
* 按year字段去重,合并项的dataType设为"hb",叠加attachmentArray和months
* @param {Array} data - 原始数据数组
* @returns {Array} 处理后的数组
*/
function mergeByYear(data) {
// 先按year分组,记录每个year的原始数据数量(判断是否为合并项)
const yearGroups = {};
data.forEach(item => {
const year = item.year;
if (!yearGroups[ year ]) {
yearGroups[ year ] = [];
}
yearGroups[ year ].push(item);
});
const yearMap = new Map();
data.forEach(item => {
const year = item.year;
if (!yearMap.has(year)) {
// 初始化时判断是否为合并项(同一year有多个数据)
const isMerged = yearGroups[ year ].length > 1;
yearMap.set(year, {
year,
// 合并项的dataType初始化为"hb",否则留空后续处理
...(isMerged ? {dataType: "hb"} : {})
});
}
const target = yearMap.get(year);
const isMerged = yearGroups[ year ].length > 1;
Object.keys(item).forEach(key => {
if (key === 'year') return; // 跳过year字段
const currentValue = item[ key ];
// 特殊处理需要叠加的数组字段:attachmentArray和months
if ((key === 'attachmentArray' || key === 'months') && Array.isArray(currentValue)) {
if (!Array.isArray(target[ key ])) {
target[ key ] = [];
}
target[ key ].push(...currentValue);
return;
}
// 合并项强制将dataType设为"hb",跳过原始dataType处理
if (key === 'dataType' && isMerged) {
return;
}
// 处理其他字段:仅保留第一个非空有效值
if (currentValue === null || currentValue === undefined || currentValue === '') {
return;
}
// 目标字段未定义时才赋值
if (target[ key ] === undefined) {
target[ key ] = currentValue;
}
});
});
return Array.from(yearMap.values());
}
function renderer(renderTemp, data) {
let type = renderTemp.type;
// 干部测评没有数据不展示
......@@ -927,7 +1024,9 @@ function renderer(renderTemp, data) {
case RENDER_TYPE.F:
container.appendChild(listFRenderer(renderTemp.list, data));
break;
case RENDER_TYPE.I:
container.appendChild(listIRenderer(renderTemp.list, data));
break;
}
}
......@@ -985,6 +1084,9 @@ function propertyRenderer(renderTemp, data) {
case RENDER_TYPE.F:
container.appendChild(propertyListFRenderer(renderTemp.list, data));
break;
case RENDER_TYPE.I:
container.appendChild(propertyListIRenderer(renderTemp.list, data));
break;
}
}
......@@ -1441,8 +1543,6 @@ function listHRenderer(config, data) {
// 半年度
if (halfArr) {
halfArr.forEach((items) => {
childrenHtml += itemRenderer(
`· 半年度`,
......@@ -1491,7 +1591,7 @@ function listHRenderer(config, data) {
//新增月度数据
temp += itemRenderer(
`${item[ list.title ]}年`,
`<span class='item__content-note t-black'>${item[ note ]} </span>`,
`<span class='item__content-note t-black'>${item[ note ]||''} </span>`,
`${(item.months && item.months.length) || (item.attachmentArray && item.attachmentArray.length) ? 'has-children text-left' : 'text-left'}`
);
......@@ -1526,6 +1626,93 @@ function listHRenderer(config, data) {
temp += '</div>';
}
} else if (item.dataType === 'hb') {
console.log('item------------>>',item)
const list = config.cadreEvaluationVoListConfig;
let note = list.note;
let chil = list.chilkey;
let children = item[ list.children ]; //附件
let halfArr = item.halfArr;
// 有附件或有半年度
if ((chil instanceof Array && children) || (halfArr && halfArr.length)||item.months&&item.months.length) {
let childrenHtml = ``;
// 文件名称排序
let sortChildren = children ? children.sort((a, b) => {
return a[ list.chilkey[ 0 ] ].localeCompare(b[ list.chilkey[ 0 ] ]);
}) : [];
sortChildren.forEach((items) => {
childrenHtml += itemRenderer(
`<span class="file_link"> ${renderFileIcon(items[ list.chilkey[ 1 ] ])} ${renderFileName(items[ list.chilkey[ 0 ] ])}</span>`,
'',
'children_content'
);
cadreFile.push(items[ list.chilkey[ 1 ] ]);
});
// 半年度
if (halfArr) {
halfArr.forEach((items) => {
childrenHtml += itemRenderer(
`· 半年度`,
`<span class="item__content-note t-black half_value">${items.result || ''}</span>`,
'children_content half_content'
);
// 半年度文件名称排序
let halfattAchmentArray = items.attachmentArray || [];
let sortChildren = halfattAchmentArray.sort((a, b) => {
return a[ list.chilkey[ 0 ] ].localeCompare(b[ list.chilkey[ 0 ] ]);
});
sortChildren.forEach((items) => {
childrenHtml += itemRenderer(
`<span class="file_link"> ${renderFileIcon(items[ list.chilkey[ 1 ] ])} ${renderFileName(items[ list.chilkey[ 0 ] ])}</span>`,
'',
'children_content half_content'
);
cadreFile.push(items[ list.chilkey[ 1 ] ]);
});
});
}
if (item.months && item.months.length) {
const list = config.assessVoListConfig;
// console.log('----------->.', item.dataType, list);
let note = list.note;
// temp += '<div class="children_box">';
item.months.forEach((itemM, indexM) => {
childrenHtml += itemRenderer(
`<span class='child_row_title_dot'>·</span><span>${itemM.month}</span>`,
`<span class='item__content-note'>${itemM.assgrade}</span>`,
'text-left'
);
});
// temp += '</div>';
}
temp += itemRenderer(
`${item[ list.title ]}年`,
`<span class="item__content-note t-black ">${item[ note ] || ''}</span>`,
`${childrenHtml ? 'has-children text-left' : 'text-left'}`
);
if (childrenHtml) {
temp += `<div class="children_box">${childrenHtml}</div>`;
}
} else {
temp += itemRenderer(
`${item[ list.title ]}年`,
`<span class="item__content-note t-black">${item[ note ]}</span>`
);
}
cadreFileList = cadreFile;
}
});
......@@ -1537,6 +1724,52 @@ function listHRenderer(config, data) {
return renderWrap(temp, data.length > 3);
}
/**
* @description 项目经历
*/
function listIRenderer(list, data) {
let temp = ``;
if (data && data.length) {
data.forEach((item, index) => {
let sub = '';
let note = list.note;
if (list.subTitle) {
list.subTitle.forEach((s, i) => {
sub += (i && '|') || '';
sub += item[ s ] || '无';
});
}
if (note instanceof Object && note.length) {
let t1 = data[ index ][ list.note[ 0 ] ];
let t2 = data[ index ][ list.note[ 1 ] ];
//temp += itemRenderer(item[list[0]], item[list[1]], index > 2 && 'hide')
temp +=
`<div class="item_main"><div class="item__content work">${
item[ list.title ] || '无'
}</div>` +
itemRenderer(
`<p class="item__content-sub-title">${sub}</p>`,
`<p class="item__content-note">${t1}${nowOrNot(
t2
)}</p>`
) +
`</div>`;
} else {
temp += itemRenderer(
`${
item[ list.title ]
}<p class="item__content-sub-title">${sub}</p>`,
`<p class="item__content-note">${item[ note ]}</p>`
);
}
});
} else {
temp = noDataRenderer();
}
return renderWrap(temp, data.length > 3);
}
// 绩效列表
let performanceArr = [],
performanceSelected = '';
......@@ -3120,6 +3353,48 @@ function propertyListFRenderer(list, data) {
return renderWrap(temp, data.length > 3);
}
// 项目经历
function propertyListIRenderer(list, data) {
let temp = ``;
if (data && data.length) {
data.forEach((item, index) => {
let sub = '';
let note = list.note;
if (list.subTitle) {
list.subTitle.forEach((s, i) => {
sub += (i && '|') || '';
sub += item[ s ] || '无';
});
}
if (note instanceof Object && note.length) {
let t1 = data[ index ][ list.note[ 0 ] ];
let t2 = data[ index ][ list.note[ 1 ] ];
temp +=
`<div class="item_main"><div class="item__content work">${
item[ list.title ] || '无'
}</div>` +
propertyItemRenderer(
`<p class="item__content-sub-title">${sub}</p>`,
`<p class="item__content-note">${t1}${nowOrNot(
t2
)}</p>`
) +
`</div>`;
} else {
temp += propertyItemRenderer(
`${
item[ list.title ]
}<p class="item__content-sub-title">${sub}</p>`,
`<p class="item__content-note">${item[ note ]}</p>`
);
}
});
} else {
temp = noDataRenderer();
}
return renderWrap(temp, data.length > 3);
}
function noDataRenderer() {
return `<div class='item__content empty'>暂无数据</div>`;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment