<template>
<div class="card-wrapper">
  <div class="line" :style="lineStyle"/>
  <div class="card-title" :style="style" @click="handleTitleClick">
    <div class="edge top-left" />
    <div class="triangle" />
    <div class="dot">
      <span></span>
      <span></span>
    </div>
    {{title}}
    <img class="title-bottom" src="@/assets/images/title-bottom.png"/>
  </div>
  <div class="card-content">
    <span @click="handleClick" class="btn span" v-if="btn && btn == '模型'" >{{btn}}</span>
    <img @click="handleClick" class="btn" v-else-if="btn && btn != '模型'" :src="require(`@/assets/images/${btn}.png`)"/>
    <div class="edge top-right" />
    <div class="edge bottom-left" />
    <div class="edge bottom-right" />
    <div class="content">
      <slot />
    </div>
  </div>
</div>
</template>

<script>
export default {
  name: 'Mode4',
  props: {
    btn: {
      type: String,
    },
    title: {
      type: String,
      default: '标题',
    },
    width: {
      type: Number,
    },
  },
  computed: {
    style() {
      if (this.width) {
        return {
          width: this.width + '%'
        }
      }
    },
    lineStyle() {
      if (this.width) {
        const width = 100 - this.width
        return {
          width: `calc(${width}% - 2rem)`
        }
      }
    }
  },
  methods: {
    handleClick() {
      if (this.btn == 'map-icon') {
        this.$store.commit('SET_STREETMENU', true)
      } else if (this.btn == '模型') {
        this.$store.commit('SET_ELEMENTMODAL', true)
      }
    },
    handleTitleClick() {
      if (this.title === '联勤联动动态流程') {
        this.$store.commit('SET_PROCESSMODAL', true)
      }
      if (this.title === '智能发现') {
        this.$store.commit('SET_DISCOVERMODAL', true)
      }
    }
  },
}
</script>

<style lang="stylus" scoped>
$color = rgba(113,235,255,.5)
// $color = #308bd8
// $color = transparent
.card-wrapper
  padding 0 !important
  position relative
  .line
    position absolute
    top 0
    right 0
    height 2rem
    width calc(69% - 1.8rem)
    border-bottom .1rem solid $color
  .card-title
    display flex
    align-items center
    position relative
    color #fff
    font-size 1.2rem
    height 2rem
    width 31%
    z-index 999
    padding .3rem 0 0 .8rem
    background $cardBg
    border .1rem solid $color
    border-bottom none
    border-right none
    box-sizing border-box
    .title-bottom
      display block
      position absolute
      bottom -0.5rem
      width 100%
    .triangle
      position absolute
      width 0
      height 0
      border 1.4rem solid transparent
      border-top-color $cardBg
      // box-shadow 0 -0.1rem 0 0 $color
      left 100%
      top 0
      transform-origin top left
      transform rotate(45deg)
      &:before
        content ''
        display block
        width 2.8rem
        height 0.1rem
        background $color
        position relative
        left -1.5rem
        top -1.5rem
    .dot
      display flex
      align-items center
      margin-right .5rem
      span
        display block
        width .4rem
        height 1.2rem
        margin-right .2rem
        background $color-blue
        &:first-child
          height 1rem
          opacity .5
  .card-content
    $blur()
    position relative
    background $cardBg
    border .1rem solid $color
    border-top none
    overflow hidden !important
    .btn
      z-index 100
      position absolute
      top .3rem
      right @top
      width 1.3rem
      height @width
      cursor pointer
      &.span
        z-index 999
        display block
        width auto
        top .2rem
        right .4rem
        text-align right
        color $color-blue
      &:hover
        box-shadow 0 0 1rem 0.1rem rgba(255,255,255,.5)
    .content
      width 100%
      height 100%
      padding 0.5rem 0.7rem
      overflow-y auto
.edge
  position absolute
  width 1rem
  height @width
  border 0.1rem solid $color-blue
  z-index 100
  &.top-left
    border-width .1rem
    top -0.1rem
    left -0.1rem
    border-right none
    border-bottom none
  &.top-right
    top -0.1rem
    right -0.1rem
    border-left none
    border-bottom none
  &.bottom-left
    bottom -0.1rem
    left -0.1rem
    border-right none
    border-top none
  &.bottom-right
    bottom -0.1rem
    right -0.1rem
    border-left none
    border-top none
</style>
