index.js 6.16 KB
import Api from "~/service/Api"
import commonFunctions from '~/mixin/commonFunctions.js';
import moment from 'moment'
import Utils from "~/utils"
export default {
	mixins: [commonFunctions],
    methods: {
		async handleSearch(orderObj) {
      if (this.model.opndatfrom == null) {
        this.$notify.error({ title: '错误', message: '查询开始日期必输!' });
        return;
      }
      if (this.model.opndatto == null) {
        this.$notify.error({ title: '错误', message: '查询结束日期必输!' });
        return;
      }
			if(this.model.searol != '' && (this.model.ptyExtkey == '' && this.model.seapty == '') ){
				this.$notify.error({ title: '错误', message: '选择角色时请先输入当事人编号或者当事人BIC编号!' });
				return
			}
			if(this.model.seacur == '' && this.model.seaamt > 0 ){
				this.$notify.error({ title: '错误', message: '输入金额前请先选择币种!' });
				return
			}
      if(new Date(this.model.opndatfrom).getTime() > new Date(this.model.opndatto).getTime()){
        this.$notify.error({ title: '错误', message: '开始日期应小于结束日期!' });
        return
      } 
    //  if(this.model.seasta != '' && this.model.isauthorize == ''){
    //   this.$notify.error({ title: '错误', message: '选择状态时请先选择是否已授权!' });
    //   return
    //  }
      const loading = this.loading();
      if (orderObj) {
        if(orderObj.order){
          this.model.column = orderObj.column
        }else{
          this.model.column = ''
        }
        
        this.model.order = orderObj.order === 'descending' ? 'desc' : 'asc'
      }
      this.model.hndtyps = ['OC','OT','OL']
      this.model.branch = JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber
			let rtnmsg = await Api.post("/business/infgid/queryInfgid", {
				...this.model,
				pageNum: this.pagination.pageNum,
				pageSize: this.pagination.pageSize
			});
			if (rtnmsg.respCode == SUCCESS) {
				this.tableData = rtnmsg.data.list || [];
				this.pagination = {
					pageNum: rtnmsg.data.pageNum || 1,
					pageSize: rtnmsg.data.pageSize || 10,
					total: rtnmsg.data.total
				};
			}
			loading.close();
		},
		async handleReset() {
      this.model.gidopentyps = [];
      this.model.seaamt = 0;
      this.model.isClaim = "";
			this.model.seaownref = "";
			this.model.opndatfrom = new Date();
			this.model.opndatto = new Date();
			this.model.nam = "";
			this.model.searef = "";
			this.model.relflg = "";
			this.model.hndtyp = "";
			this.model.ptyExtkey = "";
			this.model.ptyNam = "";
			this.model.seapty = "";
			this.model.searol = "";
			this.model.seasta = "";
			this.model.seacur = "";
			this.model.seaamtfr = "";
			this.model.seaamtto = "";
			this.model.seagtyp = "";
			this.model.cxmflg = "";
			this.model.seapurpos = "";
			this.model.segtyp = "";
			this.model.fromflg = "";
			this.model.fenlishi = "";
			this.model.cmtflg = "";
			this.model.fingua = "";
      this.model.grtnam = "";
      this.model.fenlishi = "";
      this.model.isauthorize = "";
      this.model.finfingua = "";
			this.ptyExtkeyChange();
      this.seaptyChange();
      this.chgFingua();
    },
    async exportExcel(){
      const loading = this.loading();
      this.model.branch = JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber
			let res = await Api.post("/business/infgid/exportExcel",{
				...this.model,});
			if (res.respCode == SUCCESS) {
        let  objdata  = res.data
        for(let a = 0; a < objdata.length; a ++ ){
            objdata[a].ccvamt = parseFloat(objdata[a].ccvamt)
            objdata[a].maxamt = parseFloat(objdata[a].maxamt)
            objdata[a].maxxrfamt = parseFloat(objdata[a].maxxrfamt)
            objdata[a].opnamt = parseFloat(objdata[a].opnamt)
            objdata[a].opnxrfamt = parseFloat(objdata[a].opnxrfamt)
        }
      let name=moment(new Date()).format('yyyy-MM-DD HH:mm:ss') ;
      let obj = []
      let arr =[]
      for (let i = 0; i< this.columns.length;i++){
        arr.push(this.columns[i].label)
      }
      obj.push(arr);
      for(let m = 0; m< res.data.length; m++){
        let array =  []
        for(let n = 0; n < this.columns.length; n++){
          array.push(res.data[m][this.columns[n].prop])
        }
        obj.push(array)
        
      }
      Utils.exportToExcel (obj, "保函开立登记薄_"+name+".xlsx", "保函开立登记薄") ;
    }
      loading.close();
		  },
		async claimInfo(inr) {
			let params = {
				gidinr: inr
			}
			let rtnmsg = await Api.post("/business/infgid/queryGcdByGidinr", params);
			if (rtnmsg.respCode == SUCCESS) {
				const data = rtnmsg.data.list || [];
				const pagination = {
					pageNum: rtnmsg.data.pageNum || 1,
					pageSize: rtnmsg.data.pageSize || 10,
					total: rtnmsg.data.total
				};
				return {
					data,
					pagination
				}
			}
    },
    chgFingua(){
      if(this.model.fingua == 'Y'){
        this.isOnShow = true
      }else if(this.model.fingua == ''){
        this.model.finfingua = ''
        this.isOnShow = false

      }
    },
    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.model.dbCodes[codeNam] = curList
      }
    },
    getCodelabel(value,codenam) {
      const codeobj = this.model.dbCodes[codenam].find(obj => obj.value === value)
      return codeobj ? codeobj.label : value;
    },
    changefenlsh(){
      if(this.model.fenlishi !='' || this.model.fenlishi != null){
        this.model.isfenlishi = 'X'
      }
      if(this.model.fenlishi == '' || this.model.fenlishi == null){
        this.model.isfenlishi = ''
      }
    },
    isfenlishi(){
      if(this.model.isfenlishi == 'X' ){
        this.model.fenlishi = '2'
      }
      if(this.model.isfenlishi == '' ){
        this.model.fenlishi = ''
      }

    },
    sortChange(obj) {
      let orderObj = {
          order: obj.order,
          column: obj.prop
      }
      this.handleSearch(orderObj);
  },
    },
    
}