<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 in data.list">
        <i class="del el-icon-circle-close" @click="data.list.splice(k, 1);"></i>
        <div class="image">
          <UploadEl :data="i"/>
        </div>
        <div class="info">
          <span contenteditable="true" @blur="edit1('value', k,$event)">
          {{ i.value }}
          </span>
        </div>
      </div>
      <div class="item">
        <div style="width:100%;height:100%;" @click="data.list.push({value:'请输入'})">
          <i class="el-icon-circle-plus" style="font-size: 3vw; line-height: 16.7vw"></i>
        </div>
      </div>
    </div>
  </div>
</template>

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

export default {
  name: 'EditEl9',
  props: ['data'],
  components: {
    UploadEl,
  },
  data() {
    return {}
  },
  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: 65%;
  margin: 3vw auto 0;

  .item {
    margin-right: 2.6%;
    width: 23%;
    height: 16vw;
    display: inline-block;
    box-shadow: 0 0 3px #0002;
    margin-bottom: 1.4vw;
    vertical-align: top;
    position: relative;

    .del {
      position: absolute;
      right: 0;
      top: 0;
      cursor: pointer;
    }

    .image {
      width: 100%;
      height: 50%;
    }

    .info {
      width: calc(100% - 2.2vw);
      height: calc(50% - 2.1vw);
      padding: 1.1vw;
      font-size: 0.85vw;
      line-height: 1.2vw;
      letter-spacing: 0.6px;
      color: #0006;

      span {
        display: inline-block;
        width: calc(100%);
        height: calc(100%);
        overflow: hidden;
      }
    }

    &:nth-child(4n) {
      margin-right: 0%;
    }
  }
}
</style>
