Prechádzať zdrojové kódy

fix:knowledgeId字段由储存id改为储存abbrevation

sky 5 rokov pred
rodič
commit
12ad827558
3 zmenil súbory, kde vykonal 54 pridanie a 16 odobranie
  1. 6 3
      src/App.vue
  2. 13 9
      src/views/Edit.vue
  3. 35 4
      src/views/Home.vue

+ 6 - 3
src/App.vue

@@ -1,6 +1,8 @@
 <template>
   <div id="app">
-    <router-view></router-view>
+    <div>
+      <router-view></router-view>
+    </div>
   </div>
 </template>
 <style>
@@ -13,8 +15,9 @@
   }
   #app {
     width: 980px;
-    margin-left: 50%;
-    transform: translate(-50%);
+    margin: 0 auto;
+    /*margin-left: 50%;*/
+    /*transform: translate(-50%);*/
   }
   img {
     max-width: 900px;

+ 13 - 9
src/views/Edit.vue

@@ -176,7 +176,7 @@
                         this.weight = d.weight;
                         this.analysis = d.analysis;
                         this.keyPoints = d.keyPoints;
-                        this.knowledgeId = d.knowledgeId;
+                        this.knowledgeId = d.knowledgeId ? d.knowledgeId : [];
                         this.tags = d.tags;
                         this.options = d.options;
                         this.blanks = d.blanks;
@@ -196,7 +196,7 @@
             /* 提交 */
             modify() {
                 if(confirm("您确定要进行修改?")) {
-                    this.knowledgeId = this.knowledgeName.map(name => this.searchNodeByNodeName(name)["id"]);
+                    this.knowledgeId = this.knowledgeName.map(name => this.searchNodeByNodeName(name)["abbreviation"]);
                     let questionVO = {
                         id: this.questionId,
                         type: this.type,
@@ -233,10 +233,10 @@
                 this.knowledgeName.splice(this.knowledgeName.indexOf(k_name), 1);
                 this.$refs.tree.getNode(k_name).setChecked(false);
             },
-            /* 在知识点树中,通过id获取节点 */
-            searchNodeByNodeId(id) {
+            /* 在知识点树中,通过abbreviation获取节点 */
+            searchNodeByNodeAbbr(abbreviation) {
                 for(let i=0;i<this.knowledgeList.length;i++) {
-                    if(this.knowledgeList[i].id === id) return this.knowledgeList[i];
+                    if(this.knowledgeList[i].abbreviation === abbreviation) return this.knowledgeList[i];
                 }
             },
             /* 在知识点树中,通过name获取节点 */
@@ -310,10 +310,14 @@
                 /* 构建知识点标签列表 */
                 /* 点亮对应的知识点树节点 */
                 setTimeout(()=>{
-                    this.knowledgeId.forEach(id => {
-                        let name = this.searchNodeByNodeId(id)["name"];
-                        this.knowledgeName.push(name);
-                        this.$refs.tree.getNode(name).setChecked(true);
+                    // debugger
+                    this.knowledgeId.forEach(abbreviation => {
+                        let node = this.searchNodeByNodeAbbr(abbreviation);
+                        if(node) {
+                            let name = node["name"];
+                            this.knowledgeName.push(name);
+                            this.$refs.tree.getNode(name).setChecked(true);
+                        }
                     });
                 }, 0);
 

+ 35 - 4
src/views/Home.vue

@@ -6,6 +6,10 @@
         <div>
             <el-card class="box-card" v-for="question in questionList">
                 <div slot="header" class="card-head">
+                    <div class="tag">
+                        <div :class="question.tagged ? 'tagged' : 'untagged'"></div>
+                        <div>{{question.tagged ? "已标记" : "未标记"}}</div>
+                    </div>
                     <div>
                         <span>id: </span>
                         <a @click="gotoQuestion(question.questionId)">
@@ -68,11 +72,18 @@
                         let d = data.data;
                         this.totalElements = d.totalElements;
                         this.questionList = d.content.map(item => {
+                            let tagged = true;
+                            if (item == null || item.knowledgeId == null || item.knowledgeId.length === 0
+                            || item.weight == null || item.weight === 0)
+                            {
+                                tagged = false;
+                            }
                             return {
-                                questionId: item.id,
-                                title: item.title,
-                                stem: item.stem,
-                                type: item.type
+                                tagged: tagged,
+                                questionId: item?.id,
+                                title: item?.title,
+                                stem: item?.stem,
+                                type: item?.type
                             }
                         })
                     }
@@ -128,4 +139,24 @@
         color: red;
         cursor: pointer;
     }
+    .tag {
+        display: flex;
+        justify-content: space-between;
+        width: 70px;
+    }
+    .tagged {
+        height: 10px;
+        width: 10px;
+        background-color: green;
+        position: relative;
+        bottom: -3px;
+    }
+    .untagged {
+        height: 10px;
+        width: 10px;
+        background-color: red;
+        margin-bottom: -3px;
+        position: relative;
+        bottom: -3px;
+    }
 </style>