From 88362cb1f990db8813aef112bc231745749301b0 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 31 Jan 2023 13:13:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B7=A8=E6=97=A5/=E5=91=A8=E5=86=99?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=8A=A5=E5=91=8A=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/ReportController.php | 24 ++++++++++--------- .../js/pages/manage/components/ReportEdit.vue | 3 +++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/ReportController.php b/app/Http/Controllers/Api/ReportController.php index 472519951..35bba8da3 100755 --- a/app/Http/Controllers/Api/ReportController.php +++ b/app/Http/Controllers/Api/ReportController.php @@ -120,6 +120,7 @@ class ReportController extends AbstractController * @apiName store * * @apiParam {Number} [id] 汇报ID + * @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回 * @apiParam {String} [title] 汇报标题 * @apiParam {Array} [type] 汇报类型,weekly:周报,daily:日报 * @apiParam {Number} [content] 内容 @@ -193,18 +194,17 @@ class ReportController extends AbstractController ]); } else { // 生成唯一标识 - $sign = Report::generateSign($input["type"], $input["offset"]); + $sign = Base::isNumber($input["sign"]) ? $input["sign"] : Report::generateSign($input["type"], $input["offset"]); // 检查唯一标识是否存在 - if (empty($input["id"])) { - if (Report::query()->whereSign($sign)->whereType($input["type"])->count() > 0) - throw new ApiException("请勿重复提交工作汇报"); + if (empty($input["id"]) && Report::query()->whereSign($sign)->whereType($input["type"])->count() > 0) { + throw new ApiException("请勿重复提交工作汇报"); } $report = Report::createInstance([ + "sign" => $sign, "title" => $input["title"], "type" => $input["type"], - "content" => htmlspecialchars($input["content"]), "userid" => $user->userid, - "sign" => $sign, + "content" => htmlspecialchars($input["content"]), ]); } @@ -286,9 +286,10 @@ class ReportController extends AbstractController // 如果已经提交了相关汇报 if ($one && $id > 0) { return Base::retSuccess('success', [ - "content" => $one->content, - "title" => $one->title, "id" => $one->id, + "sign" => $one->sign, + "title" => $one->title, + "content" => $one->content, ]); } @@ -341,13 +342,14 @@ class ReportController extends AbstractController } $data = [ "time" => $start_time->toDateTimeString(), - "complete_task" => $complete_task, - "unfinished_task" => $unfinished_task, + "sign" => $sign, + "title" => $title, "content" => '

' . Base::Lang('已完成工作') . '

    ' . $completeContent . '

' . Base::Lang('未完成的工作') . '

    ' . $unfinishedContent . '
', - "title" => $title, + "complete_task" => $complete_task, + "unfinished_task" => $unfinished_task, ]; if ($one) { $data['id'] = $one->id; diff --git a/resources/assets/js/pages/manage/components/ReportEdit.vue b/resources/assets/js/pages/manage/components/ReportEdit.vue index 28ade9e44..2634e6bf3 100644 --- a/resources/assets/js/pages/manage/components/ReportEdit.vue +++ b/resources/assets/js/pages/manage/components/ReportEdit.vue @@ -67,6 +67,7 @@ export default { data() { return { reportData: { + sign: "", title: "", content: "", type: "weekly", @@ -150,11 +151,13 @@ export default { if (this.id > 0) { this.getDetail(data.id); } else { + this.reportData.sign = data.sign; this.reportData.title = data.title; this.reportData.content = data.content; } } else { this.reportData.id = 0; + this.reportData.sign = data.sign; this.reportData.title = data.title; this.reportData.content = data.content; }