<style>
  .PT_teamTable {
  width: 100%;
  background-color: #fff;
  border-collapse: collapse;
}
.PT_teamTable td,
.PT_teamTable th {
  border: 1px solid #dcdcdc;
  padding: 6px;
  height: 30px;
}
.PT_teamTable tr th {
  height: 30px;
  background-color: #297bef;
  border: 1px solid #dcdcdc;
  color: #fff;
}
.Tp_table .el-table td {
  padding: 0 !important;
}
.Tp_table .el-table th {
  padding: 12px 0 !important;
}
.Tp_table .has-gutter th {
  background-color: #dcdcdc;
}
.Tp_table .el-table .cell {
  line-height: 3 !important;
}
.passgenrDialog{
    width:1000px;
}
.PgflightDiv{
  font-size: 12px;
  color: #666666;
  background-color: #e0f4ff;
  width: 230px;
  height: 175px;
  border-radius: 4px;
  float:left;
  margin-right:10px;
}
.PgflightDiv p:first-child{
  padding-left:8px;
  color: #387ea5;
  background-color: #cbe9fa;
  height: 34px;
  line-height: 34px;
}
.PgflightDiv ._add_info{
    margin-top: 12px;
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pg_table{
  width:100%;
}
.pg_table tr{
  display: block;
  margin:10px 0;
}
.pg_table tr:last-child{
  border-top:1px dashed #d1d1d1;
  padding-top:10px;
}
.PassengerList .el-input__inner{
  height:23px!important;
  padding:0 5px;
}
.Pgzhu{
  display: inline-block;
  width:30px;
  height:30px;
  background-color: #E95252;
  border-radius: 50%;
  text-align: center;
  line-height: 30px;
  color:#fff;
  position: absolute;
  top:-35px;
  left:-20px;
}
.Pglian{
  background-color: #47bf8c;
  display: inline-block;
  width:30px;
  height:30px;
  border-radius: 50%;
  text-align: center;
  line-height: 30px;
  color:#fff;
}
</style>

<template>
  <div class="flexOne PassengerList">
    <div class="query-box">
      <ul>
        <li>
          <table class="PT_teamTable">
            <tr>
              <th width="140">团号</th>
              <th>团名</th>
              <th width="50">人数</th>
              <th width="120">出发日期</th>
            </tr>
            <tr v-for="item in QueryMsg.TeamInfoData">
              <td>{{item.TCNUM}}</td>
              <td>{{item.Title}}</td>
              <td>{{item.OfferNumber}}人</td>
              <td>{{item.StartDate}} {{item.WeekStr}}</td>
            </tr>
          </table>
        </li>
        <li>
          <input type="button" class="normalBtn" value="导出报表" @click="getFlightInfo(),getCombinTeam()" />
          <input type="button" class="normalBtn" value="导出报表" @click="exportExcel()" style="display:none" />
        </li>
      </ul>
    </div>
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>旅客姓名</th>
        <th>身份证</th>
        <th>英文姓</th>
        <th>英文名</th>
        <th>性别</th>
        <th>出生日期</th>
        <th>出生地</th>
        <th>护照号码</th>
        <th>证件有效期</th>
        <th>客人联系方式</th>
      </tr>
      <tr v-for="(item,index) in QueryMsg.dataList">
        <td>{{item.GuestName}}</td>
        <td>{{item.IdCard}}</td>
        <td>{{item.ESurName}}</td>
        <td>{{item.EName}}</td>
        <td>{{item.Sex}}</td>
        <td>{{item.Birthday}}</td>
        <td>{{item.BirthdayAddress}}</td>
        <td>{{item.PassportNo}}</td>
        <td>{{item.PassportExpiry}}</td>
        <td>{{item.NaMobilePhoneme}}</td>
      </tr>
    </table>
    <div class="noData" v-show="QueryMsg.noData">
      {{$t('system.content_noData')}}
    </div>
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="msg.currentPage" layout="total,prev, pager, next, jumper"
      :page-size='msg.PageSize' :total='msg.total'>
    </el-pagination>

    <el-dialog custom-class='passgenrDialog' title="航班列表" :visible.sync="outerVisible" center>
      <table border="0" cellspacing="0" cellpadding="0" class="singeRowTable">
        <tr>
          <td colspan="6" style="text-align:left;font-weight:bold;padding-left:5px">票务航班信息</td>
        </tr>
        <tr>
          <th>航班号</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th>出发时间</th>
          <th>起飞机场</th>
          <th>到达机场</th>
        </tr>
        <tr v-for="item in flightList">
          <td>{{item.Flight_number}}</td>
          <td>
            <el-input class="w60" v-model="item.TicketDepartureTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
          </td>
          <td>
            <el-input class="w60" v-model="item.TicketArrivalTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
          </td>
          <td>{{item.FlightDate}}</td>
          <td>{{item.dName}}</td>
          <td>{{item.aName}}</td>
        </tr>
      </table>
      <table border="0" cellspacing="0" cellpadding="0" class="singeRowTable" style="margin-top:20px;" v-if="combineTeamList.length>0">
        <tr>
          <td colspan="9" style="text-align:left;font-weight:bold;padding-left:5px">联运航班信息</td>
        </tr>
        <tr>
          <th>团号</th>
          <th>公司/城市</th>
          <th>航段</th>
          <th>日期</th>
          <th>航班号</th>
          <th>出发时间</th>
          <th>到达时间</th>
          <th>起飞机场</th>
          <th>到达机场</th>
        </tr>
        <tbody v-for="subItem in combineTeamList">
          <tr>
            <td rowspan="2">{{subItem.TCNUM}}({{subItem.TCID}})</td>
            <td rowspan="2">{{subItem.UnionBranchName}}({{subItem.UnionCityName}})</td>
            <td width="50">去程</td>
            <td>{{subItem.GoFlightDateStr}}</td>
            <td>{{subItem.GoFlight_number}}</td>
            <td>
              <el-input class="w60" v-model="subItem.GoDepartTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
            <td>
              <el-input class="w60" v-model="subItem.GoArriveTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
            </td>
            </td>
            <td>{{subItem.GoDepartAirportName}}</td>
            <td>{{subItem.GoArrivalAirportName}}</td>
          </tr>
          <tr>
            <td width="50">回程</td>
            <td>{{subItem.BackFlightDateStr}}</td>
            <td>{{subItem.BackFlight_number}}</td>
            <td>
              <el-input class="w60" v-model="subItem.BackDepartTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
            <td>
              <el-input class="w60" v-model="subItem.BackArriveTime" onkeyup="value=value.replace(/[^\d^\:]/g,'')"></el-input>
            </td>
            </td>
            <td>{{subItem.BackDepartAirportName}}</td>
            <td>{{subItem.BackArrivalAirportName}}</td>
          </tr>
        </tbody>
      </table>
      <div slot="footer" class="dialog-footer">
        <button class="normalBtn" type="primary" @click="getCheckInfo()">确认航班信息</button> &nbsp;
        <button class="hollowFixedBtn" @click="outerVisible = false">{{$t('pub.cancelBtn')}}</button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        //请求数据
        msg: {
          PageIndex: 1,
          PageSize: 15,
          AirTicketId: 0,
          total: 0,
          currentPage: 1
        },
        QueryMsg: {
          loading: true,
          //返回数据
          dataList: [],
          noData: false,
          AirTicketId: 0,
          //团期数据
          TeamInfoData: [],
          nowDate: "",
          //模板代码
          TempCode: ""
        },
        outerVisible: false,
        flightList: [],
        combineTeamList: [],
      };
    },
    methods: {
      //获取数据
      getList() {
        this.QueryMsg.loading = true;
        this.apipost(
          "travel_get_GetAirTicketGuestPageList",
          this.msg,
          res => {
            this.QueryMsg.loading = false;
            if (res.data.resultCode == 1) {
              this.msg.total = res.data.data.count;
              this.QueryMsg.dataList = res.data.data.pageData;
              this.QueryMsg.noData = !this.msg.total > 0;
              this.QueryMsg.dataList.forEach(item => {
                if (item.Sex == 1) {
                  item.Sex = "男";
                } else {
                  item.Sex = "女";
                }
              });
            }
          },
          err => {}
        );
      },
      getFlightInfo() {
        let msg = {
          ID: this.$route.query.id
        }
        this.apipost("ticket_get_GetEntityExtend", msg, res => {
          if (res.data.resultCode == 1) {
            this.flightList = res.data.data.flightList;
          } else {
            this.Error(res.data.message);
          }
        }, err => {});
        this.outerVisible = true;
      },
      //获取联运团信息
      getCombinTeam() {
        let msg = {
          AirTicketId: this.$route.query.id
        }
        this.apipost("ticket_get_GetUnionFlightAllInfo", msg, res => {
          if (res.data.resultCode == 1) {
            this.combineTeamList = res.data.data;
          } else {
            this.Error(res.data.message);
          }
        }, err => {});
      },
      //确定
      getCheckInfo() {
        let FlightList = []
        this.flightList.forEach(x => {
          var obj = {
            ID: x.ID,
            TicketDepartureTime: x.TicketDepartureTime,
            TicketArrivalTime: x.TicketArrivalTime
          }
          FlightList.push(obj);
        })
        var unionFlightList = [];
        this.combineTeamList.forEach(item => {
          unionFlightList.push({
            Id: item.Id,
            GoDepartTime: item.GoDepartTime,
            GoArriveTime: item.GoArriveTime,
            BackDepartTime: item.BackDepartTime,
            BackArriveTime: item.BackArriveTime
          });
        });
        let msg = {
          AirTicketId: this.$route.query.id,
          FlightList: FlightList,
          UnionFlightList: unionFlightList
        }
        this.apipost("ticket_post_SetFlightChildConfirm", msg, res => {
          if (res.data.resultCode == 1) {
            this.Success(res.data.message);
            this.exportExcel();
            this.outerVisible = false;
          } else {
            this.Error(res.data.message);
          }
        }, err => {});
      },
      //导出报表
      exportExcel() {
        let msg = {
          AirTicketId: this.msg.AirTicketId
        };
        var fileName = this.$route.query.flightdate //this.QueryMsg.nowDate;
        var TempfileName = ""
        this.QueryMsg.TeamInfoData.forEach(item => {
          if (TempfileName.length > 0) {
            TempfileName += "/" + item.TCNUM
          } else {
            TempfileName += item.TCNUM
          }
        })
        fileName = fileName + TempfileName
        fileName = fileName + this.$route.query.alcode
        //国航的用word
        if (this.QueryMsg.TempCode == "CATempla") {
          fileName = fileName + ".doc";
        } else {
          fileName = fileName + ".xls";
        }
        this.GetLocalFile("travel_get_GetAirTicketGuestExport", msg, fileName);
      },


      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      resetPageIndex() {
        this.msg.pageIndex = 1;
        this.msg.currentPage = 1;
      },
      //获取团期信息
      getTeamInfo() {
        var msg = {
          AirTicketId: this.QueryMsg.AirTicketId
        };
        this.apipost(
          "travel_get_GetAirTicketTravelPriceReportInfo",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.QueryMsg.TeamInfoData = res.data.data.resultData;
              this.QueryMsg.TempCode = res.data.data.TempCode;
            }
          },
          err => {}
        );
      }
    },
    mounted() {
      this.QueryMsg.AirTicketId = this.$route.query.id;
      this.msg.AirTicketId = this.$route.query.id;
      var myDate = new Date();
      this.QueryMsg.nowDate =
        myDate.getFullYear() +
        "-" +
        (Number(myDate.getMonth()) + 1) +
        "-" +
        myDate.getDate();
      this.getTeamInfo();
      this.getList();
    }
  };

</script>
