Official.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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\adm\controller;
  15. use app\base\BaseController;
  16. use app\adm\model\OfficialDocs;
  17. use app\adm\validate\CarValidate;
  18. use think\exception\ValidateException;
  19. use think\facade\Db;
  20. use think\facade\View;
  21. class Official extends BaseController
  22. {
  23. /**
  24. * 构造函数
  25. */
  26. protected $model;
  27. public function __construct()
  28. {
  29. parent::__construct(); // 调用父类构造函数
  30. $this->model = new OfficialDocs();
  31. }
  32. /**
  33. * 数据列表
  34. */
  35. public function datalist()
  36. {
  37. $param = get_params();
  38. if (request()->isAjax()) {
  39. $where=[];
  40. $whereOr = [];
  41. $map1 = [];
  42. $map2 = [];
  43. $map3 = [];
  44. $map4 = [];
  45. $uid = $this->uid;
  46. $tab = isset($param['tab']) ? $param['tab'] : 0;
  47. //条件1
  48. $map1[] = ['admin_id','=',$uid];
  49. //条件2
  50. $map2[] = ['check_status','=',2];
  51. $map2[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',send_uids)")];
  52. //条件3
  53. $map3[] = ['check_status','=',2];
  54. $map3[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',copy_uids)")];
  55. //条件4
  56. $map4[] = ['check_status','=',2];
  57. $map4[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',share_uids)")];
  58. $where[]=['delete_time','=',0];
  59. if (!empty($param['keywords'])) {
  60. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  61. }
  62. if (!empty($param['secrets'])) {
  63. $where[] = ['secrets', '=', $param['secrets']];
  64. }
  65. if (!empty($param['urgency'])) {
  66. $where[] = ['urgency', '=', $param['urgency']];
  67. }
  68. if($tab == 0){
  69. $whereOr = [$map1,$map2];
  70. }
  71. if($tab == 1){
  72. $where[] = ['admin_id','=',$uid];
  73. }
  74. if($tab == 2){
  75. $where[] = ['check_status','=',2];
  76. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',send_uids)")];
  77. }
  78. if($tab == 3){
  79. $where[] = ['check_status','=',2];
  80. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',copy_uids)")];
  81. }
  82. if($tab == 4){
  83. $where[] = ['check_status','=',2];
  84. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',share_uids)")];
  85. }
  86. $list = $this->model->datalist($param,$where,$whereOr);
  87. return table_assign(0, '', $list);
  88. }
  89. else{
  90. View::assign('secrets', $this->model::$Secrets);
  91. View::assign('urgency', $this->model::$Urgency);
  92. return view();
  93. }
  94. }
  95. /**
  96. * 添加/编辑
  97. */
  98. public function add()
  99. {
  100. $param = get_params();
  101. if (request()->isAjax()) {
  102. if (isset($param['draft_time'])) {
  103. $param['draft_time'] = strtotime($param['draft_time']);
  104. }
  105. if (!empty($param['id']) && $param['id'] > 0) {
  106. $this->model->edit($param);
  107. } else {
  108. $param['admin_id'] = $this->uid;
  109. $this->model->add($param);
  110. }
  111. }else{
  112. $id = isset($param['id']) ? $param['id'] : 0;
  113. if(is_mobile()){
  114. return view('qiye@/index/405',['msg' => '由于公文包含了富文本编辑,手机端不方便操作,请到PC端新增或编辑']);
  115. }
  116. if ($id>0) {
  117. $detail = $this->model->getById($id);
  118. View::assign('detail', $detail);
  119. return view('edit');
  120. }
  121. return view();
  122. }
  123. }
  124. /**
  125. * 查看
  126. */
  127. public function view($id)
  128. {
  129. $detail = $this->model->getById($id);
  130. if (!empty($detail)) {
  131. View::assign('detail', $detail);
  132. View::assign('auth_office', isAuth($this->uid,'office_admin','conf_1'));
  133. if(is_mobile()){
  134. return view('qiye@/index/official_view');
  135. }
  136. return view();
  137. }
  138. else{
  139. return view(EEEOR_REPORTING,['warning'=>'找不到页面']);
  140. }
  141. }
  142. /**
  143. * 删除
  144. */
  145. public function del()
  146. {
  147. $param = get_params();
  148. $id = isset($param['id']) ? $param['id'] : 0;
  149. if (request()->isDelete()) {
  150. $this->model->delById($id);
  151. } else {
  152. return to_assign(1, "错误的请求");
  153. }
  154. }
  155. //待审公文列表
  156. public function pending()
  157. {
  158. if (request()->isAjax()) {
  159. $param = get_params();
  160. $uid = $this->uid;
  161. $where=[];
  162. if (!empty($param['keywords'])) {
  163. $where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
  164. }
  165. $where[] = ['check_status', '=', 1];
  166. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
  167. $list = $this->model->datalist($param,$where);
  168. return table_assign(0, '', $list);
  169. } else {
  170. return view();
  171. }
  172. }
  173. //已审公文列表
  174. public function reviewed()
  175. {
  176. if (request()->isAjax()) {
  177. $param = get_params();
  178. $uid = $this->uid;
  179. $where=[];
  180. if (!empty($param['keywords'])) {
  181. $where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
  182. }
  183. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
  184. $list = $this->model->datalist($param,$where);
  185. return table_assign(0, '', $list);
  186. } else {
  187. return view();
  188. }
  189. }
  190. }