index.js 7.26 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
import Api from "~/service/Api";
import commonFunctions from "~/mixin/commonFunctions.js";
import buildFn from "./buildCommons.js";
import Pts from "~/components/business/commonModel/Pts.js";
import { cloneDeep } from "lodash";

export default {
  mixins: [commonFunctions],
  methods: {
    // 点击获取按钮拉取当前key字段下的表单数据
    queryFormData(key) {
      console.log(key);
    },
    // 业务信息=》基本信息=》保函编号-----获取保函编号
    async queryOwnref() {
      let params = {
        ptainr: this.model.gidgrp.apl.pts.ptainr,
        businessType: "LC",
        tbl: "LC",
      };
      const loading = this.loading();
      let res = await Api.post("/service/litame/getOwnRef", params);
      if (res.respCode == SUCCESS) {
        loading.close();
        this.model.gidgrp.rec.ownref = res.data;
      }
    },
    // 获取gitopn弹框表格数据
    async queryGridEtyPromptDialogData(type, ptytyp) {
      let params = {
        userId: window.sessionStorage.userId || "ZL",
        ptytyp: ptytyp,
        extkey: this.model.lidgrp[type.toLowerCase()].pts.extkey,
      };
      let res = await Api.post("/service/ptspta/list", params);
      if (res.respCode == SUCCESS) {
        this.root.$refs["etyDialog"].show = true;
        this.root.promptData.data = res.data.ptaInfos;
        this.root.promptData.type = type;
      }
    },
    // 选中gitopn弹框表格的行数据
    async selectGridEtyPromptData(row) {
      let params = {
        ...row,
      };
      let res = await Api.post("/service/ptspta/fetch", params);
      if (res.respCode == SUCCESS) {
        this.$set(this.model.lidgrp, row.role.toLowerCase(), res.data);
      }
    },
    // 业务信息=》基本信息=》支出目的
    purposChange(key, value) {
      this.handleChangeForm(key, value);
    },
    buildLiaccv() {
      let params = {
        ...buildFn.buildCommonData(this.model, this.trnName),
        liaccvg: this.model.liaccv.liaccvg,
        oldamt: this.model.liaccv.oldamt,
        chgamt: this.model.liaccv.chgamt,
        concur: this.model.liaccv.concur,
      };

      return params;
    },
    // 公共组件setmod处理方式改变触发联动
    changeSetmodModel(emitParams) {
      let reqParams = {};
      switch (emitParams.code) {
        case "processMethods":
          reqParams = buildFn.buildSetglg(this.model, this.trnName);
          this.calcPayDetail(reqParams);
          break;
        case "changeDsp":
          let index = emitParams.index;
          let setglgRequest = buildFn.buildSetglg(this.model, this.trnName);
          setglgRequest.setglg = { setgll: emitParams.list };
          this.setgllAccts(setglgRequest, index);
          break;
        default:
          return;
      }
    },

    //获取信用证编号
    async onLitpButgetref() {
      let params = {
        businessType: "LC",
        littyp: "LC",
        ptainr: this.model.lidgrp.apl.pts.ptainr,
        ownref: this.model.lidgrp.rec.ownref,
      };
      const loading = this.loading();
      let res = await Api.post("/Lc/ref/lid", params);
      if (res.respCode == SUCCESS) {
        loading.close();
        this.model.lidgrp.rec.ownref = res.data;
      } else {
        loading.close();
      }
    },

    // 获取码表
    async getdbCode(codeType, uil, codeNam) {
      let params = {
        codeType: codeType,
        uil: uil ? uil : "EN",
      };
      let rtnmsg = await Api.post("/manager/dic/listDicInfo", params);
      if (rtnmsg.respCode === SUCCESS) {
        let curList = rtnmsg.data.map((item) => ({
          value: item.codeValue,
          label: item.codeName,
        }));
        this.dbCodes[codeNam] = curList;
      }
    },

    onSeainf() {},
    onAvbwthChange() {
      // 1.控制是否可输入
      let val = this.model.lidgrp.rec.avbwth;
      if (val == "O" && (this.model.lidgrp.blk.avbwthtxt == null || this.model.lidgrp.blk.avbwthtxt == "")) {
        let value = this.getCodeTableValue("O", "avbwth");
        this.model.lidgrp.blk.avbwthtxt = value;
      }
      // 2.填充字段
      // 先将原有数据清空
      this.model.lidgrp.avb.pts = new Pts().data;
      let ptsList = [];
      ptsList.push(this.model.lidgrp.adv);
      ptsList.push(this.model.lidgrp.con);
      ptsList.push(this.model.lidgrp.rmb);
      ptsList.push(this.model.litp.own);
      let rol = "";
      if ("A" == this.model.lidgrp.rec.avbwth) {
        rol = "ADV";
      } else if ("C" == this.model.lidgrp.rec.avbwth) {
        rol = "CON";
      } else if ("R" == this.model.lidgrp.rec.avbwth) {
        rol = "RMB";
      } else if ("I" == this.model.lidgrp.rec.avbwth) {
        rol = "OWN";
      }
      let res = ptsList.find((item) => item.pts.rol == rol);
      if (res != null && res != "") {
        let newRes = cloneDeep(res);
        this.model.lidgrp.avb = newRes;
        this.model.lidgrp.avb.pts.rol = "AVB";
      } else {
        if (rol === "ADV") {
          this.$alert("Please enter an advising bank or change Available with.", "警告", {
            confirmButtonText: "确定",
          });
        } else if (rol === "CON") {
          this.$alert("Please enter an Confirming Bank on Parties penal or change Available with.", "警告", {
            confirmButtonText: "确定",
          });
        }
      }
    },

    // 正则匹配特殊字符替换,例如将'[',替换成'\['这样的话就不会作为正则表达式的转义字符处理了
    specialCharactersProcess(inputStr) {
      let specialCharacterArr = ["[", "]", "\\", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}"];
      let processedStr = "";
      let index;
      for (index = 0; index < inputStr.length; index++) {
        let indexChar = inputStr.charAt(index);
        // 包含特殊字符
        if (specialCharacterArr.indexOf(indexChar) != -1) {
          processedStr += "\\" + indexChar;
        } else {
          processedStr += indexChar;
        }
      }
      return processedStr;
    },

    // 需客户确认按钮是否显示
    async judgementNeedCustomerButtonShow() {
      let trninr;
      if (this.$route.query.businessInr) {
        trninr = this.$route.query.businessInr;
      } else {
        trninr = "";
      }
      let type;
      if (this.$route.query.businessType) {
        type = this.$route.query.businessType;
      } else {
        type = "";
      }
      let data = {
        extkey: this.$store.state.UserContext.currentOrg.departmentNumber,
        trninr: trninr,
        type: type,
      };
      const loading = this.loading();
      let res = await Api.post("/Lc/litopn/judgementNeedCustomerButtonShow", data);
      loading.close();
      if (res.respCode === SUCCESS) {
        this.model.needcusVisible = res.data;
      }
    },

    async onAplChange() {
      // 查询是否亮显"需客户确认"按钮
      if (this.model.lidgrp.apl.pts.extkey != "") {
        let map = {
          aplExtkey: this.model.lidgrp.apl.pts.extkey,
        };
        let res = await Api.post("/Lc/litopn/havePermissionToEdit", map);
        if (res.respCode == SUCCESS) {
          this.model.needcusEnable = res.data;
          if (this.model.needcusEnable !== 'Y') {
            this.model.lidgrp.rec.needcuscomopn = "";
          }
        }
      } else {
        this.model.needcusEnable = "";
        this.model.lidgrp.rec.needcuscomopn = "";
      }
    },
  },
};