调整成绩的绘制,根据返回判断是否显示分数,增加charts的纵坐标格式化

This commit is contained in:
ywyonui 2025-07-01 17:22:38 +08:00
parent 5f59d3d8d4
commit e424322ec7
4 changed files with 39 additions and 45 deletions

View File

@ -35,7 +35,7 @@ export const xkqddeleteApi = async (params: any) => {
};
// 获取配置:家长端是否显示分钟数
export const getJzdShowFs = async (params: any) => {
export const getJzdShowFs = async () => {
return await get("/api/comConfig/getJzdShowFs");
};

View File

@ -4692,6 +4692,7 @@ function drawYAxisGrid(categories, opts, config, context) {
}
function drawYAxis(series, opts, config, context) {
console.log('画Y轴');
if (opts.yAxis.disabled === true) {
return;
}
@ -4735,6 +4736,7 @@ function drawYAxis(series, opts, config, context) {
let textAlign = yData.textAlign || "right";
//画Y轴刻度及文案
rangesFormat.forEach(function(item, index) {
var label = opts.yAxis.format(item);
var pos = points[index];
context.beginPath();
context.setFontSize(yAxisFontSize);
@ -4764,7 +4766,7 @@ function drawYAxis(series, opts, config, context) {
context.setTextAlign('center');
tmpstrat = tStartLeft - yAxisWidth.width / 2
}
context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
context.fillText(String(label), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
} else if (yAxisWidth.position == 'right') {
//画刻度线
@ -4786,7 +4788,7 @@ function drawYAxis(series, opts, config, context) {
context.setTextAlign('center');
tmpstrat = tStartRight + yAxisWidth.width / 2
}
context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
context.fillText(String(label), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
} else if (yAxisWidth.position == 'center') {
//画刻度线
if (yData.calibration == true) {
@ -4808,7 +4810,7 @@ function drawYAxis(series, opts, config, context) {
context.setTextAlign('center');
tmpstrat = tStartCenter - yAxisWidth.width / 2
}
context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
context.fillText(String(label), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
}
context.closePath();
context.stroke();
@ -7016,7 +7018,10 @@ var uCharts = function uCharts(opts) {
dashLength: 4 * opts.pix,
gridColor: '#cccccc',
padding: 10,
fontColor: '#666666'
fontColor: '#666666',
format: function format(val) {
return val;
}
}, opts.yAxis);
opts.xAxis = assign({}, {
rotateLabel: false,

View File

@ -37,6 +37,10 @@ onLoad((options: any) => {
}, 1000)
}
});
onUnmounted(() => {
ws.closeConnect();
});
</script>
<style lang="scss" scoped></style>

View File

@ -61,7 +61,7 @@
>
<view class="subject-header">
<text class="subject-name">{{ kscj.kmmc }}</text>
<text v-if="kscj.ksdj.id">分数{{ kscj.ksfs }}</text>
<text v-if="showFsFlag && kscj.ksdj.id">分数{{ kscj.ksfs }}</text>
</view>
<view class="subject-body">
<text class="subject-grade">{{ kscj.ksdj.dfbs }}</text>
@ -158,7 +158,7 @@
import { ref, onMounted, watch, nextTick } from "vue";
import uCharts from "@/components/charts/u-charts.js";
import dayjs from "dayjs";
import { xsKscjApi } from "@/api/base/server";
import { xsKscjApi, getJzdShowFs } from "@/api/base/server";
import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data";
import { format } from "path";
@ -181,25 +181,16 @@ const curKm = ref<any>({})
const curKmIndex = ref<number>(0)
const xqKmmcList = ref<string[]>([])
const showFsFlag = ref(false);
//
const activeTab = ref("scores");
//
function switchTab(tab: string) {
const switchTab = (tab: string) => {
activeTab.value = tab;
}
//
const subjects = ref([
{ id: "1", kmmc: "语文", fullScore: 98, grade: "B" },
{ id: "2", kmmc: "数学", fullScore: 96, grade: "A" },
{ id: "3", kmmc: "英语", fullScore: 98, grade: "A" },
{ id: "4", kmmc: "科学", fullScore: 94, grade: "A" },
// { id: "5", kmmc: "", fullScore: 93, grade: "A" },
// { id: "6", kmmc: "", fullScore: 93, grade: "A" },
{ id: "7", kmmc: "体育", fullScore: 93, grade: "A" },
]);
type ColorMapType = {
[key: string]: string;
};
@ -343,7 +334,7 @@ const drawTrendChart = () => {
animation: true,
background: "#FFFFFF",
padding: [15, 15, 0, 15],
dataLabel: false,
dataLabel: showFsFlag.value, //
dataPointShape: true,
enableScroll: false,
legend: {
@ -363,12 +354,9 @@ const drawTrendChart = () => {
max: 100,
},
],
min: 0, // 0
max: 100, // 100
axisLabel: { //
show: function(value: any) {
return value === 0 || value === 100; // 0100
}
format: (val : number) => {
console.log(val);
return val == 0 || val == 100 ? val : '';
},
},
extra: {
@ -488,30 +476,27 @@ const rebuildData = () => {
buildXqKmKscjList();
}
onMounted(() => {
onMounted(async () => {
curXs.value = getCurXs;
kscc.value = getData;
xsKscjApi({
const res = await xsKscjApi({
xsId: getCurXs.id,
ksccId: getData.id,
njmcId: getData.njmcId
}).then(res => {
if (res.resultCode == 1) {
srcKmList.value = res.result.kmList;
srcKsdjList.value = res.result.ksdjList;
srcKsccKscjList.value = res.result.ksccKscjList;
srcXqKscjList.value = res.result.xqKscjList;
//
initKsdj();
//
rebuildData();
activeTab.value = "trend";
}
})
.catch((error) => {
//
console.error("调用查询成绩接口失败:", error);
});
});
if (res.resultCode == 1) {
srcKmList.value = res.result.kmList;
srcKsdjList.value = res.result.ksdjList;
srcKsccKscjList.value = res.result.ksccKscjList;
srcXqKscjList.value = res.result.xqKscjList;
showFsFlag.value = res.result.showFs;
//
initKsdj();
//
rebuildData();
} else {
showFsFlag.value = false;
}
//
// DOM
setTimeout(() => {