<template>
  <van-popup 
    v-model="show"
    position="bottom" 
    :close-on-click-overlay="false"
    :style="{height: '100%'}"
    class="base-info select-template" >
   <div class="preview">
      <template-detail
        :detailInformation="proof" 
        class="detail"
        style="padding:0 17px;margin-bottom:70px;" ></template-detail>
      <div class="btn-group">
        <div role="button" class="cancel" @click="cancel">取消</div>
        <div role="button" class="confirm" @click="employ">使用</div>
      </div>
   </div>
  </van-popup>
</template>
<script lang="ts">
import { Component, Prop, Vue, Emit, Watch } from 'vue-property-decorator';
import { Collapse, CollapseItem, Field, Button, NavBar, SwipeCell, Popup } from 'vant';
import { TEMPLATETYPE } from '@/const/enum';
@Component({
  components: {
    [Collapse.name]: Collapse,
    [CollapseItem.name]: CollapseItem,
    [Field.name]: Field,
    [Button.name]: Button,
    [NavBar.name]: NavBar,
    [SwipeCell.name]: SwipeCell,
    [Popup.name]: Popup,
  },
})
export default class PreviewTemplate extends Vue {
  private show: boolean = true;
  @Prop( {
    required: true,
  })private data!: any;

  private proof: any = [];

  @Watch('data', { immediate: true, deep: true})
  private onDataChange(data: any, oldData: any) {
    this.proof = JSON.parse(JSON.stringify(data));
  }

  @Emit('cancel')
  private cancel() {
    this.show = false;
    return;
  }
  @Emit('employ')
  private employ() {
    return;
  }
}
</script>
<style scoped lang="scss">
    .preview{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      padding: 10px 0;
      min-height: 100vh;
      z-index: 20001;
      background: #ffffff;
      ::v-deep .van-field{
        flex-direction: column;
        input{
          font-size: 16px;
        }
        &__label{
          text-align: left;
          font-size: 14px;
          color: $labelColor;
        
        }
        &__value{
          margin-top: 8px;
          color: $valueColor;
        }
      }
      ::v-deep .van-cell{
        padding: 12px 0;
      }
      .detail{
        margin-bottom: 100px;
      }
      .btn-group{
        .cancel{
          color: #353535;
          background: #F0F1F5;
          border-radius:4px;
          width: 107px;
          padding: 9px;
          margin-right: 10px;
        }
        .confirm{
          flex: auto;
          color: #FFFFFF;
          background:linear-gradient(180deg,rgba(93,123,246,1) 0%,rgba(108,122,254,1) 100%);
          box-shadow:0px 2px 10px 0px rgba(63,121,254,0.3);
          border-radius:4px;
          width: 228px;
          padding: 9px;
        }
      }
    }
</style>