1.实现的效果如下:
2.上面切换效果写个展示或隐藏就行,只说明数据展示来源
3.引入js,加载表格:lay-data:代表数据重载
请求后台数据:
1 layui.use('table', function(){ 2 var table = layui.table; 3 //第一个实例 4 table.render({ 5 elem: '#demo' 6 // ,height: 312 7 // ,width:1000 8 ,url: '{:url("index/ordersitem")}' //数据接口 9 ,page: true //开启分页 10 ,limit:10 11 ,id:uid 12 ,cols: [[ //表头 13 {field: 'id', title: 'ID', width:80, sort: true, align: 'center'} 14 ,{field: 'orders', title: '订单号', width:200,align: 'center'} 15 ,{field: 'service', title: '服务项目', width:200,align: 'center'} 16 ,{field: 'contract', title: '是否签订合同', width: 120,align: 'center'} 17 ,{field: 'isjie', title: '是否结汇', width: 120} 18 ,{field: 'istui', title: '是否退税', width: 120} 19 ,{field: 'addtime', title: '提交时间', width: 160, sort: true,align: 'center'} 20 ,{field: 'status', title: '状态', width: 120,align: 'center'} 21 ]] 22 }); 23 table.reload('rest', { 24 url: '{:url("index/ordersitem")}' 25 ,id:uid 26 });
后台:
1 public function ordersitem(){ 2 //所有订单 3 $page=input('page')?input('page'):1; 4 $limit=input('limit')?input('limit'):1; 5 $uid=input('id'); 6 $limit=intval($limit); 7 $start=$limit*($page-1); 8 $res=db('sum a ')->join('user v','v.id=a.uid')->limit($start,$limit)->field('a.*,v.nameCn')->order('a.addtime desc')->select(); 9 foreach ($res as $key => $value) { 10 if($value['isharvest']==0){ 11 $res[$key]['isharvest']="未收到"; 12 }else{ 13 $res[$key]['isharvest']="已收到"; 14 } 15 if($value['contract']==0){ 16 $res[$key]['contract']="未签订"; 17 }else{ 18 $res[$key]['contract']="已签订"; 19 } 20 if($value['isjie']==0){ 21 $res[$key]['isjie']="未结汇"; 22 }elseif($value['isjie']==1){ 23 $res[$key]['isjie']="结汇中"; 24 }else{ 25 $res[$key]['isjie']="已结汇"; 26 } 27 28 if($value['istui']==0){ 29 $res[$key]['istui']="未退税"; 30 }elseif($value['istui']==1){ 31 $res[$key]['istui']="退税中"; 32 }else{ 33 $res[$key]['istui']="已退税"; 34 } 35 if($value['istui']==2&&$value['isjie']==2){ 36 $res[$key]['status']="已完成"; 37 38 }elseif(!$res[$key]['status']){ 39 $res[$key]['status']="正在进行中"; 40 } 41 $res[$key]['service']=pros($value['service']); 42 $res[$key]['addtime']=date("Y-m-d H:i:s",$value['addtime']); 43 } 44 $count=db('sum a ')->join('user v','v.id=a.uid')->field('a.*,v.nameCn')->order('a.addtime desc')->count(); 45 if(!$res){ 46 $data=json(['code'=>0,'msg'=>'暂无数据!']); 47 48 }else{ 49 $data=json(['code'=>0,'msg'=>'获取数据成功!','count'=>$count,'data'=>$res]); 50 51 } 52 return $data; 53 }
标签:width,layui,value,field,limit,key,res,数据,加载 From: https://www.cnblogs.com/mo3408/p/16725898.html