<template>
<div class="card-wrapper">
  <div class="card-title" :style="`color:${color}`">
    <div class="dot"/>
    {{title}}
    <p v-if="showTab">
      <span :class="{on: curTab === '处置中'}" @click="handleClick('处置中')">处置中</span>
      |
      <span :class="{on: curTab === '已完成'}" @click="handleClick('已完成')">已完成</span>
    </p>
    <div class="line">
      <img src="@/assets/images/card-title-line.png"/>
    </div>
    <p v-if="showTip" class="tip"><span>数值为</span>报修数量/占比/密度</p>
  </div>
  <div class="card-content">
    <slot />
  </div>
</div>
</template>

<script>
export default {
  name: 'Mode2',
  props: {
    title: {
      type: String,
      default: '标题',
    },
    showTip: {
      type: Boolean,
      default: false,
    },
    color: {
      type: String,
    },
    showTab: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      curTab: '处置中',
    }
  },
  methods: {
    handleClick(type) {
      this.curTab = type
      this.$store.commit('SET_CUR_TAB', type)
    },
  },
}
</script>

<style lang="stylus" scoped>
.card-wrapper
  .card-title
    display flex
    align-items center
    font-size .11rem
    font-weight bold
    position relative
    >p
      font-weight normal
      margin-left .05rem
      font-size .09rem
      >span
        color #999
        cursor pointer
        &:hover
        &.on
          color #fff
    .tip
      position absolute
      right 0
      font-weight normal
      font-size .08rem
      >span
        color #999
    .dot
      width .03rem
      height .1rem
      background $edgeColor
      margin-right .05rem
    .line
      margin-left .05rem
      flex 1
      >img
        width 100%
        min-height .05rem
  .card-content
    padding 0.03rem 0 0
    >div
      width 100%
      height 100%
</style>
