<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">
      <template v-for="(i,k) in data.list">
        <div class="item">
          <div class="icon">
            <UploadEl :data="i"/>
          </div>
          <div class="itemTitle" contenteditable="true" @blur="edit1('title', k,$event)">{{ i.title }}</div>
          <div class="itemInfo" contenteditable="true" @blur="edit1('value', k,$event)">{{ i.value }}</div>
        </div>
        <br v-if="(k+1)%4===0"/>
      </template>
      <div class="item">
        <div style="width:100%;height:100%;" @click="data.list.push({title:'输入。。。',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: 'EditEl1',
  components: {UploadEl},
  props: ['data'],
  data() {
    return {}
  },
  mounted() {
  },
  methods: {
    edit(key, e) {
      console.log(this.$props)
      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 {
  margin-top: 3.9vw;
  padding-bottom: 5.3vw;
  text-align: center;

  .item {
    display: inline-block;
    width: 14.5vw;
    height: 16.7vw;
    border-radius: 5px;
    box-shadow: 0 0 3px #0002;
    transition: all 0.2s;
    vertical-align: top;
    margin: 0 0.75vw 1vw;

    &:hover {
      background-color: @standard-color;

      .itemTitle {
        color: #fff;
      }

      .itemInfo {
        color: #fff;
      }
    }

    .icon {
      width: 4vw;
      height: 4vw;
      margin-top: 2vw;
      display: inline-block;
    }

    .itemTitle {
      transition: all 0.2s;
      font-size: 1vw;
      color: #000;
      margin-top: 1vw;
      letter-spacing: 1px;
    }

    .itemInfo {
      transition: all 0.2s;
      display: inline-block;
      width: 82%;
      font-size: 0.8vw;
      color: #666;
      margin-top: 0.9vw;
      letter-spacing: 2px;
      line-height: 1.45vw;
      text-align: left;
    }
  }
}


</style>
