import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils/index"

export default {
	mixins: [commonFunctions],
	methods: {
		//索赔编号
		queryOwnref() {
			let params = this.model.gcdgrp.rec
			if (!this.model.gcdgrp.apl.pts.ptainr) {
				return
			}
			let ptainr = this.model.gcdgrp.apl.pts.ptainr;
			const loading = this.loading();
			Api.post(`/business/ref/gcd?ptaInr=${ptainr}`, params).then(res => {
				if (res.respCode == SUCCESS) {
					loading.close();
					this.model.gcdgrp.rec.ownref = res.data;
				}
			}).catch(() => {
				loading.close();
			});
		},	
		clsflgChange(){
			this.ifClsflg="X";
			if (this.model.clsflg == "true") {
				if(this.model.coninf.conexedat!=""){
					this.model.gcdgrp.rec.clsdat=this.model.coninf.conexedat
				}
				else{
					this.model.gcdgrp.rec.clsdat=new Date();
				}
			}
			else{
				this.model.gcdgrp.rec.clsdat="";
			}
		},
		rejtypselChange(){
			if (this.model.rejtypsel == "I") {
				this.model.clsflg = "false";
				this.model.gcdgrp.rec.clsdat="";
			} else if (this.model.rejtypsel == "R"&&this.ifClsflg=="") {
				this.model.clsflg = "true";
				if(this.model.coninf.conexedat!=""){
					this.model.gcdgrp.rec.clsdat=this.model.coninf.conexedat
				}
				else{
					this.model.gcdgrp.rec.clsdat=new Date();
				}
			}
		},
		// gcdgrp.rec.docprbrol
		calcPrb() {
			let prbref=this.model.gcdgrp.prb.pts.ref;
			switch (this.model.gcdgrp.rec.docprbrol) {
				case "ADV":
					Utils.copyValueFromVoData(this.model.gcdgrp.prb.pts, this.model.gidgrp.adv.pts);
					this.model.gcdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.gidgrp.adv.pts.ref!=""){
						this.model.gcdgrp.prb.pts.ref=this.model.gidgrp.adv.pts.ref;
					}
					else{
						this.model.gcdgrp.prb.pts.ref=prbref;
					}
					break;
				case "BEN":
					Utils.copyValueFromVoData(this.model.gcdgrp.prb.pts, this.model.gidgrp.ben.pts);
					this.model.gcdgrp.prb.pts.rol = "PRB";
					this.model.gcdgrp.prb.pts.ref=this.model.gcdgrp.ben.pts.ref;
					break;
				case "ISS":
					Utils.copyValueFromVoData(this.model.gcdgrp.prb.pts, this.model.gidgrp.iss.pts);
					this.model.gcdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.gidgrp.iss.pts.ref!=""){
						this.model.gcdgrp.prb.pts.ref=this.model.gidgrp.iss.pts.ref;
					}
					else{
						this.model.gcdgrp.prb.pts.ref=prbref;
					}
					break;
				case "ATB":
					Utils.copyValueFromVoData(this.model.gcdgrp.prb.pts, this.model.gidgrp.atb.pts);
					this.model.gcdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.gidgrp.atb.pts.ref!=""){
						this.model.gcdgrp.prb.pts.ref=this.model.gidgrp.atb.pts.ref;
					}
					else{
						this.model.gcdgrp.prb.pts.ref=prbref;
					}
					break;
				case "AT2":
					Utils.copyValueFromVoData(this.model.gcdgrp.prb.pts, this.model.gidgrp.at2.pts);
					this.model.gcdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.gidgrp.at2.pts.ref!=""){
						this.model.gcdgrp.prb.pts.ref=this.model.gidgrp.at2.pts.ref;
					}
					else{
						this.model.gcdgrp.prb.pts.ref=prbref;
					}
					break;
				case "PRB":
					this.model.gcdgrp.prb.pts = new Pts().data;
					this.model.gcdgrp.prb.pts.rol = "PRB";
					this.model.gcdgrp.prb.pts.ref=prbref;
					break;
			}
		},
		// gcdgrp.rec.payrol
		// APC,BEC,CTR,CTC
		calcOth() {
			switch (this.model.gcdgrp.rec.payrol) {
				case "APL":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.apl.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;

				case "APC":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.apc.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;
				case "BEC":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.bec.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;
				case "CTR":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.ctr.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;
				case "CTC":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.ctr.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;
				case "ADA":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.ada.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;

				case "ADV":
					Utils.copyValueFromVoData(this.model.gcdgrp.oth.pts, this.model.gidgrp.adv.pts);
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;

				case "OTH":
					this.model.gcdgrp.oth.pts = new Pts().data;
					this.model.gcdgrp.oth.pts.rol = "OTH";
					break;
			}
		},
		
	},
};