Parcourir la source

Merge branch 'feature_check' into main

Leonezhurui il y a 4 ans
Parent
commit
1d5983c779

+ 3 - 1
src/api/index.js

@@ -5,7 +5,8 @@ import {
     getTargetQuestionList,
     getStateQuestion,
     updateQuestion,
-    requestQuestion
+    requestQuestion,
+    getQuestionById
 } from "./question";
 
 import {getUserById,
@@ -26,6 +27,7 @@ const api = {
     getStateQuestion: getStateQuestion,
     updateQuestion: updateQuestion,
     requestQuestion: requestQuestion,
+    getQuestionById: getQuestionById,
 
     getUserById: getUserById,
 

+ 9 - 0
src/api/question.js

@@ -91,6 +91,15 @@ export function getStateQuestion(states, offset, pageSize) {
   });
 }
 
+/**
+ * 根据qid找到题目
+ * @param qid
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+export function getQuestionById(qid){
+  return axios.get("/api/getQuestion/"+qid);
+}
+
 // /**
 //  * 上传题目列表到线上Bok
 //  * @param questions

+ 85 - 5
src/components/QuestionCard/UpdatingQuestionCard.vue

@@ -41,10 +41,10 @@
     <!--更新审核题目卡片的按钮-->
     <template v-slot:button>
       <el-col :span="1">
-        <el-button type="primary" icon="el-icon-check" circle @click="mockApproveQuestion"/>
+        <el-button type="primary" icon="el-icon-check" circle @click="approveQuestion"/>
       </el-col>
       <el-col :span="1">
-        <el-button type="danger" icon="el-icon-close" circle @click="mockDisapproveQuestion"/>
+        <el-button type="danger" icon="el-icon-close" circle @click="disapproveQuestion"/>
       </el-col>
     </template>
     <!--新旧题目题干不同-->
@@ -156,6 +156,7 @@ import PrimaryQuestionCard from "@/components/QuestionCard/PrimaryQuestionCard";
 import MarkdownText from "@/components/MarkdownText";
 import UpdateChoiceOption from "@/components/QuestionCard/AnswerDisplay/ChoiceDisplay/UpdatingChoiceDisplay";
 import {map} from "@/utils/knowledgeMapper";
+import store from "@/store";
 
 export default {
   name: "UpdatingQuestionCard",
@@ -243,6 +244,48 @@ export default {
 
     // 审核通过更新的题目
     approveQuestion() {
+      const _this = this;
+      for (const key in this.oldQuestionVO) {
+        if(key !== 'id' && this.newQuestionVO[key] !== null){
+          _this.oldQuestionVO[key] = _this.newQuestionVO[key];
+        }
+      }
+      _this.oldQuestionVO.state = "APPROVED";
+      let record = {
+        userId: store.state.user.id,
+        operationType: "Approve",
+      }
+      _this.$api.updateQuestion(_this.oldQuestionVO)
+          .then(res => {
+            _this.$message({
+              type: 'success',
+              message: '修改审核通过!'
+            });
+            console.log("UpdatingQuestionCard-approve");
+            console.log(res);
+            record.questionId = res.data.result.id;
+            record.time = new Date();
+            // 审核通过,添加操作记录
+            _this.$api.createRecord(record)
+                .then(res1 => {
+                  console.log("Updating-approve-createRecord");
+                  console.log(res1);
+                }).catch(err1 => {
+              console.log(err1);
+            })
+          })
+          .catch(err => {
+            _this.$notify.error({
+              title: '错误',
+              message: '通过失败'
+            });
+            console.log(err);
+          });
+      _this.$api.deleteQuestionById(_this.newQuestionVO.id).then(res => {
+        console.log("中间状态题目删除成功");
+      }).catch(err => {
+        console.log(err);
+      })
     },
 
     mockApproveQuestion() {
@@ -255,6 +298,43 @@ export default {
 
     // 审核不通过更新的题目
     disapproveQuestion() {
+      const _this = this;
+      _this.oldQuestionVO.state = "APPROVED";
+      let record = {
+        userId: store.state.user.id,
+        operationType: "Refuse",
+      }
+      _this.$api.updateQuestion(_this.oldQuestionVO)
+          .then(res => {
+            _this.$message({
+              type: 'error',
+              message: '修改审核不通过!'
+            });
+            console.log("UpdatingQuestionCard-refuse");
+            console.log(res);
+            record.questionId = res.data.result.id;
+            record.time = new Date();
+            // 审核通过,添加操作记录
+            _this.$api.createRecord(record)
+                .then(res1 => {
+                  console.log("Updating-refuse-createRecord");
+                  console.log(res1);
+                }).catch(err1 => {
+              console.log(err1);
+            })
+          })
+          .catch(err => {
+            _this.$notify.error({
+              title: '错误',
+              message: '通过失败'
+            });
+            console.log(err);
+          });
+      _this.$api.deleteQuestionById(_this.newQuestionVO.id).then(res => {
+        console.log("中间状态题目删除成功");
+      }).catch(err => {
+        console.log(err);
+      })
     },
 
     mockDisapproveQuestion() {
@@ -276,7 +356,7 @@ export default {
 }
 
 .old-content {
-  text-align: center;
+  text-align: left;
   background: #feefea;
   color: #dc745a;
   border-color: #dc745a;
@@ -284,7 +364,7 @@ export default {
 }
 
 .new-content {
-  text-align: center;
+  text-align: left;
   background: #e8fdf4;
   color: #59a48d;
   border-color: #59a48d;
@@ -308,4 +388,4 @@ export default {
   margin-right: 1%;
   height: auto;
 }
-</style>
+</style>

+ 32 - 13
src/components/QuestionUpdater.vue

@@ -160,6 +160,7 @@
 
 <script>
     import store from "../store";
+    import {createQuestion} from "@/api/question";
 
     export default {
         name: "QuestionUpdater",
@@ -202,6 +203,7 @@
                     label: '难度5'
                 }],
                 chosenTags: ["Java", "软工系列", "Python", "Vue", "SpringBoot"],
+              old_question: String,
                 myknowledgeId: '',
             }
         },
@@ -210,43 +212,60 @@
                 this.$emit('closeDialog');
             },
             updateQuestion(){
+              const old_question = JSON.parse(this.old_question);
+              // console.log("old_question", old_question);
+              // console.log("question", this.question);
+              this.question.state = null;
                 this.question.lastModifiedTime = new Date();
                 let record = {
                     userId: store.state.user.id,
                     operationType: "Update",
                 }
-                this.$api.updateQuestion(this.question).then(res => {
+                delete this.question.id;
+                this.$api.createQuestion(this.question).then(res2 => {
+                  console.log("创建中间状态的题目", res2);
+                  const new_question = res2.data.result;
+                  old_question.remark = new_question.id;
+                  old_question.state = "UPDATING";
+                  this.$api.updateQuestion(old_question).then(res => {
                     this.$notify({
-                        title: '成功',
-                        message: '更新成功',
-                        type: 'success'
+                      title: '成功',
+                      message: '更新成功',
+                      type: 'success'
                     });
 
+                    console.log(res.data.result);
                     record.questionId = res.data.result.id;
                     record.time = new Date();
                     // 如果题目更新成功,那么添加操作记录
                     this.$api.createRecord(record)
                         .then(res1 => {
-                            console.log(res1);
+                          console.log("createRecord", res1);
                         }).catch(err1 => {
-                        console.log(err1);
+                      console.log(err1);
                     })
 
                     setTimeout(() => {
-                        this.$emit('closeDialog');
+                      this.$emit('closeDialog');
                     }, 1000);
-                }).catch(err => {
+                  }).catch(err => {
                     console.log(err);
                     this.$notify.error({
-                        title: '错误',
-                        message: '更新失败'
+                      title: '错误',
+                      message: '更新失败'
                     });
-                }).finally(() => {
-                    console.log('updateQuestion');
+                  })
+                }).catch(err2 => {
+                  console.log(err2);
                 })
 
+
+
             }
-        }
+        },
+      mounted() {
+          this.old_question = JSON.stringify(this.question);
+      }
     }
 </script>
 

+ 78 - 53
src/views/Bok/Main/Check.vue

@@ -49,7 +49,7 @@
         <!--todo: 设计UpdateQuestionCard并且在这里应用-->
         <el-pagination
           @size-change="handleSizeChange"
-          @current-change="handleCurrentChange(updateCurrentPage, updateQuestionList, 'UPDATE')"
+          @current-change="handleCurrentChange(updateCurrentPage, updateQuestionList, 'UPDATING')"
           :current-page="updateCurrentPage"
           :page-sizes="[5, 10, 15, 20]"
           :page-size="pageSize"
@@ -67,9 +67,9 @@
         />
       </el-tab-pane>
 
-      <el-tab-pane label="审核失败" name="refused">
-        <!--todo: 设计RefuseQuestionCard并且在这里应用-->
-      </el-tab-pane>
+<!--      <el-tab-pane label="审核失败" name="refused">-->
+<!--        &lt;!&ndash;todo: 设计RefuseQuestionCard并且在这里应用&ndash;&gt;-->
+<!--      </el-tab-pane>-->
 
       <el-tab-pane label="删除审核" name="executing">
         <!--todo: 设计DeleteQuestionCard并且在这里应用-->
@@ -91,25 +91,25 @@
         />
       </el-tab-pane>
 
-      <el-tab-pane label="删除完成" name="deleted">
-        <!--todo: 设计DeleteQuestionCard并且在这里应用-->
-        <el-pagination
-          @size-change="handleSizeChange"
-          @current-change="handleCurrentChange(deleteCurrentPage, deleteQuestionList, 'DELETED')"
-          :current-page="deleteCurrentPage"
-          :page-sizes="[5, 10, 15, 20]"
-          :page-size="pageSize"
-          layout="total, sizes, prev, pager, next, jumper"
-          :total=deleteTotalNum
-          v-if="deleteQuestionList.length !== 0"
-        />
-        <deleted-question-card v-for="(item, index) in deleteQuestionList"
-                               :question-v-o="item"
-                               :key="item.id"
-                               :cur-num="index+(deleteCurrentPage-1)*pageSize"
-                               :total-num="deleteTotalNum"
-        />
-      </el-tab-pane>
+<!--      <el-tab-pane label="删除完成" name="deleted">-->
+<!--        &lt;!&ndash;todo: 设计DeleteQuestionCard并且在这里应用&ndash;&gt;-->
+<!--        <el-pagination-->
+<!--          @size-change="handleSizeChange"-->
+<!--          @current-change="handleCurrentChange(deleteCurrentPage, deleteQuestionList, 'DELETED')"-->
+<!--          :current-page="deleteCurrentPage"-->
+<!--          :page-sizes="[5, 10, 15, 20]"-->
+<!--          :page-size="pageSize"-->
+<!--          layout="total, sizes, prev, pager, next, jumper"-->
+<!--          :total=deleteTotalNum-->
+<!--          v-if="deleteQuestionList.length !== 0"-->
+<!--        />-->
+<!--        <deleted-question-card v-for="(item, index) in deleteQuestionList"-->
+<!--                               :question-v-o="item"-->
+<!--                               :key="item.id"-->
+<!--                               :cur-num="index+(deleteCurrentPage-1)*pageSize"-->
+<!--                               :total-num="deleteTotalNum"-->
+<!--        />-->
+<!--      </el-tab-pane>-->
     </el-tabs>
   </div>
 </template>
@@ -149,9 +149,9 @@ export default {
       createTotalNum: 0,
 
       // 审核失败题目列表
-      refuseQuestionList: [],
-      refuseCurrentPage: 1,
-      refuseTotalNum: 0,
+      // refuseQuestionList: [],
+      // refuseCurrentPage: 1,
+      // refuseTotalNum: 0,
 
       // 更新审核题目列表
       updateQuestionList: [],
@@ -164,9 +164,9 @@ export default {
       executeTotalNum: 0,
 
       // 删除完成题目列表
-      deleteQuestionList: [],
-      deleteCurrentPage: 1,
-      deleteTotalNum: 0,
+      // deleteQuestionList: [],
+      // deleteCurrentPage: 1,
+      // deleteTotalNum: 0,
     }
   },
   methods: {
@@ -199,7 +199,11 @@ export default {
         console.log(error);
       })
     },
-
+    async getQuestionById(id){
+      let res = await this.$api.getQuestionById(id)
+      console.log("test", res.data.result);
+      return res.data.result
+    },
     // 切换分页
     handleClick(tab, event) {
       const _this = this
@@ -238,23 +242,44 @@ export default {
           break;
         // 更新审核
         case "updating":
-          mockApi.mockGetUpdateQuestion().then().catch(err => {
-            _this.updateTotalNum = err.data.length;
-            _this.updateQuestionList = err.data
-          })
-          break;
+          _this.$api.getStateQuestion(tab.props.name.toUpperCase(), 0, this.pageSize)
+              .then(async res => {
+                console.log("getStateQuestion-UPDATING");
+                const update_list = res.data.result.content;
+                let updating_num = 0;
+                // console.log(update_list)
+                for (const updateListElement of update_list) {
+                  if (updateListElement.remark) {
+                    updating_num += 1;
+                    console.log(updateListElement);
+                    let item = {"oldQuestionVO": updateListElement};
+                    let newQuestionVO = await _this.getQuestionById(updateListElement.remark);
+                    item.newQuestionVO = newQuestionVO;
+                    this.updateQuestionList.push(item);
+                  }
+                }
+                this.updateTotalNum = updating_num;
+              }).catch(err => {
+              console.log(err);
+            })
+            break;
+          // mockApi.mockGetUpdateQuestion().then().catch(err => {
+          //   _this.updateTotalNum = err.data.length;
+          //   _this.updateQuestionList = err.data
+          // })
+          // break;
         // 审核失败
-        case "refused":
-          this.$api.getStateQuestion(tab.props.name.toUpperCase(), 0, this.pageSize)
-            .then(res => {
-              console.log("getStateQuestion-REFUSED");
-              console.log(res);
-              this.refuseQuestionList = res.data.result.content;
-              this.refuseTotalNum = res.data.result.totalElements;
-            }).catch(err => {
-            console.log(err);
-          })
-          break;
+        // case "refused":
+        //   this.$api.getStateQuestion(tab.props.name.toUpperCase(), 0, this.pageSize)
+        //     .then(res => {
+        //       console.log("getStateQuestion-REFUSED");
+        //       console.log(res);
+        //       this.refuseQuestionList = res.data.result.content;
+        //       this.refuseTotalNum = res.data.result.totalElements;
+        //     }).catch(err => {
+        //     console.log(err);
+        //   })
+        //   break;
         // 删除审核
         case "executing":
           mockApi.mockGetExecuteQuestion().then().catch(err => {
@@ -263,13 +288,13 @@ export default {
             _this.executeQuestionList = err.data
           })
           break;
-        case "deleted":
-          mockApi.mockGetExecuteQuestion().then().catch(err => {
-            console.log(err)
-            _this.deleteTotalNum = err.data.length;
-            _this.deleteQuestionList = err.data
-          })
-          break;
+        // case "deleted":
+        //   mockApi.mockGetExecuteQuestion().then().catch(err => {
+        //     console.log(err)
+        //     _this.deleteTotalNum = err.data.length;
+        //     _this.deleteQuestionList = err.data
+        //   })
+        //   break;
         default:
           break;
       }