<style>
  .studyproauditInfo {
    margin: 20px;
  }

  .studyproauditInfo .row {
    margin-bottom: 20px;
  }

  .studyproauditInfo .border-bottom {
    border-bottom: 1px dashed #EEE;
    padding-bottom: 8px;
    margin-bottom: 5px;
  }

  .studyproauditInfo .q-radio {
    margin-bottom: 0 !important
  }

  .studyproauditInfo .audit_List {
    margin-bottom: 5px;
  }

  .studyproauditInfo .studyPass {
    color: #fff;
    padding: 1px 3px;
    border-radius: 3px;
    margin-left: 10px;
    font-size: 12px;
    background-color: #2bbb7e;
  }

  .studyproauditInfo .DirectYijian {
    width: 100%;
    min-height: 50px;
    padding: 10px;
    background-color: #F5F5F5;
    border-radius: 5px;
    position: relative;
    overflow: auto;
    max-height: 90px;
    word-break: break-all;
  }

  .DirectYijian::-webkit-scrollbar {
    width: 3px;
    height: 6px;
    background-color: #F5F5F5;
  }

  /*定义滚动条轨道 内阴影+圆角*/
  .DirectYijian::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background-color: #F5F5F5;
  }

  /*定义滑块 内阴影+圆角*/
  .DirectYijian::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: -webkit-gradient(linear, 0 0, 0 100%, color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.5, transparent), to(transparent));
    background-color: #2961fe;
  }

  .studyproauditInfo .DirTriggle {
    width: 0;
    height: 0;
    border-right: 7px solid transparent;
    border-left: 7px solid transparent;
    border-bottom: 8px solid #f5f5f5;
    position: absolute;
    top: -8px;
  }

  .studyproauditInfo .studyHeader {
    border-top: 1px dashed #EEE;
    border-bottom: 1px dashed #EEE;
    padding: 8px 0;
    margin-bottom: 10px;
  }

  .studyproauditInfo .auditName {
    font-size: 14px;
    color: #333;
    font-weight: 700;
  }

  .stidyRoleLine {
    width: 3px;
    height: 11px;
    margin-right: 10px;
    background-color: #3FC4FF;
    display: inline-block;
  }

  .studyRemark {
    width: 100%;
    overflow: auto;
    max-height: 90px;
  }

  .studyRemark::-webkit-scrollbar {
    width: 3px;
    height: 6px;
    background-color: #F5F5F5;
  }

  /*定义滚动条轨道 内阴影+圆角*/
  .studyRemark::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background-color: #F5F5F5;
  }

  /*定义滑块 内阴影+圆角*/
  .studyRemark::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: -webkit-gradient(linear, 0 0, 0 100%, color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.5, transparent), to(transparent));
    background-color: #2961fe;
  }
  .studyDrawerTop{
    font-weight: bold;
  }
  .studyproauditInfo .payTable {
    width: 100%;
    border-collapse: collapse;
  }

  .studyproauditInfo .payTable tr th {
    background: #fff;
    height: 40px;
    font-size: 12px;
    font-weight: bold;
    color: #2D2D2D;
    background: #DDDEE0;
  }

  .studyproauditInfo .payTable tr {
    background: #fff;
    text-align: center;
    height: 40px;
  }

  .studyproauditInfo .payTable tr td {
    font-size: 13px;
    text-align: center;
    color: #2D2D2D;
    padding: 10px 0;
    font-weight: bold;
    border-bottom: 1px solid #E5E5E5;}
</style>
<template>
  <q-dialog v-model="persistent" persistent maximized full-height seamless position="right" @hide="closeperForm">
    <q-card style="margin-top:61px;width:500px" class="no-border-radius classinfo_Dialog">
      <div class="studyDrawerTop">
        <div style="display:flex;align-items:center;margin:20px 0 0 20px;">
          <span class="drawer_Span">
            {{saveObj.Type==1?'留学':'就业'}}详情
          </span>
        </div>
      </div>
      <div class="studyproauditInfo">
        <div class="row">
          <div class="col-12">
            <span class="stidyRoleLine"></span>
            <span>基本信息</span>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <span>项目名称：{{saveObj.Name}}</span>
          </div>
        </div>
        <div class="row">
          <div class="col-6">
            <span>创建人：{{saveObj.CreateByName}}</span>
          </div>
          <div class="col-6">
            <span>创建时间：{{saveObj.CreateTimeStr}}</span>
          </div>
        </div>
        <div class="row">
          <div class="col-12" v-if="isHaveViewSupplierAction">
            <div>供应商：{{saveObj.SupplierName}}
              <template v-if="isHaveViewContractAction">
                <a v-if="saveObj.SupplierContract&&saveObj.SupplierContract!=''" :href="saveObj.SupplierContract"
                  style="text-decoration:none;color:#2961fe;" target="_blank">
                  <i class="iconfont icon-view" style="font-size:18px;cursor:pointer;" @click="" title="查看合同"></i>
                </a>
                <a v-else style="font-size:12px;color:red;">(未上传合同)</a>
              </template>
            </div>
          </div>

        </div>
        <div class="row">
          <div class="col-12">
            <span>状态：{{saveObj.SaleStateName}}</span>
          </div>
        </div>
        <div class="row">
          <!-- <div class="col-6">
            <span>建议卖价：{{Number(saveObj.SuggestPrice).toFixed(2)}}</span>
          </div> -->
          <div class="col-6">
            <span>实际卖价：{{Number(saveObj.SellPrice).toFixed(2)}}</span>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <div style="display:flex;">
              <div style="flex-shrink:0">备注：</div>
              <div class="studyRemark">
                {{saveObj.Remark}}
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-12">
            <span class="stidyRoleLine"></span>
            <span>优惠信息</span>
          </div>
        </div>
        <div class="row studyHeader">
          <div class="col-4">
            优惠政策
          </div>
          <div class="col-4">
            优惠比例
          </div>
          <div class="col-4">
            优惠价格
          </div>
        </div>
        <div class="row audit_List"  >
          <div class="col-4">
            <div class="border-bottom">首次报名优惠</div>
            <div class="border-bottom">续费报名优惠</div>
          </div>
          <div class="col-4">
            <div class="border-bottom" style="padding-left: 16px;padding-right: 16px" >
                {{saveObj.B2CRatio}}%
              </div>
              <div class="border-bottom" style="padding-left: 16px;padding-right: 16px" >
                {{saveObj.B2CReNewRatio}}%
              </div>
          
          </div>
          <div class="col-4">
             <div class="border-bottom"  >
                {{getPrePrice(1)}}
              </div>
               <div class="border-bottom"  >
                {{getPrePrice(2)}}
              </div>
          </div>
         
        </div>
        <div class="row">
          <div class="col-12">
            <span class="stidyRoleLine"></span>
            <span>返佣</span>
          </div>
          <div style="margin-top: 10px;" v-if="saveObj.CommissionReType==1">返佣类型：比例返佣</div>
          <div style="margin-top: 10px;" v-if="saveObj.CommissionReType==2">返佣类型：固定金额返佣</div>
           <table class="payTable">
            <tr>
              <th>同行</th>
              <th>{{saveObj.CommissionReType==1?'首报返佣比例':'首报固定金额'}}</th>
              <th v-if="saveObj.CommissionReType==1">首报返佣值</th>
              <th>{{saveObj.CommissionReType==1?'续费比例':'续费固定金额'}}</th>
              <th v-if="saveObj.CommissionReType==1">续费返佣值</th>
            </tr>
            
            <tr v-for="(item,index) in saveObj.scalelist" :key="index">
              <td>
                <span>{{item.Name}}</span>
              </td>
              <td>
                <span>{{item.scale}}{{saveObj.CommissionReType==1?'%':''}}</span>
              </td>
              <td v-if="saveObj.CommissionReType==1">
                <span>{{item.scalevalue}}</span>
              </td>
              <td>
                <span>{{item.continue}}{{saveObj.CommissionReType==1?'%':''}}</span>
              </td>
              <td v-if="saveObj.CommissionReType==1">
                <span>{{item.continuevalue}}</span>
              </td>
            
            </tr>
          </table>
        </div>
        <template>
          <div class="studyDrawerTop">
            <div style="display:flex;align-items:center;margin:20px 0">
              <span class="drawer_Span">
                部门主管审核
              </span>
            </div>
          </div>
          <div class="row" style="margin-bottom:100px;">
            <div class="col-6">
              <span class="auditName">{{saveObj.DirectorName}}</span>
              <span class="studyPass" v-if="saveObj.DirectorStatus==0" style="background-color:#1273bc;">待审核</span>
              <span class="studyPass" v-if="saveObj.DirectorStatus==1">通过</span>
              <span class="studyPass" v-if="saveObj.DirectorStatus==2" style="background-color:#e95252;">拒绝</span>
            </div>
            <div class="col-6" style="text-align:right;" v-if="saveObj.DirectorStatus>0">
              <span>{{saveObj.DirectorAuditTimeStr}}</span>
            </div>
          </div>
          <div class="row" v-if="saveObj.DirectorStatus>0">
            <div class="col-12">
              <div class="DirectYijian">
                <div class="DirTriggle"></div>
                {{saveObj.DirectorOpinion==''?'无':saveObj.DirectorOpinion}}
              </div>
            </div>
          </div>
        </template>
        <template v-if="saveObj.DirectorStatus>0">
          <div class="studyDrawerTop">
            <div style="display:flex;align-items:center;margin:20px 0">
              <span class="drawer_Span">
                部门负责人审核
              </span>
            </div>
          </div>
          <div class="row" style="margin-bottom:100px;">
            <div class="col-6">
              <span class="auditName">{{saveObj.ManagerName}}</span>
              <span class="studyPass" v-if="saveObj.ManagerStatus==0" style="background-color:#1273bc;">待审核</span>
              <span class="studyPass" v-if="saveObj.ManagerStatus==1">通过</span>
              <span class="studyPass" v-if="saveObj.ManagerStatus==2" style="background-color:#e95252;">拒绝</span>
            </div>
            <div class="col-6" style="text-align:right;" v-if="saveObj.ManagerStatus>0">
              <span>{{saveObj.ManagerAuditTimeStr}}</span>
            </div>
          </div>
          <div class="row" v-if="saveObj.ManagerStatus>0">
            <div class="col-12">
              <div class="DirectYijian">
                <div class="DirTriggle"></div>
                {{saveObj.ManagerOpinion==''?'无':saveObj.ManagerOpinion}}
              </div>
            </div>
          </div>
        </template>
      </div>
    </q-card>
    <div class="dialog-out-close" @click="closeperForm"
      style="height:40px !important;border-top-left-radius: 4px !important;border-bottom-left-radius: 4px !important;">
      <q-icon name="iconfont icon-jujue1" size="26px" />
    </div>
  </q-dialog>
</template>
<script>
  import {
    queryStudyAbroadInfo,
    
  } from "../../api/studyabroad/index";

  import {
    mapState
  } from "vuex";
  export default {
    meta: {
      title: "留学详情"
    },
    props: {
      Id: {
        type: Number,
        default: null
      }
    },
    data() {
      return {
        persistent: true,
        saveObj: {},
        msg: {
          Id: 0,
          IsGetPrice: 1
        },
      }
    },
    computed: mapState({
      //是否有查看合同权限
      isHaveViewContractAction(state) {
        if (state.user.userInfo && state.user.userInfo.ActionMenuList && state.user.userInfo.ActionMenuList.length >
          0) {
          let action = state.user.userInfo.ActionMenuList.find(x => {
            if (x.FunctionCode == "View_Supplier_Contract") {
              return x;
            }
          });
          return action && action.FunctionCode;
        }
        return false;
      },
      //是否有查看供应商权限
      isHaveViewSupplierAction(state) {
        if (state.user.userInfo && state.user.userInfo.ActionMenuList && state.user.userInfo.ActionMenuList.length >
          0) {
          let action = state.user.userInfo.ActionMenuList.find(x => {
            if (x.FunctionCode == "View_Supplier") {
              return x;
            }
          });
          return action && action.FunctionCode;
        }
        return false;
      },
      
    }),
    mounted() {
      this.msg.Id = this.Id;
      this.initObj();
    },
    created() {},
    methods: {
      //获取数据
      initObj() {
        queryStudyAbroadInfo(this.msg).then(res => {
            this.saveObj = res.Data;
            let scalelist= [
              {Name:'同行返佣',scale:this.saveObj.B2BRebateRatio,scalevalue:this.getShouBAO(3),continue:this.saveObj.B2BReNewRatio,continuevalue:this.getShouBAO(4)},
              {Name:'校代返佣',scale:this.saveObj.SchoolRebateRatio,scalevalue:this.getShouBAO(5),continue:this.saveObj.SchoolReNewRatio,continuevalue:this.getShouBAO(6)},
              {Name:'学员转介返佣',scale:this.saveObj.TransIntroductceRatio,scalevalue:this.getShouBAO(7),continue:this.saveObj.TransIntroductceReNewRatio,continuevalue:this.getShouBAO(8)},
              {Name:'内推返佣',scale:this.saveObj.InnerRecommendRatio,scalevalue:this.getShouBAO(9),continue:this.saveObj.InnerRecommendReNewRatio,continuevalue:this.getShouBAO(10)},
              {Name:'直客返佣',scale:this.saveObj.B2CRbRatio,scalevalue:this.getShouBAO(11),continue:this.saveObj.B2CRNRatio,continuevalue:this.getShouBAO(12)},
            ]
            this.saveObj.scalelist = scalelist
          })
          .catch(() => {});
      },
 
      closeperForm() {
        this.$emit("close");
        this.persistent = false;
      },
      getPrePrice(type) {
        //首次优惠
        var Count = ''
        if (type == 1) {
          if (this.saveObj.B2CRatio) {
            let num = Number(100 - this.saveObj.B2CRatio) / 100;
            Count = (num * this.saveObj.SellPrice).toFixed(2);
          }else{
            Count = this.saveObj.SellPrice
          }
        }
        if (type == 2) {
          if (this.saveObj.B2CReNewRatio) {
            let num = Number(100 - this.saveObj.B2CReNewRatio) / 100;
            Count = (num * this.saveObj.SellPrice).toFixed(2);
          }else{
            Count = this.saveObj.SellPrice
          }
        }
        return Count;
      },
        //获取首报返佣比例
      getShouBAO(type) {
        //首次优惠
        var Count = ''
        var currentPrice = Number(100 - this.saveObj.B2CRatio) * this.saveObj.SellPrice / 100;
        var currrntXufei = Number(100 - this.saveObj.B2CReNewRatio) * this.saveObj.SellPrice / 100;
        if (type == 3) {
          if (this.saveObj.B2BRebateRatio) {
            let num = currentPrice * Number(this.saveObj.B2BRebateRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 4) {
          if (this.saveObj.B2BReNewRatio) {
            let num = currrntXufei * Number(this.saveObj.B2BReNewRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 5) {
          if (this.saveObj.SchoolRebateRatio) {
            let num = currentPrice * Number(this.saveObj.SchoolRebateRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 6) {
          if (this.saveObj.SchoolReNewRatio) {
            let num = currrntXufei * Number(this.saveObj.SchoolReNewRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 7) {
          if (this.saveObj.TransIntroductceRatio) {
            let num = currentPrice * Number(this.saveObj.TransIntroductceRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 8) {
          if (this.saveObj.TransIntroductceReNewRatio) {
            let num = currrntXufei * Number(this.saveObj.TransIntroductceReNewRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 9) {
          if (this.saveObj.InnerRecommendRatio) {
            let num = currentPrice * Number(this.saveObj.InnerRecommendRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 10) {
          if (this.saveObj.InnerRecommendReNewRatio) {
            let num = currrntXufei * Number(this.saveObj.InnerRecommendReNewRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 11) {
          if (this.saveObj.B2CRbRatio) {
            let num = currentPrice * Number(this.saveObj.B2CRbRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
        if (type == 12) {
          if (this.saveObj.B2CRNRatio) {
            let num = currrntXufei * Number(this.saveObj.B2CRNRatio) / 100;
            Count = num.toFixed(2);
            return Count;
          }
        }
      }
    }
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')
   
  
</style>
