123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- <?php
- declare (strict_types=1);
- namespace app\admin\controller\project;
- use app\admin\BaseController;
- use app\admin\model\ProjectRecord;
- use think\exception\ValidateException;
- use HTMLPurifier;
- use HTMLPurifier_Config;
- use think\facade\Db;
- use think\facade\View;
- class Record extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct()
- {
- $this->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; $i<count($list); $i++){
- $a = $list[$i]["type"];
- if(!($a==2)){
- unset($list[$i]);
- }
- }
- $list = array_values($list);
- $list["data"] = $list;
- $list["total"] = count($list["data"]);
- // $list["data"] = $list;
- // halt($list);
- return table_assign(0, '', $list);
- }
- }
- /**
- * 业主数据列表
- */
- public function yzlist()
- {
- // 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')
- ->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'] = '测试<script>alert(0);</script>';
- $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'] = '测试<script>alert(0);</script>';
- $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'] = '测试<script>alert(0);</script>';
- $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'] = '测试<script>alert(0);</script>';
- $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 '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';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 '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';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 '<div style="text-align:center;color:red;margin-top:20%;">该文档不存在</div>';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,"非创建人,不可删除");
- }
- }
- }
|