OfficeItems.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class OfficeItems extends Base
  7. {
  8. // 新增
  9. public function save(){
  10. model('OfficeItems')->add($this->userId);
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 编辑
  14. public function update(){
  15. model('OfficeItems')->add($this->userId);
  16. HelpHander::success([],'操作成功');
  17. }
  18. // 详情
  19. public function detail(){
  20. $id = input('id/d',0);
  21. $ret = model('OfficeItems')->info($id);
  22. HelpHander::success($ret);
  23. }
  24. // 列表
  25. public function list(){
  26. $page = input('page/d',1);
  27. $size = input('size/d',10);
  28. $title = input('title','','trim');
  29. $cateId = input('cateId/d',0);
  30. $type = input('type/d',0);
  31. $ret = model('OfficeItems')->lists($page,$size,$title,$cateId,$this->orgId,$type);
  32. HelpHander::success($ret);
  33. }
  34. // 导出列表
  35. public function export(){
  36. $title = input('title','','trim');
  37. $cateId = input('cateId/d',0);
  38. $type = input('type/d',0);
  39. $ret = model('OfficeItems')->export($title,$cateId,$this->orgId,$type);
  40. HelpHander::success($ret);
  41. }
  42. // 删除
  43. public function del(){
  44. $id = input('id/d',0);
  45. model('OfficeItems')->del($id);
  46. HelpHander::success([],'操作成功');
  47. }
  48. // 申领物品列表
  49. public function receive(){
  50. $page = input('page/d',1);
  51. $size = input('size/d',10);
  52. $title = input('title','','trim');
  53. $items = input('items','','trim');
  54. $startTime = input('startTime','','trim');
  55. $endTime = input('endTime','','trim');
  56. $ret = model('OfficeReceive')->lists($page,$size,$title,$items,$startTime,$endTime,$this->orgId);
  57. HelpHander::success($ret);
  58. }
  59. // 修改物品数量
  60. public function modifyNums(){
  61. $id = input('id/d',0);
  62. $nums = input('nums/d',0);
  63. if($id <= 0||$nums <= 0){
  64. HelpHander::error('参数错误');
  65. }
  66. if($nums <= 0){
  67. HelpHander::error('修改数量必须大于0');
  68. }
  69. $reason = input('reason','','trim');
  70. if(!$reason){
  71. HelpHander::error('未填写原因');
  72. }
  73. $type = input('type/d',0);
  74. if(!in_array($type,[0,1])){
  75. HelpHander::error('类型错误');
  76. }
  77. model('OfficeItems')->modifyNums($id,$nums,$reason,$type,$this->userId,$this->orgId);
  78. HelpHander::success([],'操作成功');
  79. }
  80. // 物品入库
  81. public function modifyNumsReceive(){
  82. $id = input('id/d',0);
  83. $nums = input('nums/d',0);
  84. if($id <= 0||$nums <= 0){
  85. HelpHander::error('参数错误');
  86. }
  87. if($nums <= 0){
  88. HelpHander::error('修改数量必须大于0');
  89. }
  90. $remark = input('remark','','trim');
  91. model('OfficeItems')->modifyNumsReceive($id,$nums,$remark,$this->userId,$this->orgId);
  92. HelpHander::success([],'操作成功');
  93. }
  94. // 入库记录
  95. public function inreceipt(){
  96. $page = input('page/d',1);
  97. $size = input('size/d',10);
  98. $id = input('id/d',0);
  99. $ret = model('OfficeItems')->inreceipt($page,$size,$id);
  100. HelpHander::success($ret);
  101. }
  102. // 数量修改日志
  103. public function numsLog(){
  104. $page = input('page/d',1);
  105. $size = input('size/d',10);
  106. $title = input('title','','trim');
  107. $name = input('name','','trim');
  108. $ret = model('OfficeItems')->numsLog($page,$size,$title,$name,$this->orgId);
  109. HelpHander::success($ret);
  110. }
  111. // 物品入库月统计
  112. public function tj(){
  113. $page = input('page/d',1);
  114. $size = input('size/d',10);
  115. $title = input('title','','trim');
  116. $month = input('month','','trim');
  117. if(!$month){
  118. HelpHander::error('请选择月份');
  119. }
  120. $ret = model('OfficeItems')->numsTj($page,$size,$title,$month,$this->orgId);
  121. HelpHander::success($ret);
  122. }
  123. public function tjexport(){
  124. $title = input('title','','trim');
  125. $month = input('month','','trim');
  126. if(!$month){
  127. HelpHander::error('请选择月份');
  128. }
  129. $ret = model('OfficeItems')->tjexport($title,$month,$this->orgId);
  130. HelpHander::success($ret);
  131. }
  132. }