LeaderTeam.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Lang;
  4. class LeaderTeam extends AdminControl
  5. {
  6. public function _initialize()
  7. {
  8. parent::_initialize();
  9. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/product.lang.php');
  10. }
  11. /**
  12. * 领导团队列表
  13. */
  14. public function index(){
  15. $model_leaderteam = Model('LeaderTeam');
  16. $leaderteam_keywords = input('post.product_keywords');
  17. $leaderteam_type = input('post.product_type');
  18. $condition = array();
  19. if($leaderteam_keywords){
  20. $condition['product_keywords'] = $leaderteam_keywords;
  21. }
  22. if($leaderteam_type){
  23. $condition['product_type'] = $leaderteam_type;
  24. }
  25. $leaderteam_list = $model_leaderteam->getLeaderTeam($condition,'*',10);
  26. for($i=0;$i<count($leaderteam_list);$i++){
  27. $leaderteam_list[$i]['add_time'] = date("Y-m-d h:i:s",$leaderteam_list[$i]['add_time']);
  28. $leaderteam_list[$i]['update_time'] = date("Y-m-d h:i:s",$leaderteam_list[$i]['update_time']);
  29. }
  30. $allpower = $this->qxhans();
  31. $this->assign('allpower',$allpower);
  32. $this->assign('leaderteam_list', $leaderteam_list);
  33. //$this->assign('show_page', $Case_list->page_info->render());
  34. $this->setAdminCurItem('index');
  35. return $this->fetch();
  36. }
  37. /**
  38. * 添加领导团队
  39. * @return mixed
  40. */
  41. public function add()
  42. {
  43. $allpower = $this->qxhans();
  44. $this->assign('allpower',$allpower);
  45. if (request()->isPost()) {
  46. $data = array(
  47. 'name_ch' => input('post.name_ch'),
  48. 'name_en' => input('post.name_en'),
  49. 'gender' => input('post.gender'),
  50. 'age' => input('post.age'),
  51. 'position' => input('post.position'),
  52. 'department' => input('post.department'),
  53. 'info' => input('post.info'),
  54. 'add_time' => time(),
  55. 'update_time' => time(),
  56. );
  57. $imgurl = DS_THEME_STYLE_URL . 'images/team';
  58. $numurl = '/static/home/images/team';
  59. $file = request()->file('image');
  60. if($file){
  61. $imgname = time().'.jpg';
  62. $file = $file->setSaveName($imgname);//设置保存文件名
  63. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  64. if($imgo){
  65. $data['img_url'] =$numurl.'/'.$imgname;
  66. }
  67. }
  68. $result = model('LeaderTeam')->add($data);
  69. if ($result){
  70. $this->success(lang('add_succ'), url('LeaderTeam/index'));
  71. }
  72. $this->error(lang('add_fail'));
  73. } else {
  74. $this->setAdminCurItem('add');
  75. return $this->fetch('form');
  76. }
  77. }
  78. /**
  79. * 修改领导团队信息
  80. * @return mixed
  81. */
  82. public function edit()
  83. {
  84. $allpower = $this->qxhans();
  85. $this->assign('allpower',$allpower);
  86. $id = input('param.id');
  87. if ($id <= 0) {
  88. $this->error('系统错误');
  89. }
  90. $condition['id'] = $id;
  91. if (request()->isPost()) {
  92. $data = array(
  93. 'name_ch' => input('post.name_ch'),
  94. 'name_en' => input('post.name_en'),
  95. 'gender' => input('post.gender'),
  96. 'age' => input('post.age'),
  97. 'position' => input('post.position'),
  98. 'department' => input('post.department'),
  99. 'info' => input('post.info'),
  100. 'update_time' => time(),
  101. );
  102. $imgurl = DS_THEME_STYLE_URL . 'images/team';
  103. $numurl = '/static/home/images/team';
  104. $file = request()->file('image');
  105. if($file){
  106. $imgname = time().'.jpg';
  107. $file = $file->setSaveName($imgname);//设置保存文件名
  108. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  109. if($imgo){
  110. $data['img_url'] =$numurl.'/'.$imgname;
  111. }
  112. }
  113. $result = model('LeaderTeam')->edit(['id' => $id], $data);
  114. if ($result >= 0) {
  115. $this->success(lang('edit_succ'), 'LeaderTeam/index');
  116. } else {
  117. $this->error(lang('edit_fail'));
  118. }
  119. } else {
  120. $leaderteam = model('LeaderTeam')->getOneleaderteam(['id' => $id]);
  121. $this->assign('leaderteam', $leaderteam);
  122. $this->setAdminCurItem('edit');
  123. return $this->fetch('form');
  124. }
  125. }
  126. /**
  127. * 删除领导团队
  128. * @return mixed
  129. */
  130. function del()
  131. {
  132. $id = intval(input('param.id'));
  133. if ($id) {
  134. $condition['id'] = $id;
  135. $result = model('LeaderTeam')->deleteLeaderTeam($condition);
  136. if ($result) {
  137. ds_json_encode(10000, lang('del_succ'));
  138. } else {
  139. ds_json_encode(10001, lang('del_fail'));
  140. }
  141. } else {
  142. ds_json_encode(10001, lang('param_error'));
  143. }
  144. }
  145. }