123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- //declare (strict_types=1);
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\model\ProjectComment;
- use app\admin\validate\project\CostProjectValidate;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\View;
- use think\App;
- class Comment extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new ProjectComment();
- $this->uid = get_login_admin('id');
- }
- /**
- * 数据列表
- */
- public function datalist()
- {
- if (request()->isAjax()) {
- $param = get_params();
- $where = [
- ["delete_time","=",0],
- ["entrust_maker","=",$this->uid],
- ["project_status","<",4]
- ];
- $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
- $order = empty($param['order']) ? 'id desc' : $param['order'];
- $list = $this->model->where($where)->order($order)->paginate($rows, false, ['query' => $param])
- ->each(function ($item){
- });
- // halt($list);
- return table_assign(0, '', $list);
- } else {
- return view();
- }
- }
- /**
- * 添加-财政局
- */
- public function add()
- {
- $param = get_params();
- function get_unit_id($uint_id){
- $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
- $pid = $id["pid"];
- if($pid == 0 ){
- return $id["id"];
- }else{
- return get_unit_id($id["pid"]);
- }
- }
- if(!empty($param["thumb"])){
- $param["thumb"] = cleanHtml($param["thumb"]);
- }
- $uint_id = get_login_admin("unit_name");
- $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
- $param["unit_name"] = $unit["title"];
- $param["unit_type"] = $unit["type"];
- $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
- $content = $param["content"];
- if(empty($content)){
- $content = "图片";
- }
- add_project_log("发送日志",$param["project_id"],$content,2);
- $this->model->addComment($param);
- }
- /**
- * 添加-公司
- */
- public function add_company()
- {
- $param = get_params();
- function get_unit_id($uint_id){
- $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
- $pid = $id["pid"];
- if($pid == 0 ){
- return $id["id"];
- }else{
- return get_unit_id($id["pid"]);
- }
- }
- if(!empty($param["thumb"])){
- $param["thumb"] = cleanHtml($param["thumb"]);
- }
- $uint_id = get_login_admin("unit_name");
- $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
- $param["unit_name"] = $unit["title"];
- $param["unit_type"] = $unit["type"];
- $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
- $content = $param["content"];
- if(empty($content)){
- $content = "图片";
- }
- add_project_log("发送日志",$param["project_id"],$content,2);
- $this->model->addComment($param);
- }
- /**
- * 添加-业主
- */
- public function add_proprietor()
- {
- $param = get_params();
- function get_unit_id($uint_id){
- $id = Db::name("department")->where("id",$uint_id)->field("id,pid")->find();
- $pid = $id["pid"];
- if($pid == 0 ){
- return $id["id"];
- }else{
- return get_unit_id($id["pid"]);
- }
- }
- if(!empty($param["thumb"])){
- $param["thumb"] = cleanHtml($param["thumb"]);
- }
- $uint_id = get_login_admin("unit_name");
- $unit = Db::name("department")->where("id",get_unit_id($uint_id))->field("title,type")->find();
- $param["unit_name"] = $unit["title"];
- $param["unit_type"] = $unit["type"];
- $param["maker"] = Db::name("admin")->where("id",$this->uid)->value("nickname");
- $content = $param["content"];
- if(empty($content)){
- $content = "图片";
- }
- add_project_log("发送日志",$param["project_id"],$content,2);
- $this->model->addComment($param);
- }
- /**
- * 删除
- * type=0,逻辑删除,默认
- * type=1,物理删除
- */
- public function del()
- {
- $param = get_params();
- $status = Db::name("cost_project")->where("id",$param["id"])->field("project_status")->select();
- if( $status[0]["project_status"] < 3 ){
- $id = isset($param['id']) ? $param['id'] : 0;
- $type = isset($param['type']) ? $param['type'] : 0;
- $this->model->delCostProjectById($id, $type);
- }else{
- return to_assign(0, "已审核,无法删除");
- }
- }
- }
|