<style>
  .busInfo {
    font-size: 12px;
  }

  .busInfo .bus_Notice {
    color: #e95252;
    margin: 20px 0;
    text-align: left;
  }

  .busInfo .bus_Title {
    display: inline-block;
    padding-left: 10px;
    border-left: 3px solid #e95252;
    margin-bottom: 20px;
  }

  .busInfo .bus_uu li {
    float: left;
    width: 280px;
  }

  .busInfo .bo_bus {
    width: 100%;
    background: #eee;
    min-width: 1125px;
    margin-bottom: 30px;
  }

  .busInfo .bo_bus th {
    background: #edeef0;
    height: 40px;
  }

  .busInfo .bo_bus tr {
    height: 40px;
  }

  .busInfo .bo_bus td {
    height: 50px;
    text-align: center;
    background-color: #fff;
    padding: 0 10px;
  }

  .busInfo .bus_uu em {
    font-style: normal;
    display: inline-block;
    width: 60px;
  }

  .busInfo .areaInfo li {
    width: auto;
    margin-bottom: 30px;
  }

  .busInfo .subName {
    padding: 0 10px;
    border: 1px solid #d1d1d1;
    border-radius: 14px;
    height: 30px;
    display: inline-block;
    line-height: 30px;
    cursor: pointer;
  }

  .busInfo .spanCked {
    border-color: #ff4400;
    color: #ff4400;
  }

  .BusinfoSpan {
    display: inline-block;
    margin-right: 3px;
    margin: 5px 4px 5px 0;
  }

  .busInfo .upBtnList {
    margin: 20px 0 30px 20px;
  }

  .carInfo .el-input__inner {
    height: 34px !important;
  }

  .disSpan {
    background-color: #e4e7ed;
    color: #c0c4cc;
  }

  .busInfoP {
    display: inline-block;
    text-decoration: underline;
    cursor: pointer;
  }

  .BusTyleFirst .w170 {
    margin-right: 22px;
  }

  .busAddbtn {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 1px solid #d1d1d1;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    top: 2px;
  }

  .busAddbtn:hover i {
    color: #e95252;
  }

  .carPlanOne .w320 {
    margin: 5px 0;
  }

  .busInfo .w200 {
    padding: 10px 0;
  }

  .busInfo .has-gutter tr th,
  .el-table th.is-leaf {
    background: #EAEAEA !important;
    text-align: center;
  }

  .disClick {
    background-color: #d1d1d1;
    color: #fff;
    border: 1px solid #d1d1d1;
  }

  .disClick:hover {
    background-color: #d1d1d1 !important;
    cursor: default !important;
    box-shadow: none !important;
  }

  .busInfo .comBTM {
    margin-bottom: 10px;
  }

  .busInfo .comBTM:last-child {
    margin-bottom: 0;
  }

  .park_List {
    width: 50px;
    height: 34px;
    line-height: 34px;
    text-align: left;
  }
