<style>
  .commonBusInfo {
    margin-top: 10px;
  }

  .commonBusInfo tr td {
    text-align: left;
    width: 50%;
    padding: 5px 0;
  }

  .commonBusInfo .tdRight {
    text-align: right;
    width: 20%;
  }

  .commonBusInfo .tdLeft {
    text-align: left;
    padding-left: 5px;
    width: 30%;
  }

</style>

<template>
  <div>
    <div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="singeRowTable">
        <tr>
          <td>
            {{$t('salesModule.CompanyNum')}}
          </td>
          <td style="text-align:left;" colspan="2">
            <span style="padding-left:5px;">{{TCNUM}} ({{TCID}})</span>
          </td>
          <td>
            {{$t('salesModule.DJNum')}}
          </td>
          <td style="text-align:left;" colspan="2">
            <span style="padding-left:5px;">{{DMCNum}}</span>
          </td>
        </tr>
        <tr>
          <td>
            车型
          </td>
          <td style="text-align:left;" colspan="2">
            <span style="padding-left:5px;">
              <template v-if="busData&&busData.length>0&&busData[0].CarName">
                {{busData[0].CarName}}
              </template>
            </span>
          </td>
          <td>
            司机
          </td>
          <td style="text-align:left;" colspan="2">
            <span style="padding-left:5px;">
              <template v-if="busData&&busData.length>0&&busData[0].DriverName">
                {{busData[0].DriverName}}
              </template>
            </span>
          </td>
        </tr>
        <tr>
          <th width="100">{{$t('pub.date')}}</th>
          <th width="80">用车类型</th>
          <th width="180" colspan="2">行程</th>
          <th width="95">操作人</th>
          <th width="125">状态</th>
        </tr>
        <template v-for="(busItem,bIndex) in  busData">
          <tr v-for="(dItem,dIndex) in busItem.OrderDetailList" :key="bIndex+dIndex">
            <td>
              {{dItem.DayStr}}({{getDayByDate(dItem.DayStr)}})
            </td>
            <td style="padding-left:3px;">
              {{dItem.UseTypeName}}
            </td>
            <td style="text-align:left;padding-left:3px;" colspan="2">
              {{dItem.BusContent}}
            </td>
            <td style="padding-left:3px;">
              {{dItem.UpdateName}}
            </td>
            <td>
              <template v-if="dItem.UseState==0">
                <a style="color:red">{{$t('salesModule.DJZK')}}</a>
              </template>
              <template v-else>
                <a style="color:green">{{$t('salesModule.DJOK')}}<br />{{dItem.SureDate}}</a>
              </template>
            </td>
          </tr>
        </template>
      </table>
    </div>
  </div>
</template>
<script>
  export default {
    props: ["busData", "TCID", "DMCNum", "TCNUM"],
    data() {
      return {
        loading: false,
      };
    },
    methods: {
      DownLoadShouPeiShu() {
        this.loading = true;
        let qMsg = {
          TCID: this.TCID
        };
        let fileName = "手配书【" + this.DMCNum + "】" + this.$commonUtils.getCurrentDate() + ".xls";
        this.GetLocalFile("hotel_SPS_DownLoad", qMsg, fileName,
          res => {
            this.loading = false;
          });
      },
      //子组件调用父组件方法
      subSetShouPeiShu(ShouPeiStatus) {
        var that = this;
        var str = "是否将手配书设置成" + (ShouPeiStatus == 0 ? "【确定】" : "【暂定】") + "?";
        this.Confirm(str, function () {
          that.$emit('SetShouPeiShu');
        });
      },
      goUrl(name, path, id, tcmun) {
        this.$router.push({
          name: path,
          query: {
            id: id,
            tcmun: tcmun,
            blank: "y",
            tab: name,
          },
        });
      },
      //根据日期返回星期几
      getDayByDate(dateString) {
        if (dateString) {
          var date;
          var dateArray = dateString.split("-");
          date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
          return "日一二三四五六".charAt(date.getDay());
        }
      }
    },
    mounted() {

    }
  };

</script>
