Comment.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. //declare (strict_types=1);
  3. namespace app\admin\controller\project;
  4. use app\admin\BaseController;
  5. use app\admin\model\ProjectComment;
  6. use app\admin\validate\project\CostProjectValidate;
  7. use think\exception\ValidateException;
  8. use think\facade\Db;
  9. use think\facade\View;
  10. use think\App;
  11. class Comment extends BaseController
  12. {
  13. /**
  14. * 构造函数
  15. */
  16. public function __construct(App $app)
  17. {
  18. parent::__construct($app);
  19. $this->model = new ProjectComment();
  20. $this->uid = get_login_admin('id');
  21. }
  22. /**
  23. * 数据列表
  24. */
  25. public function datalist()
  26. {
  27. if (request()->isAjax()) {
  28. $param = get_params();
  29. $where = [
  30. ["delete_time","=",0],
  31. ["entrust_maker","=",$this->uid],
  32. ["project_status","<",4]
  33. ];
  34. $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
  35. $order = empty($param['order']) ? 'id desc' : $param['order'];
  36. $list = $this->model->where($where)->order($order)->paginate($rows, false, ['query' => $param])
  37. ->each(function ($item){
  38. });
  39. // halt($list);
  40. return table_assign(0, '', $list);
  41. } else {
  42. return view();
  43. }
  44. }
  45. /**
  46. * 添加-财政局
  47. */
  48. public function add()
  49. {
  50. $param = get_params();
  51. function get_unit_id($uint_id){
  52. // halt($uint_id);
  53. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  54. // halt($id);
  55. $pid = $id["pid"];
  56. if($pid == 0 ){
  57. return $id["id"];
  58. }else{
  59. return get_unit_id($id["pid"]);
  60. }
  61. }
  62. if(!empty($param["thumb"])){
  63. $param["thumb"] = cleanHtml($param["thumb"]);
  64. }
  65. $uint_id = get_login_admin("unit_name");
  66. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  67. $param["unit_name"] = $unit["title"];
  68. $param["unit_type"] = $unit["type"];
  69. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  70. $content = $param["content"];
  71. if(empty($content)){
  72. $content = "图片";
  73. }
  74. add_project_log("发送日志",$param["project_id"],$content,2);
  75. $this->model->addComment($param);
  76. }
  77. /**
  78. * 添加-公司
  79. */
  80. public function add_company()
  81. {
  82. $param = get_params();
  83. function get_unit_id($uint_id){
  84. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  85. $pid = $id["pid"];
  86. if($pid == 0 ){
  87. return $id["id"];
  88. }else{
  89. return get_unit_id($id["pid"]);
  90. }
  91. }
  92. if(!empty($param["thumb"])){
  93. $param["thumb"] = cleanHtml($param["thumb"]);
  94. }
  95. $uint_id = get_login_admin("unit_name");
  96. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  97. $param["unit_name"] = $unit["title"];
  98. $param["unit_type"] = $unit["type"];
  99. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  100. $content = $param["content"];
  101. if(empty($content)){
  102. $content = "图片";
  103. }
  104. add_project_log("发送日志",$param["project_id"],$content,2);
  105. $this->model->addComment($param);
  106. }
  107. /**
  108. * 添加-业主
  109. */
  110. public function add_proprietor()
  111. {
  112. $param = get_params();
  113. function get_unit_id($uint_id){
  114. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  115. $pid = $id["pid"];
  116. if($pid == 0 ){
  117. return $id["id"];
  118. }else{
  119. return get_unit_id($id["pid"]);
  120. }
  121. }
  122. if(!empty($param["thumb"])){
  123. $param["thumb"] = cleanHtml($param["thumb"]);
  124. }
  125. $uint_id = get_login_admin("unit_name");
  126. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  127. $param["unit_name"] = $unit["title"];
  128. $param["unit_type"] = $unit["type"];
  129. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  130. $content = $param["content"];
  131. if(empty($content)){
  132. $content = "图片";
  133. }
  134. add_project_log("发送日志",$param["project_id"],$content,2);
  135. $this->model->addComment($param);
  136. }
  137. /**
  138. * 删除
  139. * type=0,逻辑删除,默认
  140. * type=1,物理删除
  141. */
  142. public function del()
  143. {
  144. $param = get_params();
  145. $status = Db::name("cost_project")->where("id",$param["id"])->field("project_status")->select();
  146. if( $status[0]["project_status"] < 3 ){
  147. $id = isset($param['id']) ? $param['id'] : 0;
  148. $type = isset($param['type']) ? $param['type'] : 0;
  149. $this->model->delCostProjectById($id, $type);
  150. }else{
  151. return to_assign(0, "已审核,无法删除");
  152. }
  153. }
  154. }