</style>
<template>
  <div class="flexOne busInfo">
    <div class="bus_Notice">{{$t('ground.cichubuhe')}}</div>
    <table class="singeRowTable">
      <tr>
        <td colspan="7" style="text-align:left;padding-left:5px;">{{title}}</td>
      </tr>
      <tr>
        <th>{{$t('Operation.Op_jinchudian')}}</th>
        <th>{{$t('ground.ddrenshu')}}</th>
        <th>{{$t('ground.jiweizongshu')}}</th>
        <th>{{$t('leader.leader_Leader')}}</th>
        <th>{{$t('leader.leader_Guide')}}</th>
        <th>{{$t('visa.v_tuanhao')}}</th>
        <th>{{$t('visa.v_hangban')}}</th>
      </tr>
      <tr v-for="(item,index) in CommonList" :key="index">
        <td>{{item.InOut}}</td>
        <td>{{item.GuestNum}}</td>
        <td>{{item.TotalSeat}}</td>
        <td>{{item.LeaderName}}</td>
        <td>{{item.GuideName}}</td>
        <td>
          <p class="busInfoP" @click="goUrlT('TravelControlList',item.TCNUM,'团控列表')">{{item.TCNUM}}</p>
        </td>
        <td>
          <div v-for="(subItem,subIndex) in item.FlightList" :key="subIndex">
            <span style="height:25px; line-height:25px;">
              <a style="color: #ff0066;font-weight: bold;">{{subItem.Flight_number}}</a> {{subItem.FlightDateStr}}
              {{subItem.Departure_time}} {{subItem.dName}} {{subItem.TicketArrivalTime}} {{subItem.aName}}
            </span>
          </div>
        </td>
      </tr>
      <tfoot>
        <tr>
          <td>
            {{$t('ground.dingtuanhao')}}:{{NewCombinationNum}}
          </td>
          <td>{{$t('ground.busType')}}</td>
          <td align="left" style="padding-left:5px;">
            <el-select class="w150" :placeholder="$t('pub.pleaseSel')" v-model="PostData.BusType">
              <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
              <el-option v-for="item in BusTypeList" :key="item.Id" :label="item.newName" :value="item.Id">
              </el-option>
            </el-select>
          </td>
          <td colspan="2">{{$t('ground.huisongfei')}}</td>
          <td colspan="2" align="left" style="padding-left:5px;">
            <el-input v-model="PostData.BackFee" @keyup.native="checkPrice(PostData,'BackFee')"
              :placeholder="$t('ground.shuruhsf')" maxlength="10" class='w135'></el-input>
          </td>
        </tr>
      </tfoot>
    </table>
    <div style="width: 100%; overflow-x: auto;margin-top:20px;" class="ownScrollbarStyle">
      <el-form>
        <el-table :data="PlanTableData" style="width:100%" border v-loading='loading'>
          <el-table-column fixed :label="$t('pub.date')" prop="UseTimeStr" min-width="100"></el-table-column>
          <el-table-column fixed :label="$t('hotel.hotel_name')" min-width="200">
            <template slot-scope="scope">
              {{scope.row.HotelName}}
              <template v-if="scope.row.IsHavearking==0">
                <br />
                <font style="color:red;">{{$t('fnc.no')}}{{$t('ground.park')}}</font>
              </template>
              <template v-else>
                <br />
                <font style="color:green;">{{$t('objFill.you')}}{{$t('ground.park')}}</font>
              </template>
            </template>
          </el-table-column>
          <el-table-column fixed :label="$t('sm.yongchejihua')" min-width="180">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_ap_`+subIndex">
                <em>
                  <!--接机送机-->
                  <el-select class="w100" :placeholder="$t('pub.pleaseSel')" v-model="subItem.AirportPickUp"
                    :disabled="forbidInput" @change="getBusPrice(subItem)">
                    <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
                    <el-option v-for="childitem in BusAirportPickUpList" :key="childitem.Id" :label="childitem.Name"
                      :value="childitem.Id">
                    </el-option>
                  </el-select>
                </em>
                <span style="display:inline-block;margin-left:5px;" v-if="subIndex>0">
                  <a @click="DeleteSubItem(scope.row,subIndex),getBusPrice(subItem)"
                    style="color:blue;cursor:pointer">{{$t('system.table_delete')}}</a>
                </span>
                <span style="display:inline-block;margin-left:5px;" v-if="subIndex==0">
                  <a @click="AddSubItem(scope.row)" style="color:blue;cursor:pointer">{{$t('fnc.tianjia')}}</a>
                </span>
                <br />
              </div>
              {{$t('objFill.v101.busManagement.chezhibj')}}:<font style="color:red">{{scope.row.BusOfferPrice}}
                <template v-if="scope.row.IsBusChange">
                  <el-tooltip :content="scope.row.BusChangeRemark">
                    <font style="color:blue;">
                      <template v-if="scope.row.BusChangeValue>0">
                        +{{scope.row.BusChangeValue}}
                      </template>
                      <template v-else>
                        {{scope.row.BusChangeValue}}
                      </template>
                    </font>
                  </el-tooltip>
                </template>
              </font>
            </template>
          </el-table-column>
          <!--
          <el-table-column :label="$t('objFill.v101.busManagement.taotuanth')" min-width="230">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_tt_`+subIndex">
                <template v-if="subItem.AirportPickUp==15">
                  <div v-for="(childItem,childIndex) in subItem.MergeList" :key="`bpo_me_`+childIndex">
                    <em>
                      <el-select filterable style="margin-bottom:5px;" class="w170" :placeholder="$t('pub.pleaseSel')"
                        v-model="childItem.MTCID" @visible-change="GetPriceList(subItem)"
                        @change="GetPriceChange(subItem,childItem)">
                        <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
                        <el-option v-for="pItem in subItem.PriceList" :key="pItem.TCID" :label="pItem.TCNUM"
                          :value="pItem.TCID"></el-option>
                      </el-select>
                    </em>
                    <span style="display:inline-block;margin-left:5px;">
                      <a @click="DeleteMergeSubItem(subItem.MergeList,childIndex)"
                        style="color:blue;cursor:pointer">{{$t('system.table_delete')}}</a>
                    </span>
                  </div>
                  <span style="display:inline-block;margin-left:5px;">
                    <a @click="AddMergeSubItem(subItem.MergeList)"
                      style="color:blue;cursor:pointer">{{$t('fnc.tianjia')}}</a>
                  </span>
                </template>
              </div>
            </template>
          </el-table-column>
          -->
          <el-table-column :label="$t('hotel.hotel_Supplier')" min-width="150">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bps_`+subIndex">
                <el-select filterable :placeholder="$t('pub.pleaseSel')" v-model="subItem.BusCompany"
                  @change="getDirverList(subItem)">
                  <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
                  <el-option v-for="item in SupplierList" :key="item.ID" :label="item.Name" :value="item.ID">
                  </el-option>
                </el-select>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.sijiName')" min-width="120">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpd_`+subIndex">
                <el-autocomplete class="inline-input" v-model="subItem.DriverName" value-key="Name"
                  :fetch-suggestions="(queryString, cb) => { getSearchList(queryString, cb, subItem);}"
                  :placeholder="$t('pub.pleaseSel')" @select="(dItem)=>{handleSelect(dItem,subItem)}"></el-autocomplete>
                <!-- <el-input v-model="subItem.DriverName"></el-input> -->
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('restaurant.res_ContactNumber')" min-width="140">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpdt_`+subIndex">
                <el-input v-model="subItem.DriverTel"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.cphaoma')" min-width="100">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_`+subIndex">
                <el-input v-model="subItem.BusNum"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.busType')" min-width="150">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_b_`+subIndex">
                <el-select filterable :placeholder="$t('pub.pleaseSel')" v-model="subItem.BusType"
                  :disabled="forbidInput" @change='getBusPrice(subItem)'>
                  <el-option :key="0" :value="0" :label="$t('pub.pleaseSel')"></el-option>
                  <el-option v-for="item in BusTypeList" :key="item.Id" :label="item.newName" :value="item.Id">
                  </el-option>
                </el-select>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('fnc.fkfangshi')" min-width="130">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_p_`+subIndex">
                <el-select class='sel' v-model='subItem.PayType' :disabled="isShowBtn==1||IsEditBus==0?true:false"
                  :placeholder="$t('pub.pleaseSel')" @change="PayTypeChange(scope.row)">
                  <el-option :label="$t('pub.pleaseSel')" :value='0'></el-option>
                  <el-option :label="$t('ground.xianfu')" :value='1'></el-option>
                  <el-option :label="$t('ground.gsjiesuan')" :value='2'></el-option>
                  <el-option :label="$t('ground.yufu')" :value='3'></el-option>
                  <el-option :label="$t('ground.htgszf')" :value='6'></el-option>
                  <el-option :label="$t('ground.zyhdwyc')" :value='7'></el-option>
                  <el-option :label="$t('ground.jdjiesong')" :value='8'></el-option>
                   <el-option :label="$t('ground.enterpriseAlipay')"  :value='15'></el-option>
                </el-select>
              </div>
            </template>
          </el-table-column>
          <!--订团号-->
          <!-- <el-table-column :label="$t('ground.dingtuanhao')" min-width="180">
            <template slot-scope="scope">
              <div class="comBTM" v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" :key="`bpo_bo_`+subIndex">
                <template v-if="scope.$index==0&&subIndex==0">
                  <i class="iconfont icon-tongshang" style="opacity:0;filter:alpha(opacity=0); "></i>
                  <el-input class='w135' type="text" v-model="subItem.BookGroup"></el-input>
                </template>
                <template v-else>
                  <el-tooltip class="item" effect="dark" :content="$t('ground.tongshang')" placement="top">
                    <i class="iconfont icon-tongshang" style="cursor:pointer;"
                      @click="getBeforeInfo(scope.$index,subIndex),getBusPrice(subItem)"></i>
                  </el-tooltip>
                  <el-input class='w135' type="text" v-model="subItem.BookGroup"></el-input>
                </template>
              </div>
            </template>
          </el-table-column> -->
          <el-table-column :label="$t('ground.sjzhusu')" min-width="180">
            <template slot-scope="scope">
              <!--司机住宿类型-->
              <div v-for="(childItem,childIndex) in scope.row.BusPlanOrderList" class="comBTM"
                :key="`bpo_ac_`+childIndex">
                <span v-for="(subItem,subIndex) in AccommodationTypeArray" :key="`bpo_acc_`+childIndex+subIndex">
                  <span class="subName" :class="{'spanCked':childItem.AccommodationType==subItem.Id}"
                    @click="AccommodationCLick(subItem.Id,childItem)">{{subItem.Name}}</span>
                  <span v-if="subItem.Id==1 && childItem.AccommodationType==1">
                    <el-input style="margin-top:13px;" v-model="childItem.AccommodationRemark"
                      :placeholder="$t('ground.qsrwsdz')">
                    </el-input>
                  </span>
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.bcsm')" min-width="180">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_pe_`+subIndex">
                <el-input v-model="subItem.ParkExplain" :placeholder="$t('ground.qsrsm')"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.gsfeiyong')" min-width="120">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_hsp_`+subIndex">
                <el-input v-model="subItem.HighSpeedPrice" @keyup.native="checkPrice(subItem,'HighSpeedPrice')"
                  :placeholder="$t('ground.qsrfyong')" :disabled="isShowBtn==1||IsEditBus==0?true:false" class='w100'>
                </el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.gsfkfs')" min-width="140">
            <template slot-scope="scope">
              <div>
                <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_hsp_`+subIndex">
                  <el-select class='sel w120' v-model='subItem.HighSpeedPayType' :placeholder="$t('pub.pleaseSel')"
                    @change="PayTypeChange(subItem)" :disabled="isShowBtn==1||IsEditBus==0?true:false">
                    <el-option :label="$t('pub.pleaseSel')" :value='0'></el-option>
                    <el-option :label="$t('ground.xianfu')" :value='1'></el-option>
                    <el-option :label="$t('ground.gsjiesuan')" :value='2'></el-option>
                    <el-option :label="$t('ground.yufu')" :value='3'></el-option>
                    <el-option :label="$t('ground.htgszf')" :value='6'></el-option>
                    <el-option :label="$t('ground.zyhdwyc')" :value='7'></el-option>
                    <el-option :label="$t('ground.jdjiesong')" :value='8'></el-option>
                  </el-select>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.UsePCount')" min-width="80">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_un_`+subIndex">
                <el-input v-model="subItem.UseNum" @keyup.native="checkPrice(subItem,'UseNum')"
                  :disabled="isShowBtn==1||IsEditBus==0?true:false"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.cbenjia')" min-width="120">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_cp_`+subIndex">
                <el-input v-model="subItem.CostPrice" :disabled="isShowBtn==1||IsEditBus==0?true:false"
                  @keyup.native="checkPrice(subItem,'CostPrice')" :placeholder="$t('ground.qingshurcbj')" class="w100">
                </el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('pub.pubRemark')" min-width="180">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="`bpo_rk_`+subIndex">
                <el-input type="text" v-model="subItem.Remarks"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.xiaoji')" min-width="80">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="park_List comBTM"
                :key="`bpo_cpt_`+subIndex">
                {{subItem.CostPrice*(Number(subItem.TransferNum)+1) + Number(subItem.HighSpeedPrice)}}
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="upBtnList">

          <el-button v-if="isShowBtn==0" type="primary" class="normalBtn" @click="SaveList(1)" :loading="saveLoading">
            {{$t('pub.saveBtn')}}</el-button>
          <el-button v-if="isShowBtn==1&&currentUserInfo.EmployeeId==615" type="primary" class="normalBtn"
            @click="SaveList(1)" :loading="saveLoading">
            {{$t('pub.saveBtn')}}</el-button>

          <span v-if="isShowBtn==1" style="color:red;margin-left:10px;">
            {{$t('ground.xzdanbuneng')}}
          </span>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        //车辆类型列表
        BusTypeList: [],
        /*供应商列表*/
        SupplierList: [],
        //地址参数
        BusId: 0,
        //地址参数
        parametersData: {
          TCID: 0,
          StartDate: "",
          DayNum: 0,
          TotalNumber: 0
        },
        PostData: {},
        //公用信息
        CommonList: [],
        /*计划表数据*/
        forbidInput: false,
        PlanTableData: [],
        BusAirportPickUpList: [], //用车类型
        //防止重复提交
        saveLoading: false,
        //司机住宿类型
        AccommodationTypeArray: [],
        //团名
        title: '',
        loading: false,
        isShowBtn: 1, //1禁用高速费,成本费,高速付款方式文本框
        IsEditBus: 0, //车辆修改权限
        currentUserInfo: {},
        NewCombinationNum: "", //订团号
      };
    },
    methods: {
      getSearchList(queryString, cb, subItem) {
        var tempArray = subItem.DriverList;
        var results = [];
        if (queryString && queryString != "") {
          results = tempArray.filter(temp => temp.Name.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        } else {
          results = tempArray;
        }
        // 调用 callback 返回建议列表的数据
        cb(results);
      },
      handleSelect(dItem, subItem) {
        subItem.DriverTel = ""
        if (subItem && dItem) {
          if (dItem.Mobile && dItem.Mobile != '') {
            subItem.DriverTel = dItem.Mobile;
          }
        }
      },
      //获取团期列表
      GetPriceList(obj) {
        this.apipost(
          "bus_get_GetBusTravelPriceList", {
            StartDate: this.parametersData.StartDate,
          },
          res => {
            if (res.data.resultCode == 1) {
              obj.PriceList = res.data.data;
            }
          },
          null
        );
      },
      GetPriceChange(obj, childItem) {
        var pObj = obj.PriceList.find(qitem => {
          return qitem.TCID === childItem.MTCID;
        });
        if (pObj) {
          childItem.MTCNUM = pObj.TCNUM;
        }
      },
      //删除拼团
      DeleteMergeSubItem(list, index) {
        list.splice(index, 1);
      },
      //添加拼团
      AddMergeSubItem(list) {
        list.push({
          ID: 0,
          PlanId: 0,
          MTCID: 0,
          MTCNUM: ""
        });
      },
      PayTypeChange(obj) {
        if (obj.PayType == 7) {
          obj.CostPrice = 0;
        }
        if (obj.HighSpeedPayType == 7) {
          obj.HighSpeedPrice = 0;
        }
      },
      /*获取车辆成本价格*/
      getBusPrice(obj) {
        if (this.isShowBtn != 1) {
          let tempCostFee = 0;
          var tempHighSpeedFee = 0;
          if (obj.AirportPickUp == 3 || obj.AirportPickUp == 4) {
            obj.PayType = 8;
          } else if (obj.AirportPickUp == 13) {
            obj.PayType = 7;
          } else {
            obj.PayType = 2;
          }
          //高速付款方式默认现付
          obj.HighSpeedPayType = 1;
          this.apipost(
            "bus_get_GetBusTypePriceByDateList", {
              StartDate: obj.PlanDateStr,
              Id: obj.BusType,
            },
            response => {
              if (response.data.resultCode == 1) {
                let busTypeObj = response.data.data;
                if (busTypeObj) {
                  //接送价格
                  if (obj.AirportPickUp == 1 || obj.AirportPickUp == 2) {
                    tempCostFee += parseFloat(busTypeObj.ReceivePrice);
                    //接送高速
                    tempHighSpeedFee += parseFloat(busTypeObj.PickUpHighSpeedFee);
                  }
                  //全天价格
                  if (obj.AirportPickUp == 12) {
                    tempCostFee += parseFloat(busTypeObj.AllDayPrice);
                    //全天高速
                    tempHighSpeedFee += parseFloat(busTypeObj.AllDayHighSpeedFee);
                  }
                  obj.HighSpeedPrice = tempHighSpeedFee;
                  obj.CostPrice = tempCostFee;

                  if (!obj.HighSpeedPrice) {
                    obj.HighSpeedPrice = 0;
                  }
                  if (!obj.CostPrice) {
                    obj.CostPrice = 0;
                  }
                }
              }
            },
            null
          );
        }
      },
      AddSubItem(item) {
        let msg = JSON.parse(JSON.stringify(item.BusPlanOrderList[0]));
        msg.Id = 0;
        item.BusPlanOrderList.push(msg);
      },
      DeleteSubItem(item, index) {
        var chooseitem = item.BusPlanOrderList[index];
        if (chooseitem.Id > 0) {
          this.apipost(
            "bus_Get_RemoveBusPlan", {
              ID: chooseitem.Id
            },
            res => {
              if (res.data.resultCode == 1) {
                item.BusPlanOrderList.splice(index, 1);
              }
            },
            null
          );
        } else {
          item.BusPlanOrderList.splice(index, 1);
        }
      },
      /*获取车辆类型列表*/
      getBusTypeList() {
        this.apipost(
          "bus_get_GetBusTypePriceList", {
            StartDate: this.parametersData.StartDate
          },
          res => {
            if (res.data.resultCode == 1) {
              this.BusTypeList = res.data.data;
              this.BusTypeList.forEach(item => {
                var tempStr = item.AreaTypeStr;
                if (item.BusTypeStr) {
                  tempStr += '-' + item.BusTypeStr;
                }
                item['newName'] = tempStr + '(' + item.UseNum + '座)';
              });
            }
          },
          null
        );
      },
      //获取供应商列表
      getSupplierList() {
        this.apipost(
          "supplier_post_GetAllList", {
            Type: 5
          },
          response => {
            if (response.data.resultCode == 1) {
              this.SupplierList = response.data.data;
            }
          },
          null
        );
      },
      //获取供应商下司机列表
      getDirverList(item) {
        var dMsg = {
          SupplierId: item.BusCompany
        }
        this.apipost(
          "supplier_post_GetBusSupplierManList", dMsg,
          response => {
            if (response.data.resultCode == 1) {
              item.DriverList = response.data.data;
            }
          },
          null
        );
      },
      //选择司机
      changeDirver(subItem) {
        subIte
      },
      /*生成表格数据*/
      createTableData() {
        this.loading = true;
        this.apipost(
          "bus_get_GetTravelBusDetailsTCIDs_V3", {
            TCIDs: this.parametersData.TCID
          },
          response => {
            this.loading = false;
            if (response.data.resultCode == 1) {
              var tempArray = response.data.data.busExtend.BusPlanReportList;
              if (tempArray && tempArray.length > 0) {
                tempArray.forEach(x => {
                  x.BusPlanOrderList.forEach(subItem => {
                    if (subItem.BookGroup == '' || subItem.BookGroup == null) {
                      subItem.BookGroup = this.NewCombinationNum;
                    }
                    subItem.DriverList = [];
                  })
                });
              }
              this.PlanTableData = tempArray;
              this.PostData = response.data.data.busExtend;
              this.CommonList = response.data.data.commonList;
              this.isShowBtn = response.data.data.busExtend.IsOperation;
            }
          },
          null
        );
      },
      SaveList(type) {
        this.PostData.BusPlanReportList.forEach(x => {
          x.BusPlanOrderList.forEach(y => {
            y.OrderState = type;
          })
        })
        this.saveLoading = true;
        this.apipost('bus_get_SetPlan_V2', this.PostData, res => {
          this.saveLoading = false;
          if (res.data.resultCode == 1) {
            this.Success(this.$t('tips.saveYes'));
            this.MsgBus.$emit('msg');
            this.createTableData();
          } else {
            this.Error(res.data.message);
          }
        }, err => {})
      },
      //司机住宿点击事件
      AccommodationCLick(value, item) {
        if (
          item.AccommodationType == "0" ||
          item.AccommodationType != value
        ) {
          item.AccommodationType = value;
        } else {
          item.AccommodationType = "0";
        }
      },
      /*获取接送机类型列表*/
      GetAirportPickUpList() {
        this.apipost(
          "bus_get_GetAirportPickUpList",
          null,
          response => {
            if (response.data.resultCode == 1) {
              this.BusAirportPickUpList = response.data.data;
            }
          },
          null
        );
      },
      /*获取司机住宿类型列表*/
      GeAccommodationTypeList() {
        this.apipost(
          "bus_get_GeAccommodationTypeList",
          null,
          response => {
            if (response.data.resultCode == 1) {
              this.AccommodationTypeArray = response.data.data;
            }
          },
          null
        );
      },
      goUrlT(path, TCNUMS, title) {
        this.$router.push({
          name: path,
          query: {
            tcmun: TCNUMS,
            blank: 'y',
            tab: title
          }
        })
      },
      //计算总成本
      CalculatePrice() {
        var CoastPrice = this.$commonUtils.CaluJsonArraySum(
          this.PlanTableData,
          "CostPrice",
          2
        );
        this.PostData.CostPrice = CoastPrice;
      },
      //获取同上信息
      getBeforeInfo(index, subIndex) {
        let oldPlanData = {};
        //判断是否为当天最后一条数据
        if (this.PlanTableData[index].BusPlanOrderList.length > 1) {
          if (subIndex == 0) {
            oldPlanData = this.PlanTableData[index - 1].BusPlanOrderList[this.PlanTableData[index - 1].BusPlanOrderList
              .length - 1];
          } else {
            oldPlanData = this.PlanTableData[index].BusPlanOrderList[subIndex - 1];
          }
        } else {
          oldPlanData = this.PlanTableData[index - 1].BusPlanOrderList[this.PlanTableData[index - 1].BusPlanOrderList
            .length - 1];
        }
        let newPlanData = this.PlanTableData[index].BusPlanOrderList[subIndex];
        newPlanData.AirportPickUp = oldPlanData.AirportPickUp;
        newPlanData.DriverName = oldPlanData.DriverName;
        newPlanData.DriverTel = oldPlanData.DriverTel;
        newPlanData.BusNum = oldPlanData.BusNum;
        newPlanData.BusCompany = oldPlanData.BusCompany;
        newPlanData.BusType = oldPlanData.BusType;
        newPlanData.PayType = oldPlanData.PayType;
        newPlanData.BookGroup = oldPlanData.BookGroup;
        newPlanData.HighSpeedPayType = oldPlanData.HighSpeedPayType;
      },
      GetAuth() {
        this.apipost('dmcstatistics_get_GetGetDmcTotalTablePageAuth', {}, res => {
          if (res.data.resultCode == 1) {
            this.IsEditBus = res.data.data.IsEditBus;
          } else {
            this.$message.error(res.data.message);
          }
        }, err => {})
      }

    },
    mounted() {
      this.currentUserInfo = this.getLocalStorage();
      this.GetAuth();
      this.GetAirportPickUpList();
      this.GeAccommodationTypeList();
      this.BusId = this.$route.query.id;
      this.title = this.$route.query.title;
      if (this.$route.query.NewCombinationNum) {
        this.NewCombinationNum = this.$route.query.NewCombinationNum;
      }
      this.parametersData.TCID = this.$route.query.TCID;
      this.parametersData.StartDate = this.$route.query.StartDate;
      this.parametersData.DayNum = this.$route.query.DayNum;
      this.parametersData.TotalNumber = this.$route.query.TotalNumber;
      this.PostData.TCID = this.parametersData.TCID;
      this.PostData.CarrierNum = this.parametersData.TotalNumber;
      this.createTableData();
      this.getBusTypeList();
      this.getSupplierList();
    }
  };
</script>