Blame view

application/admin/controller/qingdong/general/Remind.php 2.93 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  <?php

  

  namespace app\admin\controller\qingdong\general;

  

  use addons\qingdong\model\Staff;

  use app\admin\controller\qingdong\Base;

  use addons\qingdong\model\Field;

  use think\Db;

  use think\Exception;

  

  /**

   * 提醒人管理

   */

  class Remind extends Base {

  	protected $relationSearch = true;

  	/**

  	 * @var \addons\qingdong\model\Remind

  	 */

  	protected $model       = null;

  

  

  	public function _initialize() {

  		parent::_initialize();

  		$this->model =new \addons\qingdong\model\Remind();

  	}

  

  

  	/**

  	 * 查看

  	 */

  	public function index() {

  		//设置过滤方法

  		$this->request->filter(['strip_tags', 'trim']);

  		if ($this->request->isAjax()) {

  

  			$reminds = $this->model->where([])->select();

              $reminds = collection($reminds)->toArray();

  

  

  			$result = array("total" => count($reminds), "rows" => $reminds);

  

  			return json($result);

  		}

  

  		return $this->view->fetch();

  	}

      /**

       * 添加

       */

      public function add() {

          if ($this->request->isAjax()) {

              $data             = $this->request->post('row/a');

              $reminds = $this->model->where(array('type'=>$data['type']))->find();

              if($reminds){

                  $this->error('此类型已经存在,请前去修改');

              }

              $result           = $this->model->save($data);

              if (!$result) {

                  $this->error('提交失败');

              }

              $this->success('提交成功');

          }

  

          return $this->view->fetch();

      }

  

      /**

       * 修改

       */

      public function edit($ids = null) {

          $map['id'] = $ids;

          if ($this->request->isAjax()) {

              $data   = $this->request->post('row/a');

              $reminds = $this->model->where(array('type'=>$data['type'],'id'=>array('neq',$ids)))->find();

              if($reminds){

                  $this->error('此类型已经存在,请前去修改');

              }

              $result = $this->model->save($data, $map);

  

              if (!$result) {

                  $this->error('修改失败');

              }

              $this->success('修改成功');

          }

          $data = $this->model->where($map)->find();

          $this->view->assign("row", $data);

  

          return $this->view->fetch();

      }

  

      /**

       * 获取客户列表

       */

      public function getstaff()

      {

          $pageSize = input('pageSize');

          $pageNumber = input('pageNumber');

          $where = [];

          if ($keyValue = $this->request->request("keyValue")) {

              $where['id'] = ['in',explode(',',$keyValue)];

          }

          $name = input('name');

          if (!empty($name)) {

              $where['name'] = ['like', '%' . $name . '%'];

          }

          $customer = Staff::where($where)->field('id,name')->order('id desc')->paginate($pageSize, false, ['page' => $pageNumber]);

          return json(['list' => $customer->items(), 'total' => $customer->total()]);

      }

  

  }