<template>
  <div class="opBtn">
    <VaButton :round="false" color="info" gradient @click="showModal = true"> 新增角色</VaButton>
    <VaModal :modelValue="showModal" :noDismiss="true" blur @cancel='showModal=false' @ok="submit" ok-text="提交" cancelText="取消">
      <h3 class="va-h3">角色信息</h3>
      <roleForm ref="roleForm"></roleForm>
    </VaModal>
  </div>
</template>

<script>
  import roleForm from './roleForm.vue'
  export default {
    name: 'addRoleBtn',
    components: {
      roleForm,
    },
    methods: {
      submit() {
        let params = { ...this.$refs.roleForm.form }
        this.$api.addRole(params).then((res) => {
          this.$toast.success({ message: res.message })
          this.showModal = false
          this.$emit('after-op')
        })
      },
    },
    data() {
      return {
        showModal: false,
      }
    },
  }
</script>

<style scoped>
  .opBtn {
    display: inline-block;
    vertical-align: 11%;
  }
</style>
