<template>
  <div class="template-item">
    <van-image
      class="thumb"
      width="50px"
      height="50px"
      :src="thumb || require('@/assets/defaulttemplate.png')"
      round
      >
    </van-image>
    <div class="title van-ellipsis">
        {{title}}
    </div>      
    <div 
        class="desc van-multi-ellipsis--l2">
        {{desc}}
    </div>
    <common-svg v-if="showActionIcon && !isSystemTemplate" @click.stop.native="showMoreAction" class="more" name="cunzhengliebiao-gengduo"></common-svg>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue, Emit } from 'vue-property-decorator';
@Component({
  name: 'TemplateItem',
})
export default class TemplateItem extends Vue {
  @Prop() private thumb!: string;
  @Prop() private title!: string;
  @Prop() private desc!: string;
  @Prop() private id!: number;
  @Prop({type: Boolean, default: ()=> true }) private showActionIcon!:boolean;
  @Prop({type: Boolean, default: ()=>false }) private isSystemTemplate !:boolean
  @Emit('show-more-action')
  private async showMoreAction() {
    const id = this.id;
    const name = this.title;
    return {
      id,
      name,
    };
  }
}
</script>
<style scoped lang="scss">
  .template-item{
    display: grid;
    grid-template-columns: 50px auto 27px;
    grid-template-rows: repeat(2, minmax(25px,1fr));
    grid-auto-flow: column dense;
    place-items: center;
    grid-column-gap: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    padding: 15px;
    background: #FFFFFF;
    box-shadow: 0px 2px 10px 0px rgba(0,0,0,0.06);
    border-radius: 15px;
    color:#353535;
    text-align: left;
    font-size: 15px;
    .thumb{
      grid-row-start: span 2;
      width: 50px;
    }
    .title,.desc{
      place-self: center start;
    }
    .title{
      font-weight: 500;
    }
    .desc{
      font-size: 14px;
      color:#989898;
    }
    .add{
      grid-row-start: span 2;
      width:27px;
    }
    .more{
      place-self: center;
      grid-row: 1/ span 2;
    }
  }
</style>
