import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import Utils from "~/utils";
import Pts from '~/components/business/commonModel/Pts';

export default {
	mixins: [commonFunctions],
	methods: {
		//索赔编号
		queryOwnref () {
			let params = this.model.ncdgrp.rec
			if (!this.model.ncdgrp.apl.pts.ptainr) {
				return
			}
			let ptainr = this.model.ncdgrp.apl.pts.ptainr;
			const loading = this.loading();
			Api.post(`/business/ref/ncd?ptaInr=${ptainr}`, params).then(res => {
				loading.close();
				if (res.respCode == SUCCESS) {
				this.model.ncdgrp.rec.ownref = res.data;
				}
			}).catch(() => {
				loading.close();
			});
		},
		calcPrb() {
			let prbref=this.model.ncdgrp.prb.pts.ref;
			switch (this.model.ncdgrp.rec.docprbrol) {
				case "ADV":
					Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.adv.pts);
					this.model.ncdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.nidgrp.adv.pts.ref!=""){
						this.model.ncdgrp.prb.pts.ref=this.model.nidgrp.adv.pts.ref;
					}
					else{
						this.model.ncdgrp.prb.pts.ref=prbref;
					}
					break;
				case "BEN":
					Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.ben.pts);
					this.model.ncdgrp.prb.pts.rol = "PRB";
					this.model.ncdgrp.prb.pts.ref=this.model.ncdgrp.ben.pts.ref;
					break;
				case "ISS":
					Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.iss.pts);
					this.model.ncdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.nidgrp.iss.pts.ref!=""){
						this.model.ncdgrp.prb.pts.ref=this.model.nidgrp.iss.pts.ref;
					}
					else{
						this.model.ncdgrp.prb.pts.ref=prbref;
					}
					break;
				case "ATB":
					Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.atb.pts);
					this.model.ncdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.nidgrp.atb.pts.ref!=""){
						this.model.ncdgrp.prb.pts.ref=this.model.nidgrp.atb.pts.ref;
					}
					else{
						this.model.ncdgrp.prb.pts.ref=prbref;
					}
					break;
				case "AT2":
					Utils.copyValueFromVoData(this.model.ncdgrp.prb.pts, this.model.nidgrp.at2.pts);
					this.model.ncdgrp.prb.pts.rol = "PRB";
					if(prbref==""&&this.model.nidgrp.at2.pts.ref!=""){
						this.model.ncdgrp.prb.pts.ref=this.model.nidgrp.at2.pts.ref;
					}
					else{
						this.model.ncdgrp.prb.pts.ref=prbref;
					}
					break;
				case "PRB":
					this.model.ncdgrp.prb.pts = new Pts().data;
					this.model.ncdgrp.prb.pts.rol = "PRB";
					this.model.ncdgrp.prb.pts.ref=prbref;
					break;
			}
		},
		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 "ISS":
					Utils.copyValueFromVoData(this.model.ncdgrp.oth.pts, this.model.nidgrp.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;
			}
		},
	},
}