/**
*  @Author      LiuShaolong
*  @Description 下拉菜单
*  @CreateDate  2020/2/14
*/
<template>
  <el-dropdown v-bind="$attrs" size="medium" trigger="click" placement="bottom-start" @command="handleCommand">
    <el-button :type="type ? type : 'primary'" size="mini" :icon="icon">
      {{ name }}<i class="el-icon-arrow-down el-icon--right"></i>
    </el-button>
    <el-dropdown-menu slot="dropdown">
      <template v-for="item in items">
        <el-dropdown-item :icon="item.icon" :command="item.click" v-permission="item.permission"
                          :disabled="checkDisabled(item.disabled, selection, params)">
          {{ item.name }}
        </el-dropdown-item>
      </template>
    </el-dropdown-menu>
  </el-dropdown>
</template>
<script>

  export default {
    name: 'ZyDropdown',
    components: {},
    props: ['name', 'type', 'icon', 'items', 'selection', 'params'],
    data() {
      return {}
    },
    created() {
    },
    mounted() {
    },
    watch: {},
    computed: {},
    methods: {
      checkDisabled(disabled, selection, params) {
        if (disabled instanceof Function) {
          return disabled(selection, params);
        } else {
          return disabled;
        }
      },
      handleCommand(command) {
        if (command instanceof Function) {
          command(this.selection, this.params);
        }
      }
    },
  }
</script>
<style scoped>

</style>
