diff --git a/src/api/teacher.js b/src/api/teacher.js index 18b7c5c..262f133 100644 --- a/src/api/teacher.js +++ b/src/api/teacher.js @@ -613,6 +613,27 @@ export function retrySchoolDefaultTaskInitialization() { }); } // 成绩中心-查询成绩列表 +export function getOwnedTeachingClasses() { + return request({ + url: "/api/weight/ownedTeachingClasses", + method: "get", + }); +} +export function getTeachingClassWeight(teachingClassId) { + return request({ + url: "/api/weight/selectTeachingClassWeight", + method: "post", + params: { teachingClassId }, + }); +} +export function updateTeachingClassWeight(teachingClassId, data) { + return request({ + url: "/api/weight/updateTeachingClassWeight", + method: "post", + params: { teachingClassId }, + data, + }); +} export function getScoreList(params) { return request({ url: "/api/weight/selectStuRankAndScore", diff --git a/src/views/teacherEnd/index.vue b/src/views/teacherEnd/index.vue index 449cab6..932b78d 100644 --- a/src/views/teacherEnd/index.vue +++ b/src/views/teacherEnd/index.vue @@ -58,7 +58,6 @@ const classList = ref([]); const classParams = ref({ classId: "", time: "", - schoolId: userStore.userInfo.schoolId, }); const initstatus = ref(false); const circularData = ref([ @@ -144,10 +143,11 @@ const getStatisticsData = async () => { }; // 获取班级成绩走势函数功能函数 const getClassGradeTrend = () => { - teacherApi.getAverageScoreTrend({ schoolId: userStore.userInfo.schoolId, userId: userStore.userInfo.userId }).then((res) => { - classTime.value = res.startTime; - className.value = res.map((item) => item.className); - classList.value = res.map((item) => { + teacherApi.getAverageScoreTrend().then((res) => { + const trends = Array.isArray(res) ? res : []; + classTime.value = trends[0]?.startTime || []; + className.value = trends.map((item) => item.className); + classList.value = trends.map((item) => { return { name: item.className, type: "line", @@ -186,10 +186,10 @@ const getClassGradeStatistics = () => { }; // 获取班级 const getClassList = () => { - teacherApi.getClasses({ schoolMajorId: userStore.userInfo.schoolId }).then((res) => { - userStore.classList = Object.keys(res).map((key) => ({ - class_name: res[key], - class_id: key, + teacherApi.getOwnedTeachingClasses().then((res) => { + userStore.classList = (res.data || []).map((item) => ({ + class_name: item.className, + class_id: item.schoolClassId, })); }); }; @@ -320,4 +320,4 @@ onMounted(() => { margin-right: 0px !important; } } - \ No newline at end of file + diff --git a/src/views/teacherEnd/score/index.vue b/src/views/teacherEnd/score/index.vue index b82b586..3e034a1 100644 --- a/src/views/teacherEnd/score/index.vue +++ b/src/views/teacherEnd/score/index.vue @@ -62,28 +62,33 @@ - - + + - - + + - - + + - - + + - - + + + + + + + @@ -147,28 +152,11 @@ const trainingProgressTitle = (row) => { if (row.trainingProgress === null || row.trainingProgress === undefined) return ""; return `已完成 ${row.completedTaskCount || 0}/${row.totalTaskCount || 0} 项`; }; -const rules = { - marketResearchWeight: [ - { required: true, message: "请输入市场需求挖掘权重", trigger: "blur" }, - { type: "number", message: "权重必须为数字值" }, - ], - productEvaluationWeight: [ - { required: true, message: "请输入产品评估与考核权重", trigger: "blur" }, - { type: "number", message: "权重必须为数字值" }, - ], - productLaunchTestWeight: [ - { required: true, message: "请输入产品投放测试权重", trigger: "blur" }, - { type: "number", message: "权重必须为数字值" }, - ], - productPlanningWeight: [ - { required: true, message: "请输入产品规划权重", trigger: "blur" }, - { type: "number", message: "权重必须为数字值" }, - ], - supplyChannelWeight: [ - { required: true, message: "请输入供应渠道管理权重", trigger: "blur" }, - { type: "number", message: "权重必须为数字值" }, - ], -}; +const weightFields = ["foundationWeight", "marketInsightWeight", "planningDesignWeight", "developmentValidationWeight", "launchOperationWeight", "comprehensiveTrainingWeight"]; +const rules = Object.fromEntries(weightFields.map((field) => [field, [ + { required: true, message: "请输入权重", trigger: "blur" }, + { type: "number", message: "权重必须为数字值" }, +]])); const buildScoreQuery = () => { const { studentId, ...query } = scoreParams.value; return { @@ -185,14 +173,14 @@ const getList = () => { }); }; const scoreweight = () => { + if (!scoreParams.value.classId) { + proxy.$modal.msgWarning("请选择自己的教学班后再设置权重"); + return; + } WeightStart.value = true; - indexApi.getWeightList({ schoolId: userStore.userInfo.schoolId }).then((res) => { + indexApi.getTeachingClassWeight(scoreParams.value.classId).then((res) => { scoreWeightObj.value = res.data; - for (const key in scoreWeightObj.value) { - if (key !== "schoolId") { - scoreWeightObj.value[key] = scoreWeightObj.value[key] * 100; - } - } + weightFields.forEach((key) => (scoreWeightObj.value[key] = Number(scoreWeightObj.value[key]) * 100)); }); }; const workingCapitalWeightHandle = () => { @@ -200,18 +188,15 @@ const workingCapitalWeightHandle = () => { if (valid) { let params = {}; let sum = 0; - for (const key in scoreWeightObj.value) { - if (key !== "schoolId") { - params[key] = scoreWeightObj.value[key] / 100; - sum += scoreWeightObj.value[key] / 100; - } - } - if (sum !== 1) { + weightFields.forEach((key) => { + params[key] = Number(scoreWeightObj.value[key]) / 100; + sum += params[key]; + }); + if (Math.abs(sum - 1) > 0.000001) { proxy.$message.error("权重合计为100%"); return; } - params.schoolId = userStore.userInfo.schoolId; - indexApi.updateWeight(params).then((res) => { + indexApi.updateTeachingClassWeight(scoreParams.value.classId, params).then((res) => { proxy.$message.success("权重设置成功"); WeightStart.value = false; }); @@ -221,7 +206,7 @@ const workingCapitalWeightHandle = () => { const classList = ref([]); const teachingClassList = computed(() => classList.value.filter((item) => item.classType === "TEACHING")); const getClassList = () => { - indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => { + indexApi.getOwnedTeachingClasses().then((res) => { classList.value = res.data; if (scoreParams.value.classId && !teachingClassList.value.some((item) => item.schoolClassId === scoreParams.value.classId)) { scoreParams.value.classId = ""; @@ -242,6 +227,10 @@ const exportExcel = () => { }); }; const getClassScoreDetail = (row) => { + if (!scoreParams.value.classId) { + proxy.$modal.msgWarning("请选择自己的教学班后再查看成绩详情"); + return; + } indexApi.getScoreDetail({ userId: row.userId, classId: scoreParams.value.classId }).then((res) => { tableData.value = res.data; scoreDetailsStart.value = true; @@ -249,6 +238,10 @@ const getClassScoreDetail = (row) => { }; // 更新成绩 const updateScore = () => { + if (!scoreParams.value.classId) { + proxy.$modal.msgWarning("请选择自己的教学班后再更新成绩"); + return; + } loading.value = true; const params = { schoolId: userStore.userInfo.schoolId }; diff --git a/tests/teacher-score-scope.static.test.cjs b/tests/teacher-score-scope.static.test.cjs new file mode 100644 index 0000000..e5f4f9b --- /dev/null +++ b/tests/teacher-score-scope.static.test.cjs @@ -0,0 +1,21 @@ +const assert = require('assert'); +const fs = require('fs'); + +const page = fs.readFileSync('src/views/teacherEnd/score/index.vue', 'utf8'); +const home = fs.readFileSync('src/views/teacherEnd/index.vue', 'utf8'); +const api = fs.readFileSync('src/api/teacher.js', 'utf8'); + +assert(api.includes('/api/weight/ownedTeachingClasses')); +assert(api.includes('/api/weight/selectTeachingClassWeight')); +assert(api.includes('/api/weight/updateTeachingClassWeight')); +assert(page.includes('getOwnedTeachingClasses')); +assert(page.includes('互联网产品开发基础认知')); +assert(page.includes('市场洞察与需求分析')); +assert(page.includes('产品规划与设计')); +assert(page.includes('产品开发与测试验证')); +assert(page.includes('产品上线与运营推广')); +assert(page.includes('综合实训')); +assert(page.includes('foundationWeight')); +assert(page.includes('comprehensiveTrainingWeight')); +assert(home.includes('getOwnedTeachingClasses')); +console.log('teacher score scope static checks passed');