Log.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\qingdong\customer;
  3. use app\admin\controller\qingdong\Base;
  4. use addons\qingdong\model\OperationLog;
  5. use think\Db;
  6. use think\Exception;
  7. /**
  8. * 操作文档:https://doc.fastadmin.net/qingdong
  9. * 软件介绍:https://www.fastadmin.net/store/qingdong.html
  10. * 售后微信:qingdong_crm
  11. * 日志管理
  12. */
  13. class Log extends Base
  14. {
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \addons\qingdong\model\OperationLog;
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //设置过滤方法
  27. $this->request->filter(['strip_tags', 'trim']);
  28. $customer_id = input('customer_id','','trim');
  29. $contacts_id = input('contacts_id','','trim');
  30. $leads_id = input('leads_id','','trim');
  31. $contract_id = input('contract_id','','trim');
  32. if ($this->request->isAjax()) {
  33. if ($this->request->request('keyField')) {
  34. return $this->selectpage();
  35. }
  36. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  37. $wheres = [];
  38. if(isset($customer_id) && $customer_id){
  39. $wheres['relation_type'] = 1;
  40. $wheres['relation_id'] = $customer_id;
  41. }
  42. if(isset($contacts_id) && $contacts_id){
  43. $wheres['relation_type'] = 2;
  44. $wheres['relation_id'] = $contacts_id;
  45. }
  46. if(isset($leads_id) && $leads_id){
  47. $wheres['relation_type'] = 4;
  48. $wheres['relation_id'] = $leads_id;
  49. }
  50. if(isset($contract_id) && $contract_id){
  51. $wheres['relation_type'] = 3;
  52. $wheres['relation_id'] = $contract_id;
  53. }
  54. $list = $this->model->with('staff')->where($where)->where($wheres)
  55. ->order($sort, $order)->paginate($limit);
  56. $rows = $list->items();
  57. $result = array("total" => $list->total(), "rows" => $list->items());
  58. return json($result);
  59. }
  60. return $this->view->fetch();
  61. }
  62. }