<style>
  .appointTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    table-layout: fixed
  }

  .appointTable tr th {
    height: 50px;
    font-size: 14px;
    color: #111111;
    font-weight: bold;
    border: 1px solid #E6E6E6
  }

  .appointTable tr {
    background: #fff;
    text-align: center;
    height: 40px;
  }

  .appointTable tr td {
    font-size: 12px;
    height: 60px;
    color: #333333;
    border: 1px solid #E5E5E5;
  }

  .appointmentBoard .content .searchInput {
    border: 1px solid #DCDFE6;
    border-radius: 4px;
    display: inline-block;
  }

  .appointmentBoard .content .searchInput .el-input__inner {
    border: none;
    outline: none;
    height: 30px;
    line-height: 30px;
  }

  .appointmentBoard .content .searchInput {
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width: 250px;
  }

  .posi {
    position: relative;
  }

  .abso {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: #409EFF;
  }

  .abso2 {
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: #67C23A;

  }

</style>
<template>
  <div class="appointmentBoard">
    <div class="content">
      <div>
        <el-select class="w200" style="margin-right: 10px;" v-model="msg.StoreId" @change="getList" size="small" placeholder="请选择">
          <el-option :key="0" label="不限" :value="0"></el-option>
          <el-option v-for="item in StoreList" :key="item.Id" :label="item.Name" :value="item.Id">
          </el-option>
        </el-select>
        <div style="display:inline-block;">
          <el-date-picker v-model="msg.WorkDate" @change="getList" value-format="yyyy-MM-dd" size="small" type="date" placeholder="选择日期">
          </el-date-picker>
        </div>
      </div>
      <table class="appointTable" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th style="width:100px;">服务</th>
          <th v-for="(subItem,subIndex) in dataList.KanBanList" :key="subIndex">{{subItem.Name}}</th>
        </tr>
          <tr v-for="(item,index) in dataList.allTime" :key="index">
            <td>{{item}} {{index}}</td>
            <td class="posi" v-for="(childItem,childIndex) in dataList.KanBanList" :key="childIndex" :rowspan="getRow(item,childItem)">
              <!-- <div v-if="childItem."></div>
              <div class="abso"></div> -->{{childIndex}}
              <template v-for="(sItem,sIndex) in childItem.OrderList">
                <div v-if="sItem.ServiceTime==item" :key="sIndex" class="OrderDiv_Main">
                  <div class="appointUser">
                    <img :src="sItem.UserPhoto" class="UserPhote" alt=""/>
                    <span>{{sItem.Name}}</span>
                  </div>
                  <div>
                    {{sItem.GoodsName}}<span v-if="sItem.GoodServiceTime>0">{{getHours(sItem.GoodServiceTime)}}小时</span>
                  </div>
                </div>
              </template>
            </td>
          </tr>
      </table>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        dataList: [],
        msg: {
          StoreId: 0, //门店名
          WorkDate: '' //日期
        },
        StoreList: [], //门店下拉
      };
    },
    created() {

    },
    methods: {
      //获取数据
      getList() {
        this.apipost("/api/Reserve/GetStoreOrderInfo", this.msg, res => {
          if (res.data.resultCode == 1) {
            console.log(res,'数据来了');
            this.dataList=res.data.data;
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //获取门店下拉
      getStoreList() {
        this.apipost("/api/MContent/GetStoresList", {}, res => {
          if (res.data.resultCode == 1) {
            this.StoreList = res.data.data;
            // if(this.StoreList.length>0){
            //   this.msg.StoreId = this.StoreList[0].Id
            //   this.getList();
            // }else{
            //   this.getList();
            // }
          } else {
            this.Error(res.data.message);
          }
        })
      },
      //获取小时
      getHours(time){
        return time*2;
      },
      //获取跨行
      getRow(data1,data2){
        var count=0;
        data2.OrderList.forEach(x => {
          if(x.ServiceTime==data1){
            count++;
          } 
        });
        console.log(count,'count');
        if(count>0){
          return count;
        }
      },
      getItem(time,data){
        data.forEach(x=>{
          if(x.OrderList.length>0){
            if(time==x.OrderList[0].ServiceTime){
              return true
            }else{
              return false
            }
          }
        })
      },
    },
    mounted() {
      this.getStoreList();
      this.getList();
    }
  };
</script>
<style>
  .appointmentBoard .content {
    background: #fff;
    margin-top: 10px;
    padding: 20px;
    box-sizing: border-box;
  }
  .appointmentBoard .appointUser{
    text-align: left;
    line-height: 33px;
  }
  .appointmentBoard .UserPhote{
    width:30px;
    height:30px;
    border-radius: 50%;
  }
  .appointmentBoard .OrderDiv_Main{
    width:100px;
    text-align: left;
  }
</style>
