<template>
  <div>
    <div class="content">
      <div class="left">
        <UploadEl :data="data"/>
      </div>
      <div class="right">
        <div class="list">
          <div class="item" v-for="(i,k) in data.list.slice(0,4)">
            <i class="del el-icon-circle-close" @click="data.list.splice(k, 1);"></i>
            <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>
          <div class="item" v-if="data.list.length <4">
            <div style="width:100%;height:100%;text-align: center"
                 @click="data.list.push({title:'请输入',value:'请输入'})">
              <i class="el-icon-circle-plus" style="font-size: 3vw; line-height: 14.8vw"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

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

export default {
  name: 'EditEl4',
  components: {UploadEl},
  props: ['data'],
  data() {
    return {}
  },
  mounted() {
  },
  methods: {

    edit1(key, index, e) {
      this.$props.data.list[index][key] = e.target.innerText
    },
  }
}
</script>

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

.content {
  display: inline-block;
  padding-top: 5.1vw;
  width: 65vw;
  height: 31vw;
  text-align: left;
  vertical-align: top;
  margin: 0 auto 5.3vw;

  .left {
    width: 26%;
    height: 100%;
    margin: 0% 2%;
    display: inline-block;
    vertical-align: top;
    background-color: #0378f9;
    background-repeat: no-repeat;
    background-size: contain;

    .leftTitle {
      color: #fff;
      font-size: 1.9vw;
      letter-spacing: 2px;
      margin-top: 21.7%;
      margin-left: 11.8%;
    }

    .leftSubTitle {
      color: #fff;
      width: 75%;
      line-height: 1.8vw;
      font-size: 1.1vw;
      letter-spacing: 2px;
      margin-top: 5.1%;
      margin-left: 11.8%;
      word-break: break-all;
    }
  }

  .right {
    width: 68.5%;
    height: 100%;
    display: inline-block;

    .list {
      width: 100%;
      height: 100%;

      .item {
        display: inline-block;
        width: 48%;
        height: 48%;
        box-shadow: 0 0 3px #0002;
        background-color: #f2f3f5;
        vertical-align: top;
        position: relative;

        .del {
          position: absolute;
          right: 10px;
          top: 10px;
          cursor: pointer;
        }
        &:nth-child(1) {
          margin: 0 4% 3% 0;
        }

        &:nth-child(2) {
          margin: 0 0 3% 0;
        }

        &:nth-child(3) {
          margin: 0 4% 0 0;
        }

        .itemTitle {
          margin-top: 8.2%;
          margin-left: 7.6%;
          font-size: 1.2vw;
          line-height: 1.4vw;
          color: #000;
          letter-spacing: 2.7px;
          border-left: 4px solid #3372ff;
          padding-left: 0.7vw;
        }

        .itemInfo {
          margin-top: 6%;
          width: 88%;
          margin-left: 7.3%;
          font-size: 1.1vw;
          line-height: 1.8vw;
          color: #333;
          letter-spacing: 4px;
        }
      }
    }
  }
}
</style>
