TalentAllowance.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace app\enterprise\controller;
  8. use app\enterprise\common\EnterpriseController;
  9. use app\common\state\CommonConst;
  10. use app\common\api\BatchApi;
  11. use app\common\api\TalentAllowanceApi;
  12. use app\common\api\EnterpriseApi;
  13. use app\common\state\ProjectState;
  14. /**
  15. * Description of TalentAllowance
  16. *
  17. * @author sgq
  18. */
  19. class TalentAllowance extends EnterpriseController {
  20. public function index() {
  21. $tpl = "";
  22. switch ($this->user["type"]) {
  23. case CommonConst::ENTERPRISE_JC:
  24. $tpl = "indexIC";
  25. break;
  26. }
  27. return view($tpl, ['type' => $this->user["type"]]);
  28. }
  29. public function list() {
  30. $res = EnterpriseLaApi::getList($this->request);
  31. return json($res);
  32. }
  33. /**
  34. * 申请
  35. */
  36. public function apply(\think\Request $request) {
  37. $type = $this->user["type"];
  38. $param = $request->param();
  39. $id = isset($param["id"]) ? $param["id"] : 0;
  40. $info = TalentAllowanceApi::getInfoById($id);
  41. $ep = EnterpriseApi::getOne($this->user["uid"]);
  42. if (!chkEnterpriseFull($ep))
  43. return;
  44. /* if ($info && !in_array($info["checkState"], [LaState::LA_SAVE, LaState::LA_FIRST_REJECT])) {
  45. return view("", ["row" => $info, "enterprise" => $ep, "hand" => "select"]);
  46. } */
  47. if ($request->isPost()) {
  48. return $this->save($info, $request);
  49. }
  50. $hand = $info ? "update" : "add";
  51. $batch = $info["year"] ?: BatchApi::getValidBatch(ProjectState::LIVINGALLOWANCE, $this->user["type"])["batch"];
  52. return view("", ["year" => $batch, "row" => $info, "enterprise" => $ep, "hand" => $hand]);
  53. }
  54. public function detail(\think\Request $request) {
  55. $param = $request->param();
  56. $id = $param["id"];
  57. $info = CommonLaApi::getInfoById($id);
  58. $ep = EnterpriseApi::getOne($this->user["uid"]);
  59. if (!chkEnterpriseFull($ep))
  60. return;
  61. return view("apply", ["row" => $info, "enterprise" => $ep, "hand" => "select"]);
  62. }
  63. }