SystemPrintTpl.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\admin\controller\base;
  3. /**
  4. * @title: 打印模板控制器
  5. * @Description:
  6. * @Author: goldenrock 112049337@qq.com
  7. * @Date: 2024-09-23 15:18:34
  8. * @LastEditTime: 2024-11-20 09:43:21
  9. * @LastEditors: goldenrock
  10. * @FilePath: \OA_hbdrwhe:\HBDRWHCODE\DRSERVER_dev\app\admin\controller\base\SystemPrintTpl.php
  11. */
  12. use app\admin\controller\Base;
  13. use app\common\model\base\SystemPrintTpl as PrintModel;
  14. class SystemPrintTpl extends Base
  15. {
  16. private $model = null;
  17. public function initialize()
  18. {
  19. parent::initialize();
  20. $this->model = new PrintModel;
  21. }
  22. /**
  23. * 获取
  24. */
  25. private function createWhere()
  26. {
  27. $data = $this->request->param();
  28. $where = [];
  29. if(!empty($data['keyword'])){
  30. $where[] = ['title|code','LIKE',"%{$data['keyword']}%"];
  31. }
  32. return ['where'=>$where,'whereOr'=>[]];
  33. }
  34. /**
  35. *获取列表
  36. */
  37. public function getList(int $pageNo=0,int $pageSize=10)
  38. {
  39. $whereAry = $this->createWhere();
  40. if(!empty($pageNo)){
  41. $res = $this->model->where($whereAry['where'])->where(function($query)use($whereAry){
  42. $query->where($whereAry['whereOr']);
  43. })->with([])->paginate(['page'=>$pageNo,'list_rows'=>$pageSize]);
  44. return pageRes(1,'获取成功',$res->total(),$res->items());
  45. }else{
  46. $list = $this->model->where($whereAry['where'])->where(function($query)use($whereAry){
  47. $query->where($whereAry['whereOr']);
  48. })->with([])->select();
  49. return res(1,'获取成功',$list);
  50. }
  51. }
  52. public function doEdit()
  53. {
  54. $data = $this->request->param();
  55. $this->model->replace()->save($data);
  56. slog(1,"编辑了打印模板".$data['title']);
  57. return res(1,"保存成功");
  58. }
  59. public function getInfo(string $code='')
  60. {
  61. $info = $this->model->where('code',$code)->find();
  62. return res(1,"获取成功",$info);
  63. }
  64. public function doDelete(int $id=0)
  65. {
  66. $info = $this->model->where("id",$id)->find();
  67. if(empty($info)){
  68. return res(1,"删除成功");
  69. }
  70. $info->delete();
  71. slog(1,"删除了打印模板".$info->title);
  72. return res(1,"删除成功");
  73. }
  74. public function getOptions()
  75. {
  76. $option = [];
  77. return res(1,"获取成功",$option);
  78. }
  79. public function __call($name,$arguments)
  80. {
  81. return res(2,"控制器方法{$name}不存在");
  82. }
  83. }