model = new ProjectRecord(); $this->uid = get_login_admin('id'); } /** * 财评数据列表 */ public function cplist() { if (request()->isAjax()) { $param = get_params(); $where = [ ["cp_project_record.delete_time", "=", 0], ["project_id", "=", $param["project_id"]], ["maker_id","=",$this->uid] ]; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $order = empty($param['order']) ? 'a.id desc' : $param['order']; $list = $this->model->where($where) ->field('a.*,u.nickname as admin_name') ->alias('a') ->join('Admin u', 'a.maker_id = u.id', "left") ->order($order) ->paginate($rows, false, ['query' => $param]) ->each(function ($item, $key) { }); // halt($list); return table_assign(0, '', $list); } } /** * 公司数据列表 */ public function gslist() { if (request()->isAjax()) { $param = get_params(); $where = [ ["cp_project_record.delete_time", "=", 0], ["project_id", "=", $param["project_id"]], ]; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $order = empty($param['order']) ? 'a.id desc' : $param['order']; $list = $this->model->where($where) ->field('a.*,u.nickname as admin_name,u.unit_name') ->alias('a') ->join('Admin u', 'a.maker_id = u.id', "left") ->order($order) ->paginate($rows, false, ['query' => $param]) ->each(function ($item, $key) { $item->type = Db::name("department")->where("id",$item->unit_name)->value("type"); })->toArray(); // halt($list); $list = $list["data"]; for($i=0; $iisAjax()) { $param = get_params(); $where = [ ["cp_project_record.delete_time", "=", 0], ["project_id", "=", $param["project_id"]] ]; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $order = empty($param['order']) ? 'a.id desc' : $param['order']; $list = $this->model->where($where) ->field('a.*,u.nickname as admin_name') ->alias('a') ->join('Admin u', 'a.maker_id = u.id', "left") ->order($order) ->paginate($rows, false, ['query' => $param]) ->each(function ($item, $key) { }); // halt($list); return table_assign(0, '', $list); // } } /** * 添加-财政局 */ public function add() { $param = get_params(); if (request()->isAjax()) { if (isset($param['table-align'])) { unset($param['table-align']); } if (isset($param['content'])) { $param['md_content'] = ''; } if (isset($param['docContent-html-code'])) { $param['content'] = $param['docContent-html-code']; $param['md_content'] = $param['docContent-markdown-doc']; unset($param['docContent-html-code']); unset($param['docContent-markdown-doc']); } // 创建HTMLPurifier配置对象 $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.DefinitionID', 'html5-definitions'); $config->set('HTML.DefinitionRev', 1); $config->set('HTML.ForbiddenAttributes', ['width', 'height']); //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd'); $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname if ($def = $config->maybeGetRawHTMLDefinition()) { $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool', ]); $def->addElement('source', 'Block', 'Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', ]); } // 创建HTMLPurifier对象 $purifier = new HTMLPurifier($config); //防止xss,过滤输入并输出结果 //$param['content'] = '测试'; $param['content'] = $purifier->purify($param['content']); $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $param['project_id'] = $project_id; $param['maker_id'] = $this->uid; $content =strip_tags($param["content"]); $this->model->addRecord($param); add_project_log("新增工作记录", $project_id, $content, 3); } else { $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $project = Db::name("cost_project")->where("id",$project_id)->field('id,project_name')->find(); //富文本类型 View::assign('editor', get_system_config('other', 'editor')); //关联项目id View::assign('project', $project); View::assign('project_id', $project_id); return view(); } } /** * 添加-公司 */ public function add_company() { $param = get_params(); if (request()->isAjax()) { if (isset($param['table-align'])) { unset($param['table-align']); } if (isset($param['content'])) { $param['md_content'] = ''; } if (isset($param['docContent-html-code'])) { $param['content'] = $param['docContent-html-code']; $param['md_content'] = $param['docContent-markdown-doc']; unset($param['docContent-html-code']); unset($param['docContent-markdown-doc']); } // 创建HTMLPurifier配置对象 $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.DefinitionID', 'html5-definitions'); $config->set('HTML.DefinitionRev', 1); $config->set('HTML.ForbiddenAttributes', ['width', 'height']); //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd'); $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname if ($def = $config->maybeGetRawHTMLDefinition()) { $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool', ]); $def->addElement('source', 'Block', 'Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', ]); } // 创建HTMLPurifier对象 $purifier = new HTMLPurifier($config); //防止xss,过滤输入并输出结果 //$param['content'] = '测试'; $param['content'] = $purifier->purify($param['content']); $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $param['project_id'] = $project_id; $param['maker_id'] = $this->uid; $content =strip_tags($param["content"]); add_project_log("新增工作记录",$project_id,$content,3); $this->model->addRecord($param); } else { $project_id = isset($param['project_id']) ? $param['project_id'] : 0; $project = Db::name("cost_project")->where("id",$project_id)->field('id,project_name')->find(); //富文本类型 View::assign('editor', get_system_config('other', 'editor')); //关联项目id View::assign('project', $project); View::assign('project_id', $project_id); return view('add_company'); } } /** * 编辑-财政局 */ public function edit() { $param = get_params(); if (request()->isAjax()) { if (isset($param['table-align'])) { unset($param['table-align']); } if (isset($param['content'])) { $param['md_content'] = ''; } if (isset($param['docContent-html-code'])) { $param['content'] = $param['docContent-html-code']; $param['md_content'] = $param['docContent-markdown-doc']; unset($param['docContent-html-code']); unset($param['docContent-markdown-doc']); } // 创建HTMLPurifier配置对象 $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.DefinitionID', 'html5-definitions'); $config->set('HTML.DefinitionRev', 1); $config->set('HTML.ForbiddenAttributes', ['width', 'height']); //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd'); $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname if ($def = $config->maybeGetRawHTMLDefinition()) { $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool', ]); $def->addElement('source', 'Block', 'Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', ]); } // 创建HTMLPurifier对象 $purifier = new HTMLPurifier($config); //防止xss,过滤输入并输出结果 //$param['content'] = '测试'; $param['content'] = $purifier->purify($param['content']); $this->model->editRecord($param); add_project_log('编辑工作记录', $param['project_id'], '编辑工作记录', 3); } else { $id = isset($param['id']) ? $param['id'] : 0;//记录id $project_id = $this->model->where('id',$id)->value("project_id"); $project = Db::name("cost_project")->where("id",$project_id)->field('id,project_name')->find(); $detail = $this->model->getRecordById($id); View::assign('editor', get_system_config('other', 'editor')); if (!empty($detail)) { if (!empty($article['md_content'])) { View::assign('editor', 1); } View::assign('id', $id); View::assign('project', $project); View::assign('detail', $detail); return view(); } else { throw new \think\exception\HttpException(404, '找不到页面'); } } } /** * 编辑-公司 */ public function edit_company() { $param = get_params(); if (request()->isAjax()) { if (isset($param['table-align'])) { unset($param['table-align']); } if (isset($param['content'])) { $param['md_content'] = ''; } if (isset($param['docContent-html-code'])) { $param['content'] = $param['docContent-html-code']; $param['md_content'] = $param['docContent-markdown-doc']; unset($param['docContent-html-code']); unset($param['docContent-markdown-doc']); } // 创建HTMLPurifier配置对象 $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.DefinitionID', 'html5-definitions'); $config->set('HTML.DefinitionRev', 1); $config->set('HTML.ForbiddenAttributes', ['width', 'height']); //$config->set('HTML.Allowed', 'p,b,a[href],pre[class],code,blockquote,img[src],table,tr,th,td,ul,li,ol,dl,dt,dd'); $config->set('HTML.ForbiddenElements', array('script'), true);//设置拒绝使用的tagname if ($def = $config->maybeGetRawHTMLDefinition()) { $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool', ]); $def->addElement('source', 'Block', 'Flow', 'Common', [ 'src' => 'URI', 'type' => 'Text', ]); } // 创建HTMLPurifier对象 $purifier = new HTMLPurifier($config); //防止xss,过滤输入并输出结果 //$param['content'] = '测试'; $param['content'] = $purifier->purify($param['content']); $this->model->editRecord($param); // add_project_log('编辑工作记录', $param['project_id'], '新内容:'.$param['content']); add_project_log('编辑工作记录', $param['project_id'], '编辑工作记录', 3); } else { $id = isset($param['id']) ? $param['id'] : 0;//记录id $project_id = $this->model->where('id',$id)->value("project_id"); $project = Db::name("cost_project")->where("id",$project_id)->field('id,project_name')->find(); $detail = $this->model->getRecordById($id); View::assign('editor', get_system_config('other', 'editor')); if (!empty($detail)) { if (!empty($article['md_content'])) { View::assign('editor', 1); } View::assign('id', $id); View::assign('project', $project); View::assign('detail', $detail); return view(); } else { throw new \think\exception\HttpException(404, '找不到页面'); } } } /** * 查看信息-财政局 */ public function view() { $param = get_params(); $id = isset($param['id']) ? $param['id'] : 0; $detail = (new ProjectRecord())->detail($id); if (empty($detail)) { if (empty($detail)) { echo '
该文档不存在
';exit; } } else { $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname"); $detail["maker_name"] = $maker_name; View::assign('detail', $detail); return view(); } } /** * 查看信息-公司 */ public function view_company() { $param = get_params(); $id = isset($param['id']) ? $param['id'] : 0; $detail = (new ProjectRecord())->detail($id); if (empty($detail)) { if (empty($detail)) { echo '
该文档不存在
';exit; } } else { $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname"); $detail["maker_name"] = $maker_name; View::assign('detail', $detail); return view('view'); } } /** * 查看信息-业主 */ public function view_proprietor() { $param = get_params(); $id = isset($param['id']) ? $param['id'] : 0; $detail = (new ProjectRecord())->detail($id); if (empty($detail)) { if (empty($detail)) { echo '
该文档不存在
';exit; } } else { $maker_name = Db::name('admin')->where(['id' => $detail["maker_id"]])->value("nickname"); $detail["maker_name"] = $maker_name; View::assign('detail', $detail); return view(); } } /** * 删除-财政局 */ public function del() { $param = get_params(); $id = isset($param['id']) ? $param['id'] : 0; $maker = $this->model->where("id",$id)->value("maker_id"); if($this->uid == $maker){ $type = isset($param['type']) ? $param['type'] : 0; $name = $this->model->where('id',$id)->value("content"); $project_id = $this->model->where("id",$id)->value("project_id"); $content = strip_tags($name); add_project_log("删除了工作记录",$project_id,$content,3); $this->model->delRecordById($id, $type); }else{ return to_assign(1,"非创建人,不可删除"); } } /** * 删除-公司 */ public function del_company() { $param = get_params(); $id = isset($param['id']) ? $param['id'] : 0; $maker = $this->model->where("id",$id)->value("maker_id"); if($this->uid == $maker){ $type = isset($param['type']) ? $param['type'] : 0; $name = $this->model->where('id',$id)->value("content"); $project_id = $this->model->where("id",$id)->value("project_id"); $content = strip_tags($name); add_project_log("删除了工作记录", $project_id, $content, 3); $this->model->delRecordById($id, $type); }else{ return to_assign(1,"非创建人,不可删除"); } } }