Procuremenexport.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * 外发采购 — 月度报表导出列表
  6. *
  7. * @icon fa fa-file-excel-o
  8. */
  9. class Procuremenexport extends Backend
  10. {
  11. /**
  12. * @var \app\admin\model\Purchasemonthexport
  13. */
  14. protected $model = null;
  15. protected $searchFields = 'ym,admin_name';
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\Purchasemonthexport;
  20. }
  21. public function index()
  22. {
  23. $this->relationSearch = false;
  24. $this->request->filter(['strip_tags', 'trim']);
  25. if ($this->request->isAjax()) {
  26. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  27. $list = $this->model
  28. ->where($where)
  29. ->order($sort ?: 'id', $order ?: 'desc')
  30. ->paginate($limit);
  31. foreach ($list as $row) {
  32. $ct = (int)($row['createtime'] ?? 0);
  33. $row->createtime_text = $ct > 0 ? date('Y-m-d H:i:s', $ct) : '';
  34. $row->total_amount_text = number_format((float)($row['total_amount'] ?? 0), 2, '.', ',');
  35. }
  36. return json(['total' => $list->total(), 'rows' => $list->items()]);
  37. }
  38. return $this->view->fetch();
  39. }
  40. }