quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<template>
  <!--
        作者:luoyiming
        时间:2020-06-20
        描述:diy组件-组件类别
    -->
  <div v-if="typeList!=null">
    <div class="common-form">组件库</div>
    <div class="min-group">
      <div v-for="(group,key) in typeList" :key="key">
         <div class="hd">{{key | typename}}</div>
         <div class="bd">
           <div class="item" v-for="(item,index) in group.children" :key="index" @click="$parent.onAddItem(item.type)">
             <p class="p-icon icon iconfont icon-tuichu"></p>
             <p class="p-txt">{{item.name}}</p>
           </div>
         </div>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      /*类别列表*/
      typeList:null
    };
  },
  props: {
    defaultData: Object
  },
  created() {
    this.init();
  },
  filters:{
 
    /*组名转换成中文*/
    typename:function(type){
      let name='';
      if(type=='media'){
        name="媒体组件";
      }else if(type=='shop'){
        name="商城组件";
      }else if(type=='tools'){
        name="工具组件";
      }
      return name;
    }
 
  },
  methods: {
 
    /*初始化数据*/
    init() {
      let tempList={};
      for(let key in this.defaultData){
        let item=this.defaultData[key];
        if(!tempList.hasOwnProperty(item.group)){
          tempList[item.group]={};
          tempList[item.group].children=[];
        }
        tempList[item.group].children.push(item);
      }
      this.typeList=tempList;
    }
  }
};
</script>
 
<style></style>