Seal.php 6.0 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\Seal as SealModel;
  17. use app\adm\validate\CarValidate;
  18. use think\exception\ValidateException;
  19. use think\facade\Db;
  20. use think\facade\View;
  21. class Seal extends BaseController
  22. {
  23. /**
  24. * 构造函数
  25. */
  26. protected $model;
  27. public function __construct()
  28. {
  29. parent::__construct(); // 调用父类构造函数
  30. $this->model = new SealModel();
  31. }
  32. /**
  33. * 数据列表
  34. */
  35. public function datalist()
  36. {
  37. $param = get_params();
  38. if (request()->isAjax()) {
  39. $tab = isset($param['tab']) ? $param['tab'] : 0;
  40. $uid=$this->uid;
  41. $where = array();
  42. $whereOr = array();
  43. $where[]=['delete_time','=',0];
  44. if($tab == 0){
  45. //全部
  46. $whereOr[] = ['admin_id', '=', $this->uid];
  47. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
  48. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
  49. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
  50. }
  51. if($tab == 1){
  52. //创建的
  53. $where[] = ['admin_id', '=', $this->uid];
  54. }
  55. if($tab == 2){
  56. //待我审核的
  57. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
  58. }
  59. if($tab == 3){
  60. //我已审核的
  61. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
  62. }
  63. if($tab == 4){
  64. //抄送给我的
  65. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
  66. }
  67. if (!empty($param['seal_cate_id'])) {
  68. $where[] = ['seal_cate_id', '=', $param['seal_cate_id']];
  69. }
  70. if (isset($param['check_status']) && $param['check_status'] != "") {
  71. $where[] = ['check_status', '=', $param['check_status']];
  72. }
  73. if (!empty($param['keywords'])) {
  74. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  75. }
  76. $list = $this->model->datalist($where,$whereOr, $param);
  77. return table_assign(0, '', $list);
  78. }
  79. else{
  80. return view();
  81. }
  82. }
  83. /**
  84. * 添加/编辑
  85. */
  86. public function add()
  87. {
  88. $param = get_params();
  89. if (request()->isAjax()) {
  90. if (!empty($param['use_time'])) {
  91. $param['use_time'] = strtotime($param['use_time']);
  92. }
  93. if (!empty($param['start_time'])) {
  94. $param['start_time'] = strtotime($param['start_time']);
  95. }
  96. else{
  97. $param['start_time'] = 0;
  98. }
  99. if (!empty($param['end_time'])) {
  100. $param['end_time'] = strtotime($param['end_time']);
  101. if($param['end_time']<$param['start_time']){
  102. return to_assign(1, "结束借用日期需要大于等于印章借用日期");
  103. }
  104. }
  105. else{
  106. $param['end_time'] = 0;
  107. }
  108. if (!empty($param['id']) && $param['id'] > 0) {
  109. $this->model->edit($param);
  110. } else {
  111. $param['admin_id'] = $this->uid;
  112. $this->model->add($param);
  113. }
  114. }else{
  115. $id = isset($param['id']) ? $param['id'] : 0;
  116. $did = $this->did;
  117. $map1 = [];
  118. $map2 = [];
  119. $map1[] = ['status', '=', 1];
  120. $map1[] = ['dids', '=', ''];
  121. $map2[] = ['status', '=', 1];
  122. $map2[] = ['', 'exp', Db::raw("FIND_IN_SET('{$did}',dids)")];
  123. $sealcate = Db::name('SealCate')->whereOr([$map1,$map2])->order('id desc')->select()->toArray();
  124. View::assign('sealcate', $sealcate);
  125. View::assign('user', get_admin($this->uid));
  126. if ($id>0) {
  127. $detail = $this->model->getById($id);
  128. if($detail['check_status']==0 || $detail['check_status']==4){
  129. View::assign('detail', $detail);
  130. if(is_mobile()){
  131. return view('qiye@/approve/add_seal');
  132. }
  133. return view('edit');
  134. }
  135. }
  136. if(is_mobile()){
  137. return view('qiye@/approve/add_seal');
  138. }
  139. return view();
  140. }
  141. }
  142. /**
  143. * 查看
  144. */
  145. public function view($id)
  146. {
  147. $detail = $this->model->getById($id);
  148. if (!empty($detail)) {
  149. View::assign('detail', $detail);
  150. View::assign('create_user', get_admin($detail['admin_id']));
  151. if(is_mobile()){
  152. return view('qiye@/approve/view_seal');
  153. }
  154. return view();
  155. }
  156. else{
  157. return view(EEEOR_REPORTING,['warning'=>'找不到页面']);
  158. }
  159. }
  160. /**
  161. * 删除
  162. */
  163. public function del()
  164. {
  165. $param = get_params();
  166. $id = isset($param['id']) ? $param['id'] : 0;
  167. if (request()->isDelete()) {
  168. $this->model->delById($id);
  169. } else {
  170. return to_assign(1, "错误的请求");
  171. }
  172. }
  173. //用章记录
  174. public function record()
  175. {
  176. if (request()->isAjax()) {
  177. $param = get_params();
  178. $where = [];
  179. $whereOr = [];
  180. $where[]=['delete_time','=',0];
  181. $where[]=['check_status','=',2];
  182. if (!empty($param['seal_cate_id'])) {
  183. $where[] = ['seal_cate_id', '=', $param['seal_cate_id']];
  184. }
  185. if (!empty($param['keywords'])) {
  186. $where[] = ['id|title', 'like', '%' . $param['keywords'] . '%'];
  187. }
  188. $list = $this->model->datalist($where,$whereOr, $param);
  189. return table_assign(0, '', $list);
  190. } else {
  191. View::assign('status', ['未使用','已使用','已归还']);
  192. return view();
  193. }
  194. }
  195. }