<template>
  <div>
    <div class="title">
      <span contenteditable="true" @blur="edit('title', $event)">
        {{ data.title }}
      </span>
    </div>
    <div class="subTitle">
      <span contenteditable="true" @blur="edit('subTitle', $event)">
        {{ data.subTitle }}
      </span>
    </div>
    <div class="list">
      <div class="item" v-for="(i,k) in data.list">
        <i class="del el-icon-circle-close" @click="data.list.splice(k, 1);"></i>
        <div class="icon">
          <UploadEl :data="i"/>
        </div>
        <div class="itemTitle" contenteditable="true" @blur="edit1('itemTitle', k,$event)">{{ i.itemTitle }}</div>
        <div class="itemInfo" contenteditable="true" @blur="edit1('itemInfo', k,$event)">{{ i.itemInfo }}</div>
      </div>
      <div class="item" style="vertical-align: top">
        <div style="width:100%;height:100%;" @click="data.list.push({itemTitle:'请输入',itemInfo:'请输入'})">
          <i class="el-icon-circle-plus" style="font-size: 3vw; line-height: 10vw"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

import UploadEl from "@/components/editEl/uploadEl.vue";

export default {
  name: 'EditEl3',
  components: {UploadEl},
  props: ['data'],
  data() {
    return {}
  },
  mounted() {
  },
  methods: {
    edit(key, e) {
      this.$props.data[key] = e.target.innerText
    },
    edit1(key, index, e) {
      this.$props.data.list[index][key] = e.target.innerText
    },
  }
}
</script>

<style lang="less" scoped>
@import "~@/style.less";

.title {
  padding-top: 4.2vw;
  width: 100%;
  text-align: center;
  font-size: 2.5vw;
  letter-spacing: 4px;
  color: #0003;
}

.subTitle {
  padding-top: 0.4vw;
  width: 100%;
  text-align: center;
  font-size: 1.9vw;
  letter-spacing: 2px;
  color: #000;
}

.list {
  width: 65vw;
  display: inline-block;
  margin-top: 3.5vw;
  margin-bottom: 3.9vw;

  .item {
    display: inline-block;
    position: relative;
    width: 47%;
    height: 10vw;
    box-shadow: 0 0 3px #0002;
    margin: 0 1.5% 1.1vw 1.5%;

    .del {
      position: absolute;
      right: 10px;
      top: 10px;
      cursor: pointer;
    }
    .icon {
      width: 4vw;
      height: 4vw;
      position: absolute;
      top: 54%;
      left: 18.2%;
      transform: translate(-50%, -50%);
    }

    .itemTitle {
      top: 37%;
      left: 33.9%;
      position: absolute;
      transform: translatey(-50%);
      font-size: 1.2vw;
      letter-spacing: 3px;
    }

    .itemInfo {
      top: 62.2%;
      left: 33.9%;
      position: absolute;
      transform: translatey(-50%);
      font-size: 0.9vw;
      color: #666;
      letter-spacing: 2px;
      text-align: left;
      white-space: nowrap;
      width: 63%;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

</style>
