Overtimes.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. declare (strict_types = 1);
  14. namespace app\home\controller;
  15. use app\base\BaseController;
  16. use app\home\model\Overtimes as OvertimesModel;
  17. use app\home\validate\OvertimesValidate;
  18. use think\exception\ValidateException;
  19. use think\facade\Db;
  20. use think\facade\View;
  21. class Overtimes extends BaseController
  22. {
  23. /**
  24. * 构造函数
  25. */
  26. protected $model;
  27. public function __construct()
  28. {
  29. parent::__construct(); // 调用父类构造函数
  30. $this->model = new OvertimesModel();
  31. }
  32. /**
  33. * 数据列表
  34. */
  35. public function datalist()
  36. {
  37. $param = get_params();
  38. if (request()->isAjax()) {
  39. $where=[];
  40. $where[]=['delete_time','=',0];
  41. if (!empty($param['keywords'])) {
  42. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  43. }
  44. $list = $this->model->datalist($where, $param);
  45. return table_assign(0, '', $list);
  46. }
  47. else{
  48. return view();
  49. }
  50. }
  51. /**
  52. * 添加/编辑
  53. */
  54. public function add()
  55. {
  56. $param = get_params();
  57. if (request()->isAjax()) {
  58. if(!empty($param['start_date'])){
  59. $param['start_date'] = strtotime($param['start_date']);
  60. }
  61. if(!empty($param['end_date'])){
  62. $param['end_date'] = strtotime($param['end_date']);
  63. if($param['end_date']<$param['start_date']){
  64. return to_assign(1, '结束时间不能小于开始时间');
  65. }
  66. }
  67. if (!empty($param['id']) && $param['id'] > 0) {
  68. $this->model->edit($param);
  69. } else {
  70. $param['admin_id'] = $this->uid;
  71. $param['did'] = $this->did;
  72. $this->model->add($param);
  73. }
  74. }else{
  75. $id = isset($param['id']) ? $param['id'] : 0;
  76. if ($id>0) {
  77. $detail = $this->model->getById($id);
  78. View::assign('detail', $detail);
  79. }
  80. if(is_mobile()){
  81. return view('qiye@/approve/add_jiaban');
  82. }
  83. return view();
  84. }
  85. }
  86. /**
  87. * 查看
  88. */
  89. public function view($id)
  90. {
  91. $detail = $this->model->getById($id);
  92. if (!empty($detail)) {
  93. View::assign('create_user', get_admin($detail['admin_id']));
  94. View::assign('detail', $detail);
  95. if(is_mobile()){
  96. return view('qiye@/approve/view_jiaban');
  97. }
  98. return view();
  99. }
  100. else{
  101. return view(EEEOR_REPORTING,['code'=>404,'warning'=>'找不到页面']);
  102. }
  103. }
  104. /**
  105. * 删除
  106. */
  107. public function del()
  108. {
  109. $param = get_params();
  110. $id = isset($param['id']) ? $param['id'] : 0;
  111. if (request()->isDelete()) {
  112. $this->model->delById($id);
  113. } else {
  114. return to_assign(1, "错误的请求");
  115. }
  116. }
  117. }