<template>
  <div>
    <div class="medias">
      <div class="btn-push">
        <span v-if="!tAudio.fileName">请选择音频素材</span>
        <div class="audio-con" v-else>
          <span>{{ tAudio.fileName }}</span>
          <div class="del">
            <span @click="del" class="ui-button submit">删除</span>
          </div>
        </div>
      </div>
    </div>
    <button class="ui-button submit" @click="selectHandle">选择音频</button>
  
  </div>
</template>

<script>

export default {
  props: ["audio"],
  data() {
    return {
      type: "audio",
      tAudio: { ...this.audio[0] },
      isShowSelect: false,
      list: [],
    };
  },
  methods: {
    del() {
      this.tAudio = {
        fileName:''
      };
      this.$emit("audioChange", []);
    },
    selectHandle() {
      this.$emit('uploadClick',{
        type:'audio'
      })
    },
  },
  watch: {
     audio:{
      deep:true,
      handler:function (newVal) {
        this.tAudio = newVal.length>0 ? newVal[0] : {}
      }
    },
  },
};
</script>

<style lang="less" src="./style.less"></style>

<style lang="less" scoped>
.ui-button {
  width: 100%;
  margin-top: 10px;
}
.medias {
  min-height: 70px;
  overflow-y: auto;
  .audio-con {
    width: 100%;
    height: 100%;
    position: relative;
    > span {
      position: absolute;
      transform: translate(-50%, -50%);
      top: 50%;
      left: 50%;
      width: 90%;
      color: @color;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .del {
      display: none;
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      z-index: 9;
      background: rgba(0, 0, 0, 0.5);
      > .ui-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
        padding: 0 10px;
        margin: 0;
        line-height: 24px;
        height: 24px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }
    }
    &:nth-of-type(3n) {
      margin-right: 0;
    }
    &:hover {
      .del {
        display: block;
      }
    }
  }
}
</style>
