index.js 17.4 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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
export default {
	mixins: [commonFunctions],
	methods: {
		initSetmod (requestParams) {
      this.model.setmod.buildParams = requestParams;
      this.getSetmodCodeTable();
			this.processSetpan();
			
    },
		buildSetfeg () {
			let params = {
				...this.model.setmod.buildParams,
				liaall: this.model.liaall,
				liaccv: this.model.liaccv,
        //doceot: this.model.docpan ? this.model.docpan.doceot : [],
        doceot: this.filterDoceot(),
        setfeg: this.model.setmod.setfeg,
        setfog: this.model.setmod.setfog,
        ptydet: this.model.setmod.ptydet
			}
			return params
		},
		buildSetglg () {
			let params = {
				...this.model.setmod.buildParams,
				liaall: this.model.liaall,
				liaccv: this.model.liaccv,
				setfog: this.model.setmod.setfog,
				setfeg: this.model.setmod.setfeg,
        setglg: this.model.setmod.setglg,
        ptydet: this.model.setmod.ptydet,
        doccur: this.model.setmod.doccur,
        docamt: this.model.setmod.docamt
			};
			return params
    },
    buildSetmodCodeTable(requestParams){
      if(requestParams){
        this.model.setmod.buildParams = requestParams
      }
      let params = {
				ptsList: this.model.setmod.buildParams.ptsList,
				transName: this.model.setmod.buildParams.transName,
        userId: this.model.setmod.buildParams.userId,
        rec: this.model.setmod.buildParams.rec,
      }
      return params
    },
		async getSetmodCodeTable (requestParams) {
			let params = this.buildSetmodCodeTable(requestParams)
			let res = await Api.post(`/${this.moduleRouter()}/codetable/setmod/list`, params);
			if (res.respCode === SUCCESS) {
				this.model.setmod.feeCodeSet = res.data.feeCodeSet;
        this.model.setmod.roleSet = res.data.roleSet;
        this.model.setmod.foreignRoleSet = res.data.foreignRoleSet;
      }
      return res;
		},
		async processSetpan() {
			let rtnmsg = await this.calcFeeDetail();
			if (rtnmsg.respCode === SUCCESS) {
				// 试算账务
				this.calcSettleDetail();
			}
    },
    async calcFeeDetail(requestParams){
      if(requestParams){
        this.model.setmod.buildParams = requestParams
      }
      let loading = this.loading('正在计算费用数据');
			let setfegRequest = this.buildSetfeg();
      let objtyp = setfegRequest.rec.objtyp;
			setfegRequest.sptinr = this.$route.query.businessInr || ''
      let rtnmsg = await Api.post(`/${this.moduleRouter()}/${objtyp.toLowerCase()}/setmod/calcFeeDetail`, setfegRequest);
      if (rtnmsg.respCode === SUCCESS) {
        this.model.setmod.setfog = rtnmsg.data.setfog;
				this.model.setmod.setfeg = rtnmsg.data.setfeg;
        this.model.setmod.ref = rtnmsg.data.ref;
        let doccurModified = false;
        if (this.model.setmod
            && this.model.setmod.modifySet
            && this.model.setmod.modifySet.includes('doccur')) {
            doccurModified = true;
        }
        if (!doccurModified) {
          this.model.setmod.doccur = rtnmsg.data.doccur;
        }
        let docamtModified = false;
        if (this.model.setmod
            && this.model.setmod.modifySet
            && this.model.setmod.modifySet.includes('docamt')) {
            docamtModified = true;
        }
        if (!docamtModified) {
          this.model.setmod.docamt = rtnmsg.data.docamt;
        }
        this.model.setmod.ptydet = rtnmsg.data.ptydet;
        this.model.setmod.feeclirol = rtnmsg.data.feeclirol;
        this.model.setmod.feecorrol = rtnmsg.data.feecorrol;
        this.model.setmod.refdat = rtnmsg.data.refdat;
        this.model.setmod.zmqflg = rtnmsg.data.zmqflg;
        this.model.setmod.zmqacc = rtnmsg.data.zmqacc;
			}
      loading.close()
      return rtnmsg;
    },
		// 计算结算表格
		async calcSettleDetail(requestParams) {
      if(requestParams){
        this.model.setmod.buildParams = requestParams
      }
			let loading = this.loading('正在计算账务数据');
      let setglgRequest = this.buildSetglg()
      let objtyp = setglgRequest.rec.objtyp;
			setglgRequest.sptinr = this.$route.query.businessInr || ''
			let rtnmsg = await Api.post(`/${this.moduleRouter()}/${objtyp.toLowerCase()}/setmod/calcSettleDetail`, setglgRequest);
			if (rtnmsg.respCode === SUCCESS) {
        this.model.setmod.setglg = rtnmsg.data.setglg;
        this.model.setmod.wrksumMap = rtnmsg.data.wrksumMap;
        this.model.setmod.fale01List = rtnmsg.data.fale01List;
        if (this.model.setmod.setglg.recalcSetglg) {
           loading.close();
           this.$alert('Inconsistent settlement has been cleared due to changes in basic data', '警告', {
            confirmButtonText: '确定'
          });
           this.model.setmod.setglg.recalcSetglg = false;
           this.model.setmod.setglg.macold = "";
           this.calcSettleDetail();
        }
			}
      loading.close();
      return rtnmsg;
    },
    handleChangeCallback(setfel, prop) {
      this.customAddModify(setfel, prop);
      if (setfel.role === '' || setfel.feecod === '') {
        //角色和费用代码存在一个为空,就是无效条目,不需要调用费用账务服务
        return;
      }
      if (prop === 'feetxtinf') {
        return;
      }
      if (prop === 'amt') {
        setfel.modflg = 'a';
        if (setfel.dsp === 'P') {
          //费用处理方式是后收,不需要试算账务
          return;
          }
          this.calcSettleDetail();
      } else if (prop === 'rol') {
        //更新了角色,会触发费用币种,扣费方式
          if (setfel.dsp === 'P') {
            //费用处理方式是后收,不需要试算账务
            this.calcFeeDetail();
            return;
          }
          this.processSetpan();
      } else if (prop === 'dsp') {
        if (setfel.dsp === 'X') {
          if (setfel.amt === 0) {
            //重置
            setfel.modflg = "r";
            let fecChanged = setfel.modifySet.includes('wrkfec');
            setfel.modifySet = ['dsp'];
            if (fecChanged) {
              setfel.modifySet.push('wrkfec');
            }
            setfel.dat2 = setfel.dat2dft;
            setfel.graceDays = 0;
            this.model.setmod.setfeg.macbogold = '';
            this.processSetpan();
          } else {
            this.calcSettleDetail();
          }
        } else if (setfel.dsp === 'N'){
          this.customAddModify(setfel, 'amt');
          setfel.modflg = 'a';
          setfel.amt = 0;
          this.calcSettleDetail();
        } else if (setfel.dsp === 'P'){
          if (this.isAmeFee(setfel)) {
            this.calcSettleDetail();
          } else  if (setfel.commFeeFlag === 'Y') {
            this.customAddModify(setfel, 'unt');
            setfel.modflg = 'u';
            setfel.unt = 0;
            this.processSetpan();
          } else {
            if (setfel.amt === 0) {
              //重置
              setfel.modflg = "r";
              let fecChanged = setfel.modifySet.includes('wrkfec');
              setfel.modifySet = ['dsp'];
              if (fecChanged) {
                setfel.modifySet.push('wrkfec');
              }
              setfel.dat2 = setfel.dat2dft;
              setfel.graceDays = 0;
              this.model.setmod.setfeg.macbogold = '';
              this.processSetpan();
            } else {
              this.calcSettleDetail();
            }
          }
        }
      } else if (prop === 'feecod') {
        //if (setfel.modflg !== 'a') {
          setfel.modflg = 'c';
        //}
        this.processSetpan();
      } else if (prop === 'unt') {
        //if (setfel.modflg !== 'a') {
          setfel.modflg = 'u';
        //}
        this.processSetpan();
      }
    },
    handleSetfogCallback(setfol, prop) {
      this.customAddModify(setfol, prop);
      if (setfol.ptydbt === '' && setfol.ptypay === '') {
        //角色信息不全,不调用账务组件
        return;
      }
      this.processSetpan();
    },
    handleSetgllCallback(setgll, prop) {
      this.customAddModify(setgll, prop);
      if (prop === 'amt') {
          //参考Setgll的@Rule(target="fmtamt",order=1000)
          if (setgll.fmtamt > 0) {
            if (setgll.debcdtflg === 'C') {
               if (setgll.modflg === '-' && Number(setgll.fmtamt) > Number(Math.abs(setgll.amt))) {
                  this.$alert('Don\'t use more than the available amount', '警告', {
                    confirmButtonText: '确定'
                  });
                  setgll.fmtamt = Math.abs(setgll.amt);
                  setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
                  return;
               } else {
                  if (Number(setgll.fmtamt) === Number(Math.abs(setgll.amt))) {
                    setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
                    return;
                  } else {
                    setgll.amt = 0 - setgll.fmtamt;
                  }
               }
            } else {
              if (setgll.modflg === '-' && Number(setgll.fmtamt) > Number(Math.abs(setgll.amt))) {
                this.$alert('Don\'t use more than the available amount', '警告', {
                  confirmButtonText: '确定'
                });
                setgll.fmtamt = Math.abs(setgll.amt);
                setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
                return;
              } else  {
                if (Number(setgll.fmtamt) === Number(Math.abs(setgll.amt))) {
                  setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
                  return;
                } else {
                  setgll.amt = setgll.fmtamt;
                }
              }
            }
          } else if (Number(setgll.fmtamt) === 0) {
            setgll.amt = 0;
            setgll.fmtaccamt = 0;
            setgll.accamt = 0
            setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
          }
      } else if (prop === 'accamt') {
          //参考Setgll的@Rule(target="fmtaccamt",order=1000)
          if (Number(setgll.fmtaccamt) === Number(Math.abs(setgll.accamt))) {
            setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
            return;
          }
          if (Number(setgll.fmtaccamt) > 0) {
            if (setgll.debcdtflg === 'C') {
              setgll.accamt = 0 - setgll.fmtaccamt;
            } else {
              setgll.accamt = setgll.fmtaccamt;
            }
          } else if (Number(setgll.fmtaccamt) === 0) {
            setgll.amt = 0;
            setgll.fmtamt = 0;
            setgll.modifySet.splice(setgll.modifySet.indexOf(prop), 1);
          }
          //前端控制了金额必须大于等于0
      } else if (prop === 'act') {
        setgll.acccode = '';
        setgll.accountBalance = 0;
        this.updateOrcact(setgll);
        //this.getAcctInfo(setgll);
        //return;
      }
      this.calcSettleDetail();
		},
		// 此方法为了重置点击获取按钮获取核心业务代号的校验规则重置
		resetValidField (propIndex) {
			let fields = this.root.$refs.modelForm.fields
			for (let i = 0; i < fields.length; i++) {
				let fieldItem = fields[i]
				let prop = 'setmod.setglg.setgll.' + propIndex + '.act'
				if (fieldItem.prop === prop) {
					if (fieldItem.validateMessage === '请点击获取按钮获取核心业务代号') {
						this.root.$refs.modelForm.clearValidate([prop])
					}
					break;
				}
			}
		},
    async getCoreAccountInfo(setgll, propIndex) {
      if (setgll.act === '') {
        this.$alert('请先获取账号!', '提示', {
          confirmButtonText: '确定'
        });
        return;
			}
			this.resetValidField(propIndex)
      let objtyp = this.model.setmod.buildParams.rec.objtyp;
      let request = {
        account: setgll.act
      }
      let loading = this.loading('正在请求Account8091接口');
      let rtnmsg = await Api.post(`/${this.moduleRouter()}/${objtyp.toLowerCase()}/getCoreAcctInfo`, request);
			if (rtnmsg.respCode === SUCCESS) {
          if (rtnmsg.data.errorMsg !== '' && rtnmsg.data.errorMsg !== null) {
            this.$alert(rtnmsg.data.errorMsg, '提示', {
              confirmButtonText: '确定'
            });
          } else {
            setgll.acccode = rtnmsg.data.acctCode;
            setgll.accountBalance = rtnmsg.data.acctBalance;
            this.$alert('账号:'+setgll.act+'<br/>核心业务代号为:'+setgll.acccode+'<br/>账户余额为:'+setgll.acccur+this.moneyFormat(setgll.accountBalance,setgll.acccur)+'<br/>账户状态为:'+rtnmsg.data.jiluzt, '提示', {
              confirmButtonText: '确定',
              dangerouslyUseHTMLString: true
            });
          }
      }
      loading.close();
      //获取账号性质
      if (setgll.dsp.startsWith('LO') && setgll.acccur != 'CNY') {
        let loading = this.loading('正在请求Account8023接口');
        rtnmsg = await Api.post(`/${this.moduleRouter()}/codetable/getAccountNature`, request);
        if (rtnmsg.respCode === SUCCESS) {
          if (rtnmsg.data.errorMsg !== '' && rtnmsg.data.errorMsg !== null) {
            this.$alert(rtnmsg.data.errorMsg, '提示', {
              confirmButtonText: '确定'
            });
          } else {
            if (rtnmsg.data.wjzhxz === '1101') {
              let actPro = this.model.setmod.setglg.actPro;
              let txtDr = "【" + setgll.act + "】账户性质为待核查账户,请确认是否符合相关规定,是否使用此账户?";
              let txtCr = "【" + setgll.act + "】账户性质为待核查账户,请确认是否为货物贸易外汇收入,是否使用此账户?";
              let txt = setgll.debcdtflg === 'D' ? txtDr : txtCr;
              this.$confirm(txt, '提示', {
                confirmButtonText: '是',
                cancelButtonText: '否',
                type: 'warning',
                showClose: false
              }).then(() => { 
                if (actPro.some(element => element.act === setgll.act)) {
                  for (let item of actPro) {
                    if (item.act === setgll.act) {
                      item.sta = 'Y';
                    }
                  }
                } else {
                  let actproObject = {
                    act: setgll.act,
                    sta: 'Y'
                  };
                  actPro.push(actproObject);
                }
              }).catch(() => { 
                if (actPro.some(element => element.act === setgll.act)) {
                  for (let item of actPro) {
                    if (item.act === setgll.act) {
                      item.sta = 'N';
                    }
                  }
                } else {
                  let actproObject = {
                    act: setgll.act,
                    sta: 'N'
                  };
                  actPro.push(actproObject);
                }
              });
            } else {
              this.$alert('账号:'+setgll.act+'<br/>账户性质为:'+ rtnmsg.data.wjzhxz + '-' + rtnmsg.data.acctNatureName, '提示', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true
              });
            }
          }
        }
        loading.close();
      }
    },
    async getAcctInfo(setgll) {
      let loading = this.loading('正在请求账号信息');
      let objtyp = this.model.setmod.buildParams.rec.objtyp;
      let rtnmsg = await Api.post(`/${this.moduleRouter()}/${objtyp.toLowerCase()}/getAcctInfo`, setgll);
			if (rtnmsg.respCode === SUCCESS) {
          setgll.actflg = rtnmsg.data.actflg;
          setgll.acttrmtyp = rtnmsg.data.acttrmtyp;
          setgll.disableSet = rtnmsg.data.disableSet;
          setgll.acttrmtypSet = rtnmsg.data.acttrmtypSet;
      }
      loading.close();
    },
    async changeDoccur(){
      if (this.model.setmod.doccur === '') {
        return;
      }
      if (isNaN(Number(this.model.setmod.docamt))) {
        return;
      }
      this.customAddModify(this.model.setmod, 'doccur');
      //更新业务入参Bizinfo的docamt,通知其他组件
      if (this.model.setmod.buildParams && this.model.setmod.buildParams.rec) {
        this.model.setmod.buildParams.rec.docamt = this.model.setmod.docamt;
        this.model.setmod.buildParams.rec.doccur = this.model.setmod.doccur;
      }
      this.processSetpan();
    },
    async changeDocamt() {
      if (isNaN(Number(this.model.setmod.docamt))) {
        return;
      }
      this.customAddModify(this.model.setmod, 'docamt');
      //更新业务入参Bizinfo的docamt,通知其他组件
      if (this.model.setmod.buildParams && this.model.setmod.buildParams.rec) {
        this.model.setmod.buildParams.rec.docamt = this.model.setmod.docamt;
      }
      this.calcSettleDetail();
    },
    isAmeFee(setfel){
      return setfel.feecod === 'GIAME1' || setfel.feecod === 'GIAME2' || setfel.feecod === 'GIAME3'
             || setfel.feecod === 'GIAME4' || setfel.feecod === 'GIAME5' || setfel.feecod === 'GIAME6'
             || setfel.feecod === 'GIAME7' || setfel.feecod === 'GIAME8' || setfel.feecod === 'GIAME9'
    },
    updateOrcact(setgll) {
       let transName = this.model.setmod.buildParams.transName;
       if (transName === 'cptopn') {
          let txncur = this.model.cpdgrp.cbs.max.cur;
          if (setgll.dsp === 'LOD' && setgll.rol === 'ORC' && setgll.cur === txncur) {
            this.model.cpdgrp.rec.orcact = setgll.act;
          }
       }
    },
    filterDoceot(){
       if (this.model.docpan) {
          return this.model.docpan.doceot.filter(doceot => (doceot.cortyp === 'SWT' ||
           (doceot.cortyp === 'LET' && (doceot.docsnf === 'LETCOU' || doceot.docsnf === 'LETAML'))));
       }
       return [];
    }
	}
}