Jelajahi Sumber

Leone update 审核

Leonezhurui 5 tahun lalu
induk
melakukan
1a17de5f09

+ 21 - 0
src/api/index.js

@@ -1,4 +1,25 @@
+import {testFunc,
+    createQuestion,
+    deleteQuestionById,
+    getTargetQuestionList,
+    getStateQuestion,
+    updateQuestion
+} from "./question";
+
+import {getUserById,
+
+
+} from "./user";
+
+
 const api = {
+    createQuestion: createQuestion,
+    deleteQuestionById: deleteQuestionById,
+    getTargetQuestionList: getTargetQuestionList,
+    getStateQuestion: getStateQuestion,
+    updateQuestion: updateQuestion,
+
+    getUserById: getUserById,
 }
 
 export {api}

+ 18 - 12
src/api/question.js

@@ -1,16 +1,13 @@
 import axios from 'axios'
-import {api} from "./index";
-import {QUESTION_MODULE} from "./prefix";
 
 /**
  * 用于测试$api是否可以使用
  * @param name
  * @returns {string}
  */
-function testFunc(name) {
+export function testFunc(name) {
     return "你的名字叫"+name;
 }
-api.testFunc = testFunc;
 
 
 /**
@@ -19,14 +16,13 @@ api.testFunc = testFunc;
  * @param pageSize
  * @returns {Promise<AxiosResponse<any>>}
  */
-function getTargetQuestionList(offset, pageSize) {
+export function getTargetQuestionList(offset, pageSize) {
     return axios.get("/api/api/pageQuestion", {
         params:{
             offset: offset,
             pageSize: pageSize
         }});
 }
-api.getTargetQuestionList = getTargetQuestionList;
 
 
 /**
@@ -34,10 +30,9 @@ api.getTargetQuestionList = getTargetQuestionList;
  * @param id
  * @returns {Promise<AxiosResponse<any>>}
  */
-function deleteQuestionById(id) {
+export function deleteQuestionById(id) {
     return axios.delete("/api/api/question/"+id);
 }
-api.deleteQuestionById = deleteQuestionById;
 
 
 /**
@@ -45,10 +40,9 @@ api.deleteQuestionById = deleteQuestionById;
  * @param questionvo
  * @returns {Promise<AxiosResponse<any>>}
  */
-function createQuestion(questionvo) {
+export function createQuestion(questionvo) {
     return axios.post("/api/api/question", questionvo);
 }
-api.createQuestion = createQuestion;
 
 
 /**
@@ -56,10 +50,22 @@ api.createQuestion = createQuestion;
  * @param questionvo
  * @returns {Promise<AxiosResponse<any>>}
  */
-function updateQuestion(questionvo) {
+export function updateQuestion(questionvo) {
     return axios.put("/api/api/question/"+questionvo.id, questionvo);
 }
-api.updateQuestion = updateQuestion;
 
 
+/**
+ * 根据题目状态
+ * @param states
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+export function getStateQuestion(states) {
+    return axios.get("/api/api/state", {
+        params:{
+            state: states,
+            offset: 0,
+            pageSize: 1000,
+        }});
+}
 

+ 1 - 3
src/api/user.js

@@ -1,17 +1,15 @@
 import axios from "axios";
-import {api} from "./index";
 
 /**
  * 根据用户ID获得用户对象
  * @param id
  * @returns {Promise<AxiosResponse<any>>}
  */
-function getUserById(id) {
+export function getUserById(id) {
     return axios.get("api/api/user/uid", {params:{
             uid: id
         }});
 }
-api.getUserById = getUserById;
 
 
 export function getUserInfo(){

+ 3 - 2
src/components/QuestionCreater.vue

@@ -144,8 +144,8 @@
 </template>
 
 <script>
-    import axios from "axios";
     import store from "../store"
+    import {createQuestion} from "../api/question"
 
     export default {
         name: "QuestionCreater",
@@ -244,9 +244,10 @@
                 console.log(this.question);
                 this.question.knowledgeId.push(this.myknowledgeId);
                 this.question.createdTime = new Date();
-                this.question.state = 'CHECKING';
+                this.question.state = "APPROVED";
                 this.question.checkedUserId = 364; //这里是审核人的ID
                 this.question.savedUserId = store.state.user.id;
+                console.log(this.$api)
                 this.$api.createQuestion(this.question)
                     .then(res => {
                         this.$notify({

+ 12 - 2
src/views/Bok/Main/Check.vue

@@ -12,6 +12,7 @@
 
 <script>
     import checkQuestionCard from "../../../components/checkQuestionCard";
+    import axios from "axios";
     export default {
         name: "Check",
         components:{
@@ -23,10 +24,19 @@
 
             }
         },
-        mounted() {
+        methods:{
 
+        },
+        mounted() {
+            let states = 'CHECKING';
+            this.$api.getStateQuestion(states)
+                .then(res => {
+                    console.log(res);
+                    this.questionvoList = res.data.result.content;
+                }).catch(err => {
+                    console.log(err);
+                })
         }
-
     }
 </script>
 

+ 7 - 2
src/views/Bok/SideBar.vue

@@ -33,7 +33,7 @@
 <!--        <i class="el-icon-collection"></i>-->
 <!--        <template #title>收藏</template>-->
 <!--      </el-menu-item>-->
-      <el-menu-item index="check">
+      <el-menu-item index="check" v-if="role">
         <i class="el-icon-circle-check"></i>
         <template #title>审核</template>
       </el-menu-item>
@@ -52,6 +52,10 @@ export default {
   computed:{
     active(){
       return this.$route.path.split("/")[1]
+    },
+    role(){
+      console.log(this.$store.state.user);
+      return this.$store.state.user.role === 'ADMIN';
     }
   },
   // data(){
@@ -71,7 +75,8 @@ export default {
     handleSelect(index){
       this.$router.push('/' + index)
     }
-  }
+  },
+
 }
 </script>