Explorar o código

paper by hand - add cart prevent concurrency

hare8999@163.com %!s(int64=2) %!d(string=hai) anos
pai
achega
9fa9691b63

+ 8 - 3
src/views/questioncenter/components/generate-tabs/paper-by-hand.vue

@@ -190,7 +190,8 @@ export default {
       mathId: 'question_by_hand',
       show: false,
       enableBox: true,
-      ignoreQType: false
+      ignoreQType: false, // 智能组卷会乎略题型
+      uploading: false
     }
   },
   computed: {
@@ -323,24 +324,28 @@ export default {
     },
     /* methods of question box */
     addQueCard(item) {
+      if (this.uploading) return
+      if (this.queCardForm.queList.includes(item.id)) return
       if (this.queCardForm.queList.length == 0) {
         // 为0直接添加
+        this.uploading = true
         addToQuestionCard({
           questionId: item.id,
           ...this.extraData
         }).then(() => {
           this.queCardForm.queList.push(item)
-        })
+        }).finally(() => this.uploading = false)
       } else {
         // 判断是否是同一个科目下的题目
         if (item.subjectid == this.queCardForm.queList[0].subjectid) {
           // 是,则添加
+          this.uploading = true
           addToQuestionCard({
             questionId: item.id,
             ...this.extraData
           }).then((res) => {
             this.queCardForm.queList.push(item)
-          })
+          }).finally(() => this.uploading = false)
         } else {
           // 不是,弹出警告
           this.$message.error('科目不一致,请清空试题篮或选择同一科目')