<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" :IsEdit="IsEdit"></CostNewPriceAudit>
    </div>
  </div>
</template>
<script>
  import CostNewPriceAudit from "../TravelNewQuotation/CostNewPriceAudit";
  export default {
    data() {
      return {
        haveData: 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: "", //出发时间
          OutDateTimeList: [],
          OfferPayType: 0, //报价单付款方式()
          SaleOfferPayType: 0, //售价付款方式
          AuditContent: "", //审核备注
          AuditByName: "", //审核人员
          AuditDate: "", //审核日期
          TravelState: 0, //审核状态
          ManagerAduitContent: "", //欧洲线审核备注
          ManagerAduitDate: "", //欧洲线审核日期
          ManagerAduitName: "", //欧洲线审核人员
          ManagerAduitStatus: 0, //欧洲线审核状态(1-通过，2-驳回)
          OPName: "", //主OP
          AssistantList: [], //助理OP
          PriceTeamType: 0, //团队类型,
          PriceTeamTypeName: "", //团队类型,
          CRemarks: "", //审核备注
          ChangeManagerAduitName: "", //分公司报价单变更审核人
          ChangeManagerAduitContent: "", //分公司报价单变更审核内容
          ChangeManagerAduitDate: "", //分公司报价单变更审核日期
          ChangeManagerAduitStatus: 0, //分公司报价单变更审核状态
          ChangeAduitContent: "", //总经理审核报价单变更备注
          ChangeAuditByName: "", //总经理审核
          ChangeAduitDate: "", //总经理审核时间
          OpAuditDate: "", //印尼团 OP审核时间
          OpAuditContent: "", //印尼团OP审核备注
          OpAuditStatus: "", //印尼团OP审核状态
          OfferArray: [],
        },
        loading: false,
        IsEdit: 0,
      };
    },
    methods: {
      //保存数据
      SaveData(Type) {
        var nObj = {
          ID: this.$route.query.offerid,
          BatchNum: this.$route.query.BatchNum,
          AuditContent: this.postData.CRemarks,
          TravelState: Type,
          OfferPayType: this.postData.OfferPayType,
          TeamType: this.postData.TeamType,
        };
        var cmdStr = "travel_get_AuditTravelOffer";
        if (Type == 7 || Type == 8) {
          cmdStr = "travel_get_AuditChangeOffer";
        }
        this.loading = true;
        this.apipost(cmdStr, 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() {
        this.haveData = false;
        let BatchNum = "";
        let offerid = 0;
        if (this.$route.query.BatchNum) {
          BatchNum = this.$route.query.BatchNum;
        }
        if (this.$route.query.offerid) {
          offerid = this.$route.query.offerid;
        }
        let msg = {
          BatchNum: BatchNum,
          offerId: offerid,
        };
        this.loading = true;
        this.apipost(
          "travel_get_PriceOfferInfo",
          msg,
          res => {
            this.loading = false;
            console.log("travel_get_PriceOfferInfo",res.data);
            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.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) {
                    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.ChangeManagerAduitName) {
                    this.postData.ChangeManagerAduitName = offerObj.ChangeManagerAduitName;
                  }
                  if (offerObj.ChangeManagerAduitContent) {
                    this.postData.ChangeManagerAduitContent = offerObj.ChangeManagerAduitContent;
                  }

                  if (offerObj.ChangeManagerAduitDate) {
                    this.postData.ChangeManagerAduitDate = offerObj.ChangeManagerAduitDate;
                  }
                  if (offerObj.ChangeManagerAduitStatus) {
                    this.postData.ChangeManagerAduitStatus = offerObj.ChangeManagerAduitStatus;
                  }

                  if (offerObj.ChangeAduitContent) {
                    this.postData.ChangeAduitContent = offerObj.ChangeAduitContent;
                  }

                  if (offerObj.ChangeAuditByName) {
                    this.postData.ChangeAuditByName = offerObj.ChangeAuditByName;
                  }
                  if (offerObj.ChangeAduitDate) {
                    this.postData.ChangeAduitDate = offerObj.ChangeAduitDate;
                  }
                  if (offerObj.OpAuditStatus) {
                    this.postData.OpAuditStatus = offerObj.OpAuditStatus;
                  }
                  if (offerObj.OpAuditContent) {
                    this.postData.OpAuditContent = offerObj.OpAuditContent;
                  }
                  if (offerObj.OpAuditDate) {
                    this.postData.OpAuditDate = offerObj.OpAuditDate;
                  }
                  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.OutDateTimeList = tempData.OutDateTimeList;
              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;
              this.postData.PriceTeamTypeName = tempData.PriceTeamTypeName;
              this.postData.PriceTeamType = tempData.PriceTeamType;
              if (tempData.OfferArray) {
                this.postData.OfferArray = tempData.OfferArray;
              }
              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>
