<style>
  .ComTripList .leftDayList {
    display: inline-block;
    width: 30px;
    height: 100%;
    vertical-align: top;
  }

  .ComTripList .dayNum {
    font-weight: bold;
    font-size: 16px;
    margin-left: -42px;
    position: relative;
    z-index: 2;
    margin-bottom: 5px;
    display: block;
  }

  .ComTripList .siteList {
    display: inline-block;
    position: relative;
    border-left: 2px solid #ebebec;
    position: relative;
    padding: 0 0 50px 50px;
    margin-left: 10px;
  }

  .ComTripList .Trip_Content {
    margin-left: 100px;
  }

  .ComTripList .Trip_Content:first-child {
    margin-top: 20px;
  }

  .ComTripList .Trip_Content:last-child {
    margin-bottom: 20px;
  }

  .ComTripList .TC_circles {
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 100%;
    border: 2px solid rgba(13, 36, 129, .8);
    position: absolute;
    left: -11px;
    top: 0;
  }

  .ComTripList .TripControl {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    top: -170px;
    margin-left: 30px;
  }

  .ComTripList .TripControl i {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    cursor: pointer;
    border-radius: 50%;
    text-align: center;
  }

  .ComTripList .TripControl i:hover {
    background-color: rgba(13, 36, 129, .8);
    color: #fff;
  }

  .ComTripList .addTrip {
    width: 30px;
    height: 30px;
    color: #fff;
    text-align: center;
    font-size: 25px;
    line-height: 28px;
    background-color: #f60;
    border-radius: 100%;
    cursor: pointer;
    margin: -2px 0 20px 130px;
  }

</style>

<template>
  <div class="ComTripList">
    <div v-if="TripType==0">
      <quill-editor v-model="TripListArr[0].TravelContent" style="height:400px;"></quill-editor>
    </div>
    <div v-else class="Trip_Content" v-for="(item,index) in TripListArr" :key="index">
      <div class="leftDayList">
        <span class="dayNum">第{{index+1}}天</span>
      </div>
      <div class="siteList">
        <el-form-item label="前往地" label-width='100px' style="display:inline-block;">
          <el-input type="text" class="w150" v-model="item.Go"></el-input>
        </el-form-item>
        <el-form-item label="前往省份/国家地区" label-width='160px' style="display:inline-block;">
          <el-input type="text" class="w150" v-model="item.GoProvice"></el-input>
        </el-form-item>
        <el-form-item label="是否过境" label-width='100px' style="display:inline-block;">
          <el-checkbox v-model="item.IsOut" :true-label="CheckedVaule" :false-label="UnCheckedVaule"></el-checkbox>
        </el-form-item>
        <quill-editor v-model="item.TravelContent" style="height:300px;"></quill-editor>
        <div class="TC_circles"></div>
      </div>
      <div class="TripControl">
        <i class="iconfont icon-img_delete_small" style="margin-left:10px;" @click="delTrip(index)"></i>
      </div>
      <div class="addTrip" @click="addTrip()">+</div>
    </div>
  </div>
</template>
<script>
  export default {
    props: ["ContractTripList", "TripType"],
    data() {
      return {
        checked: false,
        TripListArr: [],
        //选中过境
        CheckedVaule: 1,
        //不过境
        UnCheckedVaule: 0,
      };
    },
    mounted() {

    },
    created() {
      if (this.ContractTripList) {
        if (this.ContractTripList.length > 0) {
          this.TripListArr = JSON.parse(JSON.stringify(this.ContractTripList));
        } else {
          var tripObj = {
            DayNum: 1, //天数
            Go: '', // 前往地
            GoProvice: '', //前往国家地区
            IsOut: 0, // 是否过境(0-不过，1-过)
            TravelContent: '', //行程内容
          }
          this.TripListArr.push(tripObj);
        }
      }
    },
    methods: {
      //添加行程
      addTrip() {
        let obj = {
          DayNum: '', //天数
          Go: '', // 前往地
          GoProvice: '', //前往国家地区
          IsOut: 0, // 是否过境(0-不过，1-过)
          TravelContent: '', //行程内容
        }
        this.TripListArr.push(obj);
        this.getSavedData();
      },
      //删除行程
      delTrip(index) {
        this.TripListArr.splice(index, 1);
        this.getSavedData();
      },
      //遍历已经保存数据
      getSavedData() {
        this.TripListArr.forEach((x, index) => {
          x.DayNum = index + 1;
        })
      }
    },
    watch: {
      //监听参数
      TripListArr: {
        handler: function (val, oldVal) {
          this.$emit('tripData', this.TripListArr);
        },
        deep: true
      },
    }
  };

</script>
