作者:何卫先生 | 来源:互联网 | 2014-06-12 18:37
这个问题困扰了我很久,终于还是自己写JQUERY把它搞掂了,希望能对遇到同样问题的人有所帮助,好吧,下面就是源代码:
jquery code:
- $(function(){
-
-
- function _getIds(selectedIds,targetType){
- var ids="";
- var $box=targetType=="dialog"?$.pdialog.getCurrent():navTab.getCurrentPanel();
- $box.find("input:checked").filter("[name='"+selectedIds+"']").each(function(i){
-
- var val=$(this).val();
- ids+=i==0?val:","+val;});
- return ids;
- }
-
- $(".iconn").click(
- function(){
-
- var targetType="navTab";
- var selectedIds="ids";
- var postType="string";
- var ids=_getIds(selectedIds,targetType);
- if(!ids){
- alertMsg.error($(".iconn").attr("warn"));
- return false;
-
- }else{
-
- window.open("__URL__/memberExport/ids/"+ids);
- }
-
- });
- });
PHP code:
-
- public function memberExport(){
- $id=$_REQUEST['ids'];
-
-
-
- $filename=date('Y-m-d');
- header("Pragma:public");
- header("Expires:0");
- header("Cache-Control:must-revalidate,post-check=0,pre-check=0");
- header("Content-Type:application/force-download");
- header("Content-Type:application/vnd.ms-execl;charset=gb2312");
- header("Content-Type:application/octet-stream");
- header("Content-Type:application/download");
- header('Content-Disposition:attachment;filename="'.$filename.'.xls"');
- header("Content-Transfer-Encoding:binary");
- if(!$id){
- $this->error('非法操作!');
- }else{
-
- $map['id']=array('in',$id);
- $title="用户名\t 姓名\t 部门\t 职务\t 身份证\t 职称\t 学历\t 毕业时间\t 录用时间";
- $title=iconv('utf-8','gbk',$title);
- echo $title;
- set_time_limit(0);
- $offset= 0;
- $length=100;
- $Member = M('Member');
- $list=$Member->where($map)->order('id desc')->select();
- if(!$list){
- $this->error('操作错误!');
- }else{
- foreach($list as $key=>$row){
- echo "\n";
- echo iconv('utf-8','gbk',$row['username'])."\t";
- echo iconv('utf-8','gbk',$row['name'])."\t";
- echo iconv('utf-8','gbk',$row['department'])."\t";
- echo iconv('utf-8','gbk',$row['zhiwu'])."\t";
- echo iconv('utf-8','gbk',$row['sfz'])."\t";
- echo iconv('utf-8','gbk',$row['zhicheng'])."\t";
- echo iconv('utf-8','gbk',$row['xueli'])."\t";
- echo iconv('utf-8','gbk',$row['bytime'])."\t";
- echo iconv('utf-8','gbk',$row['lytime'])."\t";
-
- }
- $offset+=$length;
- }
- }
- }