index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="goods">
  3. <el-row :gutter="20">
  4. <el-col :span="4" :xs="24">
  5. <div class="cate">
  6. <el-input placeholder="输入分类名称搜索" v-model="filterText" style="margin-bottom: 20px"></el-input>
  7. <el-tree :data="cateList" node-key="id" default-expand-all :highlight-current="true" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree">
  8. <span class="custom-tree-node" slot-scope="{ data }">
  9. <span @click="cateClick(data)">{{ data.name }}</span>
  10. <span style="margin-left: 20px" v-if="false">
  11. <el-button type="text" size="mini" @click="() => addCate(data)">添加</el-button>
  12. <el-button type="text" size="mini" @click="() => updCate(data)">修改</el-button>
  13. <el-button type="text" size="mini" @click="() => delCate(data)">删除</el-button>
  14. </span>
  15. </span>
  16. </el-tree>
  17. </div>
  18. </el-col>
  19. <el-col :span="20" :xs="24"> </el-col>
  20. </el-row>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'Goods',
  26. data() {
  27. return {
  28. cateData: [
  29. { id: 1, name: '电子设备', pid: 0 },
  30. { id: 2, name: '食品', pid: 0 },
  31. { id: 3, name: '服装', pid: 0 },
  32. { id: 4, name: '鞋子', pid: 0 },
  33. { id: 5, name: '手机', pid: 1 },
  34. { id: 6, name: '电脑', pid: 1 },
  35. { id: 7, name: '照相机', pid: 1 },
  36. { id: 8, name: '水果', pid: 2 },
  37. { id: 9, name: '熟食', pid: 2 },
  38. { id: 10, name: '零食', pid: 2 },
  39. { id: 11, name: '饮料', pid: 2 },
  40. { id: 12, name: '外套', pid: 3 },
  41. { id: 13, name: '上衣', pid: 3 },
  42. { id: 14, name: '裤子', pid: 3 },
  43. { id: 15, name: '衬衫', pid: 3 },
  44. { id: 16, name: '毛衣', pid: 3 },
  45. { id: 17, name: '休闲鞋', pid: 4 },
  46. { id: 18, name: '篮球鞋', pid: 4 },
  47. { id: 19, name: '滑板鞋', pid: 4 },
  48. { id: 20, name: '高跟鞋', pid: 4 }
  49. ],
  50. filterText: ''
  51. }
  52. },
  53. computed: {
  54. cateList() {
  55. return this.handleTree(this.cateData, 'id', 'pid')
  56. }
  57. },
  58. methods: {
  59. filterNode() {}
  60. },
  61. components: {}
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .goods {
  66. .cate {
  67. padding: 10px;
  68. }
  69. }
  70. </style>