Log.php 2.6 KB

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