update 难度系数统计过滤字典状态外的脏数据
This commit is contained in:
@@ -36,7 +36,7 @@ const getDifficultyLevelColor = (difficulty: number) => {
|
||||
if (Number(difficulty) <= 1) {
|
||||
return '#67c23a'; // 绿色
|
||||
} else if (Number(difficulty) == 2) {
|
||||
return 'rgb(248, 227, 197)';
|
||||
return 'rgb(243, 209, 158)';
|
||||
} else {
|
||||
return '#f56c6c'; // 红色
|
||||
}
|
||||
@@ -54,6 +54,7 @@ const initUserDifficultyCoefficientChart = async (formData: any) => {
|
||||
let xData: any = [];
|
||||
let titles: any = [];
|
||||
let colors: any = [];
|
||||
let legendData: any = [];
|
||||
const seriesList: any = [];
|
||||
const params = {
|
||||
...formData,
|
||||
@@ -66,14 +67,16 @@ const initUserDifficultyCoefficientChart = async (formData: any) => {
|
||||
res.data?.result?.map((item: any) => {
|
||||
return item.userName;
|
||||
}) || [];
|
||||
titles = res.data?.alldifficultyValue || [];
|
||||
colors = titles
|
||||
.sort((a: any, b: any) => Number(a) - Number(b))
|
||||
.map((key: any) => getDifficultyLevelColor(Number(key)));
|
||||
// titles = res.data?.alldifficultyValue || [];
|
||||
titles = (res.data?.alldifficultyValue || [])
|
||||
.filter((key: string) => DIFFICULTY_COEFFICIENT.value.O.hasOwnProperty(key))
|
||||
.sort((a: any, b: any) => Number(a) - Number(b));
|
||||
legendData = titles.map((key: any) => getDifficultyLevel(Number(key)));
|
||||
colors = titles.map((key: any) => getDifficultyLevelColor(Number(key)));
|
||||
for (let i = 0; i < titles.length; i++) {
|
||||
const str = titles[i].toFixed(1);
|
||||
const obj: any = {
|
||||
name: getDifficultyLevel(Number(str)) + str,
|
||||
name: getDifficultyLevel(Number(str)),
|
||||
coefficient: Number(str),
|
||||
type: 'bar',
|
||||
emphasis: {
|
||||
@@ -89,7 +92,7 @@ const initUserDifficultyCoefficientChart = async (formData: any) => {
|
||||
const option = {
|
||||
color: colors,
|
||||
legend: {
|
||||
data: titles,
|
||||
data: legendData,
|
||||
},
|
||||
grid: {
|
||||
bottom: '50',
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
'createTime',
|
||||
'finishTime',
|
||||
]"
|
||||
:multipleItems="['user']"
|
||||
:nodata="nodata"
|
||||
@update="updateStatistics"
|
||||
/>
|
||||
@@ -36,7 +35,7 @@ const getDifficultyLevelColor = (difficulty: number) => {
|
||||
if (Number(difficulty) <= 1) {
|
||||
return '#67c23a'; // 绿色
|
||||
} else if (Number(difficulty) == 2) {
|
||||
return 'rgb(248, 227, 197)';
|
||||
return 'rgb(243, 209, 158)';
|
||||
} else {
|
||||
return '#f56c6c'; // 红色
|
||||
}
|
||||
@@ -57,19 +56,20 @@ const updateStatistics = async (formData: any) => {
|
||||
nodata.value = res.data.result.length === 0;
|
||||
res.data.result.forEach((item: any) => {
|
||||
// 遍历item.difficultyCount这个对象,将key和value分别存入difficultyCount对象中,如果key已经存在,则将value累加
|
||||
Object.keys(item.difficultyCount).forEach((key: any) => {
|
||||
if (difficultyCount[key]) {
|
||||
difficultyCount[key] += item.difficultyCount[key];
|
||||
} else {
|
||||
difficultyCount[key] = item.difficultyCount[key];
|
||||
}
|
||||
});
|
||||
Object.keys(item.difficultyCount)
|
||||
.filter((key: string) => DIFFICULTY_COEFFICIENT.value.O.hasOwnProperty(Number(key)))
|
||||
.forEach((key: any) => {
|
||||
if (difficultyCount[key]) {
|
||||
difficultyCount[key] += item.difficultyCount[key];
|
||||
} else {
|
||||
difficultyCount[key] = item.difficultyCount[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const seriesData = Object.keys(difficultyCount).map((key: any) => {
|
||||
return {
|
||||
key: Number(key),
|
||||
name: getDifficultyLevel(key) + key,
|
||||
name: getDifficultyLevel(key),
|
||||
value: difficultyCount[key],
|
||||
};
|
||||
});
|
||||
|
||||
@@ -145,14 +145,14 @@ const performanceColorList = getAchieveColorList(
|
||||
const taskExeStatusLegendData = TASK_ACHIEVE_STATUS.value.A.map((item: any) => {
|
||||
return { name: item.label };
|
||||
});
|
||||
const difficultyCountColorList = [
|
||||
'#67c23a',
|
||||
'rgb(179, 225, 157)',
|
||||
'rgb(248, 227, 197)',
|
||||
'rgb(243, 209, 158)',
|
||||
'rgb(248, 152, 152)',
|
||||
'#f56c6c',
|
||||
];
|
||||
// const difficultyCountColorList = [
|
||||
// '#67c23a',
|
||||
// 'rgb(179, 225, 157)',
|
||||
// 'rgb(248, 227, 197)',
|
||||
// 'rgb(243, 209, 158)',
|
||||
// 'rgb(248, 152, 152)',
|
||||
// '#f56c6c',
|
||||
// ];
|
||||
// 封装方法,根据对象的某个属性对对象数组进行排序 升序
|
||||
const sortObjectArray = (arr: any, key: any) => {
|
||||
return arr.sort((a: any, b: any) => {
|
||||
@@ -216,7 +216,7 @@ const getDifficultyLevelColor = (difficulty: number) => {
|
||||
if (Number(difficulty) <= 1) {
|
||||
return '#67c23a'; // 绿色
|
||||
} else if (Number(difficulty) == 2) {
|
||||
return 'rgb(248, 227, 197)';
|
||||
return 'rgb(243, 209, 158)';
|
||||
} else {
|
||||
return '#f56c6c'; // 红色
|
||||
}
|
||||
@@ -234,14 +234,17 @@ const queryUserDifficultStatistics = async () => {
|
||||
xData = res.data.result.map((item: any) => {
|
||||
return item.userName;
|
||||
});
|
||||
titles = res.data.alldifficultyValue;
|
||||
// titles = res.data.alldifficultyValue;
|
||||
titles = (res.data?.alldifficultyValue || []).filter((key: string) =>
|
||||
DIFFICULTY_COEFFICIENT.value.O.hasOwnProperty(key)
|
||||
);
|
||||
colors = titles
|
||||
.sort((a: any, b: any) => Number(a) - Number(b))
|
||||
.map((key: any) => getDifficultyLevelColor(Number(key)));
|
||||
seriesData = titles.map((title: any) => {
|
||||
const str = title.toFixed(1);
|
||||
return {
|
||||
name: getDifficultyLevel(Number(str)) + str,
|
||||
name: getDifficultyLevel(Number(str)),
|
||||
coefficient: Number(str),
|
||||
type: 'bar',
|
||||
emphasis: {
|
||||
|
||||
Reference in New Issue
Block a user