<style>
  @import "../../../assets/css/newTravelManager.css";

  .CostNewPrice .el-form-item__content,
  .CostNewPrice .el-form-item__label {
    line-height: 30px;
  }

  .CostNewPrice .CP_halfWi {
    width: 45%;
  }

  .CostNewPrice .QuotationFirstDiv1 {
    padding-top: 30px;
  }

  .CostNewPrice .CP_ComTitle2 {
    color: #106BAF;
    font-weight: bold;
    background-color: #D1EEEE;
    white-space: nowrap;
  }

  .CostNewTable {
    border-collapse: collapse;
  }

  .CostNewTable td {
    height: 40px;
    border: 1px solid #106BAF !important;
    border-collapse: collapse;
    padding: 0 3px;
  }

  .CostNewTable .el-input .el-input__inner {
    height: 25px !important;
    border: none;
    border-bottom: 1px solid #606266;
    padding-left: 5px !important;
  }

  .CP_ComTitle {
    color: #106BAF;
  }

  .w70 {
    width: 70px !important;
  }

  .CostcomCenter {
    text-align: center;
  }

  .txtRightCost {
    text-align: right;
    padding-right: 10px;
  }

  .CostNewPrice .el-form-item {
    margin-bottom: 0 !important;
  }

</style>

<template>
  <div>
    <div class="CostNewPrice clearfix CP_Div">
      <el-form>
        <table class="CostNewTable" style="width:1600px;">
          <thead>
            <tr>
              <td colspan="13" class="CP_ComTitle2 CostcomCenter">报价信息</td>
            </tr>
            <tr>
              <td class="CP_ComTitle2">默认报价单</td>
              <td colspan="12">
                <el-switch type="textarea" :disabled="!canEdit" v-model="IsDefault"
                  @change="queryMsg.IsDefault = IsDefault"></el-switch>
              </td>
            </tr>
            <tr>
              <td class="CP_ComTitle2 CostcomCenter" style="width:120px">币种</td>
              <td v-for='(item,index) in CostCurrencyList'>
                {{item.CurrencyName}}
                <span>
                  <i class="iconfont icon-quxiao" style="display:inline-block;" @click="DeleteCurrency(index)"></i>
                </span>
              </td>
              <td :colspan="13-2-CostCurrencyList.length+1">
                <el-form-item class="w70">
                  <el-select v-model='currencyType' @change="getRate(currencyType),addCurrency()">
                    <el-option v-for="item in currencyTypeArr" :label='item.Name' :value='item.ID' :key='item.ID'>
                    </el-option>
                  </el-select>
                </el-form-item>
              </td>
            </tr>
            <tr>
              <td class="CP_ComTitle2 CostcomCenter">汇率</td>
              <td v-for='item in CostCurrencyList'>
                <el-input class="w70" v-model='item.ExchangeRate'
                  @keyup.native="checkRate(item,'ExchangeRate'),getchange()">
                </el-input>
              </td>
              <td :colspan="13-2-CostCurrencyList.length+1">
                <el-input class="w70" v-model='queryMsg.RateInput'
                  @keyup.native="checkRate(queryMsg,'RateInput'),getchange()">
                </el-input>
              </td>
            </tr>
            <tr>
              <td class="CP_ComTitle2 CostcomCenter">人数</td>
              <td v-for="(item,index) in CostNumberList" :key='item.subCode'>
                <el-input class="w70" v-model='item.PeopleNumber' @keyup.native="checkInteger(item,'PeopleNumber')">
                </el-input>
                <span>
                  <i class="iconfont icon-quxiao" @click="DeletePNumber(index),getchange()"></i>
                </span>
              </td>
              <td :colspan="13-2-CostNumberList.length+1">
                <el-form-item>
                  <el-input placeholder="请填写人数" v-model='priceObj.priceNum' style="width:180px;"
                    @keyup.native="checkInteger(priceObj,'priceNum'),getchange()">
                    <el-button slot="append" class="iconfont icon-img_haha" @click="addPeoNunber"></el-button>
                  </el-input>
                </el-form-item>
                <div colspan="13" style="color: #f12121;font-weigth: bold;">填入人数后请点击"+"</div>
              </td>
            </tr>
          </thead>
          <tr>
            <td rowspan="2" style="width:100px" class="CP_ComTitle2 CostcomCenter">Day</td>
            <td rowspan="2" style="width:120px" class="CP_ComTitle2 CostcomCenter">币种</td>
            <td rowspan="2" style="width:180px" class="CP_ComTitle2 CostcomCenter">行程</td>
            <td colspan="2" style="width:220px;" class="CP_ComTitle2 CostcomCenter">酒店</td>
            <td colspan="2" style="width:120px" class="CP_ComTitle2 CostcomCenter">车/天</td>
            <td colspan="2" style="width:200px" class="CP_ComTitle2 CostcomCenter">餐</td>
            <td colspan="2" style="width:150px" class="CP_ComTitle2 CostcomCenter">门票</td>
            <td colspan="2" style="width:100px" class="CP_ComTitle2 CostcomCenter">其它费用<br />(保险、司导杂费等)</td>
          </tr>
          <tr>
            <td style="width:150px" class="CP_ComTitle2 CostcomCenter">酒店名称</td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">价格/人</td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">车资/天</td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">过路费<br />停车费/天</td>
            <td style="width:110px" class="CP_ComTitle2 CostcomCenter">餐厅名称<br /><span
                style="color:red;">填写餐厅名称才能带出价格</span></td>
            <td style="width:90px" class="CP_ComTitle2 CostcomCenter">价格/餐</td>
            <td style="width:100px" class="CP_ComTitle2 CostcomCenter">景点名称<br />
              <span style="color:red;">填写景点名称才能带出价格</span>
            </td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">价格/人</td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">名称</td>
            <td style="width:50px" class="CP_ComTitle2 CostcomCenter">{{$t('Operation.Op_price')}}</td>
          </tr>
          <template v-for="(subItem,subIndex) in dayCostPrice">
            <tr :key="subIndex">
              <td align="center">
                第{{subItem.DayNum}}天
                <br />
                {{GetDayStr(subItem.DayNum-1)}}
              </td>
              <td>
                <el-form-item>
                  <el-select v-model='subItem.CurrencyId' class="w100">
                    <el-option :label="$t('pub.unlimitedSel')" :value='defaultSelect'></el-option>
                    <el-option v-for="items in CostCurrencyList" :label='items.CurrencyName' :value='items.CurrencyId'
                      :key='items.CurrencyId'>
                    </el-option>
                  </el-select>
                </el-form-item>
              </td>
              <td>
                <el-input type="textarea" resize="none" style="width:180px;" v-model="subItem.Title"></el-input>
              </td>
              <td>
                酒店: <el-select filterable remote :remote-method="(query) => remoteSearchAdGroup(query, subItem)"
                  v-model='subItem.HotelId' placeholder="请输入酒店名称" :loading="loading"
                  @change="getHotel(subItem,subItem.HotelId)" style="width:135px;">
                  <el-option v-for="(x) in subItem.HotelList" :key="x.ID" :label="x.Name" :value='x.ID'>
                  </el-option>
                </el-select>
                <el-form-item label="含餐:">
                  <el-select v-model='subItem.ContainDinnerType' style="width:100px;" placeholder="含餐类型"
                    @change="DinnerTypeChange(subItem)">
                    <el-option label="含餐类型" :value='0'></el-option>
                    <el-option label="含早餐" :value='1'></el-option>
                    <el-option label="含晚餐" :value='2'></el-option>
                    <el-option label="含早晚餐" :value='3'></el-option>
                  </el-select>
                </el-form-item>
              </td>
              <td>
                <el-input type='text' v-model="subItem.HotelCostPrice" class="w70"
                  @keyup.native="checkPrice(subItem,'HotelCostPrice'),getchange(1)" placeholder="酒店价格"></el-input>
              </td>
              <td>
                <el-input type='text' v-model="subItem.BusCostPrice" class="w70"
                  @keyup.native="checkPrice(subItem,'BusCostPrice'),getchange(1)" placeholder="车资">
                </el-input>
              </td>
              <td>
                <el-input type='text' v-model="subItem.PassFee" class="w70"
                  @keyup.native="checkPrice(subItem,'PassFee'),getchange(1)" placeholder="过路费、请车费">
                </el-input>
              </td>
              <td>
                <template v-if="postConfig.LineId==14||postConfig.LineId==118">
                  早:<el-input placeholder="请输入餐厅名称" v-model="subItem.BreakfastName">
                    <el-button slot="append" icon="el-icon-search" @click="showDiningDig(subItem,1)">
                    </el-button>
                  </el-input>
                  <br />
                  午:<el-input placeholder="请输入餐厅名称" v-model="subItem.LunchName">
                    <el-button slot="append" icon="el-icon-search" @click="showDiningDig(subItem,2)">
                    </el-button>
                  </el-input>
                  <br />
                  晚:<el-input placeholder="请输入餐厅名称" v-model="subItem.DinnerName">
                    <el-button slot="append" icon="el-icon-search" @click="showDiningDig(subItem,3)">
                    </el-button>
                  </el-input>
                </template>
                <template v-else>
                  早:<el-input type="text"
                    :disabled="(subItem.ContainDinnerType==1||subItem.ContainDinnerType==3)?true:false"
                    v-model='subItem.BreakfastName' class="w120" placeholder="早餐名称"> </el-input>
                  <br />
                  午:<el-input type="text" v-model='subItem.LunchName' class="w120" placeholder="午餐名称"></el-input>
                  <br />
                  晚:<el-input type="text"
                    :disabled="(subItem.ContainDinnerType==2||subItem.ContainDinnerType==3)?true:false"
                    v-model='subItem.DinnerName' class="w120" placeholder="晚餐名称"></el-input>
                </template>
              </td>
              <td>
                <template v-if="postConfig.LineId==14||postConfig.LineId==118">
                  早:<el-input type="text" :disabled="true" v-model='subItem.BreakfastCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'BreakfastCostPrice'),getchange(1)"></el-input>
                  <br />
                  午:<el-input type="text" v-model='subItem.LunchCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'LunchCostPrice'),getchange(1)" :disabled="true"></el-input>
                  <br />
                  晚:<el-input type="text" :disabled="true" v-model='subItem.DinnerCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'DinnerCostPrice'),getchange(1)"></el-input>
                </template>
                <template v-else>
                  早:<el-input type="text"
                    :disabled="(subItem.ContainDinnerType==1||subItem.ContainDinnerType==3)?true:false"
                    v-model='subItem.BreakfastCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'BreakfastCostPrice'),getchange(1)"></el-input>
                  <br />
                  午:<el-input type="text" v-model='subItem.LunchCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'LunchCostPrice'),getchange(1)"></el-input>
                  <br />
                  晚:<el-input type="text"
                    :disabled="(subItem.ContainDinnerType==2||subItem.ContainDinnerType==3)?true:false"
                    v-model='subItem.DinnerCostPrice' class="w70"
                    @keyup.native="checkPrice(subItem,'DinnerCostPrice'),getchange(1)"></el-input>
                </template>

              </td>
              <td>
                <el-input type='text' v-model="subItem.TicketName" style="width:120px;" placeholder="景点名称"></el-input>
              </td>
              <td>
                <el-input type='text' v-model="subItem.ScenicCostPrice" class="w70"
                  @keyup.native="checkPrice(subItem,'ScenicCostPrice'),getchange(1)" placeholder="景点价格"></el-input>
              </td>
              <td>
                <el-input type="text" v-model='subItem.OtherName' class="w70" placeholder="杂支名称"></el-input>
              </td>
              <td>
                <el-input type="text" v-model='subItem.OtherPrice' class="w70"
                  @keyup.native="checkPrice(subItem,'OtherPrice'),getchange(1)"></el-input>
              </td>
            </tr>
          </template>
          <tr>
            <td colspan="3" class="CP_ComTitle2 CostcomCenter">
              外币小计
            </td>
            <!--酒店小计-->
            <td colspan="2">
              酒店小计: {{getDayXiaoJi(1,1)}}
            </td>
            <!--车资小计-->
            <td colspan="2">
              车资小计:{{getDayXiaoJi(2,1)}}
            </td>
            <!--餐小计-->
            <td colspan="2">
              餐小计: {{getDayXiaoJi(4,1)}}
            </td>
            <!--门票小计-->
            <td colspan="2">
              门票小计: {{getDayXiaoJi(3,1)}}
            </td>
            <!--其它费用小计-->
            <td colspan="2">
              杂支小计: {{getDayXiaoJi(9,1)}}
            </td>
          </tr>
          <tr>
            <td colspan="3" class="CP_ComTitle2 CostcomCenter">
              人民币小计
            </td>
            <!--酒店小计-->
            <td colspan="2">
              酒店小计: {{getDayXiaoJi(1,2)}}
            </td>
            <!--车资小计-->
            <td colspan="2">
              车资小计:{{getDayXiaoJi(2,2)}}
            </td>
            <!--餐小计-->
            <td colspan="2">
              餐小计: {{getDayXiaoJi(4,2)}}
            </td>
            <!--门票小计-->
            <td colspan="2">
              门票小计: {{getDayXiaoJi(3,2)}}
            </td>
            <!--其它费用小计-->
            <td colspan="2">
              杂支小计: {{getDayXiaoJi(9,2)}}
            </td>
          </tr>
          <tr>
            <td colspan="13">其它成本(人民币)</td>
          </tr>
          <tr>
            <td colspan="2">
              <el-form-item label="机票" label-position="right">
                <el-input type="text" v-model='OtherPrice.AirTicketMoeny' class="w100"
                  @keyup.native="checkPrice(OtherPrice,'AirTicketMoeny'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="中段机票">
                <el-input type="text" v-model='OtherPrice.InlandAirTicketMoney' class="w100"
                  @keyup.native="checkPrice(OtherPrice,'InlandAirTicketMoney'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="税金">
                <el-input type="text" v-model='teamPrice.TaxPrice' class="w100"
                  @keyup.native="checkPrice(teamPrice,'TaxPrice'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="联运">
                <el-input type="text" v-model='teamPrice.UnionPrice' class="w100"
                  @keyup.native="checkPrice(teamPrice,'UnionPrice'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td colspan="6" rowspan="2">
              小计(机票+中段机票+税金+联运+领队导游分摊+过夜+签证+保险):
              <br /> {{getCostTotalMoney()}}
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <el-form-item label="领队导游分摊">
                <el-input type='text' class="w100" v-model="OtherPrice.AirTicketShareMoney"
                  @keyup.native="checkPrice(OtherPrice,'AirTicketShareMoney'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="过夜">
                <el-input type="text" v-model='teamPrice.NightPrice' class="w100"
                  @keyup.native="checkPrice(teamPrice,'NightPrice'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="签证">
                <el-input type="text" v-model='teamPrice.VisaPrice' class="w100"
                  @keyup.native="checkPrice(teamPrice,'VisaPrice'),getchange()"></el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="保险">
                <el-input type='text' class="w100" v-model="OtherPrice.SafeMoney"
                  @keyup.native="checkPrice(OtherPrice,'SafeMoney'),getchange()"></el-input>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td colspan="13"></td>
          </tr>
          <tr>
            <td colspan="2">
              <el-form-item label="婴儿">
                <el-input v-model="teamPrice.BabyPrice" @keyup.native="checkInteger(teamPrice,'BabyPrice')" class="w70">
                </el-input>
              </el-form-item>
            </td>
            <td>
              <el-form-item label="单地接(成本)">
                <el-input v-model="teamPrice.SingleDMCPrice" @keyup.native="checkInteger(teamPrice,'SingleDMCPrice')"
                  @blur="getchange()" class="w70">
                </el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="儿童不占床">
                <el-input placeholder="" v-model="teamPrice.ChildNoNeedPrice"
                  @keyup.native="checkInteger(teamPrice,'ChildNoNeedPrice')" class="w70">
                </el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="儿童占床">
                <el-input placeholder="" v-model="teamPrice.ChildNeedPrice"
                  @keyup.native="checkInteger(teamPrice,'ChildNeedPrice')" class="w70">
                </el-input>
              </el-form-item>
            </td>
            <td colspan="2">
              <el-form-item label="单房差">
                <el-input placeholder="" v-model="teamPrice.SingleRoomPrice"
                  @keyup.native="checkPrice(teamPrice,'SingleRoomPrice')" class="w70">
                </el-input>
              </el-form-item>
            </td>
            <td colspan="4">
              <el-form-item label="单地接(价格)">
                <el-input placeholder="" v-model="teamPrice.SingleDMCTCPrice"
                  @keyup.native="checkPrice(teamPrice,'SingleDMCTCPrice')" class="w70">
                </el-input>
              </el-form-item>
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <el-form-item label="主OP">
                <el-select class="w100" v-model="postConfig.OPId" :placeholder="$t('pub.pleaseSel')" filterable>
                  <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
                  <el-option v-for="(item,index) in EmployeeList" :label="item.EmName" :value="item.EmployeeId"
                    :key="index">
                  </el-option>
                </el-select>
              </el-form-item>
              <span style="color:red">关联提成,请正确填写</span>
            </td>
            <td colspan="3">
              <el-form-item label="助理OP">
                <el-select class="w250" v-model="postConfig.Assistantlist" :placeholder="$t('pub.pleaseSel')" filterable
                  multiple>
                  <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
                  <el-option v-for="(item,index) in EmployeeList" :label="item.EmName" :value="item.EmployeeId"
                    :key="index"></el-option>
                </el-select>
              </el-form-item>
              <span style="color:red">关联提成,请正确填写;美工有单独的配置,请不要配置在助理OP里面。</span>
            </td>
            <td colspan="2">
              <el-form-item label="付款方式">
                <el-select class="w70" v-model="postConfig.SaleOfferPayType" :placeholder="$t('pub.pleaseSel')"
                  filterable>
                  <el-option :label="$t('pub.unlimitedSel')" :value='0'></el-option>
                  <el-option v-for="item in payTypeList" :label='item.label' :value='item.value' :key='item.value'>
                  </el-option>
                </el-select>
              </el-form-item>
            </td>
            <td colspan="6">
              附件: <el-upload v-if="!teamPrice.ContractArray || !teamPrice.ContractArray.length" class="upload-demo"
                style="display:inline-block;position:relative;top:-1px;left:3px;" :http-request="UploadAttachment"
                :show-file-list="false" action="">
                <el-button size="small" type="primary">报价单附件</el-button>
              </el-upload>
              <template v-if="teamPrice.ContractArray&& teamPrice.ContractArray.length>0">
                <template v-for="(subItem,subIndex) in teamPrice.ContractArray">
                  <a style="margin-left:20px;color:blue;cursor:pointer;" target="_blank" :key="subIndex"
                    @click="downloadFile(subItem.Url,subItem.Name)">{{subItem.Name}}</a>
                  <a :key="subIndex+1000" style="margin-left:20px;color:blue;cursor:pointer;"
                    @click="DeleteFile(subIndex)">删除</a>
                </template>
              </template>
            </td>
          </tr>
          <tr>
            <td colspan="13"></td>
          </tr>
          <tfoot>
            <tr>
              <td>
              </td>
              <td>
                人数
              </td>
              <td colspan="2">
                酒店+车+餐+门票+杂支
              </td>
              <td>
                地接成本<br />(外币)
              </td>
              <td>
                地接成本<br />(人民币)
              </td>
              <td colspan="2">
                成本<br />[单地接+其它成本(人民币)小计]
              </td>
              <td>
                同业销售价格
                <br />(人民币)
              </td>
              <td>
                直客销售价格
                <br />(人民币)
              </td>
              <td>
                <template v-if="postConfig.LineId==14||postConfig.LineId==118">
                  销售价格
                  <br />(日币)
                </template>
              </td>
              <td colspan="2">
                备注
              </td>
            </tr>
            <!--已填写人数-->
            <template v-if="CostNumberList&&CostNumberList.length>0">
              <template v-for="(subItem,subIndex) in CostNumberList">
                <tr :key="subIndex">
                  <td v-if="subIndex==0" :rowspan="CostNumberList.length">
                    合计
                  </td>
                  <td>
                    {{subItem.PeopleNumber}}
                  </td>
                  <td colspan="2">
                    {{getDayXiaoJi(1,1)}}(酒)+
                    {{ (getDayXiaoJi(2,1)/subItem.PeopleNumber).toFixed(2)}}(车=总车资/人数)+{{getDayXiaoJi(4,1)}}(餐)+{{getDayXiaoJi(3,1)}}(门票)
                    +{{(getDayXiaoJi(9,1)/subItem.PeopleNumber).toFixed(2)}}(杂支=总杂支/人数)
                  </td>
                  <td>
                    {{getLocalJpyTotalMoney(subItem.PeopleNumber)}}
                  </td>
                  <td>
                    <template v-if="teamPrice&&teamPrice.SingleDMCPrice&&teamPrice.SingleDMCPrice>0">
                      {{teamPrice.SingleDMCPrice}}
                    </template>
                    <template v-else-if="postConfig.LineId==14||postConfig.LineId==118">
                      {{getLocalTotalMoney(subItem.PeopleNumber)}}
                    </template>
                    <template v-else-if="postConfig.LineId==168">
                      {{getLocalTotalMoney(subItem.PeopleNumber)}}
                    </template>
                    <template v-else>
                      {{subItem.SubtotalMoney}}
                    </template>
                  </td>
                  <td colspan="2">
                    {{subItem.TotalMoney}}
                  </td>
                  <td>
                    <el-input type='text' class="w70" v-model="subItem.SalePrice"
                      @keyup.native="checkPrice(subItem,'SalePrice')" maxlength="8"></el-input>
                  </td>
                  <td>
                    <el-input type='text' class="w70" v-model="subItem.B2CSalePrice"
                      @keyup.native="checkPrice(subItem,'B2CSalePrice')" maxlength="8"></el-input>
                  </td>
                  <td>
                    <el-input v-if="postConfig.LineId==14||postConfig.LineId==118" type='text' class="w70"
                      v-model="subItem.JPYSalePrice" @keyup.native="checkPrice(subItem,'JPYSalePrice')" maxlength="8">
                    </el-input>
                  </td>
                  <td colspan="2">
                    <el-input type="textarea" v-model="subItem.CostRemark"></el-input>
                  </td>
                </tr>
              </template>
            </template>
          </tfoot>
        </table>
        <div class="Cost_Line">
        </div>
      </el-form>
    </div>
    <el-dialog custom-class='w750' :title="dialogDiningTitle" :visible.sync="isShowDiningDig" center>
      <travelDinner v-if="isShowDiningDig" :qMsg="qMsg" @chooseDinner="chooseDinner" @closeDinner="closeDinner"
        :otherDinner="otherDinner" :breakFirstList="breakFirstList"></travelDinner>
    </el-dialog>
  </div>
