<script>
export default {
  name: 'MenuItem',
  functional: true,
  props: {
    auth: {
      type: Object,
      require: true,
      default: () => { }
    },
    row: {
      type: Object,
      default: () => { }
    }
  },
  render (h, context) {
    const { auth, row } = context.props
    const vnodes = []
    if (auth && Object.keys(auth).length) {
      if (auth.show_type == 1) {
        vnodes.push(<el-button size="small" plain={true} onClick={() => auth.service_type == '1' ? context.parent.handleQuery() : auth.service_type == '2' ? context.parent.handleAdd() : auth.service_type == '3' ? context.parent.handleEdit(row) : context.parent.handleRemove(row)} type={auth.service_type != '4' ? 'primary' : 'danger'}>{auth.auth_name}</el-button>)
      } else if (auth.show_type == 3) {
        vnodes.push(<el-button size="small" icon={auth.show_icon} plain={true} onClick={() => auth.service_type == '1' ? context.parent.handleQuery() : auth.service_type == '2' ? context.parent.handleAdd() : auth.service_type == '3' ? context.parent.handleEdit(row) : context.parent.handleRemove(row)} type={auth.service_type != '4' ? 'primary' : 'danger'}>{auth.auth_name}</el-button>)
      }
      else {
        vnodes.push(<el-button size="small" icon={auth.show_icon} plain={true} onClick={() => auth.service_type == '1' ? context.parent.handleQuery() : auth.service_type == '2' ? context.parent.handleAdd() : auth.service_type == '3' ? context.parent.handleEdit(row) : context.parent.handleRemove(row)} type={auth.service_type != '4' ? 'primary' : 'danger'}></el-button>)
      }
    } else {
      vnodes.push(<span></span>)
    }
    return vnodes
  }
}
</script>

<style scoped>
.sub-el-icon {
  color: currentColor;
  width: 1em;
  height: 1em;
}
</style>
