<style>
  @import url('../../assets/css/domestic/OrderToday.css');

</style>
<template>
  <div class="flexOne page_OrderToday page_OrderDetails">
    <div class='query-box'>
      <ul>
        <li>
          <div class="_qishu">
            {{$t('tips.qishu')}} {{Term}}
          </div>
        </li>
        <li>
          <span>
            <em>{{$t('system.query_airCompanyName')}}</em>
            <el-select filterable @change="flight_post_GetAirportNameList(msg.AirlineId)" v-model='msg.AirlineId'>
              <el-option :label="$t('pub.unlimitedSel')" value=''></el-option>
              <el-option v-for='item in airlineList' :label='item.AlName' :value='item.AirLineId' :key='item.AirLineId'>
              </el-option>
            </el-select>
          </span>
        </li>
        <li>
          <span>
            <em>{{$t('system.query_flightNum')}}</em>
            <el-select filterable v-model='msg.FlightNo'>
              <el-option v-for='item in AirportNameList' :label='item.Flight_number' :value='item.Flight_number'
                :key='item.Flight_number'>
              </el-option>
            </el-select>
          </span>
        </li>
        <li>
          <label>{{$t('hotel.order_Number')}}</label>

          <el-input v-model="msg.OrderID" class="w210"></el-input>
        </li>
        <li>
          <span>
            <em>{{$t('fnc.khmingcheng')}}</em>
            <el-input v-model="msg.ClientName" class="w210"></el-input>
          </span>
        </li>
        <li>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="resetPageIndex(),getList(1)" />
        </li>
      </ul>
    </div>
    <div class="_content" v-loading='loading'>
      <div class="_price">
        <span>{{$t('objFill.yinshouzje')}}:¥{{DataList.Money}}</span>
        <span>{{$t('hotel.table_CostPrice')}}:¥{{DataList.Cost}}</span>
        <span>{{$t('objFill.v101.DomesticModule.zhonglir')}}:¥{{DataList.Profit}}</span>
      </div>
      <table class="po_content singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0">
        <tr>
          <th>{{$t('hotel.hotel_SerialNumber')}}</th>
          <th>{{$t('admin.admin_personNumber')}}</th>
          <th>{{$t('fnc.ysjine')}}</th>
          <th>{{$t('hotel.hotel_cost')}}</th>
          <th>{{$t('fnc.khmingcheng')}}</th>
          <th>{{$t('objFill.xingchengsj')}}</th>
          <th>{{$t('system.query_airCompanyName')}}</th>
          <th>{{$t('visa.v_hangban')}}</th>
          <th>{{$t('Airticket.Air_segment')}}</th>
          <th>{{$t('admin.admin_czPerson')}}</th>
        </tr>
        <tr v-for="(item,index) in DataList.list" :key="index">
          <td>{{item.ID}}</td>
          <td class="_hover">
            <el-popover placement="bottom" width="220" trigger="click">
              <table class="add_table singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0">
                <tr>
                  <th width="70"></th>
                  <th>{{$t('restaurant.res_Number')}}</th>
                </tr>
                <tr>
                  <td>{{$t('salesModule.Adult')}}</td>
                  <td>{{item.AdultNumber}}</td>
                </tr>
                <tr>
                  <td>{{$t('sm.ertong')}}</td>
                  <td>{{item.ChirdNumber}}</td>
                </tr>
                <tr>
                  <td>{{$t('Operation.Op_baby')}}</td>
                  <td>{{item.BabyNumber}}</td>
                </tr>
              </table>
              <span slot="reference">{{item.Number}}{{$t('hotel.hotel_people')}}</span>
            </el-popover>
          </td>
          <td class="_hover">
            <el-popover placement="bottom" width="220" trigger="click">
              <table class="add_table singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0">
                <tr>
                  <th width="70"></th>
                  <th>{{$t('objFill.v101.DomesticModule.danjiahans')}}</th>
                </tr>
                <tr>
                  <td>{{$t('salesModule.Adult')}}</td>
                  <td>{{item.AdultPrice}}</td>
                </tr>
                <tr>
                  <td>{{$t('sm.ertong')}}</td>
                  <td>{{item.ChirdPrice}}</td>
                </tr>
                <tr>
                  <td>{{$t('Operation.Op_baby')}}</td>
                  <td>{{item.BabyPrice}}</td>
                </tr>
              </table>
              <span slot="reference">¥{{item.TotalPrice}}</span>
            </el-popover>
          </td>
          <td class="_hover">
            <el-popover placement="bottom" width="220" trigger="click">
              <table class="add_table singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0">
                <tr>
                  <th width="70"></th>
                  <th>{{$t('hotel.hotel_CostPrice')}}</th>
                </tr>
                <tr>
                  <td>{{$t('salesModule.Adult')}}</td>
                  <td>{{item.AdultCost}}</td>
                </tr>
                <tr>
                  <td>{{$t('sm.ertong')}}</td>
                  <td>{{item.ChirdCost}}</td>
                </tr>
                <tr>
                  <td>{{$t('Operation.Op_baby')}}</td>
                  <td>{{item.BabyCost}}</td>
                </tr>
              </table>
              <span slot="reference">¥{{item.TotalCost}}</span>
            </el-popover>
          </td>
          <td>{{item.ClientName}}</td>
          <td>{{item.TravelTime}}</td>
          <td colspan="3" class="_hover">
            <el-popover placement="bottom" width="450" trigger="click">
              <table class="add_table singeRowTable" style="border:1px solid #E6E6E6;" cellspacing="0" cellpadding="0">
                <tr>
                  <th>{{$t('system.query_airCompanyName')}}</th>
                  <th>{{$t('visa.v_hangban')}}</th>
                  <th>{{$t('Airticket.Air_segment')}}</th>
                </tr>
                <tr v-for="(i,d) in item.FlightList" :key="d">
                  <td>{{i.AirlineName}}</td>
                  <td>{{i.FlightNo}}</td>
                  <td>{{i.Leg}}</td>
                </tr>
              </table>
              <span
                slot="reference">{{item.FlightList[0].AirlineName+' — '+item.FlightList[0].FlightNo+' — '+item.FlightList[0].Leg}}</span>
            </el-popover>
          </td>
          <td>{{item.EmName}}</td>
        </tr>
      </table>
      <div class="noData" v-show="noData">
        {{$t('system.content_noData')}}
      </div>
      <div>
        <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
          layout="total,prev, pager, next, jumper" :page-size=msg.pageSize :total=total>
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        Term: '',
        DataList: [],
        airlineList: [],
        msg: {
          pageIndex: 1,
          pageSize: 15,
          OrderID: '',
          AirlineId: '',
          FlightNo: '',
          ClientName: '',
          ParentId: 1,
          ParentId: 0,
        },
        AirportNameList: [],
        total: 0,
        currentPage: 1,
        loading: true,
        noData: false,
        PayInfoS: null,
        PayInfoZ: null,
        PayInfoLding: true,
        RB_Branch_Id: ''
      }
    },
    created() {
      this.Term = this.$route.query.Term;
      this.msg.ParentId = this.$route.query.ID;
    },
    mounted() {
      this.getList(this.id);
      this.getAirlineList();
      let userInfo = this.getLocalStorage();
      this.RB_Branch_Id = userInfo.RB_Branch_id;
    },
    methods: {
      getInfo(id) {
        this.PayInfoLding = true;
        this.apipost('Financial_post_GetOrderFinanceList', {
          OrderId: id,
          OrderResource: 9
        }, r => {
          if (r.data.resultCode == 1) {
            let data = r.data.data;
            let PayInfoS = [],
              PayInfoZ = [];
            data.forEach(x => {
              if (x.Type == 1) {
                PayInfoS.push(x)
              } else {
                PayInfoZ.push(x)
              }
            });
            this.PayInfoZ = PayInfoZ;
            this.PayInfoS = PayInfoS;
            this.PayInfoLding = false;
          }
        }, null);
      },
      goUrl(obj, t) {
        let orderObj = {
          OrderID: obj.ID,
          OrderSource: 9,
          Obj: {},
          SourceID: obj.ParentId,
          TCIDList: []
        }
        this.$router.push({
          name: 'ChoiceAddFinancialDocuments',
          query: {
            'Type': t,
            'TCIDList': [],
            'path': 'TicketingModule',
            'Cmd': 'Domestic_Ticket_post_UpdateFrID',
            'companyID': null,
            'blank': 'y',
            'orderObj': JSON.stringify(orderObj)
          }
        });
      },
      goFinanceUrl(id) {
        this.$router.push({
          name: 'FinancialDocumentsDetail',
          query: {
            'id': id
          }
        });
      },
      getList(t) { //获取列表
        if (this.msg.OrderID == '') {
          this.msg.OrderID = 0;
        }
        if (this.msg.AirlineId == '') {
          this.msg.AirlineId = 0;
        }
        this.loading = true
        this.apipost('Domestic_Ticket_post_GetPageList', this.msg, res => {
          if (res.data.resultCode == 1) {
            this.total = res.data.data.count;
            let data = res.data.data.pageData;
            if (this.total > 0) {
              this.noData = false;
            } else {
              this.noData = true;
            }
            this.DataList = data
            this.loading = false;
            if (!t) {
              this.msg.OrderID = '';
              this.msg.AirlineId = '';
            } else {
              if (this.msg.OrderID == 0) {
                this.msg.OrderID = '';
              }
              if (this.msg.AirlineId == 0) {
                this.msg.AirlineId = '';
              }
            }
          } else {
            this.$message.error(res.data.message)
            this.loading = false;
            if (!t) {
              this.msg.OrderID = '';
              this.msg.AirlineId = '';
            } else {
              if (this.msg.OrderID == 0) {
                this.msg.OrderID = '';
              }
              if (this.msg.AirlineId == 0) {
                this.msg.AirlineId = '';
              }
            }
          }
        }, err => {})
      },
      flight_post_GetAirportNameList(id) {
        this.msg.FlightNo = '';
        this.AirportNameList = []
        if (!id) return
        this.apipost('flight_post_GetAirportNameList', {
          airlineID: id
        }, r => {
          if (r.data.resultCode == 1) {
            this.msg.FlightNo = '';
            this.AirportNameList = r.data.data;
          }
        }, null)
      },
      getAirlineList() { //获取航空公司*
        this.apipost("airline_post_GetList", {}, res => {
          this.airlineList = res.data.data;
        }, err => {});
      },
      resetPageIndex() { //查询初始化页码
        this.msg.pageIndex = 1;
        this.currentPage = 1
      },
      handleCurrentChange(val) { //翻页功能按钮
        this.msg.pageIndex = val;
        this.getList();
      },
    }
  }

</script>