<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.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>{{$t('ground.huisongfei')}}</td>
          <td colspan="4" 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 :rules="rules">
        <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')" prop="HotelName" min-width="200"></el-table-column>
          <el-table-column fixed :label="$t('sm.yongchejihua')" min-width="180">
            <template slot-scope="scope">
              <!-- {{scope.$index+1}}  -->
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="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>
              车资报价:<font style="color:red">{{scope.row.BusOfferPrice}}</font>
            </template>
          </el-table-column>
          <el-table-column label="套团团号" min-width="230">
            <template slot-scope="scope">
              <div v-for="(subItem,subIndex) in scope.row.BusPlanOrderList" class="comBTM" :key="subIndex">
                <template v-if="subItem.AirportPickUp==15">
                  <div v-for="(childItem,childIndex) in subItem.MergeList" :key="childIndex">
                    <em>
                      <!--@change="GetTravelPrice(subItem)"-->
                      <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('ground.sijiName')" min-width="120">
            <template slot-scope="scope">
              <div v-for="subItem in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <el-input v-model="subItem.BusNum"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('hotel.hotel_Supplier')" min-width="150">
            <template slot-scope="scope">
              <div v-for="subItem in scope.row.BusPlanOrderList" class="comBTM">
                <el-select filterable :placeholder="$t('pub.pleaseSel')" v-model="subItem.BusCompany">
                  <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.busType')" min-width="150">
            <template slot-scope="scope">
              <div v-for="subItem in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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-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">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <span v-for="subItem in AccommodationTypeArray">
                  <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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,index) in scope.row.BusPlanOrderList" class="comBTM">
                  <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <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 in scope.row.BusPlanOrderList" class="comBTM">
                <el-input type="text" v-model="subItem.Remarks"></el-input>
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.park')" min-width="70">
            <template slot-scope="scope">
              <div v-for="subItem in scope.row.BusPlanOrderList" class="park_List comBTM">
                {{subItem.IsHavearking=='0'?'无':'有'}}
              </div>
            </template>
          </el-table-column>
          <el-table-column :label="$t('ground.xiaoji')" min-width="80">
            <template slot-scope="scope">
              <div v-for="subItem in scope.row.BusPlanOrderList" class="park_List comBTM">
                {{subItem.CostPrice*(Number(subItem.TransferNum)+1) + Number(subItem.HighSpeedPrice)}}
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="upBtnList">
          <input v-if="IsEditBus==0" type="button" class="normalBtn" :class="{'disClick':!isSubmit}"
            @click="SaveList(1)" :disabled="disButton" :value="$t('ground.baocuncaogao')" />
          <input v-if="IsEditBus==1" type="button" class="normalBtn" :class="{'disClick':!isSubmit}"
            @click="SaveList(1)" :disabled="disButton" :value="$t('pub.saveBtn')" />
          <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 {
        defaultSelectValue: 0,
        //车辆类型列表
        BusTypeList: [],
        /*供应商列表*/
        SupplierList: [],
        //地址参数
        BusId: 0,
        //地址参数
        parametersData: {
          TCID: 0,
          StartDate: "",
          DayNum: 0,
          TotalNumber: 0
        },
        PostData: {},
        //公用信息
        CommonList: [],
        //禁用文本框
        diabledValue: true,
        /*计划表数据*/
        forbidInput: false,
        PlanTableData: [],
        UseTypeArray: [], //用车类型
        BusAirportPickUpList: [], //用车类型
        //禁止重复提交禁用按钮
        disButton: false,
        //司机住宿类型
        AccommodationTypeArray: [],
        rules: {
          //表单必填验证
          BusCode: [{
            required: true,
            message: "请填写车配号",
            trigger: "change"
          }],
          DriverName: [{
            required: true,
            message: "请填写司机姓名",
            trigger: "change"
          }],
          DriverTel: [{
            required: true,
            message: "请填写联系电话",
            trigger: "change"
          }],
          BusType: [{
            required: true,
            message: "请选择车辆类型",
            trigger: "change"
          }],
          CarrierNum: [{
              required: true,
              message: "请填写核载人数",
              trigger: "change"
            },
            {
              pattern: this.$commonUtils.Regex.el_isInteger,
              message: "请输入正确的数字"
            }
          ],
          BusNum: [{
            required: true,
            message: "请填写车牌号码",
            trigger: "change"
          }],
          StartDate: [{
            required: true,
            message: "请选择开始时间",
            trigger: "change"
          }],
          UseDays: [{
              required: true,
              message: "请填写使用天数",
              trigger: "change"
            },
            {
              pattern: this.$commonUtils.Regex.el_isInteger,
              message: "请输入正确的数字"
            }
          ],
          SupplierId: [{
            required: true,
            message: "请选择供应商",
            trigger: "change"
          }],
          CostPrice: [{
              pattern: this.$commonUtils.Regex.el_Isdecimal,
              message: "请输入正确的价格"
            },
            {
              required: true,
              message: "请填写成本价",
              trigger: "change"
            }
          ],
          SalesPrice: [{
              pattern: this.$commonUtils.Regex.el_Isdecimal,
              message: "请输入正确的价格"
            },
            {
              required: true,
              message: "请填写内部价",
              trigger: "change"
            }
          ]
        },
        //团名
        title: '',
        //团号
        TCNUMS: '',
        //进出点
        InOut: '',
        //订单人数
        RealityNum: '',
        //机位总数
        totalFlySeat: '',
        LeaderName: '',
        GuideName: '',
        loading: false,
        isSubmit: true,
        isShowBtn: 1, //1禁用高速费，成本费，高速付款方式文本框
        IsEditBus: 0, //车辆修改权限
      };
    },
    methods: {
      //获取团期列表
      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 => {
                item['newName'] = item.AreaTypeStr + '-' + item.BusTypeStr
              });
            }
          },
          null
        );
      },
      /*获取供应商列表*/
      getSupplierList() {
        this.apipost(
          "supplier_post_GetAllList", {
            Type: 5
          },
          response => {
            if (response.data.resultCode == 1) {
              this.SupplierList = response.data.data;
            }
          },
          null
        );
      },
      /*生成表格数据*/
      createTableData() {
        this.loading = true;
        this.apipost(
          "bus_get_GetTravelBusDetailsTCIDs_V3", {
            TCIDs: this.parametersData.TCID
          },
          response => {
            this.loading = false;
            if (response.data.resultCode == 1) {
              this.PlanTableData = response.data.data.busExtend.BusPlanReportList;
              this.PlanTableData.forEach(x => {
                x.BusPlanOrderList.forEach(subItem => {
                  if (subItem.BookGroup == '' || subItem.BookGroup == null) {
                    subItem.BookGroup = this.$route.query.NewCombinationNum;
                  }
                })
              });
              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;
          })
        })
        if (this.isSubmit) {
          this.isSubmit = false;
          this.apipost('bus_get_SetPlan_V2', this.PostData, res => {
            this.isSubmit = true;
            if (res.data.resultCode == 1) {
              this.Success("保存成功！");
              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";
        }
      },
      /*获取用车类型列表*/
      GetUseTypeList() {
        this.apipost(
          "bus_get_GetUseTypeList",
          null,
          response => {
            if (response.data.resultCode == 1) {
              this.UseTypeArray = response.data.data;
            }
          },
          null
        );
      },
      /*获取接送机类型列表*/
      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
        );
      },
      goUrl(path) {
        this.$router.push({
          path: path
        });
      },
      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.GetAuth();
      this.GetUseTypeList();
      this.GetAirportPickUpList();
      this.GeAccommodationTypeList();
      this.BusId = this.$route.query.id;
      this.title = this.$route.query.title;
      this.TCNUMS = this.$route.query.TCNUMS;
      this.InOut = this.$route.query.InOut;
      this.RealityNum = this.$route.query.RealityNum;
      this.totalFlySeat = this.$route.query.TotalNumber + '/' + this.$route.query.RealityYSeatNum + '/' + this.$route
        .query.RealityESeatNum + '/' + this.$route.query.RealityFSeatNum;
      this.LeaderName = this.$route.query.LeaderName;
      this.GuideName = this.$route.query.GuideName;
      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>
