<template>
  <div>
    <div class="doc-style">
      <div class="title-sty">{{ protocol }}</div>
      <div>
        <p>《面签资料》</p>
      </div>
      <div class="btn-area">
        <button @click="stopCheck">上一步</button>
        <button @click="selectSignPeople">提交复核</button>
      </div>
    </div>
    <base-popup showCancel="true" showConfirm="true" @cancel="transferPopupShow = false" @confirm="submit" v-model="transferPopupShow" title="提交">
      <div class="bottom-sty">
        <div class="reason-sty">
          <van-radio-group v-model="checked" direction="horizontal">
            <van-radio v-for="(item, index) in customerList" :key="index" icon-size="25px" class="radio-sty" checked-color="#ee0a24" :name="index+1">{{ item.USERNAME }}</van-radio>
          </van-radio-group>
        </div>
      </div>
    </base-popup>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import {NativeUI} from "@/public/ts/NativeUI";
import nettyApi from "@/constants/api/ms-netty/netty.api";
import IF from "@/public/factory/InterFaceFactory";
import BasePopup from "@/components/general/BasePopup.vue";

@Component({
  name: 'SubmitAudit',
  components: {BasePopup}
})
export default class SubmitAudit extends Vue {
  @Prop(Number) tabActive: Number | any;
  @Prop(Object) custInfo: Object | any;
  @Prop(String) flag: String | any;

  protocol = '请工作人员审核申请信息';
  transferPopupShow = false;
  checked = 0;
  customerList: any = [];

  stopCheck(){
    if (this.tabActive != 0){
      this.$emit("activeChange", this.tabActive-1);
    }
  }
  submit(){
    const custInfo = this.customerList[this.checked-1];
    const param = {
        USERCODE: sessionStorage.getItem("user_code"),
        ORGCODE: sessionStorage.getItem("org_code"),
        USERNAME: sessionStorage.getItem("ORGNAME"),
        ORGNAME: sessionStorage.getItem("USERNAME"),
        SERIALNO: this.custInfo.SERIALNO,
        OBJECTMODEL: '6', //1面签岗提交、2面签岗转让、3面签岗作废、4面签复核岗退回、5面签复核岗提交
        SIGNYPE: this.custInfo.SIGNYPE,
        REMARK: '',
        FLOWUSERID: custInfo.USERID,
        FLOWUSERNAME: custInfo.USERNAME,
        FLOWORGNAME: custInfo.ORGNAME,
        FLOWORGID: custInfo.ORGID,
        tc: nettyApi.TRADE_CODE.faceSignTaskProcess
      },
      _this = this;
    NativeUI.showWaiting('正在提交...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      console.log("提交成功",res);
      if(res.rc == 1){
        if(_this.flag == '1'){
          _this.$router.go(-1);
        }else{
          _this.$router.go(-2);
        }
      }else{
        NativeUI.toast(res.msg);
      }
    });
  }
  /**
   * @Description 面签人员查询
   * @Author xwh
   * @Date 2022-02-16 下午 18:13
   */
  selectSignPeople(){
    const param = {
        USERCODE: sessionStorage.getItem("user_code"),
        ORGCODE: sessionStorage.getItem("org_code"),
        ROLEID: 'R1016',
        OBJECTMODEL: '2',//1流程提交用户查询、2总行面签岗人员查询
        tc: nettyApi.TRADE_CODE.selectSignPerson
      },
      _this = this;
    NativeUI.showWaiting('正在查询...');
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      console.log('查询用户列表',res)
      if(res.rc == 1){
        if(res.ARRAY.length > 0){
          _this.transferPopupShow = true;
          _this.customerList = res.ARRAY;
        }else{
          NativeUI.toast('未查询到可移交人员信息');
        }
      }else{
        NativeUI.toast(res.msg);
      }
    });
  }
}
</script>
<style scoped lang="scss">
.doc-style{
  display: flex;
  flex-direction: column;
  align-items: center;
}
p{
  font-size: 16px;
  color: #53C7F8;
}
.btn-area{
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.btn-area > button {
  width: 180px;
  height: 50px;
  border: 1px solid #BEBEBE;
  font-size: 19px;
  border-radius: 30px;
  outline: none;
}
.btn-area > button:nth-child(1){
  color: #BEBEBE;
  background-color: white;
  margin-right: 20px;
}
.btn-area > button:nth-child(2){
  color: white;
  background-color: #FF8651;
}
.title-sty{
  font-size: 20px;
  font-weight: bold;
  margin: 20px 0;
}
.doc-style > div:nth-child(2){
  width: 50%;
  height: 400px;
  background-image: url("../../../assets/images/protocol.png");
  background-size: 100% 100%;
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-top: 80px;
}
.bottom-sty{
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  height: 100%;
}
::v-deep .van-field__control{
  width: 400px;
  height: 70%;
}
.radio-sty{
  height: 40px;
  margin: 0 15px 15px 0;
  font-size: 20px;
}
</style>
