1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <div class="cl-menu-icons">
- <el-popover
- ref="iconPopover"
- placement="bottom-start"
- trigger="click"
- popper-class="popper-menu-icon"
- >
- <el-row :gutter="10" class="list">
- <el-col :span="3" :xs="4" v-for="(item, index) in list" :key="index">
- <el-button
- size="mini"
- :class="{ 'is-active': item === value }"
- @click="onUpdate(item)"
- >
- <icon-svg :name="item"></icon-svg>
- </el-button>
- </el-col>
- </el-row>
- </el-popover>
- <el-input
- v-model="name"
- v-popover:iconPopover
- placeholder="请选择"
- @input="onUpdate"
- ></el-input>
- </div>
- </template>
- <script>
- import { iconList } from "cool/modules/base";
- export default {
- name: "cl-menu-icons",
- props: {
- value: String
- },
- data() {
- return {
- list: [],
- name: ""
- };
- },
- watch: {
- value: {
- immediate: true,
- handler(val) {
- this.name = val;
- }
- }
- },
- mounted() {
- this.list = iconList();
- },
- methods: {
- onUpdate(icon) {
- this.$emit("input", icon);
- }
- }
- };
- </script>
- .
- <style lang="scss">
- .popper-menu-icon {
- width: 480px;
- max-width: 90%;
- box-sizing: border-box;
- .list {
- height: 250px;
- overflow-y: auto;
- display: flex;
- flex-wrap: wrap;
- }
- .el-button {
- margin-bottom: 10px;
- height: 40px;
- width: 100%;
- padding: 0;
- .icon-svg {
- font-size: 18px;
- color: #444;
- }
- }
- }
- </style>
|