</template>
<script>
  import travelDinner from '@/components/commonPage/travelDinner'
  export default {
    props: ["postConfig", "OtherPrice", "dayCostPrice", "LineList", "CostNumberList", "CurrencyNumberListExt",
      "CostCurrencyList", "teamPrice", 'queryMsg'
    ],
    data() {
      return {
        canEdit: true,
        IsDefault: false,
        //下拉框默认值
        defaultSelect: 0,
        //币种下拉
        currencyType: "",
        currencyTypeArr: [], //币种下拉列表
        priceObj: {
          priceNum: "", //人数
        },
        payTypeList: [{
          value: 1,
          label: '现金'
        }, {
          value: 2,
          label: '汇款'
        }, {
          value: 3,
          label: '外站自理'
        }],
        loading: false,
        EmployeeList: [], //员工列表
        dialogDiningTitle: "选择餐厅",
        qMsg: {
          Country: 651,
          DinnerType: 0, //1-早餐,2-午餐,3-晚餐
        },
        clickDinner: {},
        isShowDiningDig: false, //是否显示选择餐弹窗
        breakFirstList: [], //午餐、晚餐默认类型
        otherDinner: [], //早餐默认类型
      }
    },
    components: {
      travelDinner: travelDinner,
    },
    methods: {
      //关闭弹窗
      closeDinner() {
        this.isShowDiningDig = false;
        this.clickDinner = {};
        this.qMsg.DinnerType = 0;
      },
      chooseDinner(obj) {
        if (this.qMsg.DinnerType == 1) {
          this.clickDinner.BreakfastName = obj.DiningName;
        } else if (this.qMsg.DinnerType == 2) {
          this.clickDinner.LunchName = obj.DiningName;
          this.clickDinner.LunchCostPrice = obj.UnitPrice;
          this.clickDinner.LunchIds = obj.DiningId;
        } else if (this.qMsg.DinnerType == 3) {
          this.clickDinner.DinnerName = obj.DiningName;
          this.clickDinner.DinnerCostPrice = obj.UnitPrice;
          this.clickDinner.DinnerIds = obj.DiningId;
        }
        this.isShowDiningDig = false;
        this.clickDinner = {};
        this.qMsg.DinnerType = 0;
      },
      showDiningDig(item, dinnerType) {
        this.qMsg.DinnerType = dinnerType;
        this.clickDinner = item;
        this.isShowDiningDig = true;
      },
      GetDayStr(dayNum) {
        var str = "";
        if (this.postConfig.OutDateTime && this.postConfig.OutDateTime != '') {
          var dateFormat = new Date(this.postConfig.OutDateTime);
          dateFormat = dateFormat.setDate(dateFormat.getDate() + dayNum);
          dateFormat = new Date(dateFormat);
          let y = dateFormat.getFullYear()
          let m = (dateFormat.getMonth() + 1).toString().padStart(2, '0')
          let d = dateFormat.getDate().toString().padStart(2, '0')
          str = `${y}-${m}-${d}`;
        }
        return str;
      },
      // 获取酒店名称
      getHotel(subItem, HotelId) {
        subItem.HotelList.forEach(x => {
          if (x.ID == HotelId) {
            subItem.HotelName = x.Name
          }
        })
        this.$forceUpdate()
      },
      remoteSearchAdGroup(query, subItem) {
        if (query !== '') {
          this.loading = true;
          this.initHotel(query, subItem)
        } else {
          subItem.HotelList = []
          this.HotelName = [];
        }
      },
      // //搜索餐厅
      // remoteSearchDinner(query, dinnerType, subItem) {
      //   if (query !== '') {
      //     this.loading = true;
      //     this.initDinner(query, dinnerType, subItem)
      //   } else {
      //     if (dinnerType == 2) {
      //       subItem.LunchList = []
      //       this.DLunch = [];
      //     } else {
      //       subItem.DinnerList = []
      //       this.DDinner = [];
      //     }
      //   }
      // },
      // //初始化餐厅列表
      // initDinner(query, dinnerType, subItem, day) {
      //   this.apipost(
      //     "dining_post_GetOfferDinnerListService", {
      //       Name: query
      //     },
      //     res => {
      //       this.loading = false
      //       if (res.data.resultCode == 1) {
      //         var tempData = res.data.data;
      //         if (dinnerType == 2) {
      //           subItem.LunchList = tempData;
      //         } else if (dinnerType == 3) {
      //           subItem.DinnerList = tempData;
      //         }
      //         if (day) {
      //           for (let i = 0; i < this.dayCostPrice.length; i++) {
      //             if (!this.dayCostPrice[i].LunchList || this.dayCostPrice[i].LunchList.length == 0) {
      //               this.dayCostPrice[i].LunchList = tempData;
      //             }
      //             if (!this.dayCostPrice[i].DinnerList || this.dayCostPrice[i].DinnerList.length == 0) {
      //               this.dayCostPrice[i].DinnerList = tempData;
      //             }
      //           }
      //         }
      //         this.$forceUpdate()
      //       }
      //     },
      //     null
      //   );
      // },
      // 获取餐厅名称
      getDinner(subItem, dinnerType, dinnerIds) {
        if (dinnerType == 2) {
          subItem.LunchList.forEach(x => {
            if (x.ID == dinnerIds) {
              subItem.LunchName = x.Name;
              subItem.LunchCostPrice = x.UnitPrice;
            }
          })
        } else if (dinnerType == 3) {
          subItem.DinnerList.forEach(x => {
            if (x.ID == dinnerIds) {
              subItem.DinnerName = x.Name;
              subItem.DinnerCostPrice = x.UnitPrice;
            }
          })
        }
        this.$forceUpdate()
      },
      //初始化酒店列表
      initHotel(query, subItem, day) {
        this.apipost(
          "hotel_post_GetList", {
            Name: query
          },
          res => {
            this.loading = false
            if (res.data.resultCode == 1) {
              if (day == null) {
                for (let i = 0; i < this.dayCostPrice.length; i++) {
                  if (!this.dayCostPrice[i].HotelList || this.dayCostPrice[i].HotelList.length == 0) {
                    this.dayCostPrice[i].HotelList = res.data.data
                  }
                }
                if (subItem && (subItem.HotelList || subItem.HotelList.length > 0)) {
                  subItem.HotelList = res.data.data
                }
              } else if (day != null) {
                this.dayCostPrice[day].HotelList = res.data.data
              }
              this.$forceUpdate()
            }
          },
          null
        );
      },
      //删除文件
      DeleteFile(subIndex) {
        this.teamPrice.ContractArray.splice(subIndex, 1);
      },
      //下载文件
      downloadFile(fileUrl, fileName) {
        const link = document.createElement('a');
        link.href = fileUrl;
        link.download = fileName;
        document.body.appendChild(link);
        link.click();
      },
      UploadAttachment(file) { //上传
        let newArr = [];
        newArr.push(file.file)
        let path = "/Upload/Temporary/"
        this.$message.info(this.$t('tips.shangchuanzhong'))
        this.UploadSelfFileT(path, newArr, x => {
          var newUrl = this.domainManager().ViittoFileUrl + x.data.FilePath;
          this.teamPrice.ContractArray.push({
            Name: x.data.SourceFileName,
            Url: newUrl
          });
          this.teamPrice.ContractUrl = newUrl;
          this.Success(this.$t('tips.scchenggong'))
        });
      },
      //含餐类型切换
      DinnerTypeChange(subItem) {
        switch (subItem.ContainDinnerType) {
          //含早餐
          case 1:
            subItem.BreakfastCostPrice = 0;
            break;
            //含晚餐
          case 2:
            subItem.DinnerCostPrice = 0;
            break;
          case 3:
            subItem.BreakfastCostPrice = 0;
            subItem.DinnerCostPrice = 0;
            break;
        }
      },
      //每天小计
      getDayXiaoJi(type, currencyType) {
        var xiaoJi = 0;
        this.dayCostPrice.forEach(item => {
          var currencyRate = 1;
          if (currencyType == 2) {
            currencyRate = this.getCurrencyMoney(item.CurrencyId);
          }
          //酒店
          if (type == 1) {
            xiaoJi += Number(item.HotelCostPrice) * Number(currencyRate);
          }
          //车
          if (type == 2) {
            xiaoJi += Number(item.BusCostPrice) * Number(currencyRate);
            //过路费
            xiaoJi += Number(item.PassFee) * Number(currencyRate);
          }
          //景点
          if (type == 3) {
            xiaoJi += Number(item.ScenicCostPrice) * Number(currencyRate);
          }
          //餐合计
          if (type == 4) {
            xiaoJi += Number(item.BreakfastCostPrice) * Number(currencyRate);
            xiaoJi += Number(item.DinnerCostPrice) * Number(currencyRate);
            xiaoJi += Number(item.LunchCostPrice) * Number(currencyRate);
          }
          //回佣
          if (type == 8) {
            xiaoJi += Number(item.RebatePrice) * Number(currencyRate);
          }
          //杂费
          if (type == 9) {
            xiaoJi += Number(item.OtherPrice) * Number(currencyRate);
          }
        });
        return xiaoJi.toFixed(0);
      },
      //获取汇率
      getCurrencyMoney(currencyId) {
        let currency = 1;
        this.CostCurrencyList.forEach(x => {
          if (x.CurrencyId == currencyId) {
            currency = x.ExchangeRate;
          }
        });
        return currency;
      },
      //获取币种名称
      getCurrencyName(currencyId) {
        let CurrencyName = "";
        this.CostCurrencyList.forEach(x => {
          if (x.CurrencyId == currencyId) {
            CurrencyName = x.CurrencyName;
          }
        });
        return CurrencyName;
      },
      //判断币种是否相等
      checkExists(CurrencyId) {
        var flag = false;
        this.CurrencyNumberListExt.forEach(item => {
          if (!flag && item.Key == CurrencyId) {
            flag = true;
          }
        });
        return flag;
      },
      //其它成本价格
      getCostTotalMoney() {
        //机票+中段机票+税金+领队导游分摊+联运+过夜+保险
        let totalMoney = this.getConvertMoney(this.OtherPrice.AirTicketMoeny) +
          this.getConvertMoney(this.OtherPrice.InlandAirTicketMoney) +
          this.getConvertMoney(this.teamPrice.TaxPrice) +
          this.getConvertMoney(this.teamPrice.UnionPrice) +
          this.getConvertMoney(this.OtherPrice.AirTicketShareMoney) +
          this.getConvertMoney(this.teamPrice.NightPrice) +
          this.getConvertMoney(this.teamPrice.VisaPrice) +
          this.getConvertMoney(this.OtherPrice.SafeMoney)
        return totalMoney;
      },
      //获取币种对应 的人数报价
      getCurrencyNumberList(CurrencyId) {
        let currencyNumberList = [];
        let flag = false;
        this.CurrencyNumberListExt.forEach(item => {
          if (!flag && item.Key == CurrencyId) {
            flag = true;
            currencyNumberList = item.currencyNumberList;
          }
        });
        return currencyNumberList;
      },
      //添加币种
      addCurrency() {
        var currencyId = this.currencyType;
        var ckedName;
        var ckedRate = this.queryMsg.RateInput;
        if (currencyId == "") {
          this.Info("请选择币种");
          return;
        }
        if (ckedRate == "") {
          this.Info("请输入汇率");
          return;
        }
        this.currencyTypeArr.forEach(x => {
          if (currencyId == x.ID) {
            ckedName = x.Name;
          }
        });
        if (
          this.$tripUtils.isInObjArr(
            this.CostCurrencyList,
            "CurrencyId",
            currencyId
          )
        ) {
          this.Info("币种已经存在");
          return;
        }
        var CurObj = this.$tripUtils.CostCurrency();
        CurObj.CurrencyName = ckedName;
        CurObj.ExchangeRate = ckedRate;
        CurObj.CurrencyId = currencyId;
        this.CostCurrencyList.push(CurObj);
        this.currencyType = "";
        this.queryMsg.RateInput = "";
        let currencyNumberItem = {
          Key: currencyId,
          currencyNumberList: []
        };
        if (this.CurrencyNumberListExt.length > 0) {
          if (
            this.CurrencyNumberListExt[0].currencyNumberList
            .length > 0
          ) {
            this.CurrencyNumberListExt[0].currencyNumberList.forEach(
              x => {
                let tempData = JSON.parse(JSON.stringify(x));
                tempData.CurrencyId = currencyId;
                tempData.Money = 0.0;
                currencyNumberItem.currencyNumberList.push(tempData);
              }
            );
          }
        }
        this.CurrencyNumberListExt.push(currencyNumberItem);
        //默认添加币种第一个币种
        if (this.dayCostPrice && this.dayCostPrice.length > 0) {
          this.dayCostPrice.forEach(subItem => {
            subItem.CurrencyId = currencyId;
          })
        }
      },
      //添加人数费用
      addPeoNunber() {
        var PeopleNumber = this.priceObj.priceNum;
        if (PeopleNumber == "") {
          this.Info("请输入人数");
          return;
        }
        if (
          this.$tripUtils.isInObjArr(
            this.CostNumberList,
            "PeopleNumber",
            PeopleNumber
          )
        ) {
          this.Info("人数已经存在");
          return;
        }
        var CostNumberObj = this.$tripUtils.CostNumber();
        CostNumberObj.PeopleNumber = PeopleNumber;
        this.CostNumberList.push(CostNumberObj);
        this.CurrencyNumberListExt.forEach(x => {
          var CurrencyNumberObj = this.$tripUtils.CurrencyNumber();
          CurrencyNumberObj.CurrencyId = x.Key;
          CurrencyNumberObj.PeopleNumber = PeopleNumber;
          x.currencyNumberList.push(CurrencyNumberObj);
        });
        this.priceObj.priceNum = "";
        this.queryMsg.PeopleNumber = "";
        this.queryMsg.Money = "";
        this.shortPeopleNumber();
      },
      //删除币种
      DeleteCurrency(index) {
        this.CostCurrencyList.splice(index, 1);
      },
      //删除人数
      DeletePNumber(index) {
        this.CostNumberList.splice(index, 1);
      },
      //人数排序
      shortPeopleNumber() {
        this.CurrencyNumberListExt.forEach(x => {
          x.currencyNumberList.sort(
            this.$commonUtils.createComprisonFunction("PeopleNumber")
          );
        });
        this.CostNumberList.sort(
          this.$commonUtils.createComprisonFunction("PeopleNumber")
        );
      },
      //币种下拉获取汇率
      getRate(ID) {
        this.currencyTypeArr.forEach(x => {
          if (x.ID == ID) {
            this.queryMsg.RateInput = x.CurrentRate;
          }
        });
      },
      //获取所有币种
      getAllCurrency() {
        this.apipost(
          "financeinfo_post_GetList", {},
          res => {
            if (res.data.resultCode == 1) {
              this.currencyTypeArr = res.data.data;
              this.currencyTypeArr.forEach(item => {
                if (item.ID == 3) {
                  //徐总说日元默认加0.002
                  item.CurrentRate = Number(item.CurrentRate) + Number(0.002);
                }
              });
            }
          },
          err => {}
        );
      },
      //计算总价
      getSubtotalMoney() {
        let that = this;
        this.CostNumberList.forEach(x => {
          //房餐车景点价格
          var trip = Number(that.getLocalTotalMoney(x.PeopleNumber));
          var jpyTrip = Number(that.getLocalJpyTotalMoney(x.PeopleNumber));
          //其他价格
          var otherPrice = Number(that.getCostTotalMoney());
          var jpyotherPrice = 0;
          var SingleDMCPrice = 0;
          if (that.teamPrice && that.teamPrice.SingleDMCPrice) {
            SingleDMCPrice = Number(that.teamPrice.SingleDMCPrice);
          }
          x.TotalMoney = (otherPrice + SingleDMCPrice).toFixed(0);
          x.JPYTotalMoney = (jpyTrip + jpyotherPrice).toFixed(2);
        });
      },
      //价格转换器
      getConvertMoney(value) {
        if (value === "" || value === undefined || value === null) {
          value = 0.0;
        }
        return parseFloat(value);
      },
      //获取地接项目(人民币)
      getLocalTotalMoney(PeopleNumber) {
        let totalMoney = 0.0;
        if (PeopleNumber <= 0) {
          PeopleNumber = 1;
        }
        var hotelPrice = Number(this.getDayXiaoJi(1, 2)); //酒店费用
        var sencePrice = Number(this.getDayXiaoJi(3, 2)); //景点费用
        var canPrice = Number(this.getDayXiaoJi(4, 2)); //餐
        var otherPrice = Number(this.getDayXiaoJi(9, 2)) / PeopleNumber; //其它费用
        var busFee = Number(this.getDayXiaoJi(2, 2)) / PeopleNumber; //车费
        totalMoney = busFee + hotelPrice + sencePrice + canPrice + otherPrice;
        totalMoney = totalMoney.toFixed(2);
        return totalMoney;
      },
      //获取地接项目报价(日元)
      getLocalJpyTotalMoney(PeopleNumber) {
        if (PeopleNumber <= 0) {
          PeopleNumber = 1;
        }
        let totalMoney = 0.0;
        var busFee = Number(this.getDayXiaoJi(2, 1)) / PeopleNumber;
        var hotelPrice = Number(this.getDayXiaoJi(1, 1)); //酒店费用
        var sencePrice = Number(this.getDayXiaoJi(3, 1)); //景点费用
        var canPrice = Number(this.getDayXiaoJi(4, 1)); //早餐
        var otherPrice = Number(this.getDayXiaoJi(9, 1)) / PeopleNumber; //其它费用
        totalMoney = busFee + hotelPrice + sencePrice + canPrice + otherPrice;
        return totalMoney.toFixed(2);
      },
      getchange(type) {
        this.getSubtotalMoney();
        var that = this;
        var tempPrice = 0;
        this.CostNumberList.forEach(x => {
          //房餐车景点价格
          tempPrice = Number(that.getLocalTotalMoney(x.PeopleNumber));
        });
        if (this.teamPrice.SingleDMCPrice <= 0 || (type && type == 1)) {
          this.teamPrice.SingleDMCPrice = tempPrice.toFixed(0);
        }
      },
      //员工列表
      getEmployeeList() {
        let userInfo = this.getLocalStorage();
        let msg = {
          GroupId: userInfo.RB_Group_id,
          BranchId: "-1",
          DepartmentId: "-1",
          PostId: "-1",
          IsLeave: "0"
        };
        this.apipost(
          "admin_get_EmployeeGetList", msg,
          res => {
            if (res.data.resultCode == 1) {
              this.EmployeeList = res.data.data;
            }
          }
        );
      },
      //获取配置餐厅信息
      getConfigDinnerList() {
        this.apipost(
          "travel_get_GetConfigDinnerList", {},
          res => {
            if (res.data.resultCode == 1) {
              this.breakFirstList = res.data.data.breakFirstList;
              this.otherDinner = res.data.data.otherDinner;
            }
          },
          err => {}
        );
      }
    },
    mounted() {
      this.IsDefault = this.queryMsg.IsDefault;
      this.canEdit = this.queryMsg.canEdit;
      this.getSubtotalMoney();
      this.getAllCurrency();
    },
    created() {
      this.getEmployeeList();
      this.getConfigDinnerList();
    },
    watch: {
      postConfig: {
        handler: function (val, oldVal) {
          this.IsDefault = this.queryMsg.IsDefault
          this.canEdit = this.queryMsg.canEdit
        },
        deep: true
      },
      CostNumberList: {
        handler: function (val, oldVal) {
          this.IsDefault = this.queryMsg.IsDefault
          this.canEdit = this.queryMsg.canEdit
          this.getchange()
        },
        deep: true
      },
      dayCostPrice: {
        handler(val, oldVal) {
          // 初始化酒店
          setTimeout(() => {
            if (this.dayCostPrice && this.dayCostPrice.length > 0) {
              let arrList = function (list) {
                list.forEach(x => {
                  x.HotelList = [];
                  x.LunchList = [];
                  x.DinnerList = [];
                })
              }
              arrList(this.dayCostPrice)
              for (let i = 0; i < this.dayCostPrice.length; i++) {
                if (this.dayCostPrice[i].HotelName != '') {
                  this.initHotel(this.dayCostPrice[i].HotelName, this.dayCostPrice[i], i)
                }
                // if (this.dayCostPrice[i].LunchIds != '') {
                //   this.initDinner(this.dayCostPrice[i].LunchName, 2, this.dayCostPrice[i], i)
                // }
                // if (this.dayCostPrice[i].DinnerIds != '') {
                //   this.initDinner(this.dayCostPrice[i].DinnerName, 3, this.dayCostPrice[i], i)
                // }
              }
            }
          }, 100)
        },
        deep: true,
      }
    },
  };

</script>