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

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

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

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

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

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

  .drawer_Span {
    font-weight: bold;
  }

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

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

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

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

  /*定义滑块 内阴影+圆角*/
  .StudyDirecYijian::-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;
  }

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

  .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;
  }

</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="Study_drawerTop">
        <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" v-for="(x,index) in saveObj.PreferentialList" :key="index">
          <div class="col-4">
            <template v-if="saveObj.PreferentialList.length>0">
              <div class="border-bottom" v-if="x.PriceDiscountType == 1">
                买{{ x.BuyNum }}送{{ x.SendNum }}
              </div>
              <div class="border-bottom" v-if="x.PriceDiscountType == 2">
                单人报名享
                <template v-if="x.PriceType==0">
                  {{ 100 - x.PriceMoney }}折
                </template>
                <template v-else>
                  {{  x.PriceMoney }}元
                </template>
                优惠
              </div>
              <div class="border-bottom" v-if="x.PriceDiscountType == 3">
                双人报名享 <template v-if="x.PriceType==0">
                  {{ 100 - x.PriceMoney }}折
                </template>
                <template v-else>
                  {{  x.PriceMoney }}元
                </template>优惠
              </div>
              <div class="border-bottom" v-if="x.PriceDiscountType == 4">
                续费享 <template v-if="x.PriceType==0">
                  {{ 100 - x.PriceMoney }}折
                </template>
                <template v-else>
                  {{  x.PriceMoney }}元
                </template>优惠
              </div>
              <div class="remark-font" v-if="x.PriceDiscountType == 0">
                暂无优惠政策
              </div>
            </template>
            <template v-else>
              <span>暂无优惠政策</span>
            </template>
          </div>
          <div class="col-4">
            <template v-if="saveObj.PreferentialList.length>0">
              <div class="border-bottom" style="padding-left: 16px;padding-right: 16px"
                :class="{ 'text-red': x.SaleCommissionType == 1 }" v-if="x.PriceDiscountType != 0">
                {{ x.SaleCommissionType == 1 ? "￥" : ""
                }}{{ x.SaleCommissionMoney
                }}{{ x.SaleCommissionType == 0 ? "%" : "" }}
              </div>
              <div v-if="x.PriceDiscountType == 0">
                <div class="remark-font">暂无佣金信息</div>
              </div>
            </template>
            <template v-else>
              <span>暂无优惠政策</span>
            </template>
          </div>
          <div class="col-4">
            <template v-if="saveObj.PreferentialList.length>0">
              <div class="border-bottom" style="padding-left: 16px" :class="{ 'text-red': x.B2BCommissionType == 1 }"
                v-if="x.PriceDiscountType != 0">
                {{ x.B2BCommissionType == 1 ? "￥" : ""
                }}{{ x.B2BCommissionMoney
                }}{{ x.B2BCommissionType == 0 ? "%" : "" }}
              </div>
              <div v-if="x.PriceDiscountType == 0">
                <div class="remark-font">暂无佣金信息</div>
              </div>
            </template>
            <template v-else>
              <span>暂无优惠政策</span>
            </template>
          </div>
        </div>
      </div>

      <!--部门主管审核-->
      <template v-if="saveObj.DirectorStatus>0">
        <div style="margin:20px;">
          <div class="Study_drawerTop">
            <div>
              <span class="drawer_Span">
                部门主管审核
              </span>
            </div>
          </div>
          <div class="row" style="margin:20px 0;">
            <div class="col-6">
              <span style="font-weight:bold;">{{saveObj.DirectorName}}</span>
              <span class="studyproPass" v-if="saveObj.DirectorStatus==1">通过</span>
              <span class="studyproPass" v-if="saveObj.DirectorStatus==2" style="background-color:#e95252;">拒绝</span>
            </div>
            <div class="col-6" style="text-align:right;">
              <span>{{saveObj.DirectorAuditTimeStr}}</span>
            </div>
          </div>
          <div class="row">
            <div class="col-12">
              <div class="StudyDirecYijian">
                <div class="DirTriggle"></div>
                {{saveObj.DirectorOpinion==''?'无':saveObj.DirectorOpinion}}
              </div>
            </div>
          </div>
        </div>
      </template>
      <template v-if="saveObj.DirectorStatus==0">
        <div style="margin:20px;">
          <div class="Study_drawerTop">
            <div style="display:flex;align-items:center;margin:20px 0">
              <span class="drawer_Span">
                部门主管审核
              </span>
            </div>
          </div>
          <div class="row" style="margin-bottom:10px;">
            <div class="col-6">
              <span style="font-weight:bold;">{{saveObj.DirectorName}}</span>
              <span class="studyproPass" style="background-color:#1273bc;">待审</span>
            </div>
          </div>
        </div>
        <div style="margin:20px;" v-if="AuditType==1">
          <div class="row" style="margin-bottom:0;">
            <div class="col-12">
              <q-radio v-model="directorMsg.DirectorStatus" style="margin-right:20px;" :val="1" size="xs" label="通过"
                color="secondary" />
              <q-radio v-model="directorMsg.DirectorStatus" :val="2" size="xs" label="拒绝" color="negative" />
            </div>
          </div>
          <div class="row">
            <div class="col-12">
              <q-input filled stack-label :dense="false" v-model="directorMsg.DirectorOpinion" style="margin-top: 20px"
                type="textarea" class="col-12" label="审核意见" maxlength="200" />
            </div>
          </div>
          <div style="margin:30px 10px 0 0;text-align:right;">
            <q-btn color="accent" class="q-mr-md" icon="add" label="提交" @click="saveSatMsg()" />
          </div>
        </div>
      </template>
      <!--部门负责人审核-->
      <template v-if="saveObj.ManagerStatus>0">
        <div style="margin:20px;">
          <div class="Study_drawerTop">
            <div>
              <span class="drawer_Span">
                部门负责人审核
              </span>
            </div>
          </div>
          <div class="row" style="margin:20px 0;">
            <div class="col-6">
              <span style="font-weight:bold;">{{saveObj.ManagerName}}</span>
              <span class="studyproPass" v-if="saveObj.ManagerStatus==1">通过</span>
              <span class="studyproPass" v-if="saveObj.ManagerStatus==2" style="background-color:#e95252;">拒绝</span>
            </div>
            <div class="col-6" style="text-align:right;">
              <span>{{saveObj.ManagerAuditTimeStr}}</span>
            </div>
          </div>
          <div class="row">
            <div class="col-12">
              <div class="StudyDirecYijian">
                <div class="DirTriggle"></div>
                {{saveObj.ManagerOpinion==''?'无':saveObj.ManagerOpinion}}
              </div>
            </div>
          </div>
        </div>
      </template>
      <template v-if="saveObj.ManagerStatus==0 && saveObj.DirectorStatus>0">
        <div style="margin:20px;">
          <div class="Study_drawerTop">
            <div style="display:flex;align-items:center;margin:20px 0">
              <span class="drawer_Span">
                部门负责人审核
              </span>
            </div>
          </div>
          <div class="row" style="margin-bottom:10px;">
            <div class="col-6">
              <span style="font-weight:bold;">{{saveObj.ManagerName}}</span>
              <span class="studyproPass" style="background-color:#1273bc;">待审</span>
            </div>
          </div>
        </div>
        <div style="margin:20px;" v-if="AuditType==2">
          <div class="row" style="margin-bottom:0;">
            <div class="col-12">
              <q-radio v-model="managerMsg.ManagerStatus" style="margin-right:20px;" :val="1" size="xs" label="通过"
                color="secondary" />
              <q-radio v-model="managerMsg.ManagerStatus" :val="2" size="xs" label="拒绝" color="negative" />
            </div>
          </div>
          <div class="row">
            <div class="col-12">
              <q-input filled stack-label :dense="false" v-model="managerMsg.ManagerOpinion" style="margin-top: 20px"
                type="textarea" class="col-12" label="审核意见" maxlength="200" />
            </div>
          </div>
          <div style="margin:30px 10px 90px 0;text-align:right;">
            <q-btn color="accent" class="q-mr-md" icon="add" label="提交" @click="saveSatMsg()" />
          </div>
        </div>
      </template>
    </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,
    saveDirectorAudit,
    saveManagerAudit
  } from "../../api/studyabroad/index";
  import {
    mapState
  } from "vuex";
  export default {
    meta: {
      title: "留学详情"
    },
    props: {
      Id: {
        type: Number,
        default: null
      }
    },
    data() {
      return {
        persistent: true,
        //部门主管审核
        directorMsg: {
          Id: 0,
          DirectorOpinion: '',
          DirectorStatus: 1
        },
        //部门负责人审核
        managerMsg: {
          Id: 0,
          ManagerOpinion: '',
          ManagerStatus: 1
        },
        msg: {
          Id: 0,
          IsGetPrice: 1
        },
        saveObj: {}, //留学就业产品详情
        auditList: [], //权限数据
        AuditType: 0, //1-部门主管审核,2-部门负责人审核
      }
    },
    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.directorMsg.Id = this.Id;
      this.managerMsg.Id = this.Id;
      this.initObj();
    },
    created() {
      let userInfo = this.getLocalStorage();
      let StudyAbroadObj = userInfo.StudyAbroadObj;
      if (StudyAbroadObj && StudyAbroadObj.length > 0) {
        StudyAbroadObj.forEach((x, index) => {
          if (x.Id === userInfo.Id) {
            this.AuditType = (index + 1)
          }
        })
      }
    },
    methods: {
      //获取数据
      initObj() {
        queryStudyAbroadInfo(this.msg).then(res => {
            this.saveObj = res.Data;
          })
          .catch(() => {});
      },
      //保存
      saveSatMsg() {
        //1部门主管审核
        if (this.AuditType == 1) {
          saveDirectorAudit(this.directorMsg).then(res => {
              if (res.Code == 1) {
                this.$q.notify({
                  icon: 'iconfont icon-chenggong',
                  color: 'accent',
                  timeout: 2000,
                  message: '审核成功!',
                  position: 'top'
                })
                this.closeperForm();
                this.$emit("success")
              } else {
                this.$q.notify({
                  icon: 'iconfont icon-chenggong',
                  color: 'accent',
                  timeout: 2000,
                  message: res.Message,
                  position: 'top'
                })
              }
            })
            .catch(() => {});
        }
        //2部门负责人审核
        if (this.AuditType == 2) {
          saveManagerAudit(this.managerMsg).then(res => {
              if (res.Code == 1) {
                this.$q.notify({
                  icon: 'iconfont icon-chenggong',
                  color: 'accent',
                  timeout: 2000,
                  message: '审核成功!',
                  position: 'top'
                })
                this.closeperForm();
                this.$emit("success")
              } else {
                this.$q.notify({
                  icon: 'iconfont icon-chenggong',
                  color: 'accent',
                  timeout: 2000,
                  message: res.Message,
                  position: 'top'
                })
              }
            })
            .catch(() => {});
        }
      },
      closeperForm() {
        this.$emit("close");
        this.persistent = false;
      }
    }
  }

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

</style>
