Browse Source

Leone 添加审核逻辑

Leonezhurui 5 years ago
parent
commit
5feaeb1a02

+ 4 - 2
src/api/index.js

@@ -1,9 +1,10 @@
-import {testFunc,
+import {
+    testFunc,
     createQuestion,
     deleteQuestionById,
     getTargetQuestionList,
     getStateQuestion,
-    updateQuestion
+    updateQuestion, approveQuestion
 } from "./question";
 
 import {getUserById,
@@ -18,6 +19,7 @@ const api = {
     getTargetQuestionList: getTargetQuestionList,
     getStateQuestion: getStateQuestion,
     updateQuestion: updateQuestion,
+    approveQuestion: approveQuestion,
 
     getUserById: getUserById,
 }

+ 6 - 0
src/api/question.js

@@ -69,3 +69,9 @@ export function getStateQuestion(states) {
         }});
 }
 
+export function approveQuestion(id, states) {
+    return axios.put("/api/api/check/"+id, {
+        state: states
+    });
+}
+

+ 5 - 19
src/components/AbstractQuestionCard.vue

@@ -16,7 +16,7 @@
                                 <span><strong>KnowledgeId: </strong></span>
                                 <el-tooltip v-for="item in questionvo.knowledgeId" effect="dark" placement="bottom">
                                     <template #content>
-                                        {{map1(item)}}
+                                        {{map(item)}}
                                     </template>
                                     <el-tag  effect="dark" style="margin-right: 2px">{{item}}</el-tag>
                                 </el-tooltip>
@@ -171,6 +171,7 @@
 <script>
     import MarkdownText from "./MarkdownText";
     import {map} from "../utils/knowledgeMapper";
+    import {toMyDate} from "../utils/dateConvertor";
     import QuestionUpdater from "./QuestionUpdater";
 
     export default {
@@ -193,9 +194,8 @@
             }
         },
         methods:{
-            map1(abbreviation){
-                return map(abbreviation)
-            },
+            toMyDate,
+            map,
             expand(){
                 if(!this.isAll){
                     this.isAll = true;
@@ -250,21 +250,7 @@
             recoverQuestion(){
                 alert("Delete successfully!");
             },
-            toMyDate(instant){
-                let date = new Date(instant);
-                let year = date.getFullYear();
-                let month = date.getMonth() + 1;
-                let theDate = date.getDate();
-                let hour = date.getHours();
-                let minute = date.getMinutes();
-                let second = date.getSeconds();
-                if ( month < 10 ) { month = '0' + month; }
-                if ( theDate < 10 ) { theDate = '0' + theDate; }
-                if ( hour < 10 ) { hour = '0' + hour; }
-                if ( minute < 10 ) { minute = '0' + minute; }
-                if ( second < 10 ) { second = '0' + second; }
-                return year +"-"+ month +"-" + theDate + " "+ hour +":"+ minute +":"+ second;
-            }
+
         },
         computed: {
             // checkedUserName() {

+ 54 - 16
src/components/checkQuestionCard.vue

@@ -9,7 +9,7 @@
                 </el-col>
                 <el-col :span="5">
                     <div>
-                        <strong>申请日期: </strong>2021-9-19 09:36:00
+                        <strong>申请日期: </strong> {{toMyDate(questionvo.createdTime)}}
                     </div>
                 </el-col>
                 <el-col :span="14"></el-col>
@@ -113,13 +113,13 @@
                 <div>
                     <el-row>
                         <el-col :span="8">
-                            <el-button type="primary" @click="">通过</el-button>
+                            <el-button type="primary" @click="approve">通过</el-button>
                         </el-col>
                         <el-col :span="8">
                             <el-button type="primary" @click="">待定</el-button>
                         </el-col>
                         <el-col :span="8">
-                            <el-button type="primary" @click="">拒绝</el-button>
+                            <el-button type="primary" @click="deny">拒绝</el-button>
                         </el-col>
 
                     </el-row>
@@ -133,8 +133,8 @@
 </template>
 
 <script>
-    import {getUserById} from "../api/user";
     import MarkdownText from "./MarkdownText";
+    import {toMyDate} from "../utils/dateConvertor";
 
     export default {
         name: "checkCard",
@@ -168,22 +168,13 @@
                     lastModifiedTime: Date,
                 },
                 isAll: false,
+                savedUserName: '',
             }
         },
         computed: {
-            savedUserName: function () {
-                // let user;
-                // getUserById(this.questionvo.savedUserId).then(res => {
-                //     user = res.result.content;
-                //     return user.name;
-                // }).catch(err => {
-                //     console.log(err);
-                // })
-                return "xiaosu";
-            },
-
         },
         methods: {
+            toMyDate,
             expand(){
                 if(!this.isAll){
                     this.isAll = true;
@@ -194,7 +185,54 @@
                     this.isAll = false;
                 }
             },
-
+            approve(){ // 通过审核
+                this.questionvo.state = "APPROVED";
+                this.$api.updateQuestion(this.questionvo)
+                    .then(res => {
+                        this.$message({
+                            type: 'success',
+                            message: '通过成功!'
+                        });
+                        console.log(res);
+                    })
+                    .catch(err => {
+                        this.$notify.error({
+                            title: '错误',
+                            message: '通过失败'
+                        });
+                        console.log(err);
+                })
+            },
+            deny(){ // 拒绝通过
+                this.questionvo.state = "REFUSED";
+                this.$api.updateQuestion(this.questionvo)
+                    .then(res => {
+                        this.$message({
+                            type: 'success',
+                            message: '拒绝成功!'
+                        });
+                        console.log(res);
+                    })
+                    .catch(err => {
+                        this.$notify.error({
+                            title: '错误',
+                            message: '拒绝失败'
+                        });
+                        console.log(err);
+                    })
+            }
+        },
+        mounted() {
+            if(this.questionvo.savedUserId){
+                this.$api.getUserById(this.questionvo.savedUserId)
+                    .then(res => {
+                        if(res.data.result.name){
+                            this.savedUserName =  res.data.result.name;
+                        }
+                    }).catch(err => {
+                    console.log(err);
+                })
+            }
         }
     }
 </script>

+ 21 - 0
src/utils/dateConvertor.js

@@ -0,0 +1,21 @@
+/**
+ * instant时间类型转换工具方法
+ * @param instant
+ * @returns {string}
+ */
+
+export function toMyDate(instant) {
+    let date = new Date(instant);
+    let year = date.getFullYear();
+    let month = date.getMonth() + 1;
+    let theDate = date.getDate();
+    let hour = date.getHours();
+    let minute = date.getMinutes();
+    let second = date.getSeconds();
+    if ( month < 10 ) { month = '0' + month; }
+    if ( theDate < 10 ) { theDate = '0' + theDate; }
+    if ( hour < 10 ) { hour = '0' + hour; }
+    if ( minute < 10 ) { minute = '0' + minute; }
+    if ( second < 10 ) { second = '0' + second; }
+    return year +"-"+ month +"-" + theDate + " "+ hour +":"+ minute +":"+ second;
+}

+ 0 - 1
src/views/Bok/Main/Check.vue

@@ -12,7 +12,6 @@
 
 <script>
     import checkQuestionCard from "../../../components/checkQuestionCard";
-    import axios from "axios";
     export default {
         name: "Check",
         components:{