index.js 4.22 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
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import operationFunc from "~/mixin/commonDepend";
import moment from "moment"
import Utils from "~/utils"
export default {
	mixins: [commonFunctions, operationFunc],
	methods: {
		
		//2120对账查询
		async handleSearch(orderObj) {
      if (orderObj) {
        if(orderObj.order){
          this.column = orderObj.column
        }else{
          this.column = ''
        }
        this.order = orderObj.order === 'descending' ? 'desc' : 'asc'
      }
			if (this.model.recpan.date == null || this.model.recpan.date == '') {
				this.$notify.error({ title: '错误', message: '查询日期必输!' });
				return;
			}
			const loading = this.loading();
			let params = {
        ...this.model.recpan,
        date:moment(this.model.recpan.date).format('yyyyMMDD'),
        column:this.column,
        order:this.order,
				pageNumber: this.pagination.pageNumber,
				pageSize: this.pagination.pageSize
      }
      delete params.markSet
      delete params.modifySet
			let rtnmsg = await Api.post("/manager/infanb/queryInfanb", params)
			if (rtnmsg.respCode == SUCCESS) {
				this.stmData.data = rtnmsg.data.list
				this.pagination = {
					pageNumber: rtnmsg.data.pageNum,
					pageSize: rtnmsg.data.pageSize,
					total: rtnmsg.data.total
				}
				loading.close()
			} else {
				this.stmData.data = [],
					this.pagination = {
						pageNumber: 1,
						pageSize: 10,
						total: 0
					};
				loading.close()
			}
    },
    sortChange(obj) {
      let orderObj = {
          order: obj.order,
          column: obj.prop
      }
      this.handleSearch(orderObj);
  },
		formSerach() {
      this.column = ''
      this.order  = ''
			this.handleSearch()
		},
	  // pageSize改变
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pagination.pageNumber = 1;
      this.pagination.pageSize = val;
      this.formSerach();
    },
    // 页码改变
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.pageNumber = val;
      this.formSerach();
    },

		async exportExcel() {
			const loading = this.loading();
			let params = {
        ...this.model.recpan,
        date:moment(this.model.recpan.date).format('yyyyMMDD'),
			}
      delete params.markSet
      delete params.modifySet
			let res = await Api.post("/manager/infanb/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.stmData.columns.length; i++) {
					arr.push(this.stmData.columns[i].label + this.stmData.columns[i].prop)
				}
				obj.push(arr);
				for (let m = 0; m < res.data.length; m++) {
					let array = []
					for (let n = 0; n < this.stmData.columns.length; n++) {
            if(this.stmData.columns[n].prop == 'huobdh'){
              array.push(this.getCodelabel(res.data[m][this.stmData.columns[n].prop],'curval'))
            }else{
            array.push(res.data[m][this.stmData.columns[n].prop])
          }
					}
					obj.push(array)

				}
				Utils.exportToExcel(obj, "2120对账_" + name + ".xlsx", "2120对账");
			}
			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;
    },
     //获取机构列表
     async getBranchList() {
      let branch = JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber
      let rtnmsg = await Api.post("/manager/infanb/getBranchList", {branch:branch})
      if (rtnmsg.respCode === SUCCESS) {
        this.bchlst = rtnmsg.data;
        if(branch == '1000'){
          this.model.recpan.branch = '1000'
        }else{
          this.model.recpan.branch = this.bchlst[0].branch
        }
      }
    },
	}
}