index.js 6.98 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
import Api from '~/service/Api';
import moment from 'moment';
import Utils from "~/utils";
export default {
  methods: { 
    
  formSubmit() {
    this.column = ''
    this.order  = ''
    this.handleSearch();
  },	
    async handleSearch(orderObj) {
      if (this.model.infcon.opndatfrom == null || this.model.infcon.opndatfrom == '') {
        this.$notify.error({ title: '错误', message: '开始日期必输!' });
        return;
        }
        if (this.model.infcon.opndatto == null || this.model.infcon.opndatto == '') {
          this.$notify.error({ title: '错误', message: '截止日期必输!' });
          return;
        }
        if (this.model.infcon.opndatfrom != null && this.model.infcon.opndatto != null) {
          if (new Date(this.model.infcon.opndatfrom).getTime() > new Date(this.model.infcon.opndatto).getTime()) {
            this.$notify.error({ title: '错误', message: '开始日期应小于或等于截止日期!' });
            return
          }
        }
      if (new Date(this.model.infcon.opndatto).getTime() - new Date(this.model.infcon.opndatfrom).getTime() > 731 * 24 * 60 * 60 * 1000) {
        this.$notify.error({ title: '错误', message: '请将查询条件中时间范围控制在2年内(含)。' });
        return
      }
      if(this.model.infcon.seacur == '' && (this.model.infcon.seaamtfr != '' || this.model.infcon.seaamtto != '')){
        this.$notify.error({ title: '错误', message: '输入金额前请先选择币种!' });
        return
      }
      if(this.model.infcon.seaamtfr != '' && this.model.infcon.seaamtto != ''){
        if(Number(this.model.infcon.seaamtfr) > Number(this.model.infcon.seaamtto) ){
          this.$notify.error({ title: '错误', message: '金额下限应小于等于金额上限!' });
          return
        }
      }
      this.load = true;
      if (orderObj) {
        if(orderObj.order){
          this.column = orderObj.column
        }else{
          this.column = ''
        }
        this.order = orderObj.order === 'descending' ? 'desc' : 'asc'
      }
      let params = {
        ...this.model.infcon,
        column:this.column,
        order:this.order,
        branch : JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
        pageNumber: this.pagination.pageIndex,
        pageSize:this.pagination.pageSize,
      };
      delete params.markSet
      delete params.modifySet
      let rtnmsg = await Api.post('/Lc/infltd/queryInfltd', params);
      if (rtnmsg.respCode == SUCCESS) {
          this.stmData.data = [];
          this.stmData.data = rtnmsg.data.list;
        this.pagination.total = rtnmsg.data.total;
      } else {
        this.$notify.error({ title: '错误', message: '服务请求失败!' });
      }
      this.load = false;
    },
    async handleReset() {
      this.model.infcon = {}
      this.model.infcon.opndatfrom = new Date()
      this.model.infcon.opndatto = new Date()
    },
     //双击表格数据
     async TableDblRow(row) {
      this.toDetail(row)
  },
    // pageSize改变
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pagination.pageIndex = 1;
      this.pagination.pageSize = val;
      this.handleSearch();
    },
    // 页码改变
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.pageIndex = val;
      this.handleSearch();
    },
   
    // 详情
    async toDetail(row) {
      this.routerPush({
        path: "/business/ltdinf",
        query: { inr: row.inr,objtyp:'LTD',subobjtyp:'BTD'}
      });
    },
    async exportExcel(){
      // const loading = this.loading();
      let params = {
        ...this.model.infcon,
        branch : JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
        pageNumber: this.pagination.pageIndex,
        pageSize:this.pagination.pageSize,
      };
      delete params.markSet
      delete params.modifySet
			let res = await Api.post("/Lc/infltd/exportExcel",params);
			if (res.respCode == SUCCESS) {
      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++){
          if(this.columns[n].prop === 'stagod'){
            array.push(this.getCodelabel(res.data[m][this.columns[n].prop],'stagod'))
          }else{
            array.push(res.data[m][this.columns[n].prop])
          }
        }
        obj.push(array)
        
      }
      Utils.exportToExcel (obj, "转让证登记薄_"+name+".xlsx", "转让证登记薄") ;
       }
      // 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.model.dbCodes[codeNam] = curList
        }
      },
      getCodelabel(value,codenam) {
        const codeobj = this.model.dbCodes[codenam].find(obj => obj.value === value)
        return codeobj ? codeobj.label : value;
      },
      sortChange(obj) {
        let orderObj = {
            order: obj.order,
            column: obj.prop
        }
        this.handleSearch(orderObj);
    },

    columnSetting(cols) {
      this.showDig = false;
      this.digColumns = [];
      this.columnGroup = [];
      this.selectAll = false;
      // 点击自定义按钮
      this.digColumns = cols;
      this.showDig = true;
      this.columnGroup = cols.filter(item => item.isShow).map(it => it.label);
      this.selectAll = cols.length === this.columnGroup.length;
    },
    async handleColumnChange() {
      this.selectAll = this.digColumns.length === this.columnGroup.length;
    },
    setAll(val) {
      this.columnGroup = val ? this.digColumns.map(item => item.label) : [];
    },
    saveColumnEvent() {
      // 保存
      const list = [];
      if(this.columnGroup.length < 1){
         this.$notify.error({ title: '错误', message: '请至少选择1项结果列!' });
         return;
      }
      this.digColumns.forEach(item => {
        if (!this.columnGroup.includes(item.label)) {
          list.push({
            ...item,
            isShow: false
          });
        } else {
          list.push({ ...item, isShow: true });
        }
      });
       this.stmData.columns = list;
			this.$nextTick(() => {
				this.$refs.configTable.doLayout()
			})
      this.showDig = false;
    },
    buttonClick(key) {
      let orInr = this.handleModel.gidinr || this.handleModel.inr;
      let name =
        key.toUpperCase().substring(0, 1) + key.toLowerCase().substring(1);
      this.routerPush({ name, params: { orInr } });
      console.log(this.$route.params.orInr,4444);
      this.handleVisible=false
    },
  },

};