LeaderTeam.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. 'info' => input('post.info'),
  53. 'add_time' => time(),
  54. 'update_time' => time(),
  55. );
  56. $imgurl = DS_THEME_STYLE_URL . 'images/team';
  57. $numurl = '/static/home/images/team';
  58. $file = request()->file('image');
  59. if($file){
  60. $imgname = time().'.jpg';
  61. $file = $file->setSaveName($imgname);//设置保存文件名
  62. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  63. if($imgo){
  64. $data['img_url'] =$numurl.'/'.$imgname;
  65. }
  66. }
  67. $result = model('LeaderTeam')->add($data);
  68. if ($result){
  69. $this->success(lang('add_succ'), url('LeaderTeam/index'));
  70. }
  71. $this->error(lang('add_fail'));
  72. } else {
  73. $this->setAdminCurItem('add');
  74. return $this->fetch('form');
  75. }
  76. }
  77. /**
  78. * 修改领导团队信息
  79. * @return mixed
  80. */
  81. public function edit()
  82. {
  83. $allpower = $this->qxhans();
  84. $this->assign('allpower',$allpower);
  85. $id = input('param.id');
  86. if ($id <= 0) {
  87. $this->error('系统错误');
  88. }
  89. $condition['id'] = $id;
  90. if (request()->isPost()) {
  91. $data = array(
  92. 'name_ch' => input('post.name_ch'),
  93. 'name_en' => input('post.name_en'),
  94. 'gender' => input('post.gender'),
  95. 'age' => input('post.age'),
  96. 'position' => input('post.position'),
  97. 'info' => input('post.info'),
  98. 'update_time' => time(),
  99. );
  100. $imgurl = DS_THEME_STYLE_URL . 'images/team';
  101. $numurl = '/static/home/images/team';
  102. $file = request()->file('image');
  103. if($file){
  104. $imgname = time().'.jpg';
  105. $file = $file->setSaveName($imgname);//设置保存文件名
  106. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  107. if($imgo){
  108. $data['img_url'] =$numurl.'/'.$imgname;
  109. }
  110. }
  111. $result = model('LeaderTeam')->edit(['id' => $id], $data);
  112. if ($result >= 0) {
  113. $this->success(lang('edit_succ'), 'LeaderTeam/index');
  114. } else {
  115. $this->error(lang('edit_fail'));
  116. }
  117. } else {
  118. $leaderteam = model('LeaderTeam')->getOneleaderteam(['id' => $id]);
  119. $this->assign('leaderteam', $leaderteam);
  120. $this->setAdminCurItem('edit');
  121. return $this->fetch('form');
  122. }
  123. }
  124. /**
  125. * 删除领导团队
  126. * @return mixed
  127. */
  128. function del()
  129. {
  130. $id = intval(input('param.id'));
  131. if ($id) {
  132. $condition['id'] = $id;
  133. $result = model('LeaderTeam')->deleteLeaderTeam($condition);
  134. if ($result) {
  135. ds_json_encode(10000, lang('del_succ'));
  136. } else {
  137. ds_json_encode(10001, lang('del_fail'));
  138. }
  139. } else {
  140. ds_json_encode(10001, lang('param_error'));
  141. }
  142. }
  143. }