From 6b78ee29cfd5e0ce8f47d97e973042dae9b61f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E5=BC=BA?= <357099073@qq.com> Date: Wed, 25 Jun 2025 11:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=91=BD=E5=90=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Businessinfo.php | 2 +- app/api/controller/Index.php | 77 +- app/api/middleware.php | 2 - app/api/view/project/view_schedule.html | 3 +- app/api/view/project/view_task.html | 4 +- app/apiout/BaseController.php | 89 ++- app/apiout/controller/Businessinfo.php | 106 +++ app/apiout/controller/Download.php | 49 ++ app/apiout/middleware.php | 15 +- app/apiout/middleware/Auth.php | 30 + app/{application => applications}/common.php | 0 .../controller/Index.php | 4 +- .../controller/Nav.php | 4 +- app/{application => applications}/event.php | 0 .../middleware.php | 0 .../validate/ApplicationCheck.php | 2 +- .../view/index/add.html | 0 .../view/index/edit.html | 0 .../view/index/index.html | 0 .../view/index/view.html | 0 .../view/nav/index.html | 13 + app/base/BaseController.php | 2 +- app/business/middleware/Auth.php | 32 +- app/business/view/index/index.html | 4 +- app/business/view/supplier/index.html | 6 +- app/download/common.php | 12 + app/download/controller/Index.php | 311 ++++++++ app/download/event.php | 5 + app/download/middleware.php | 13 + app/download/validate/DownloadCheck.php | 33 + app/download/view/index/add.html | 175 +++++ app/download/view/index/edit.html | 185 +++++ app/download/view/index/index.html | 311 ++++++++ app/download/view/index/view.html | 261 +++++++ app/information/controller/Index.php | 128 ++-- app/information/view/index/conversion.html | 0 app/information/view/index/follow.html | 0 app/information/view/index/index.html | 270 ++++--- app/information/view/index/view.html | 680 ++++++------------ app/model/Download.php | 34 + app/model/DownloadCate.php | 40 ++ app/model/Information.php | 52 +- app/product/controller/Index.php | 6 +- app/product/view/index/index.html | 95 +-- app/project/controller/Index.php | 254 ++++--- app/project/view/index/add.html | 156 ++-- app/project/view/index/edit.html | 2 +- app/project/view/index/index.html | 3 +- app/project/view/index/view.html | 370 +++++----- app/reimbursement/controller/Index.php | 107 ++- app/reimbursement/view/index/edititem.html | 349 +++++++++ app/reimbursement/view/index/index.html | 24 +- app/reimbursement/view/index/view.html | 186 +++-- app/schedule/view/index/index.html | 47 +- app/task/controller/Index.php | 3 +- app/task/view/index/index.html | 25 +- composer.json | 2 +- 57 files changed, 3295 insertions(+), 1288 deletions(-) create mode 100644 app/apiout/controller/Businessinfo.php create mode 100644 app/apiout/controller/Download.php create mode 100644 app/apiout/middleware/Auth.php rename app/{application => applications}/common.php (100%) rename app/{application => applications}/controller/Index.php (99%) rename app/{application => applications}/controller/Nav.php (82%) rename app/{application => applications}/event.php (100%) rename app/{application => applications}/middleware.php (100%) rename app/{application => applications}/validate/ApplicationCheck.php (95%) rename app/{application => applications}/view/index/add.html (100%) rename app/{application => applications}/view/index/edit.html (100%) rename app/{application => applications}/view/index/index.html (100%) rename app/{application => applications}/view/index/view.html (100%) rename app/{application => applications}/view/nav/index.html (92%) create mode 100644 app/download/common.php create mode 100644 app/download/controller/Index.php create mode 100644 app/download/event.php create mode 100644 app/download/middleware.php create mode 100644 app/download/validate/DownloadCheck.php create mode 100644 app/download/view/index/add.html create mode 100644 app/download/view/index/edit.html create mode 100644 app/download/view/index/index.html create mode 100644 app/download/view/index/view.html create mode 100644 app/information/view/index/conversion.html create mode 100644 app/information/view/index/follow.html create mode 100644 app/model/Download.php create mode 100644 app/model/DownloadCate.php create mode 100644 app/reimbursement/view/index/edititem.html diff --git a/app/api/controller/Businessinfo.php b/app/api/controller/Businessinfo.php index c6d6737..f2746b7 100644 --- a/app/api/controller/Businessinfo.php +++ b/app/api/controller/Businessinfo.php @@ -26,7 +26,7 @@ class BusinessInfo extends BaseController $name = isset($_POST['name']) ? $_POST['name'] : ''; $email = isset($_POST['email']) ? $_POST['email'] : ''; $phone = isset($_POST['phone']) ? $_POST['phone'] : ''; - $ip = isset($_POST['IP']) ? $_POST['IP'] : ''; + $ip = isset($_POST['ip']) ? $_POST['ip'] : ''; $message = isset($_POST['message']) ? $_POST['message'] : ''; $product = isset($_POST['product']) ? $_POST['product'] : ''; $company = isset($_POST['company']) ? $_POST['company'] : ''; diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 26b016d..75e1168 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -92,6 +92,74 @@ class Index extends BaseController } } + // 上传程序 + public function upload_files() + { + if (request()->file('file')) { + // 获取文件信息 + $file = request()->file('file'); + $file_name = $file->getOriginalName(); + $file_size = $file->getSize(); + $file_extension = pathinfo($file->getOriginalName(), PATHINFO_EXTENSION); + + // 文件大小限制(单位:字节) + $max_file_size = 500 * 1024 * 1024; // 500MB + + // 检查文件大小 + if ($file_size > $max_file_size) { + return json([ + 'code' => 2, + 'msg' => '文件过大,已经超过500MB,请联系管理员!', + 'max_size' => $max_file_size, + 'file_size' => $file_size + ]); + } + + // 创建文件夹 + $upload_dir = 'upload/programes/' . date('Y-m-d') . '/'; + if (!is_dir($upload_dir)) { + if (!mkdir($upload_dir, 0777, true) && !is_dir($upload_dir)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $upload_dir)); + } + } + + // 生成新文件名 + $new_name = $this->generateRandomName(5) . '.' . $file_extension; + + // 保存文件 + $file->move($upload_dir, $new_name); + + // 添加数据到数据库 + $data = [ + 'path' => $upload_dir . $new_name, + 'uid' => $this->uid, + 'create_time' => date('Y-m-d H:i:s', time()) + ]; + Db::name('DownloadFiles')->insert($data); + + // 获取文件上传域名 + $fileDomain = $_SERVER['HTTP_HOST']; + + // 构建文件访问地址 + $url = $fileDomain . '/upload/programes/' . date('Y-m-d') . '/' . $new_name; + + // 返回 JSON 数据 + return json([ + 'code' => 200, + 'msg' => '文件上传成功!', + 'fileDomain' => $fileDomain, + 'filename' => $file_name, + 'filepath' => $upload_dir . $new_name, + 'file_size'=> $file_size, + 'file_extension'=> $file_extension, + 'url' => $url, + 'admin_id' => $this->uid + ]); + } else { + return json(['code' => 400, 'msg' => '未选择上传文件!']); + } + } + // 图床上传 public function upload_picbed() { @@ -563,7 +631,7 @@ class Index extends BaseController header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Content-Type'); - $images = Db::name('PicbedImages')->order('id', 'desc')->select()->toArray(); + $images = Db::name('PicbedImages')->order('id', 'desc')->select()->toArray(); // 获取当前请求的域名 $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; @@ -574,14 +642,15 @@ class Index extends BaseController $images = array_map(function ($image) use ($baseUrl) { return [ 'name' => htmlspecialchars($image['name'], ENT_QUOTES), - 'path' => $baseUrl . '/' . $image['path'], + 'path' => $baseUrl . '/' . $image['path'], ]; }, $images); - return json(['code' => 0, 'msg' => '', 'data' => $images]); + return json(['code' => 0, 'msg' => '', 'data' => $images]); } - public function getallstaff(){ + public function getallstaff() + { $employees = Db::name('admin') ->field('id, name, status') // 根据需要选择字段 ->where('status', 1) // 只获取在职员工 diff --git a/app/api/middleware.php b/app/api/middleware.php index 4ecb7bc..dce057f 100644 --- a/app/api/middleware.php +++ b/app/api/middleware.php @@ -5,6 +5,4 @@ return [ //'think\middleware\SessionInit', //验证勾股cms是否完成安装 \app\home\middleware\Install::class, - // 跳过登录验证 AuthMiddleware - \app\api\middleware\Auth::class, ]; \ No newline at end of file diff --git a/app/api/view/project/view_schedule.html b/app/api/view/project/view_schedule.html index 2fea52c..80ba7bc 100644 --- a/app/api/view/project/view_schedule.html +++ b/app/api/view/project/view_schedule.html @@ -1,6 +1,7 @@