<template>
  <a-drawer
    title="角色详情"
    width="640"
    placement="right"
    :visible="visible"
    @close="onClose">
    <a-descriptions :column="{ sm: 2, xs: 1 }">
      <a-descriptions-item label="名称">{{ model.name }}</a-descriptions-item>
      <a-descriptions-item label="描述">{{ model.description }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ model.createdAt | moment }}</a-descriptions-item>
      <a-descriptions-item label="修改时间">{{ model.updatedAt | moment }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script>
import { roleGet } from '@/api/security/role'
import { statusMap } from '@/views/status/statusMap'

export default {
  data () {
    return {
      visible: false,
      model: {}
    }
  },
  filters: {
    statusFilter (status) {
      return statusMap[status + '']
    }
  },
  methods: {
    show (id) {
      this.visible = true
      roleGet({ id: id }).then(data => {
        this.model = data.data
      })
    },
    onClose () {
      this.model = {}
      this.visible = false
    }
  }
}
</script>
