1 //导出excel 2 public function touzi_doExport() { 3 $search=$_POST[‘search‘]; //接受前端传过来的数据 4 8 $this->success(U(‘Tongji/touzi_doExport_action‘,$search)); //传值 9 } 10 11 public function touzi_doExport_action() { 12 $search=$_GET; //接收数据 13 $where=array(); 14 $starttime=$search[‘starttime‘]; 15 $endtime=$search[‘endtime‘]; 16 unset($search[‘starttime‘]); 17 unset($search[‘endtime‘]); 18 $jxstarttime=$search[‘jxstarttime‘]; 19 $jxendtime=$search[‘jxendtime‘]; 20 unset($search[‘jxstarttime‘]); 21 unset($search[‘jxendtime‘]); 22 if (session(‘roleid‘)==8) {//理财经理 23 $search[‘managerid‘]=session(‘userid‘); 24 } else { 25 $ids=A(‘Index‘)->public_checkBranchid($search[‘branchid‘]); 26 if ($ids) { 27 $where[]="Users.branchid IN (".implode(",",$ids).")"; 28 unset($search[‘branchid‘]); 29 } 30 } 31 foreach ($search as $k=>$v){//迭代获取 32 if(!$v) continue; 33 $where[] = "{$k} = ‘{$v}‘"; 34 } 35 if ($starttime) { 36 $where[] = "Tenderlist.dateline >= ".$starttime; 37 if ($endtime) { 38 $endtime=strtotime("+1 day",$endtime); 39 $where[] = "Tenderlist.dateline <= ".$endtime; 40 } 41 } 42 if ($jxstarttime) { 43 $where[] = "Loanlist.startpaytime >= ".$jxstarttime; 44 if ($jxendtime) { 45 //$jxendtime=strtotime("+1 day",$jxendtime); 46 $where[] = "Loanlist.startpaytime <= ".$jxendtime; 47 } 48 } 49 $where[] = "Loanlist.status!=‘failed‘"; 50 $where=implode(" and ", $where); 51 52 $tenderlist=D(‘Tenderlist2View‘); 53 $list=$tenderlist->where($where)->select(); 54 if ($list) { 55 foreach ($list as $key=>$val) { 56 if ($val[‘adminrealname‘]) { 57 $list[$key][‘adminrealname‘]=$val[‘adminrealname‘]."(".$val[‘adminname‘].")"; 58 } else { 59 $list[$key][‘adminrealname‘]=‘无‘; 60 } 61 if ($val[‘isfailed‘]) { 62 $list[$key][‘isfailed‘]=‘是‘; 63 } else { 64 $list[$key][‘isfailed‘]=‘否‘; 65 } 66 //$list[$key][‘crediturl‘]=getGrade(totalCredit($val)); 67 $list[$key][‘money‘]=moneyTrans($list[$key][‘money‘]); 68 $list[$key][‘paiedmoney‘]=moneyTrans($list[$key][‘paiedmoney‘]); 69 $list[$key][‘earnmoney‘]=moneyTrans($list[$key][‘earnmoney‘]); 70 $list[$key][‘dateline‘]=date(‘Y-m-d H:i:s‘,$list[$key][‘dateline‘]); 71 $list[$key][‘startpaytime‘]=date(‘Y-m-d H:i:s‘,$list[$key][‘startpaytime‘]); 72 $list[$key][‘lasttime‘]=date(‘Y-m-d H:i:s‘,strtotime("+".$val[‘loanterm‘]." month",$val[‘startpaytime‘])); 73 } 74 } //本方法以上所有步骤,都是为了从数据库获得数据:$list
//以下两行,固定方式,语法。输出。 75 $list=keysortExcel($list,array(‘loanid‘,‘loanname‘,‘branchname‘,‘nickname‘,‘adminrealname‘,‘loanterm‘,‘money‘,‘paiedmoney‘,‘earnmoney‘,‘status‘,‘isfailed‘,‘dateline‘,‘startpaytime‘,‘lasttime‘)); 76 exportexcel($list,array(‘标的ID‘,‘贷款名称‘,‘所属地区‘,‘投标用户‘,‘理财经理‘,‘借款期限‘,‘投标金额‘,‘已偿还金额‘,‘已赚取金额‘,‘投标方式‘,‘是否流标‘,‘投标日期‘,‘计息日期‘,‘截止日期‘),‘投资业务统计-‘.time()); 77 }
前台传入数据:
1 function doExportt(id) 2 { 3 var id = id; 4 $.post(‘<{:U(‘Tongji/index_edit_doExport‘)}>‘,{id:id}, function(res){ 5 if(!res.status){ 6 $.messager.alert(‘提示信息‘, res.info, ‘error‘); 7 }else{ 8 window.open(res.info,‘_blank‘); 9 } 10 }, ‘json‘); 11 }
其中,{id:id},是 post 传过去的数据
时间: 2024-10-11 21:46:01