Comment.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  53. $pid = $id["pid"];
  54. if($pid == 0 ){
  55. return $id["id"];
  56. }else{
  57. return get_unit_id($id["pid"]);
  58. }
  59. }
  60. if(!empty($param["thumb"])){
  61. $param["thumb"] = cleanHtml($param["thumb"]);
  62. }
  63. $uint_id = get_login_admin("unit_name");
  64. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  65. $param["unit_name"] = $unit["title"];
  66. $param["unit_type"] = $unit["type"];
  67. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  68. $content = $param["content"];
  69. if(empty($content)){
  70. $content = "图片";
  71. }
  72. add_project_log("发送日志",$param["project_id"],$content,2);
  73. $this->model->addComment($param);
  74. }
  75. /**
  76. * 添加-公司
  77. */
  78. public function add_company()
  79. {
  80. $param = get_params();
  81. function get_unit_id($uint_id){
  82. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  83. $pid = $id["pid"];
  84. if($pid == 0 ){
  85. return $id["id"];
  86. }else{
  87. return get_unit_id($id["pid"]);
  88. }
  89. }
  90. if(!empty($param["thumb"])){
  91. $param["thumb"] = cleanHtml($param["thumb"]);
  92. }
  93. $uint_id = get_login_admin("unit_name");
  94. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  95. $param["unit_name"] = $unit["title"];
  96. $param["unit_type"] = $unit["type"];
  97. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  98. $content = $param["content"];
  99. if(empty($content)){
  100. $content = "图片";
  101. }
  102. add_project_log("发送日志",$param["project_id"],$content,2);
  103. $this->model->addComment($param);
  104. }
  105. /**
  106. * 添加-业主
  107. */
  108. public function add_proprietor()
  109. {
  110. $param = get_params();
  111. function get_unit_id($uint_id){
  112. $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
  113. $pid = $id["pid"];
  114. if($pid == 0 ){
  115. return $id["id"];
  116. }else{
  117. return get_unit_id($id["pid"]);
  118. }
  119. }
  120. if(!empty($param["thumb"])){
  121. $param["thumb"] = cleanHtml($param["thumb"]);
  122. }
  123. $uint_id = get_login_admin("unit_name");
  124. $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
  125. $param["unit_name"] = $unit["title"];
  126. $param["unit_type"] = $unit["type"];
  127. $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
  128. $content = $param["content"];
  129. if(empty($content)){
  130. $content = "图片";
  131. }
  132. add_project_log("发送日志",$param["project_id"],$content,2);
  133. $this->model->addComment($param);
  134. }
  135. /**
  136. * 删除
  137. * type=0,逻辑删除,默认
  138. * type=1,物理删除
  139. */
  140. public function del()
  141. {
  142. $param = get_params();
  143. $status = Db::name("cost_project")->where("id",$param["id"])->field("project_status")->select();
  144. if( $status[0]["project_status"] < 3 ){
  145. $id = isset($param['id']) ? $param['id'] : 0;
  146. $type = isset($param['type']) ? $param['type'] : 0;
  147. $this->model->delCostProjectById($id, $type);
  148. }else{
  149. return to_assign(0, "已审核,无法删除");
  150. }
  151. }
  152. }