AssetItems.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. use think\response\Json;
  7. class AssetItems extends Base
  8. {
  9. // 新增
  10. public function save(){
  11. model('AssetItems')->add();
  12. HelpHander::success([],'操作成功');
  13. }
  14. // 编辑
  15. public function update(){
  16. model('AssetItems')->add();
  17. HelpHander::success([],'操作成功');
  18. }
  19. // 详情
  20. public function detail(){
  21. $id = input('id/d',0);
  22. $ret = model('AssetItems')->info($id);
  23. HelpHander::success($ret);
  24. }
  25. // 列表
  26. public function list(){
  27. $ret = model('AssetItems')->lists($this->orgId);
  28. HelpHander::success($ret);
  29. }
  30. // 导出列表
  31. public function exportList(){
  32. // $title = input('title','','trim');
  33. // $cateId = input('cateId/d',0);
  34. // $companyId = input('companyId/d',0);
  35. // $addId = input('addId/d',0);
  36. // $classId = input('classId/d',0);
  37. // $enable = input('enable/d',-1);
  38. $all = input('all/d',0);
  39. $selectData = input('selectData','','trim');
  40. $mb = input('mb','','trim');
  41. if($all == 0 && !$selectData){
  42. HelpHander::error('未选择数据');
  43. }
  44. if(!$mb){
  45. HelpHander::error('参数错误');
  46. }
  47. $mb = json_decode($mb,true);
  48. $flag = 0;
  49. foreach ($mb as $k=>$v){
  50. if($v['select']){
  51. $flag = 1;
  52. break;
  53. }
  54. }
  55. if($flag == 0){
  56. $this->error('未选择要导出的字段');
  57. }
  58. $ret = model('AssetItems')->exportLists($mb,$selectData,$this->orgId,$all);
  59. HelpHander::success($ret);
  60. }
  61. // 资产选择列表
  62. public function selectLists(){
  63. $page = input('page/d',1);
  64. $size = input('size/d',10);
  65. $title = input('title','','trim');
  66. $cateId = input('cateId/d',0);
  67. $companyId = input('companyId/d',0);
  68. $addId = input('addId/d',0);
  69. $classId = input('classId/d',0);
  70. $type = input('type/d',0);
  71. $ret = model('AssetItems')->selectlists($page,$size,$title,$cateId,$companyId,$addId,$classId,$this->userId,$this->orgId,$type);
  72. HelpHander::success($ret);
  73. }
  74. // 删除
  75. public function del(){
  76. $id = input('id/d',0);
  77. model('AssetItems')->del($id);
  78. HelpHander::success([],'操作成功');
  79. }
  80. // 拆分资产
  81. public function split(){
  82. $id = input('id/d',0);
  83. model('AssetItems')->split($id);
  84. HelpHander::success([],'操作成功');
  85. }
  86. // 申领资产列表
  87. public function receive(){
  88. $page = input('page/d',1);
  89. $size = input('size/d',10);
  90. $title = input('title','','trim');
  91. $start = input('startTime','','trim');
  92. $end = input('endTime','','trim');
  93. $ret = model('AssetReceive')->lists($page,$size,$title,$start,$end,$this->orgId);
  94. HelpHander::success($ret);
  95. }
  96. // 退库列表
  97. public function withdraw(){
  98. $page = input('page/d',1);
  99. $size = input('size/d',10);
  100. $title = input('title','','trim');
  101. $start = input('startTime','','trim');
  102. $end = input('endTime','','trim');
  103. $ret = model('AssetWithdraw')->lists($page,$size,$title,$start,$end,$this->orgId);
  104. HelpHander::success($ret);
  105. }
  106. // 维修列表
  107. public function repair(){
  108. $page = input('page/d',1);
  109. $size = input('size/d',10);
  110. $title = input('title','','trim');
  111. $start = input('startTime','','trim');
  112. $end = input('endTime','','trim');
  113. $ret = model('AssetRepair')->lists($page,$size,$title,$start,$end,$this->orgId);
  114. HelpHander::success($ret);
  115. }
  116. // 处置列表
  117. public function disposal(){
  118. $page = input('page/d',1);
  119. $size = input('size/d',10);
  120. $title = input('title','','trim');
  121. $start = input('startTime','','trim');
  122. $end = input('endTime','','trim');
  123. $ret = model('AssetDisposal')->lists($page,$size,$title,$start,$end,$this->orgId);
  124. HelpHander::success($ret);
  125. }
  126. // 我领取的资产
  127. public function myLists(){
  128. $page = input('page/d',1);
  129. $size = input('size/d',10);
  130. $title = input('title','','trim');
  131. $ret = model('AssetItems')->myLists($page,$size,$title,$this->userId,$this->orgId);
  132. HelpHander::success($ret);
  133. }
  134. }