diy-func-list.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template id="diy-func-list">
  2. <el-scrollbar style="height: 100%;">
  3. <!-- <div class="func-search">
  4. <el-input placeholder="搜索组件名称" prefix-icon="el-icon-search" v-model="search" :border="false"></el-input>
  5. </div> -->
  6. <el-collapse v-model="activeNames">
  7. <el-collapse-item :name="index" v-for="(item,index) in list" :key="index">
  8. <template slot="title">
  9. <div class="activeNames">{{item.title}}</div>
  10. </template>
  11. <el-row>
  12. <draggable :list="item.list" :sort="false" :group="{ name: 'componentsGroup', pull: 'clone', put: false }" :clone="cloneComponent" @end="onEnd">
  13. <el-col :span="6" v-for="(item1,index1) in item.list" :key="index1">
  14. <div class="func-list-item" @click="onClick(item1)">
  15. <div class="grid-img">
  16. <el-image :src="tempalateStr.replace('template',item1.type)"></el-image>
  17. </div>
  18. <div class="grid-title">{{item1.title}}</div>
  19. </div>
  20. </el-col>
  21. </draggable>
  22. </el-row>
  23. </el-collapse-item>
  24. </el-collapse>
  25. <el-scrollbar>
  26. </template>
  27. <script>
  28. Vue.component('diy-func-list', {
  29. name: "diy-func-list",
  30. template: '#diy-func-list',
  31. props: {
  32. list: {
  33. type: Array,
  34. default () {
  35. return []
  36. }
  37. },
  38. testData: {
  39. type: Function
  40. }
  41. },
  42. data() {
  43. return {
  44. activeNames: [0, 1, 2],
  45. search: "",
  46. tempalateStr: "resources/img/decorate/func/template.png"
  47. }
  48. },
  49. methods: {
  50. cloneComponent(e) {
  51. this.dragItem = e
  52. return
  53. },
  54. onEnd(e) {
  55. if (e.to === e.from) return
  56. let newIndex = e.newIndex; // 改变索引
  57. let dragItem = this.dragItem;
  58. this.$emit('end', dragItem, newIndex)
  59. },
  60. onClick(item) {
  61. this.$emit("add-prev-item", item)
  62. }
  63. }
  64. });
  65. </script>
  66. <style scoped>
  67. .el-collapse-item__header {
  68. padding: 0 30px;
  69. background-color: #f7f7f7;
  70. border: none;
  71. }
  72. .el-collapse-item__wrap {
  73. border: none;
  74. }
  75. .el-collapse-item {
  76. margin-bottom: 10px;
  77. }
  78. .el-collapse-item__content {
  79. padding-bottom: 0px;
  80. }
  81. .func-list-item {
  82. width: 75px;
  83. height: 92px;
  84. overflow: hidden;
  85. margin: 0px auto 0;
  86. border-radius: 2px;
  87. text-align: center;
  88. }
  89. .grid-img {
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. width: 50px;
  94. height: 50px;
  95. border-radius: 0px;
  96. margin: 6px auto;
  97. cursor: pointer;
  98. }
  99. .grid-img .el-image {
  100. line-height: 1;
  101. }
  102. .grid-title {
  103. font-size: 12px;
  104. font-family: PingFang SC;
  105. /*font-weight: 700;*/
  106. color: #333333;
  107. }
  108. .activeNames {
  109. font-size: 12px;
  110. font-family: PingFang SC;
  111. font-weight: bold;
  112. line-height: 0px;
  113. color: #666666;
  114. }
  115. .func-search .el-input__inner {
  116. border: none
  117. }
  118. </style>