fix: 跨日/周写工作报告导致的覆盖问题

This commit is contained in:
kuaifan 2023-01-31 13:13:24 +08:00
parent 92966ed516
commit 88362cb1f9
2 changed files with 16 additions and 11 deletions

View File

@ -120,6 +120,7 @@ class ReportController extends AbstractController
* @apiName store * @apiName store
* *
* @apiParam {Number} [id] 汇报ID * @apiParam {Number} [id] 汇报ID
* @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回
* @apiParam {String} [title] 汇报标题 * @apiParam {String} [title] 汇报标题
* @apiParam {Array} [type] 汇报类型weekly:周报daily:日报 * @apiParam {Array} [type] 汇报类型weekly:周报daily:日报
* @apiParam {Number} [content] 内容 * @apiParam {Number} [content] 内容
@ -193,18 +194,17 @@ class ReportController extends AbstractController
]); ]);
} else { } 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 (empty($input["id"]) && Report::query()->whereSign($sign)->whereType($input["type"])->count() > 0) {
if (Report::query()->whereSign($sign)->whereType($input["type"])->count() > 0) throw new ApiException("请勿重复提交工作汇报");
throw new ApiException("请勿重复提交工作汇报");
} }
$report = Report::createInstance([ $report = Report::createInstance([
"sign" => $sign,
"title" => $input["title"], "title" => $input["title"],
"type" => $input["type"], "type" => $input["type"],
"content" => htmlspecialchars($input["content"]),
"userid" => $user->userid, "userid" => $user->userid,
"sign" => $sign, "content" => htmlspecialchars($input["content"]),
]); ]);
} }
@ -286,9 +286,10 @@ class ReportController extends AbstractController
// 如果已经提交了相关汇报 // 如果已经提交了相关汇报
if ($one && $id > 0) { if ($one && $id > 0) {
return Base::retSuccess('success', [ return Base::retSuccess('success', [
"content" => $one->content,
"title" => $one->title,
"id" => $one->id, "id" => $one->id,
"sign" => $one->sign,
"title" => $one->title,
"content" => $one->content,
]); ]);
} }
@ -341,13 +342,14 @@ class ReportController extends AbstractController
} }
$data = [ $data = [
"time" => $start_time->toDateTimeString(), "time" => $start_time->toDateTimeString(),
"complete_task" => $complete_task, "sign" => $sign,
"unfinished_task" => $unfinished_task, "title" => $title,
"content" => '<h2>' . Base::Lang('已完成工作') . '</h2><ol>' . "content" => '<h2>' . Base::Lang('已完成工作') . '</h2><ol>' .
$completeContent . '</ol><h2>' . $completeContent . '</ol><h2>' .
Base::Lang('未完成的工作') . '</h2><ol>' . Base::Lang('未完成的工作') . '</h2><ol>' .
$unfinishedContent . '</ol>', $unfinishedContent . '</ol>',
"title" => $title, "complete_task" => $complete_task,
"unfinished_task" => $unfinished_task,
]; ];
if ($one) { if ($one) {
$data['id'] = $one->id; $data['id'] = $one->id;

View File

@ -67,6 +67,7 @@ export default {
data() { data() {
return { return {
reportData: { reportData: {
sign: "",
title: "", title: "",
content: "", content: "",
type: "weekly", type: "weekly",
@ -150,11 +151,13 @@ export default {
if (this.id > 0) { if (this.id > 0) {
this.getDetail(data.id); this.getDetail(data.id);
} else { } else {
this.reportData.sign = data.sign;
this.reportData.title = data.title; this.reportData.title = data.title;
this.reportData.content = data.content; this.reportData.content = data.content;
} }
} else { } else {
this.reportData.id = 0; this.reportData.id = 0;
this.reportData.sign = data.sign;
this.reportData.title = data.title; this.reportData.title = data.title;
this.reportData.content = data.content; this.reportData.content = data.content;
} }