Member.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\user\controller;
  15. use app\common\constant\CommonConstant;
  16. use app\common\model\Department;
  17. use library\Controller;
  18. /**
  19. * 员工
  20. */
  21. class Member extends Controller
  22. {
  23. /**
  24. * 绑定数据表
  25. * @var string
  26. */
  27. protected $table = 'StoreMember';
  28. /**
  29. * 列表
  30. * @auth true
  31. * @menu true
  32. * @throws \think\Exception
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @throws \think\exception\DbException
  36. */
  37. public function index()
  38. {
  39. $status = input('status');
  40. $signature_status = input('signature_status');
  41. $this->get_status_list = CommonConstant::get_status_list();
  42. $this->get_signature_status_list = CommonConstant::get_signature_status_list();
  43. $this->title = '员工列表';
  44. $query = $this->_query($this->table)
  45. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  46. ->when(array_key_exists($status, $this->get_status_list), function ($query) use ($status) {
  47. $query->where('status', $status);
  48. })
  49. ->when(array_key_exists($signature_status, $this->get_signature_status_list), function ($query) use ($signature_status) {
  50. $query->where('signature_status', $signature_status);
  51. })
  52. ->like('name,mobile');
  53. $query->page();
  54. }
  55. /**
  56. * 列表数据处理
  57. * @param array $data
  58. * @throws \Exception
  59. */
  60. protected function _index_page_filter(&$data)
  61. {
  62. $department_list = Department::column('dept_id,name');
  63. foreach ($data as &$value) {
  64. $department_ids = explode(',',$value['department']);
  65. $department = '';
  66. foreach ($department_ids as $val){
  67. if(array_key_exists($val,$department_list)){
  68. $department .= $department_list[$val].',';
  69. }
  70. }
  71. $value['department_text'] = $department;
  72. }
  73. }
  74. protected function _form_filter(&$data)
  75. {
  76. }
  77. /**
  78. * 编辑
  79. * @auth true
  80. * @throws \think\Exception
  81. * @throws \think\db\exception\DataNotFoundException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. * @throws \think\exception\DbException
  84. * @throws \think\exception\PDOException
  85. */
  86. public function edit()
  87. {
  88. $this->title = '编辑';
  89. $this->_form($this->table, 'form');
  90. }
  91. /**
  92. * 启用
  93. * @auth true
  94. * @throws \think\Exception
  95. * @throws \think\exception\PDOException
  96. */
  97. public function resume()
  98. {
  99. $this->applyCsrfToken();
  100. $this->_save($this->table, ['status' => CommonConstant::STATUS_NORMAL]);
  101. }
  102. /**
  103. * 禁用
  104. * @auth true
  105. * @throws \think\Exception
  106. * @throws \think\exception\PDOException
  107. */
  108. public function forbid()
  109. {
  110. $this->applyCsrfToken();
  111. $this->_save($this->table, ['status' => CommonConstant::STATUS_FROZEN]);
  112. }
  113. /**
  114. * 审核签名
  115. * @auth true
  116. * @throws \think\Exception
  117. * @throws \think\exception\PDOException
  118. */
  119. public function signature_status()
  120. {
  121. $signature_status = input('signature_status');
  122. if(!array_key_exists($signature_status,CommonConstant::get_signature_status_list())){
  123. $this->controller->error('审核状态参数错误');
  124. }
  125. $this->applyCsrfToken();
  126. $this->_save($this->table, ['signature_status' => $signature_status]);
  127. }
  128. }