소스 검색

close #746 打分离开提醒

liqk 3 년 전
부모
커밋
3284859f15

+ 33 - 6
TEAMModelOS/ClientApp/src/view/learnactivity/ByQuMark.vue

@@ -51,7 +51,7 @@
             <div>
                 <span class="stu-answer-label">{{$t('learnActivity.score.stuAns')}}</span>
                 <template v-if="studentsData[stuIndex] && studentsData[stuIndex].data">
-                    <InputNumber v-model="studentsData[stuIndex].data[quIndex]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="questionInfo.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
+                    <InputNumber @on-change="setUpdStatus" v-model="studentsData[stuIndex].data[quIndex]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="questionInfo.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
                 </template>
                 <span class="mark-action-item" style="background:#ed4014" @click="markStuAnswer()" v-if="quNoList.length && quNoList[quIndex] && !quNoList[quIndex].disabled">
                     <Icon type="md-create" />
@@ -175,8 +175,9 @@ export default {
     },
     data() {
         return {
+            isUpd: false,
             viewStatus: false,
-            viewMarks:[],
+            viewMarks: [],
             markBg: '',
             markStatus: false,
             studentsData: [],
@@ -193,6 +194,9 @@ export default {
         }
     },
     methods: {
+        setUpdStatus() {
+            this.isUpd = true
+        },
         //查看批注数据
         viewMark(index) {
             this.viewIndex = index
@@ -215,7 +219,6 @@ export default {
             answerIframe.onload = () => { }
         },
         saveMark() {
-            
             if (!this.markData.base64) {
                 return
             }
@@ -335,6 +338,7 @@ export default {
             this.$api.learnActivity.UpsertAllRecord(requestData).then(res => {
                 if (res.error == null) {
                     this.$Message.success(this.$t('learnActivity.score.saveScoreOk'))
+                    this.isUpd = false
                     if (this.stuIndex < this.studentsData.length - 1) {
                         this.stuIndex++
                         this.selectStudent(this.stuIndex)
@@ -349,9 +353,32 @@ export default {
             this.toggleQuStatus = !this.toggleQuStatus
         },
         selectStudent(index) {
-            this.stuIndex = index
-            if (this.studentsData[index] && !this.studentsData[index].answer) {
-                this.getStuAnswer(this.studentsData[index].ansBlob)
+            if (this.isUpd) {
+                this.$Modal.confirm({
+                    title: '保存分数',
+                    content: '您修改的分数尚未保存,是否需要保存?',
+                    okText: '是',
+                    cancelText: '否',
+                    onOk: () => {
+                        this.saveScore()
+                        this.stuIndex = index
+                        if (this.studentsData[index] && !this.studentsData[index].answer) {
+                            this.getStuAnswer(this.studentsData[index].ansBlob)
+                        }
+                    },
+                    onCancel: () => {
+                        this.isUpd = false
+                        this.stuIndex = index
+                        if (this.studentsData[index] && !this.studentsData[index].answer) {
+                            this.getStuAnswer(this.studentsData[index].ansBlob)
+                        }
+                    }
+                })
+            } else {
+                this.stuIndex = index
+                if (this.studentsData[index] && !this.studentsData[index].answer) {
+                    this.getStuAnswer(this.studentsData[index].ansBlob)
+                }
             }
         },
         async getStuAnswer(ansBlob) {

+ 22 - 9
TEAMModelOS/ClientApp/src/view/learnactivity/ByStuMark.vue

@@ -62,7 +62,7 @@
                     <!-- 非综合题-->
                     <div v-if="item.type != 'compose'" style="display:flex;width:100%;padding-top:15px;" :class="['not-compose-box', activeIndex == getScoreIndex(typeIndex,index) ? 'active-qu-wrap' : '']" :id="'qustion'+ getScoreIndex(typeIndex,index)" @click="activeIndex = getScoreIndex(typeIndex,index)">
                         <div class="scoring-input-box" @click.stop v-if="studentAnswer.scores && studentAnswer.scores.length">
-                            <InputNumber v-model="studentAnswer.scores[item.index]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="item.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
+                            <InputNumber @on-change="setUpdStatus" v-model="studentAnswer.scores[item.index]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="item.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
                             <!-- 快速打分 满分 零分 -->
                             <div style="display:flex;justify-content: space-evenly;margin-top:5px;">
                                 <span class="fast-score-tag" :title="$t('learnActivity.score.fullScore')" @click="fastSetScore(item.index,item.score)">
@@ -189,7 +189,7 @@
                         </div>
                         <div :class="['child-item', activeIndex == getScoreIndex(typeIndex,index,childIndex) ? 'active-qu-wrap' : '']" v-for="(childItem,childIndex) in item.children" :key="childIndex" style="padding-top:15px;" :id="'qustion'+getScoreIndex(typeIndex,index,childIndex)" @click="activeIndex = getScoreIndex(typeIndex,index,childIndex)">
                             <div class="scoring-input-box" @click.stop v-if="studentAnswer.scores && studentAnswer.scores.length">
-                                <InputNumber v-model="studentAnswer.scores[childItem.index]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="childItem.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
+                                <InputNumber @on-change="setUpdStatus" v-model="studentAnswer.scores[childItem.index]" size="small" :formatter="value => value < 0 ? '' : `${value}${$t('learnActivity.score.scoreUnit')}`" :parser="value => value.replace($t('learnActivity.score.scoreUnit'), '')" :min="0" :max="childItem.score" :placeholder="$t('learnActivity.score.zeroScore1')" class="score-input" />
                                 <!-- 快速打分 满分 零分 -->
                                 <div style="display:flex;justify-content: space-evenly;margin-top:5px;">
                                     <span class="fast-score-tag" :title="$t('learnActivity.score.fullScore')" @click="fastSetScore(childItem.index,childItem.score)">
@@ -353,7 +353,7 @@ export default {
             type: Object,
             default: () => { }
         },
-        studentAnswer: {
+        pStudentAnswer: {
             type: Object,
             default: () => { }
         },
@@ -364,6 +364,8 @@ export default {
     },
     data() {
         return {
+            isUpd: false,
+            studentAnswer: {},
             viewIndex: 0,
             viewStatus: false,
             isDefOrder: false, //是否默认排序  默认/题型
@@ -389,6 +391,9 @@ export default {
         }
     },
     methods: {
+        setUpdStatus() {
+            this.isUpd = true
+        },
         markByQu() {
             this.$emit('toggleMarkType', 'byQu')
         },
@@ -574,11 +579,13 @@ export default {
         //快速打分
         fastSetScore(index, score) {
             this.$set(this.studentAnswer.scores, index, score)
+            this.setUpdStatus()
         },
         // 加分
         scoreUp(index, totalScore) {
             if (this.studentAnswer.scores[index] < totalScore) {
                 this.$set(this.studentAnswer.scores, index, ++this.studentAnswer.scores[index])
+                this.setUpdStatus()
             } else {
                 this.$Message.warning(this.$t('learnActivity.score.isFullTips'))
             }
@@ -587,6 +594,7 @@ export default {
         scoreDown(index) {
             if (this.studentAnswer.scores[index] > 0) {
                 this.$set(this.studentAnswer.scores, index, --this.studentAnswer.scores[index])
+                this.setUpdStatus()
             } else {
                 this.$Message.warning(this.$t('learnActivity.score.isZeroTips'))
             }
@@ -607,6 +615,8 @@ export default {
             this.$api.learnActivity.UpsertAllRecord(requestData).then(res => {
                 if (res.error == null) {
                     this.$Message.success(this.$t('learnActivity.score.saveScoreOk'))
+                    this.isUpd = false
+                    this.$emit('updScore', this.studentAnswer)
                     if (!this.studentAnswer.scores.includes(-1)) {
                         this.isComplete = true
                     }
@@ -714,10 +724,12 @@ export default {
             },
             deep: true
         },
-        studentAnswer: {
+        pStudentAnswer: {
             async handler(newValue, oldValue) {
-                if (!this.studentAnswer.status) {
-                    if (newValue.answers.length) {
+                this.studentAnswer = this._.cloneDeep(newValue || {})
+                console.log(this.studentAnswer)
+                if (!this.studentAnswer.status && this.studentAnswer.answers && this.studentAnswer.scores) {
+                    if (this.studentAnswer.answers.length) {
                         try {
                             let sas = this.examScope == 'school' ? this.$store.state.user.schoolProfile.blob_sas : this.$store.state.user.userProfile.blob_sas
                             let blobUrl = this.examScope == 'school' ? JSON.parse(decodeURIComponent(localStorage.school_profile, "utf-8")).blob_uri : JSON.parse(decodeURIComponent(localStorage.user_profile, "utf-8")).blob_uri
@@ -727,7 +739,7 @@ export default {
                              * 2、这里就直接读取原始作答数据;
                              * 3、在渲染的时候再判断当前题目是否有批注数据。
                              */
-                            a = await this.$tools.getFile(`${blobUrl}/exam/${newValue.answers[0]}?${sas}`)
+                            a = await this.$tools.getFile(`${blobUrl}/exam/${this.studentAnswer.answers[0]}?${sas}`)
 
                             if (a) {
                                 let ans = JSON.parse(a)
@@ -742,7 +754,7 @@ export default {
                             console.log('error', e)
                         }
                     } else {
-                        let a = newValue.scores.map(item => {
+                        let a = this.studentAnswer.scores.map(item => {
                             return [this.$t('learnActivity.score.noStuAns1')]
                         })
                         this.$set(this.studentAnswer, 'answers', a)
@@ -754,7 +766,8 @@ export default {
                     })
                 }
             },
-            deep: true
+            deep: true,
+            immediate: true
         }
     },
     computed: {

+ 42 - 4
TEAMModelOS/ClientApp/src/view/learnactivity/MgtSchoolEva.vue

@@ -182,7 +182,7 @@ export default {
     inject: ['reload'],
     data() {
         return {
-            isDev:false,
+            isDev: false,
             isSetting: false,
             btnLoading: false,
             keyword: '',
@@ -491,11 +491,30 @@ export default {
                 }
             )
         },
-
         selectEvaluation(index) {
+            let comp = this.$refs['score-box'] ? this.$refs['score-box'].$refs['byStuMark'] : null
+            if (comp && comp.isUpd) {
+                this.$Modal.confirm({
+                    title: '保存分数',
+                    content: '您修改的分数尚未保存,是否需要保存?',
+                    okText: '是',
+                    cancelText: '否',
+                    onOk: () => {
+                        comp.saveScore()
+                        this.toEvaluation(index)
+                    },
+                    onCancel: () => {
+                        this.toEvaluation(index)
+                    }
+                })
+            } else {
+                this.toEvaluation(index)
+            }
+        },
+        toEvaluation(index) {
             this.curSubIndex = 0
             this.curEvaIndex = index
-            this.$nextTick(()=>{
+            this.$nextTick(() => {
                 this.$refs['score-box'].showTest = false
             })
             if (this.evaListShow[this.curEvaIndex] && this.evaListShow[this.curEvaIndex].papers.length == 0) {
@@ -535,7 +554,6 @@ export default {
                             resData.papers[index].sheetNo = sheetNo
                         }
                         this.evaListShow.splice(this.curEvaIndex, 1, resData)
-                        console.log('ddd',JSON.stringify(this.evaListShow))
                         this.examDetaiInfo = resData
                     } else {
                         this.$Message.error('API ERROR!')
@@ -607,6 +625,26 @@ export default {
             }
             return name
         },
+    },
+    beforeRouteLeave(to, from, next) {
+        let comp = this.$refs['score-box'].$refs['byStuMark']
+        if (comp && comp.isUpd) {
+            this.$Modal.confirm({
+                title: '保存分数',
+                content: '您修改的分数尚未保存,是否需要保存?',
+                okText: '是',
+                cancelText: '否',
+                onOk: () => {
+                    comp.saveScore()
+                    next()
+                },
+                onCancel: () => {
+                    next()
+                }
+            })
+        } else {
+            next()
+        }
     }
 }
 </script>

+ 51 - 9
TEAMModelOS/ClientApp/src/view/learnactivity/Scoring.vue

@@ -20,8 +20,8 @@
                     </Option>
                 </Select>
                 <!-- 切换打分UI -->
-                <span v-show="showTest" class="common-icon-text" style=" float: right; margin-right: 25px;" @click="toggleScoreStatus" icon="md-apps">
-                    <Icon :custom="showTest ? 'iconfont icon-table':'iconfont icon-scoring'" style="margin-right:5px;" />
+                <span v-show="showTest" class="common-icon-text" style=" float: right; margin-right: 15px;" @click="toggleScoreStatus" icon="md-apps">
+                    <Icon :custom="showTest ? 'iconfont icon-table':'iconfont icon-scoring'" style="margin-right:5px;" size="14" />
                     {{showTest ? $t('learnActivity.score.scoreView'):$t('learnActivity.score.scoring')}}
                 </span>
             </div>
@@ -51,7 +51,7 @@
                 </div>
                 <!-- 按人批阅 -->
                 <div class="dark-iview-table scoring-handle-box" v-show="showTest && markType== 'byStu'">
-                    <ByStuMark @toggleMarkType="(data)=>{ markType = data }" ref="paperScore" :defaultIndex="defaultIndex" :examId="examInfo.id" :owner="examInfo.owner" :examScope="examInfo.scope" :paper="paperInfo" :studentAnswer="chooseStudent" :subjectId="chooseSubject" @nextStu="getNextStu" style="color:#515a6e;"></ByStuMark>
+                    <ByStuMark @toggleMarkType="(data)=>{ markType = data }" @updScore="updScore" ref="byStuMark" :defaultIndex="defaultIndex" :examId="examInfo.id" :owner="examInfo.owner" :examScope="examInfo.scope" :paper="paperInfo" :pStudentAnswer="chooseStudent" :subjectId="chooseSubject" @nextStu="getNextStu" style="color:#515a6e;"></ByStuMark>
                     <Loading :top="200" type="1" style="text-align:center" v-show="dataLoading"></Loading>
                 </div>
                 <!-- 按题批阅 -->
@@ -199,8 +199,37 @@ export default {
             this.tableData = this.studentScore.slice(start, end)
         },
         toggleScoreStatus() {
-            this.$refs['paperScore'].isComplete = false
-            this.showTest = !this.showTest
+            if (this.$refs['byStuMark'].isUpd) {
+                this.$Modal.confirm({
+                    title: '保存分数',
+                    content: '您修改的分数尚未保存,是否需要保存?',
+                    okText: '是',
+                    cancelText: '否',
+                    onOk: () => {
+                        this.$refs['byStuMark'].saveScore()
+                        this.$refs['byStuMark'].isComplete = false
+                        this.showTest = !this.showTest
+                    },
+                    onCancel: () => {
+                        this.$refs['byStuMark'].isUpd = false
+                        this.$refs['byStuMark'].isComplete = false
+                        this.showTest = !this.showTest
+                    }
+                })
+            } else {
+                this.$refs['byStuMark'].isComplete = false
+                this.showTest = !this.showTest
+            }
+        },
+        updScore(data) {
+            console.log(this.studentScore)
+            let index = this.studentScore.findIndex(item => {
+                return item.id == data.id
+            })
+            if (index > -1) {
+                this.$set(this.studentScore[index], 'data', this._.cloneDeep(data.scores))
+            }
+            // this.chooseStudent = this._.cloneDeep(data)
         },
         getNextStu() {
             let flag = false
@@ -217,7 +246,7 @@ export default {
                         this.chooseStudent.scores = this.paperInfo[this.chooseClass].studentAns.studentScores[index]
                         this.chooseStudent.classId = this.chooseClass
                         this.chooseStudent.status = false
-                        this.$refs['paperScore'].isComplete = false
+                        this.$refs['byStuMark'].isComplete = false
                         break
                     }
                 }
@@ -242,7 +271,7 @@ export default {
         //点击学生题号前往评分页面
         getStuScore(data, qIndex) {
             if (data.status == 2 || data.status == 3) {
-                this.$refs['paperScore'].isComplete = false
+                this.$refs['byStuMark'].isComplete = false
                 this.showTest = true
                 this.defaultIndex = qIndex
                 this.chooseStudent.id = data.id
@@ -679,8 +708,21 @@ export default {
         } else {
             this.routerScope = 'school'
         }
-    }
-};
+    },
+    // beforeDestroy() {
+    //     if (this.$refs['byStuMark'].isUpd) {
+    //         this.$Modal.confirm({
+    //             title: '保存分数',
+    //             content: '您修改的分数尚未保存,是否需要保存?',
+    //             okText: '是',
+    //             cancelText: '否',
+    //             onOk: () => {
+    //                 this.$refs['byStuMark'].saveScore()
+    //             }
+    //         })
+    //     } 
+    // }
+}
 </script>
 
 <style scoped lang="less">