import commonFunctions from '~/mixin/commonFunctions.js';
import Api from '~/service/Api';

export default {
	mixins: [commonFunctions],
	methods: {
    async getOwnref(){
      let params = {
        ownref: this.model.mcdgrp.rec.ownref,
        ptainr: this.model.mcdgrp.ade.pts.ptainr,
        mcttyp: this.model.mcdgrp.rec.mcttyp,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/mctopn/getRef`, params);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.mcdgrp.rec.ownref = res.data;
        this.model.mcdgrp.rec.subref = res.data;
      } else {
        this.$message.error(res.respMsg);
      }
    },
    async querySubref() {
      let params = {
        ownref: this.model.mcdgrp.rec.ownref,
        ptainr: this.model.mcdgrp.ade.pts.ptainr,
        mcttyp: this.model.mcdgrp.rec.mcttyp,
      }
      const loading = this.loading();
      let res = await Api.post(`/${this.moduleRouter()}/mctfee/getRef`, params);
      if (res.respCode === SUCCESS) {
        this.model.mcdgrp.rec.subref = res.data;
      }
      loading.close();
    },
    async changeXgywbh(){
      if (this.model.xgywbh === '') {
        return;
      }
      let params = {
        xgywbh: this.model.xgywbh,
        branchinr: this.model.mcdgrp.rec.branchinr,
        bchkeyinr: this.model.mcdgrp.rec.bchkeyinr,
      }
      const loading = this.loading();
      let rtnmsg = await Api.post(`/${this.moduleRouter()}/mctfee/searchXgywbh`, params);
      if (rtnmsg.respCode === SUCCESS) {
        if (rtnmsg.data.errorMsg !== '' && rtnmsg.data.errorMsg !== null) {
          this.$alert(rtnmsg.data.errorMsg, '提示', {
            confirmButtonText: '确定'
          });
          this.model.xgywbh = '';
        } else {
          this.model.pnttyp = rtnmsg.data.pnttyp;
          this.model.fintyp = rtnmsg.data.fintyp;
          this.model.objtyp = rtnmsg.data.objtyp;
          this.model.objinr = rtnmsg.data.objinr;
          this.model.xgywbh = rtnmsg.data.xgywbh;
        }
      }
      loading.close();
    },
    adeChange() {
      let xxtfeeObj = {
        rol: "ADE",
        ptsObj: this.model.mcdgrp.ade
      }
      this.$set(this.codes, "xxtfeeObj", xxtfeeObj);
    }
	}
}