Forráskód Böngészése

静态信息修改时内容类型未选中bug

zhouna 3 éve
szülő
commit
1506108778

+ 28 - 0
src/components/knowledgeExtra/AddDevKnow.vue

@@ -136,6 +136,7 @@
                 :total="form.prags.length"
                 :isEdit="isEdit"
                 :isCopy="isCopy"
+                :positions="positions"
                 ref="subForm"
                 @add="addParagraph(i)"
                 @del="delParagraph"
@@ -229,6 +230,8 @@ export default {
       isFixedTop: true,
       isEdit: false,
       isCopy: false,
+      positions:[],   //当前类型术语需要显示的内容类型
+      positionsList:[],   //内容类型对象
       title: '添加',
       termTypes: [],
       terms: [], //术语列表
@@ -330,6 +333,7 @@ export default {
     }
   },
   created: function() {
+      this.zskgetDict();    //获取内容类型
     const { isEdit, data, isCopy } = this.$route.params;
     if (isEdit || isCopy) {
       const loading = this.$loading({
@@ -472,6 +476,30 @@ export default {
     }
   },
   methods: {
+      zskgetDict() {  //获取位置枚举
+          api
+              .zskgetDict()
+              .then(res => {
+                  if (res.data.code == '0') {
+                      const data = res.data.data;
+                      this.positionsList = data['50'];
+                      this.getPosition(data['51']);
+                      //this.positions = data['50'];
+                      //this.renderPositions(data['50'], data['51']);
+                  }
+              })
+              .catch(error => {
+                  console.log(error);
+              });
+      },
+      getPosition(maps){    //筛选出当前类型需要显示的内容类型
+          const data2 = maps.find(item => item.name == this.showType);
+          let val = data2.val.split(',');
+          this.positions = this.positionsList.filter(it => {
+              let arr = val.map(v => v);
+              return arr.includes(it.val);
+          });
+      },
     scrollTo(dom) {
       var div = this.$refs['elscrollbar'].$refs['wrap'];
       if (dom >= 0) {

+ 1 - 29
src/components/knowledgeExtra/DevInfo.vue

@@ -105,7 +105,7 @@ import config from '@api/config';
 import { container, ImageExtend, QuillWatch } from 'quill-image-extend-module';
 Quill.register('modules/ImageExtend', ImageExtend);
 export default {
-  props: ['data', 'index', 'isEdit', 'isCopy', 'total', 'showType'],
+  props: ['data', 'index', 'isEdit', 'isCopy', 'total', 'showType','positions'],
   name: 'DevInfo',
   components: {
     quillEditor
@@ -165,7 +165,6 @@ export default {
         position: [],
         orderNo: 0
       },
-      positions: [], //位置列表
       rules: {}
     };
   },
@@ -186,7 +185,6 @@ export default {
     this.editorOption.modules.toolbar.container = this.toolbars[
       this.toolbarMode
     ];
-    this.zskgetDict();
 
     if (this.isEdit || this.isCopy) {
       setTimeout(() => {
@@ -287,20 +285,6 @@ export default {
     );
   },
   methods: {
-    zskgetDict() {
-      api
-        .zskgetDict()
-        .then(res => {
-          if (res.data.code == '0') {
-            const data = res.data.data;
-            this.positions = data['50'];
-            this.renderPositions(data['50'], data['51']);
-          }
-        })
-        .catch(error => {
-          console.log(error);
-        });
-    },
     reOrder(i) {
       this.$emit('reOrder', i, this.index);
     },
@@ -321,18 +305,6 @@ export default {
       });
       this.data.position = arr;
     },
-    // 渲染内容类型
-    renderPositions(data1, data2) {
-      //显示位置枚举列表
-      if (this.showType>0) {
-        data2 = data2.filter(item => item.name == this.showType);
-        let val = data2[0].val.split(',');
-        this.positions = data1.filter(it => {
-          let arr = val.map(v => v);
-          return arr.includes(it.val);
-        });
-      }
-    }
   }
 };
 </script>