index.js 19.2 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 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
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.activeTab === 'sr'){
          let opndatfrom = this.model.infcon.opndatfrom
          let opndatto = this.model.infcon.opndatto
           if ( opndatfrom == null || opndatfrom == '') {
          this.$notify.error({ title: '错误', message: '开始日期必输!' });
          return;
          }
          if (opndatto == null || opndatto == '') {
            this.$notify.error({ title: '错误', message: '截止日期必输!' });
            return;
          }
          if (opndatfrom != null && opndatto != null) {
            if (new Date(opndatfrom).getTime() > new Date(opndatto).getTime()) {
              this.$notify.error({ title: '错误', message: '开始日期应小于或等于截止日期!' });
              return
            }
            if(moment(opndatto).diff(moment(opndatfrom).format('YYYY-MM-DD'), 'days') > 731){
              this.$notify.error({ title: '错误', message: '请将查询条件中时间范围控制在2年内(含)。' });
              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('/manager/infinv/queryInfinv', 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: '服务请求失败!' });
          }
        }else if(this.activeTab === 'ck'){
          if(this.model.invcon.seqnum == null || this.model.invcon.seqnum == ''){
            this.$notify.error({ title: '错误', message: '请输入批次号,若批次号未知,输入发票代码和发票号码点击批次号获取按钮获取批次号' });
            return
          }
          let params = {
            ...this.model.invcon,
            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('/manager/infinv/queryInvByseqnum', params);
          if (rtnmsg.respCode == SUCCESS) {
              this.stmDataCK.data = [];
              this.stmDataCK.data = rtnmsg.data.list;
              this.pagination.total = rtnmsg.data.total;
              if(this.stmDataCK.data.length == 0){
                this.$notify.error({ title: '错误', message: '该批次号下没有发票!' });
              }
          } else {
            this.$notify.error({ title: '错误', message: '服务请求失败!' });
          }
        }else if(this.activeTab == 'dl'){
					if (this.model.invchk.opndatfrom == null) {
						this.$notify.error({ title: '错误', message: '开始日期必输!' });
						return;
						}
						if (this.model.invchk.opndatto == null) {
							this.$notify.error({ title: '错误', message: '截止日期必输!' });
							return;
						}
						if (this.model.invchk.opndatfrom != null && this.model.invchk.opndatto != null) {
							if (new Date(this.model.invchk.opndatfrom).getTime() > new Date(this.model.invchk.opndatto).getTime()) {
								this.$notify.error({ title: '错误', message: '开始日期应小于或等于截止日期!' });
								return
							}
						}
						let params = {
							...this.model.invchk,
							branch: JSON.parse(sessionStorage.getItem('currentOrg')).departmentNumber,
							pageSize: this.pagination.pageSize,
							pageNum: this.pagination.pageIndex
						}
						let res = await Api.post('/manager/invchk/ruleQueryImf',params)
						if(res.respCode == SUCCESS){
							this.invchkData = res.data.list
							this.pagination.total = res.data.total
						}
				}else if(this.activeTab == 'dj'){
					if (this.model.imgInvmod.regsel.prebnkdat == null) {
						this.$notify.error({ title: '错误', message: '开始日期必输!' });
						return;
						}
						if (this.model.imgInvmod.regsel.prebnkdat2 == null) {
							this.$notify.error({ title: '错误', message: '截止日期必输!' });
							return;
						}
						if (this.model.imgInvmod.regsel.prebnkdat != null && this.model.imgInvmod.regsel.prebnkdat2 != null) {
							if (new Date(this.model.imgInvmod.regsel.prebnkdat).getTime() > new Date(this.model.imgInvmod.regsel.prebnkdat2).getTime()) {
								this.$notify.error({ title: '错误', message: '开始日期应小于或等于截止日期!' });
								return
							}
						}
					let params = {
						...this.model.imgInvmod.regsel,
						pageSize: this.model.imgInvmod.pagination.pageSize,
						pageNum: this.model.imgInvmod.pagination.pageNum
					}
					let res = await Api.post("/manager/invchk/getinvreglst", params)
					if (res.respCode === SUCCESS) {
						this.model.imgInvmod.tableData1 = res.data.list
						this.model.imgInvmod.pagination.total = res.data.total
					}
				}
      this.load = false
    },
    async handleReset() {
      if(this.activeTab == 'dl'){
				this.model.invchk = {
					invcod:'',//发票代码
					invnum:'',//发票号码
					imfref:'',//查验编号
					guid:'',//影像编号批次号
					ownref:'',//业务编号
					imfrefsta:'',//查验编号状态
					opndatfrom:new Date((new Date).getTime() - (3 * 24 * 60 * 60 * 1000)),//起始日期
					opndatto:new Date(),//截止日期
					isVoid:'N'
				}
			}else if(this.activeTab == 'dj'){
				this.model.imgInvmod.regsel = {
					invnum: '',
					invcod: '',
					bustyp: '',
					antnum: '',
					opndat: '',
					prebnkdat: new Date((new Date).getTime() - (3 * 24 * 60 * 60 * 1000)),//起始日期
					prebnkdat2: new Date(),//截止日期
				}
			}else if(this.activeTab == 'sr'){
				this.model.infcon = {
					seaownref: '', //业务编号
					subownref: '',//子业务编号 
					opndatfrom: new Date((new Date).getTime() - (3 * 24 * 60 * 60 * 1000)),//开始时间
					opndatto: new Date(), //截止时间
					invoicecode:'', //发票代码
					invoicenumber:'',//发票号码
					yewulx:'',//业务类型
					monstatus:'', //发票监控状态 
					hantyp: '', //处理状态
			}
			}else if(this.activeTab == 'ck'){
				this.model.invcon = {
					invoicecode:'', //发票代码
					invoicenumber:'',//发票号码
					seqnum:'',//批次号
				}
			}
		},
		async currentChange(num) {
			this.model.imgInvmod.pagination.pageNum = num
			this.handleSearch()
		},
		async sizeChange(size) {
			this.model.imgInvmod.pagination.pageSize = size
			this.handleSearch()
		},
		async getInvList(row) {
			let res = await Api.post("/manager/invchk/invdellst", row.smhinr)
			if (res.respCode == SUCCESS) {
				this.model.imgInvmod.tableData4 = res.data
				this.model.imgInvmod.invDelForm = {
					bustyp: res.data[0].bustyp,
					antnum: res.data[0].antnum,
					antdat: res.data[0].antdat,
					busdcr: res.data[0].busdcr,
					antnam: res.data[0].antnam,
					antdtl: res.data[0].antdtl,
				}
			}
			this.model.showCanTab = true
			this.model.tabVal = 'fpzf'
		},
		//发票作废发送报文
		async sendInv() {
			let params = {
				invlst: this.model.imgInvmod.tableData4
			}
			let res = await Api.post("/manager/invchk/del", params)
			if (res.respCode == SUCCESS) {
				if(res.data.errorMsg){
					this.$notify.error({
						title: "错误",
						message: res.data.errorMsg
					});
					return
				}
				this.$notify({
					title: '成功',
					message: '提交成功',
					type: 'success',
				})
				this.model.showCanTab = false
				this.model.tabVal = 'djzf'
				this.handleSearch()
			}
		},
    // 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();
		},
		closeDialog() {
			this.detailsDialog = false
		},
		file2XLSX(file) {
			return new Promise(function (resolve, reject) {
				// 通过FileReader对象读取文件
				const reader = new FileReader()
				// 读取为二进制字符串
				reader.readAsBinaryString(file)
				reader.onload = function (e) {
					console.log(e, '读取文件成功的e');
					// 获取读取文件成功的结果值
					const data = e.target.result
					// XLSX.read解析数据,按照type 的类型解析
					const XLSX = require('xlsx')
					let wb = XLSX.read(data, {
						type: 'binary' // 二进制
					})
					console.log(wb, '---->解析后的数据')
					// 存储获取到的数据
					const result = []
					// 工作表名称的有序列表
					wb.SheetNames.forEach(sheetName => {
						result.push({
							// 工作表名称
							sheetName: sheetName,
							// 利用 sheet_to_json 方法将 excel 转成 json 数据
							sheet: XLSX.utils.sheet_to_json(wb.Sheets[sheetName])
						})
					})
					resolve(result)
				}
			})
		},
    //获取批次号
    async getSeqnum(){
			if(this.model.invcon.invoicenumber == null || this.model.invcon.invoicenumber == ''){
        this.$notify.error({ title: '错误', message: '请先输入发票号码!' });
        return
			}
			if(this.model.invcon.invoicenumber.length != 8 && this.model.invcon.invoicenumber.length != 20 ) {
				this.$notify.error({ title: '错误', message: '发票号码为8位或20位!' });
        	return
			}
			if(this.model.invcon.invoicenumber.length == 8){
				if(this.model.invcon.invoicecode == null || this.model.invcon.invoicecode == ''){
        	this.$notify.error({ title: '错误', message: '请先输入发票代码!' });
        	return
      	}
			}
      let rtnmsg = await Api.post('/manager/infinv/queryInvByCodeNum', {...this.model.invcon});
      if (rtnmsg.respCode == SUCCESS) {
          if(rtnmsg.data.seqNumLst == null){
            this.$notify.error({ title: '错误', message: '该笔发票没有绑定业务!' });
            return;
					}
					this.model.invcon.seqNumLst = rtnmsg.data.seqNumLst
					this.$notify({
						title: '成功',
						message: '批次号获取成功',
						type: 'success',
					});
          // if(!rtnmsg.data.seqnum){
          //   this.$notify.error({ title: '错误', message: '该笔发票没有生成批次号' });
          //   return;
          // }
          
      } else {
        this.$notify.error({ title: '错误', message: '服务请求失败!' });
      }

    },
    //更新流程状态 
    async updateStatus(){
      if(this.model.invcon.seqnum == null || this.model.invcon.seqnum == ''){
        this.$notify.error({ title: '错误', message: '请输入批次号,若批次号未知,输入发票代码和发票号码点击批次号获取按钮获取批次号' });
        return
      }
      let rtnmsg = await Api.post('/manager/infinv/queryInvcrlBySeqnum', {...this.model.invcon});
      if (rtnmsg.respCode == SUCCESS) {
          if(!rtnmsg.data){
            this.$notify.error({ title: '错误', message: '该批次号记录不存在!' });
            return;
          }else{
            this.$confirm('是否要更新该批次发票流程状态,是点击OK!', '提示', {
              confirmButtonText: 'OK',
              cancelButtonText: 'Cancel',
              type: 'warning',
          }).then(async () => {
              let res = await Api.post('/manager/infinv/updateInvcrlBySeqnum', {
                 ...this.model.invcon
              });
              if (res.respCode == SUCCESS) {
                  this.$notify({
                      title: '成功',
                      message: '更新成功!',
                      type: 'success',
                  });
              }
          })
          }
      } else {
        this.$notify.error({ title: '错误', message: '服务请求失败!' });
      }
		},
		//发票核验跳转
		invCheck(){
			this.routerPush({
				path: "/business/invsel"
			});
		},
    //解绑
    unBind(){
      if(this.stmDataCK.data.length == 0){
        this.$notify.error({ title: '错误', message: '请先输入批次号查询!' })
        return;
      }else{
				//先注销该判断,可以随意解绑
        // for(let i = 0; i < this.stmDataCK.data.length; i++){
        //   if(this.stmDataCK.data[i].trninr){
        //     this.$notify.error({ title: '错误', message: '该批次发票中含有已经和业务关联过的发票,不能删除!' })
        //     return;
        //   }
        // }
      }
      this.$confirm('是否解绑该批次下所有发票,是请点击OK!', '提示', {
        confirmButtonText: 'OK',
        cancelButtonText: 'Cancel',
        type: 'warning',
    }).then(async () => {
        let res = await Api.post('/manager/infinv/unBind', 
         { seqNumLst:this.stmDataCK.data.map(obj => obj.seqnum)}
        );
        if (res.respCode == SUCCESS) {
            this.$notify({
                title: '成功',
                message: '解绑成功!',
                type: 'success',
            });
        }
        // this.formSubmit();
    })

    },
    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("/manager/infinv/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++){
            array.push(res.data[m][this.columns[n].prop])
        }
        obj.push(array)
        
      }
      Utils.exportToExcel (obj, "发票查询交易单_"+name+".xlsx", "发票查询交易单") ;
       }
      // loading.close();
			},
			async getdbCodes(dbCode, codeNam) {
				let params = {
					codeType: dbCode,
					uil: 'EN'
				}
				let rtnmsg = await Api.post("/manager/dic/listDicInfo", params)
				if (rtnmsg.respCode === SUCCESS) {
					let srvtxt = rtnmsg.data.map(item => ({
						value: item.codeValue,
						label: item.codeName
					}));
					this.dbCodes[codeNam] = srvtxt
				}
			},
      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
        }
			},
			getLabel(list, id) {
				if (id != '' && Array.isArray(list) && list.length != 0) {
					return !list.find(item => item['value'] == id) ? id : list.find(item => item['value'] == id)['label']
				}
			},
      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.infgidBSTableRef.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
		},
		async detailInfo(row){
			let res = await Api.post("/manager/invchk/getImfInfoByImfref",row.imfref)
			if(res.respCode == SUCCESS){
				this.imguseList = res.data.imguseList
				this.invlst = res.data.invlst
				this.showInfo = true
			}
		},
		async unbinding(row) {
			Api.post("/manager/invchk/unbindByInvsel", row.imfinr).then(res => {
				if (res.respCode == SUCCESS) {
					//独立交易上传了影像则需要解绑影像
					if (res.data.guid && row.ownref) {
						let data = {
							ownref: row.ownref,
							lotnum: res.data.guid,
							imginr: res.data.imginr,
							trncod: res.data.trncod,
							opuser: window.sessionStorage.userName,
							optype: 1,
							branch: JSON.parse(window.sessionStorage.currentOrg)
								.departmentNumber
						};
					  Api.post("/manager/img/bindOrUnbindForInvsel", data).then((resp)=>{{
							if (resp.respCode == SUCCESS) {
								this.$notify({
									title: '成功',
									message: '解绑成功',
									type: 'success',
								});
								//解绑成功重新查询
								this.handleSearch()
							}
						}})
					}else{
						this.$notify({
							title: '成功',
							message: '解绑成功',
							type: 'success',
						});
						//解绑成功重新查询
						this.handleSearch()
					}
				}
			})

		},
		onReqShow(row){
			this.$refs.invImg.showDoc = true
			this.$refs.invImg.getList(row)
		},
		async handle(row){
			let res = await Api.post('/manager/invchk/getTransacionInr',row.ownref)
			if(res.respCode == SUCCESS){
				this.routerPush({
				path: "/business/" + res.data.trnNam,
				query: {inr: res.data.inr}
				});
			}
		}
		
  },

};