Work.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\talent\controller;
  3. use app\common\model\TalentWorkModel;
  4. use app\talent\TalentBaseController;
  5. class Work extends TalentBaseController
  6. {
  7. /**
  8. * 新增
  9. */
  10. public function add()
  11. {
  12. return view('', [
  13. 'contact_list' => json_encode(TalentWorkModel::CONTACT),
  14. 'cate_list' => json_encode(TalentWorkModel::CATE),
  15. ]);
  16. }
  17. public function addPost()
  18. {
  19. $month = date('Y-m');
  20. $work_check = TalentWorkModel::where('month', $month)->where('user_id', $this->user->id)->find();
  21. if (!empty($work_check)) {
  22. ajax_return(1, '该月已填写,请勿重复填写!');
  23. }
  24. $post = input('post.');
  25. $post['user_id'] = $this->user->id;
  26. $post['month'] = $month;
  27. TalentWorkModel::create($post);
  28. ajax_return();
  29. }
  30. /**
  31. * 编辑
  32. */
  33. public function edit()
  34. {
  35. $id = input('id', 0);
  36. if (empty($id)) {
  37. jump('该信息不存在');
  38. }
  39. $info = TalentWorkModel::where('user_id', $this->user->id)->where('id', $id)->find();
  40. if (empty($info)) {
  41. jump('该信息不存在');
  42. }
  43. return view('', [
  44. 'info' => $info,
  45. 'contact_list' => json_encode(TalentWorkModel::CONTACT),
  46. 'cate_list' => json_encode(TalentWorkModel::CATE),
  47. ]);
  48. }
  49. public function editPost()
  50. {
  51. $post = input('post.');
  52. unset($post['create_time'], $post['update_time']);
  53. TalentWorkModel::update($post);
  54. ajax_return();
  55. }
  56. /**
  57. * 复制
  58. */
  59. public function copy()
  60. {
  61. $id = input('id', 0);
  62. if (empty($id)) {
  63. jump('该信息不存在');
  64. }
  65. $info = TalentWorkModel::where('user_id', $this->user->id)->where('id', $id)->find();
  66. if (empty($info)) {
  67. jump('该信息不存在');
  68. }
  69. $month = date('Y-m');
  70. $work_check = TalentWorkModel::where('month', $month)->where('user_id', $this->user->id)->find();
  71. if (!empty($work_check)) {
  72. jump('该月已填写,请勿重复填写!');
  73. }
  74. return view('', [
  75. 'info' => $info,
  76. 'contact_list' => json_encode(TalentWorkModel::CONTACT),
  77. 'cate_list' => json_encode(TalentWorkModel::CATE),
  78. ]);
  79. }
  80. public function copyPost()
  81. {
  82. $month = date('Y-m');
  83. $work_check = TalentWorkModel::where('month', $month)->where('user_id', $this->user->id)->find();
  84. if (!empty($work_check)) {
  85. ajax_return(1, '该月已填写,请勿重复填写!');
  86. }
  87. $post = input('post.');
  88. unset($post['id'], $post['create_time'], $post['update_time']);
  89. $post['month'] = $month;
  90. TalentWorkModel::create($post);
  91. ajax_return();
  92. }
  93. }