ApproveInfo.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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\approve\controller;
  15. use app\common\constant\ApplyConstant;
  16. use app\common\constant\CommonConstant;
  17. use app\common\constant\OfferConstant;
  18. use app\common\service\ApproveInfoService;
  19. use app\common\service\CommonService;
  20. use app\common\model\ApproveInfo as model;
  21. use app\common\model\ApproveMaintainUser;
  22. use library\Controller;
  23. /**
  24. * 审批申请
  25. */
  26. class ApproveInfo extends Controller
  27. {
  28. /**
  29. * 绑定数据表
  30. * @var string
  31. */
  32. protected $table = 'ApproveInfo';
  33. /**
  34. * 控制器初始化
  35. */
  36. protected function initialize()
  37. {
  38. $this->get_module_list = CommonConstant::get_module_list();
  39. $this->get_approve_status_list = CommonConstant::get_approve_status_list();
  40. $this->get_approve_status_list_admin = CommonConstant::get_approve_status_list_admin();
  41. $this->get_is_who_list = CommonConstant::get_is_who_list();
  42. $this->get_pay_type_list = ApplyConstant::get_pay_type_list();
  43. $this->get_degree_list = OfferConstant::get_degree_list();
  44. }
  45. /**
  46. * 列表
  47. * @auth true
  48. * @menu true
  49. * @throws \think\Exception
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. * @throws \think\exception\DbException
  53. */
  54. public function index()
  55. {
  56. $this->module = $module = input('module');
  57. $status = input('status');
  58. $create_at = input('create_at');
  59. $order_no = input('order_no');
  60. $reason = input('reason');
  61. $type = input('type');
  62. $desc = input('desc');
  63. $create_data = [];
  64. if ($create_at) {
  65. foreach (explode(' - ', $create_at) as $key => $val) {
  66. $create_data[] = $key == 0 ? "{$val} 00:00:00" : "{$val} 23:59:59";
  67. }
  68. }
  69. $this->title = $this->get_module_list[$this->module] . '列表';
  70. $this->get_type_list = CommonService::get_type_list($this->module);
  71. $data = model::field('is_deleted', true)
  72. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  73. ->where('module', $this->module)
  74. ->when($status > 0, function ($query) use ($status) {
  75. $query->where('status', $status);
  76. })
  77. ->when($create_data, function ($query) use ($create_data) {
  78. $query->where('create_at', 'BETWEEN', $create_data);
  79. })
  80. ->when($order_no, function ($query) use ($order_no) {
  81. $query->where('order_no', 'like', '%' . $order_no . '%');
  82. })
  83. ->when($reason, function ($query) use ($reason) {
  84. $query->where('reason', 'like', '%' . $reason . '%');
  85. })
  86. ->when($type > 0, function ($query) use ($type) {
  87. $query->where('type', $type);
  88. })
  89. ->when($desc, function ($query) use ($desc, $module) {
  90. if ($module == CommonConstant::MODULE_10) {
  91. $query->where('desc', 'like', '%' . $desc . '%');
  92. } else {
  93. $query->where('desc', $desc);
  94. }
  95. })
  96. ->with([
  97. 'createUser' => function ($query) {
  98. $query->field('id,userid,name,mobile');
  99. },
  100. ])
  101. ->order('id desc');
  102. self::_init($data);
  103. }
  104. /**
  105. * 编辑
  106. * @auth true
  107. * @throws \think\Exception
  108. * @throws \think\db\exception\DataNotFoundException
  109. * @throws \think\db\exception\ModelNotFoundException
  110. * @throws \think\exception\DbException
  111. * @throws \think\exception\PDOException
  112. */
  113. public function edit()
  114. {
  115. $this->title = '详情';
  116. $data = ApproveInfoService::get_detail(input('id') ?: 0, [], CommonConstant::IS_WHO_0, 'detail');
  117. if ($data) {
  118. // 维修人员
  119. $data['maintain_user'] = $data['module'] == CommonConstant::MODULE_8 && $data['maintain_user_id'] > 0 ? ApproveMaintainUser::field('id,name')->find($data['maintain_user_id']) : null;
  120. $this->title = $this->get_module_list[$data['module']] . '详情';
  121. $this->get_type_list = CommonService::get_type_list($data['module']);
  122. }
  123. return $this->fetch('form', ['vo' => $data]);
  124. }
  125. }