<style>
  .singlePrice {
    width: 100%;
    position: relative;
    margin-bottom: 15px;
    background-color: #fff;
    padding: 0 20px 20px 20px;
    border-radius: 4px;
  }

</style>
<template>
  <div class="DirectQuotation clearfix" v-loading="loading">
    <div class="singlePrice clearfix">
      <CostNewPriceAudit v-if="haveData" ref="CostNewPrice" :postConfig="postData" :OtherPrice="otherPrice"
        :OfferArray="OfferArray" :dayCostPrice="dayCostPriceList" :CostCurrencyList="CostCurrencyList"
        :CostNumberList="CostNumberList" :CurrencyNumberListExt="CurrencyNumberListExt" :teamPrice="teamPrice"
        :IsEdit="IsEdit"></CostNewPriceAudit>
    </div>
  </div>
</template>
<script>
  import CostNewPriceAudit from "../TravelNewQuotation/CostNewPriceAudit";
  export default {
    data() {
      return {
        haveData: false,
        OfferArray: [],
        ConfigID: 0,
        IsShow: false,
        //基本配置
        postData: {
          ID: 0,
          StartCityId: 0,
          LineId: 0,
          LineteamId: 0,
          Title: "",
          IsOrder: 1,
          IsSubstitution: 1,
          IsB2B: 1,
          IsB2C: 1,
          FSeat: 0,
          CSeat: 0,
          YSeat: 0,
          //最低成团人数
          LowNum: 0,
          //OP备注
          OpRemark: "",
          //产品经理备注
          ProductRecommend: "",
          IsDirect: 0, //是否直采（0-否-1-是）【全部默认非直采】
          PriceIsDirect: 1, //是否直采报价（1-否-2-是）【全部默认非直采】
          PDFAlias: "", //pdf别名
          ImgCover: "", //封面图
          DayNum: 0, //天数
          NightNum: 0, //晚数
          StartCityId: 0,
          ReturnArriveCityId: 0, //返回抵达城市
          CustomerName: "", //客户名称
          TeamType: 0, //团队类型,
          LineName: "", //线路名称
          LtName: "", //系列名称
          OutBranchId: -1, //出团公司
          OutBranchName: "", //出团公司名称
          OutDateTime: "", //出发时间
          OfferPayType: 0, //报价单付款方式()
          SaleOfferPayType: 0, //售价付款方式
          AuditContent: "", //审核备注
          AuditByName: "", //审核人员
          AuditDate: "", //审核日期
          TravelState: 0, //审核状态
          ManagerAduitContent: "", //欧洲线审核备注
          ManagerAduitDate: "", //欧洲线审核日期
          ManagerAduitName: "", //欧洲线审核人员
          ManagerAduitStatus: 0, //欧洲线审核状态(1-通过，2-驳回)
          OPName: "", //主OP
          AssistantList: [], //助理OP
        },
        dayCostPriceList: [], //报价列表
        isSubmit: true,
        otherPrice: {
          CostId: 0, //主键编号
          ConfigID: 0, //配置编号
          OfferId: 0, //报价单编号
          InlandAirTicketCurrency: 0, //内陆段机位币种
          InlandAirTicketMoney: 0, //内陆段机位金额（每人）
          InlandShipTicketCurrency: 0, //内陆段船票币种
          InlandShipTicketMoney: 0, //内陆段船票金额（每人）
          InlandTrainTicketCurrency: 0, //内陆段火车币种
          InlandTrainTicketMoney: 0, //内陆段火车金额（每人）
          VisaMoney: 0, //签证费用（每人）
          SafeMoney: 0, //保险费用（每人）
          LeaderTripMoney: 0, //领队小费
          DriverGuideMoney: 0, //司机小费
          SalesCommissionMoney: 0, //销售提成
          OfficeCommissionMoney: 0, //作业处提成
          TripMoney: 0, //小费
          GuidePeopleMoney: 0, //导游人头费
          AirTicketMoeny: 0, //机票成本费用
          KBMoney: 0, //KB人头费
          AirTicketShareMoney: 0, //机票分摊费用
          TicketShareMoney: 0, //门票分摊费用,
          SingleRoomShareMoney: 0, //单房差分摊费用
          InlandTrafficShareMoney: 0, //内陆段交通分摊费用
          OtherShareMoney: 0, //杂费分摊费用
          OtherRemark: "", //其他价格备注
          VisaMoneyCurrencyId: 0, //签证费币种
          SafeMoneyCurrencyId: 0, //保险费币种
          LeaderTripMoneyCurrencyId: 0, //领队小费币种
          DriverGuideMoneyCurrencyId: 0, //司机小费币种
          GuideMoneyCurrencyId: 0, //导游小费币种
          GuideMoney: 0, //导游小费
          InternationalAirTicket: 0, //国际段机票
          InternationalAirTicketCurrency: 0, //国际段机票币种
        },
        CostCurrencyList: [], //选择的币种
        CostNumberList: [], //人数
        CurrencyNumberListExt: [], //币种和人数列表
        //团报价信息
        teamPrice: {
          QuotationId: 0, //主键编号
          TeamId: 0, //团期编号
          ConfigID: 0, //团队配置编号
          OfferId: 0, //报价编号
          B2BMemberPrice: 0, //同业会员价
          B2BPrice: 0, //同业价格
          B2CMemberPrice: 0, //直客会员价,
          B2CPrice: 0, //直客价格
          ChildNeedPrice: 0, //小孩占床价格,
          ChildNoNeedPrice: 0, //小孩不占床价格
          BabyPrice: 0, //婴儿价格
          BabyChargePrice: 0, //婴儿附加费
          OldManChargePrice: 0, //老人附加费
          VisaPrice: 0, //签证
          OtherPrice: 0, //杂费
          SingleRoomPrice: 0, //单房差
          SingleDMCPrice: 0, //单地接
          RebatePrice: 0, //同行返佣
          DiscountPrice: 0, //早鸟优惠
          IsSupportChildren: 1, //是否支持儿童出游（1-支持，2-不支持）
          SafeMoney: 0, //保险费
          PeopleNumber: 0, //人数
          AirticketMoney: 0, //机票费用
          BackVisaPrice: 0, //退签证费
          BackSafeMoney: 0, //退保险费
          ContractUrl: "", //合同地址
          PriceRemark: "", //定价备注
          LeaderGuideDriveZhuSu: 0, //领队导游住宿费
          AuditContent: "", //审核备注
          TravelState: 0, //3审核通过，4拒绝
        },
        LineList: [], //线路列表
        loading: false,
        IsEdit: 0,
      };
    },
    methods: {
      //保存数据
      SaveData(Type) {
        var nObj = {
          ID: this.$route.query.offerid,
          AuditContent: this.postData.AuditContent,
          TravelState: Type,
          OfferPayType: this.postData.OfferPayType,
          TeamType: this.postData.TeamType,
        };
        this.loading = true;
        this.apipost(
          "travel_get_AuditTravelOffer", nObj,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              this.Success(res.data.message);
              this.goUrl('AuditDan');
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      goUrl(path) {
        this.$router.push({
          path: path,
          query: {
            cache: true
          }
        });
      },
      getPostData() {
        let offerId = 0;
        if (this.$route.query.offerid) {
          offerId = this.$route.query.offerid;
        }
        let msg = {
          offerId: offerId
        };
        this.loading = true;
        this.apipost(
          "travel_get_GetMyTravelInfo_V4",
          msg,
          res => {
            this.loading = false;
            if (res.data.resultCode == 1) {
              var tempData = res.data.data;
              if (tempData.ID && tempData.ID > 0) {
                this.postData.ID = tempData.ID;
              }
              if (tempData.LineId && tempData.LineId > 0) {
                this.postData.LineId = tempData.LineId;
              }
              if (tempData.LineteamId && tempData.LineteamId > 0) {
                this.postData.LineteamId = tempData.LineteamId;
              }
              if (tempData.CSeat && tempData.CSeat > 0) {
                this.postData.CSeat = tempData.CSeat;
              }
              if (tempData.FSeat && tempData.FSeat > 0) {
                this.postData.FSeat = tempData.FSeat;
              }
              if (tempData.YSeat && tempData.YSeat > 0) {
                this.postData.YSeat = tempData.YSeat;
              }
              if (tempData.LowNum && tempData.LowNum > 0) {
                this.postData.LowNum = tempData.LowNum;
              }
              if (tempData.Title && tempData.Title != '') {
                this.postData.Title = tempData.Title;
              }
              if (tempData.DayNum && tempData.DayNum > 0) {
                this.postData.DayNum = tempData.DayNum;
              }
              if (tempData.NightNum && tempData.NightNum > 0) {
                this.postData.NightNum = tempData.NightNum;
              }
              if (tempData.OfferArray && tempData.OfferArray.length > 0) {
                var offerObj = tempData.OfferArray[0];
                if (offerObj) {
                  if (offerObj.AuditContent) {
                    if (this.IsEdit == 2) {
                      this.postData.AuditContent = "";
                    } else {
                      this.postData.AuditContent = offerObj.AuditContent;
                    }
                  }
                  if (offerObj.AuditByName) {
                    this.postData.AuditByName = offerObj.AuditByName;
                  }
                  if (offerObj.AuditDate) {
                    this.postData.AuditDate = offerObj.AuditDate;
                  }
                  if (offerObj.TravelState) {
                    this.postData.TravelState = offerObj.TravelState;
                  }
                  if (offerObj.ManagerAduitContent) {
                    this.postData.ManagerAduitContent = offerObj.ManagerAduitContent;
                  }
                  if (offerObj.ManagerAduitDate) {
                    this.postData.ManagerAduitDate = offerObj.ManagerAduitDate;
                  }
                  if (offerObj.ManagerAduitName) {
                    this.postData.ManagerAduitName = offerObj.ManagerAduitName;
                  }
                  if (offerObj.ManagerAduitStatus) {
                    this.postData.ManagerAduitStatus = offerObj.ManagerAduitStatus;
                  }
                  if (offerObj.OPName && offerObj.OPName != '') {
                    this.postData.OPName = offerObj.OPName;
                  }
                  if (offerObj.AssistantList && offerObj.AssistantList.length > 0) {
                    this.postData.Assistantlist = offerObj.AssistantList;
                  }
                  if (offerObj.OfferPayType) {
                    this.postData.OfferPayType = offerObj.OfferPayType;
                  }
                  if (offerObj.SaleOfferPayType) {
                    this.postData.SaleOfferPayType = offerObj.SaleOfferPayType;
                  }
                }
              }
              this.postData.CustomerName = tempData.CustomerName;
              this.postData.OutBranchId = tempData.OutBranchId;
              this.postData.OutDateTime = tempData.OutDateTime;
              this.postData.LineName = tempData.LineName;
              this.postData.LtName = tempData.LtName;
              this.postData.OutBranchName = tempData.OutBranchName;
              this.postData.TeamTypeName = tempData.TeamTypeName;
              this.postData.TeamType = tempData.TeamType;
              if (tempData.OfferArray) {
                tempData.OfferArray.forEach(item => {
                  this.OfferArray.push(item)
                })
              }
              this.haveData = true;
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
    },
    created() {
      if (this.$route.query.Qtype) {
        this.IsEdit = this.$route.query.Qtype;
      }
      this.getPostData();
    },
    components: {
      CostNewPriceAudit: CostNewPriceAudit
    }
  };

</script>
