AdminData.php 923 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\utils\VueAdmin;
  3. use think\Request;
  4. class AdminData {
  5. public static function orderBy($default = '')
  6. {
  7. $sorts = Request::instance()->param('prop');
  8. $orders = Request::instance()->param('orderBy', 'desc');
  9. $orders = $orders == 'asc' ? 'asc' :'desc';
  10. $order = [];
  11. if(!($sorts) || $sorts == 'null' || $sorts == 'undefined')
  12. {
  13. if($default = explode(',', $default))
  14. {
  15. if(isset($default[1]) && $default[0] && $default[1]) {
  16. $order[] = ['sort'=>$default[0], 'orderBy'=>$default[1]];
  17. }
  18. }
  19. }else{
  20. $sorts = explode(',',$sorts);
  21. foreach ($sorts as $sort){
  22. $order[] = [
  23. 'sort' => $sort,
  24. 'orderBy' => $orders
  25. ];
  26. }
  27. }
  28. return $order;
  29. }
  30. }