调整成绩的绘制,根据返回判断是否显示分数,增加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"); return await get("/api/comConfig/getJzdShowFs");
}; };

View File

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

View File

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

View File

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