<template>
  <div class="ws-crud-titlebar">
    <div class="ws-crud-titlebar__label textPrimary--text">{{label}}</div>
    <v-spacer></v-spacer>
    <slot name="btns"></slot>
    <WsBtn
      class="ml-2"
      v-if="pageMode"
      :to="`/${modelName}/create`"
    >
      <v-icon>mdi-plus</v-icon>
      <div>新增{{label}}</div>
    </WsBtn>
    <WsBtn
      class="ml-2"
      v-else
      @click="$_onCreate()"
    >
      <v-icon>mdi-plus</v-icon>
      <div>新增{{label}}</div>
    </WsBtn>
  </div>
</template>

<script>
export default {
  props: {
    label: {
      type: String,
      default: null
    },
    pageMode: {
      type: Boolean,
      default: false
    },
    modelName: {
      type: String,
      required: true
    }
  },
  methods: {
    $_onCreate() {
      this.$emit("create-open");
    }
  }
};
</script>

<style>
</style>