<template>
  <div class="passengerSaleList">
    <div class="passengerSaleList_topBtn">
      <div v-if="isOrder==1 && !isDis" v-show="tableList.length<guestNum" @click="goUrlA(0)">新增</div>
      <div v-if="isOrder==1 && isOneDay !== 1 && !isDis" @click="goUrlP()">分房</div>
    </div>
    <div class="passengerSaleList_tableBox">
      <table class="passengerSaleList_table" border="0" cellspacing="0" cellpadding="0" :loading="loading">
        <thead>
          <tr>
            <th width="2%">ID</th>
            <th width="2%">分房</th>
            <th width="5%">酒店及房型</th>
            <th width="5%">旅客姓名</th>
            <th width="5%">英文姓</th>
            <th width="5%">英文名</th>
            <th width="3%">性别</th>
            <th width="7%">出生日期</th>
            <th width="4%">年龄类型</th>
            <th width="6%">出生地</th>
            <th width="6%">护照号</th>
            <th width="6%">签发地</th>
            <th width="7%">签发日期</th>
            <th width="7%">护照有效期</th>
            <th width="6%">客户手机</th>
            <th width="9%">身份证</th>
            <th width="5%">签证状态</th>
            <th width="5%">是否学生</th>
            <th width="8%">操作</th>
          </tr>
        </thead>
        <tbody v-show="tableList.length>0">
          <tr v-for="(item,index) in tableList" :key="index" :class="{'redTr':item.VisaState==1}">
            <td>{{item.Sort}}</td>
            <td>{{item.HoustNo}}</td>
            <td>{{item.HouseType}}</td>
            <td>{{item.Name}}</td>
            <td>{{item.ESurName}}</td>
            <td>{{item.EName}}</td>
            <td>{{item.Sex}}</td>
            <td>{{item.Birthday}}</td>
            <td>{{item.PeopleType}}</td>
            <td>{{item.BirthdayAddress}}</td>
            <td>{{item.PassportNo}}</td>
            <td>{{item.PassportAddress}}</td>
            <td>{{item.PassportIssued}}</td>
            <td>{{item.PassportExpiry}}</td>
            <td>{{item.MobilePhone}}</td>
            <td>{{item.IdCard}}</td>
            <td>{{item.VisaState==1?'拒签':"正常"}}</td>
            <td style="color:red;">{{item.IsHightSchool==1?'学生':""}}</td>
            <td>
              <el-button-group>
                <el-tooltip v-if="isOrder==1 && !isDis" class="item" effect="dark" content="修改" placement="top-start">
                  <el-button type="primary" style='background:#00C6FF; border-color:#00C6FF'
                    icon="iconfont icon-bianji-smal" @click="goUrlA(item.Id)"></el-button>
                </el-tooltip>
                <el-tooltip v-if="isOrder==1 && !isDis" class="item" effect="dark" content="删除" placement="top-start">
                  <el-button type="primary" style='background:#e95252; border-color:#e95252'
                    icon="iconfont icon-shanchu" @click="pal_del(item)"></el-button>
                </el-tooltip>
                <el-tooltip v-if="isOrder==1 && !isDis" class="item" effect="dark" content="下载申请表" placement="top-start">
                  <el-button type="primary" style='background:#9E8DE3; border-color:#9E8DE3'
                    icon="iconfont icon-img_download" @click="goUrlB(item.Id)"></el-button>
                </el-tooltip>
              </el-button-group>
            </td>
          </tr>
        </tbody>
        <tbody v-show="tableList.length===0" class="passengerSaleList_table_noInfo">
          <tr>
            <td colspan="19" class="">暂无数据</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        loading: false,
        msg: {
          id: '0',
          tcid: '0',
          tcnum: '0'
        },
        guestNum: 0,
        isOrder: 0,
        tableList: [],
        isOneDay: 0,
        LineId: 0,
        EndDateStr: "",
        isDis: false,
      };
    },
    methods: {
      getData: function () {
        this.loading = true
        this.apipost("sellorder_get_GetTravelGuestList", {
          OrderId: this.msg.id
        }, res => {
          if (res.data.resultCode == 1) {
            this.guestNum = res.data.data.GuestNum;
            this.tableList = res.data.data.list;
            this.isOneDay = res.data.data.IsOneDay;
            this.LineId = res.data.data.LineId;
            this.EndDateStr = res.data.data.EndDateStr
          } else {
            this.$message.error(res.data.message)
          }
          this.loading = false
        });
      },
      pal_del: function (item) {
        this.$confirm('是否删除该旅客?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.apipost('sellorder_post_DelTravelGuestInfo', {
            GuestId: item.Id
          }, res => {
            if (res.data.resultCode == 1) {
              this.$message.success('删除成功！')
              this.getData()
            } else {
              this.$message.error(res.data.message)
            }
          }, err => {})
        })
      },
      goUrlA: function (guestId) {
        this.$router.push({
          name: 'addPassenger',
          query: {
            "TCID": this.msg.tcid,
            "orderId": this.msg.id,
            'guestId': guestId,
            'isOneDay': this.isOneDay,
            'LineId': this.LineId,
            "EndDateStr": this.EndDateStr
          }
        });
      },
      goUrlB: function (guestId) {
        let routeData = this.$router.resolve({
          name: 'VisaPersonalFormSell',
          query: {
            data: guestId
          }
        });
        window.open(routeData.href, '_blank');
      },
      goUrlP: function () {
        this.$router.push({
          name: 'passengerListSale',
          query: {
            id: this.msg.id,
            tcnum: this.msg.tcnum,
            blank: 'y',
            tab: '旅客分房'
          }
        });
      },
    },
    mounted: function () {
      this.msg.id = this.$route.query.id === undefined ? "0" : this.$route.query.id
      this.msg.tcid = this.$route.query.tcid === undefined ? "0" : this.$route.query.tcid
      this.msg.tcnum = this.$route.query.tcnum === undefined ? "0" : this.$route.query.tcnum
      this.isOrder = this.$route.query.isOrder === undefined ? 0 : this.$route.query.isOrder
      this.isDis = this.$route.query.isDis ? true : false;
      this.getData()
    }
  };

</script>

<style>
  .passengerSaleList {
    width: 100%;
  }

  .passengerSaleList_topBtn {
    padding: 20px 0 0 0;
    text-align: right;
  }

  .passengerSaleList_topBtn>div {
    display: inline-block;
    margin: 0 0 0 10px;
    padding: 0 15px;
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    color: #E95252;
    border: 1px solid #E95252;
    border-radius: 15px;
    background: #FFFFFF;
    cursor: pointer;
  }

  .passengerSaleList_tableBox {
    padding: 20px 0 0 0;
    width: 100%;
  }

  .passengerSaleList_table {
    width: 100%;
    color: #333;
    border-bottom: 1px solid #cccccc;
    border-right: 1px solid #cccccc;
  }

  .passengerSaleList_table tr {
    background: #fff;
  }

  .passengerSaleList_table tr th {
    background: #e6e6e6;
    height: 30px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid #cccccc;
    border-left: 1px solid #cccccc;
  }
 

  .passengerSaleList_table tr td {
    padding: 10px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid #cccccc;
    border-left: 1px solid #cccccc;
  }

  .passengerSaleList_table_noInfo tr td {
    height: 30px;
    text-align: center;
    font-size: 12px;
    color: #999999;
  }

  /*拒签人员*/
  .passengerSaleList_table .redTr td{
    color: #E95252;
  }

</style>
