import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import buildFn from '../event/buildCommons.js';
import Utils from '~/utils';
export default {
  mixins: [commonFunctions, buildFn],
  methods: {
		async getOwnExtkeyCondition() {
			const loading = this.loading();
			let res = await Api.post('/business/nitopnRule/getOwnExtkeyCondition');
			loading.close();
			if (res.respCode === SUCCESS) {
					this.ownExtkeyList = res.data;
					
			}
	},
	change2101(val){
		if (val == '1'){
			this.model.rmbbop.rmb2112.rmbflg = '1'
		}else{
			this.model.rmbbop.rmb2112.rmbflg = '2'
			this.model.rmbbop.rmb2112.newnum = 0
	}
    let trnName = this.root ? this.root.trnName : this.trnName
    if (this.model.rmbbop.rmb2101.rmbflg == '1') {
      let rmbbop = this.buildRobbop(this.model, trnName);
      Api.post('/business/rmbbopncd/rmbbop2101Cal', rmbbop).then(res => {
        Utils.copyValueFromVoData(this.model.rmbbop.rmb2101, res.data.rmb2101);
        this.model.rmbbop.rmb2101.recgrp.ads.opertype = '1';
      });
    }
    if (this.model.rmbbop.rmb2112.rmbflg == '1') {
      let rmbbop = this.buildRobbop(this.model, trnName);
      Api.post('/business/rmbbopncd/rmbbop2112Cal', rmbbop).then(res => {
        Utils.copyValueFromVoData(this.model.rmbbop.rmb2112, res.data.rmb2112);
        this.model.rmbbop.rmb2112.recgrp.ads.opertype = '1';
      });
    } else {
      this.model.rmbbop.rmb2112.newnum = 0
    }
  },
  query2112() {
    let trnName = this.root ? this.root.trnName : this.trnName
    if (this.model.rmbbop.rmb2112.rmbflg == '1') {
      let rmbbop = this.buildRobbop(this.model, trnName);
      Api.post('/business/rmbbopncd/rmbbop2112Cal', rmbbop).then(res => {
        Utils.copyValueFromVoData(this.model.rmbbop.rmb2112, res.data.rmb2112);
        this.model.rmbbop.rmb2112.recgrp.ads.opertype = '1';
      });
    } else {
      this.model.rmbbop.rmb2112.newnum = 0
    }
  },
  query2123() {
    let trnName = this.root ? this.root.trnName : this.trnName
    if (this.model.rmbbop.rmbbop2123Vo.rmbflg == '1') {
      let rmbbop = this.buildRobbop(this.model, trnName);
      Api.post('/business/rmbbopncd/rmbbop2123Cal', rmbbop).then(res => {
        Utils.copyValueFromVoData(this.model.rmbbop.rmbbop2123Vo, res.data.rmbbop2123Vo);
        this.model.rmbbop.rmbbop2123Vo.recgrp.ads.opertype = '1';
      });
    }
  },
	//向索人--"ncdgrp.rec.payrol"
	calcOth() {
		switch (this.model.ncdgrp.rec.payrol) {
			case "APL":
				Utils.copyValueFromVoData(this.model.ncdgrp.oth.pts, this.model.nidgrp.apl.pts);
				this.model.ncdgrp.oth.pts.rol = "OTH";
				break;
			case "ADA":
				Utils.copyValueFromVoData(this.model.ncdgrp.oth.pts, this.model.nidgrp.ada.pts);
				this.model.ncdgrp.oth.pts.rol = "OTH";
				break;
			case "ISS":
				Utils.copyValueFromVoData(this.model.ncdgrp.oth.pts, this.model.ncdgrp.iss.pts);
				this.model.ncdgrp.oth.pts.rol = "OTH";
				break;
			case "OTH":
				this.model.ncdgrp.oth.pts = new Pts().data;
				this.model.ncdgrp.oth.pts.rol = "OTH";
				break;
		}
	},
	//索赔当事人--"ncdgrp.rec.docprbrol"
	calcPrb() {
		console.log("this.model.ncdgrp.rec.docprbrol-->" + this.model.ncdgrp.rec.docprbrol);
		switch (this.model.ncdgrp.rec.docprbrol) {
			case "BEN":
				Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.ben.pts);
				this.model.ncdgrp.prb.pts.rol = "PRB";
				break;
			case "ATB":
				Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.atb.pts);
				this.model.ncdgrp.prb.pts.rol = "PRB";
				break;
			case "AT2":
				Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.at2.pts);
				this.model.ncdgrp.prb.pts.rol = "PRB";
				break;
			default:
				this.model.ncdgrp.prb.pts = new Pts().data;
				this.model.ncdgrp.prb.pts.rol = "PRB";
				break;
		}
	},
	changeNcdOpn1(){
		if(Number(this.model.ncdgrp.cbs.opn1.amt) < Number(this.model.ncdgrp.cbs.max.amt)){
		  this.model.clsflg = "O";
		}
	  },
  },
};