Talent.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\enterprise\common\EnterpriseController;
  4. use app\enterprise\api\TalentApi;
  5. use app\enterprise\model\Talent as TalentModel;
  6. use think\facade\Db;
  7. /**
  8. * Description of Talent
  9. *
  10. * @author sgq
  11. */
  12. class Talent extends EnterpriseController {
  13. public function index() {
  14. return view();
  15. }
  16. public function list() {
  17. $res = TalentApi::getList($this->request);
  18. return json($res);
  19. }
  20. public function add() {
  21. $request = $this->request;
  22. $param = $request->param();
  23. $id = isset($param["id"]) ? $param["id"] : 0;
  24. if ($request->isPost()) {
  25. if ($id) {
  26. if (!$info = self::chkIsOwner($id, $this->user["uid"]))
  27. return json(["msg" => "没有对应的人才认定申报信息"]);
  28. $data["id"] = $id;
  29. }
  30. $data["enterprise_id"] = $this->user["uid"];
  31. $data["talent_type"] = $param["talent_type"];
  32. $data["tax_insurance_month"] = $param["tax_insurance_month"];
  33. $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
  34. $data["name"] = $param["name"];
  35. $data["card_type"] = $param["card_type"];
  36. $data["card_number"] = $param["card_number"];
  37. $data["sex"] = $param["sex"];
  38. $data["birthday"] = $param["birthday"];
  39. $data["nationality"] = $param["nationality"];
  40. $data["province"] = $param["province"];
  41. $data["city"] = $param["city"];
  42. $data["county"] = $param["county"];
  43. $data["nation"] = $param["nation"];
  44. $data["politics"] = $param["politics"];
  45. $headimg = $request->file("photo");
  46. $upload = new \app\common\api\UploadApi();
  47. $headimgurl = $upload->uploadOne($headimg, "talent/photo");
  48. $data["headimgurl"] = $headimgurl;
  49. TalentModel::save($data);
  50. }
  51. $where = [];
  52. $info = [];
  53. $enterprise_info = \app\admin\model\Enterprise::find($this->user["uid"]);
  54. if (isset($param["id"])) {
  55. $where[] = ["id", "=", $param["id"]];
  56. $where[] = ["enterprise_id", "=", $this->user["uid"]];
  57. $info = TalentModel::where($where)->findOrEmpty();
  58. }
  59. $checkState = 0;
  60. $info["enterprise"] = $enterprise_info;
  61. return view("first", ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
  62. }
  63. public function edit() {
  64. $param = $this->request->param();
  65. if (!isset($param["id"]))
  66. return json(["msg" => "错误的打开方式"]);
  67. $info = Db::table("new_talent_info")->findOrEmpty($param["id"]);
  68. if ($info["checkState"] == 0) {
  69. return redirect("/enterprise/talent/add/id/" . $info["id"]);
  70. }
  71. $enterprise_info = \app\admin\model\Enterprise::find($info["enterprise_id"]);
  72. $info["enterprise"] = $enterprise_info;
  73. return view("", ["year" => date("Y"), "checkState" => $checkState, "enterprise" => $enterprise_info]);
  74. }
  75. public function submit() {
  76. $id = $this->request->param("id");
  77. if (!$info = self::chkIsOwner($id, $this->user["uid"]))
  78. return json(["msg" => "没有对应的人才认定申报信息"]);
  79. switch ($info["checkState"]) {
  80. case 0:
  81. $no_empty = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics"];
  82. $return = [];
  83. foreach ($no_empty as $key) {
  84. if (!$info[$key]) {
  85. $return[] = sprintf("请填写“%s”", self::dict($key));
  86. }
  87. }
  88. if (in_array($info["talent_type"], [1, 2]) && !$info["tax_insurance_month"])
  89. $return[] = sprintf("请填写“%s”", self::dict("tax_insurance_month"));
  90. if ($info["talent_type"] == 3 && !$info["labor_contract_rangetime"])
  91. $return[] = sprintf("请填写“%s”", self::dict("labor_contract_rangetime"));
  92. if (count($return) > 0)
  93. return json(["msg" => implode("<br>", $return)]);
  94. $where = [];
  95. $where[] = ["step", "=", 1];
  96. $where[] = ["project", "=", 1];
  97. $where[] = ["type", "=", $this->user["type"]];
  98. $where[] = ["must", "=", 1];
  99. $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  100. $ft_ids = array_column($filetypes, "id");
  101. $whr = [];
  102. $whr[] = ["typeId", "in", $ft_ids];
  103. $whr[] = ["mainId", "=", $info["id"]];
  104. $upload_type_counts = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->count();
  105. if ($upload_type_counts != $filetypes)
  106. return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
  107. break;
  108. }
  109. }
  110. static private function chkIsOwner($id, $uid) {
  111. $where[] = ["id", "=", $id];
  112. $where[] = ["enterprise_id", "=", $uid];
  113. $info = TalentModel::where($where)->findOrEmpty()->toArray();
  114. return $info;
  115. }
  116. static private function dict($key) {
  117. $value = "";
  118. switch ($key) {
  119. case "talent_type":
  120. $value = "人才类型";
  121. break;
  122. case "tax_insurance_month":
  123. $value = "在我市缴交社会保险或个人所得税月份";
  124. break;
  125. case "labor_contract_rangetime":
  126. $value = "劳动合同起止时间";
  127. break;
  128. case "name":
  129. $value = "姓名";
  130. break;
  131. case "card_type":
  132. $value = "证件类型";
  133. break;
  134. case "card_number":
  135. $value = "证件号码";
  136. break;
  137. case "sex":
  138. $value = "性别";
  139. break;
  140. case "birthday":
  141. $value = "出生日期";
  142. break;
  143. case "nationality":
  144. $value = "国籍/地区";
  145. break;
  146. case "province":
  147. $value = "籍贯省";
  148. break;
  149. case "city":
  150. $value = "籍贯市";
  151. break;
  152. case "county":
  153. $value = "籍贯县";
  154. break;
  155. case "nation":
  156. $value = "民族";
  157. break;
  158. case "politics":
  159. $value = "政治面貌";
  160. break;
  161. case "talent_arrange":
  162. $value = "";
  163. break;
  164. case "talent_condition":
  165. $value = "";
  166. break;
  167. case "highest_degree":
  168. $value = "";
  169. break;
  170. case "graduate_school":
  171. $value = "";
  172. break;
  173. case "major":
  174. $value = "";
  175. break;
  176. case "professional":
  177. $value = "";
  178. break;
  179. case "bank":
  180. $value = "";
  181. break;
  182. case "bank_number":
  183. $value = "";
  184. break;
  185. case "bank_branch_name":
  186. $value = "";
  187. break;
  188. case "bank_account":
  189. $value = "";
  190. break;
  191. case "study_abroad":
  192. $value = "";
  193. break;
  194. case "abroad_school":
  195. $value = "";
  196. break;
  197. case "abroad_major":
  198. $value = "";
  199. break;
  200. case "phone":
  201. $value = "";
  202. break;
  203. case "email":
  204. $value = "";
  205. break;
  206. case "apply_year":
  207. $value = "";
  208. break;
  209. case "import_way":
  210. $value = "";
  211. break;
  212. case "fst_work_time":
  213. $value = "";
  214. break;
  215. case "cur_entry_time":
  216. $value = "";
  217. break;
  218. case "position":
  219. $value = "";
  220. break;
  221. case "source":
  222. $value = "";
  223. break;
  224. case "fujian_highcert_pubtime":
  225. $value = "";
  226. break;
  227. case "fujian_highcert_exptime":
  228. $value = "";
  229. break;
  230. case "quanzhou_highcert_pubtime":
  231. $value = "";
  232. break;
  233. case "quanzhou_highcert_exptime":
  234. $value = "";
  235. break;
  236. }
  237. return $value;
  238. }
  239. }