icons.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="cl-menu-icons">
  3. <el-popover
  4. ref="iconPopover"
  5. placement="bottom-start"
  6. trigger="click"
  7. popper-class="popper-menu-icon"
  8. >
  9. <el-row :gutter="10" class="list">
  10. <el-col :span="3" :xs="4" v-for="(item, index) in list" :key="index">
  11. <el-button
  12. size="mini"
  13. :class="{ 'is-active': item === value }"
  14. @click="onUpdate(item)"
  15. >
  16. <icon-svg :name="item"></icon-svg>
  17. </el-button>
  18. </el-col>
  19. </el-row>
  20. </el-popover>
  21. <el-input
  22. v-model="name"
  23. v-popover:iconPopover
  24. placeholder="请选择"
  25. @input="onUpdate"
  26. ></el-input>
  27. </div>
  28. </template>
  29. <script>
  30. import { iconList } from "cool/modules/base";
  31. export default {
  32. name: "cl-menu-icons",
  33. props: {
  34. value: String
  35. },
  36. data() {
  37. return {
  38. list: [],
  39. name: ""
  40. };
  41. },
  42. watch: {
  43. value: {
  44. immediate: true,
  45. handler(val) {
  46. this.name = val;
  47. }
  48. }
  49. },
  50. mounted() {
  51. this.list = iconList();
  52. },
  53. methods: {
  54. onUpdate(icon) {
  55. this.$emit("input", icon);
  56. }
  57. }
  58. };
  59. </script>
  60. .
  61. <style lang="scss">
  62. .popper-menu-icon {
  63. width: 480px;
  64. max-width: 90%;
  65. box-sizing: border-box;
  66. .list {
  67. height: 250px;
  68. overflow-y: auto;
  69. display: flex;
  70. flex-wrap: wrap;
  71. }
  72. .el-button {
  73. margin-bottom: 10px;
  74. height: 40px;
  75. width: 100%;
  76. padding: 0;
  77. .icon-svg {
  78. font-size: 18px;
  79. color: #444;
  80. }
  81. }
  82. }
  83. </style>