<template>
  <n-drawer v-bind="getDrawerOptions" @update:show="handleDrawerColse">
    <n-drawer-content closable title="图片位置">
      <PositionMsg :data="getPostionOptions" :show-legend="false" />
    </n-drawer-content>
  </n-drawer>
</template>

<script>
import PositionMsg from '@/components/PositionMsg/index.vue'
import { defineComponent, computed, reactive, toRefs } from 'vue'

export default defineComponent({
  name: 'LiveDrawer',
  components: { PositionMsg },
  props: {
    /* 可见 */
    visible: {
      type: Boolean,
      default: false
    },
    /* 选中的数据 */
    data: {
      type: Object,
      default: () => {}
    }
  },
  emits: {
    'update:visible': null
  },
  setup(props, { emit }) {
    const data = reactive({
    })

    /* 获取抽屉的信息 */
    const getDrawerOptions = computed(() => {
      return {
        show: props.visible,
        width: '100%',
        placement: 'right'
      }
    })

    const getPostionOptions = computed(() => {
      return [props.data]
    })

    function handleDrawerColse() {
      emit('update:visible', false)
    }

    return {
      ...toRefs(data),
      getDrawerOptions,
      getPostionOptions,
      handleDrawerColse
    }
  }
})
</script>

<style scoped lang='scss'>
.n-button+.n-button{
  margin-left: 30px;
}
</style>
