From b95c990a5c1cd06d1c44fbf33869a29fe432b7b4 Mon Sep 17 00:00:00 2001 From: dongzhihuan Date: Tue, 14 Apr 2026 11:19:20 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=9A=BE=E5=BA=A6=E7=B3=BB=E6=95=B0?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=BF=87=E6=BB=A4=E5=AD=97=E5=85=B8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=A4=96=E7=9A=84=E8=84=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userDifficultyCoefficientChart.vue | 17 +++++++------ .../userDifficultyRateChart.vue | 22 ++++++++-------- .../components/statisticAnalysis.vue | 25 +++++++++++-------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/views/task/dashboard/components/dataStatistics/userDifficultyCoefficientChart.vue b/src/views/task/dashboard/components/dataStatistics/userDifficultyCoefficientChart.vue index e1fac6a2..11aaf145 100644 --- a/src/views/task/dashboard/components/dataStatistics/userDifficultyCoefficientChart.vue +++ b/src/views/task/dashboard/components/dataStatistics/userDifficultyCoefficientChart.vue @@ -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', diff --git a/src/views/task/dashboard/components/dataStatistics/userDifficultyRateChart.vue b/src/views/task/dashboard/components/dataStatistics/userDifficultyRateChart.vue index db5a1ad9..136d3b0e 100644 --- a/src/views/task/dashboard/components/dataStatistics/userDifficultyRateChart.vue +++ b/src/views/task/dashboard/components/dataStatistics/userDifficultyRateChart.vue @@ -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], }; }); diff --git a/src/views/task/projectDetail/components/statisticAnalysis.vue b/src/views/task/projectDetail/components/statisticAnalysis.vue index ba1316e2..5deb10f0 100644 --- a/src/views/task/projectDetail/components/statisticAnalysis.vue +++ b/src/views/task/projectDetail/components/statisticAnalysis.vue @@ -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: {