fix: allow rejected report resubmission
This commit is contained in:
@@ -707,6 +707,8 @@ class AppraisalTasksController
|
||||
$order = Db::name('orders')->where('id', (int)$task['order_id'])->find() ?: [];
|
||||
$task['order_status'] = $order['order_status'] ?? '';
|
||||
$report = $this->findLatestAppraisalReport((int)$task['order_id']);
|
||||
$materialTagService = new MaterialTagService();
|
||||
$boundMaterialTag = $report ? $materialTagService->findBoundTagForReport((int)$report['id']) : null;
|
||||
$effectiveStatus = $this->effectiveTaskStatus($task, $report);
|
||||
if ($effectiveStatus !== $task['status']) {
|
||||
Db::name('appraisal_tasks')->where('id', $id)->update([
|
||||
@@ -729,7 +731,7 @@ class AppraisalTasksController
|
||||
if ($action !== 'save' && $resultText === '') {
|
||||
return api_error('鉴定结论不能为空', 422);
|
||||
}
|
||||
if ($action !== 'save' && $qrInput === '') {
|
||||
if ($action !== 'save' && $qrInput === '' && !$boundMaterialTag) {
|
||||
return api_error('请扫描验真吊牌二维码', 422);
|
||||
}
|
||||
$productInput = $request->input('product_info', null);
|
||||
@@ -836,8 +838,10 @@ class AppraisalTasksController
|
||||
Db::rollback();
|
||||
return api_error('报告草稿生成失败', 500);
|
||||
}
|
||||
$tag = (new MaterialTagService())->bindTagToReportByTask($id, $qrInput, $request);
|
||||
$freshReport = $this->findLatestAppraisalReport((int)$task['order_id']) ?: $report;
|
||||
$tag = $boundMaterialTag && $qrInput === ''
|
||||
? ($materialTagService->findBoundTagForReport((int)$freshReport['id']) ?: $boundMaterialTag)
|
||||
: $materialTagService->bindTagToReportByTask($id, $qrInput, $request);
|
||||
$this->insertReportLog((int)$freshReport['id'], $draftChange['action'], $draftChange['before'], $freshReport, $request, '报告已提交,待管理员发布');
|
||||
$this->insertReportLog((int)$freshReport['id'], 'submit', $draftChange['before'], $freshReport, $request, '鉴定师提交报告');
|
||||
|
||||
@@ -858,6 +862,12 @@ class AppraisalTasksController
|
||||
'report_page_url' => '',
|
||||
],
|
||||
], '报告已提交,待管理员发布');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
Db::rollback();
|
||||
return api_error($e->getMessage(), 422);
|
||||
} catch (\RuntimeException $e) {
|
||||
Db::rollback();
|
||||
return api_error($e->getMessage(), $e->getCode() ?: 500);
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
return api_error('结论保存失败', 500, [
|
||||
|
||||
@@ -55,6 +55,7 @@ const isTaskReadonly = computed(() => {
|
||||
const internalTagNo = computed(() => detail.value?.task_info.internal_tag_no || "");
|
||||
const resultSummary = computed(() => detail.value?.result_info.result_text || "暂未填写");
|
||||
const reportSummary = computed(() => detail.value?.report_summary?.report_no || "");
|
||||
const hasBoundMaterialTag = computed(() => Boolean(detail.value?.material_tag?.id));
|
||||
type AppraisalTemplate = NonNullable<AdminAppraisalTaskDetail["appraisal_template"]>;
|
||||
|
||||
function hasConditionFields(template?: AppraisalTemplate | null) {
|
||||
@@ -297,13 +298,13 @@ function returnToWorkOrders(message: string) {
|
||||
}, 700);
|
||||
}
|
||||
|
||||
function confirmPublishReport() {
|
||||
function confirmPublishReport(requiresMaterialTag = true) {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
uni.showModal({
|
||||
title: "提交确认",
|
||||
content: "是否已鉴定完成并提交报告待发布?",
|
||||
cancelText: "取消",
|
||||
confirmText: "去绑定",
|
||||
confirmText: requiresMaterialTag ? "去绑定" : "提交",
|
||||
success: (result) => resolve(Boolean(result.confirm)),
|
||||
fail: () => resolve(false),
|
||||
});
|
||||
@@ -513,10 +514,20 @@ async function submitResult(action: "save" | "submit") {
|
||||
return;
|
||||
}
|
||||
|
||||
const qrInput = action === "submit" ? await confirmAndScanMaterialTag() : "";
|
||||
if (action === "submit" && !qrInput) {
|
||||
let qrInput = "";
|
||||
if (action === "submit") {
|
||||
if (hasBoundMaterialTag.value) {
|
||||
const confirmed = await confirmPublishReport(false);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qrInput = await confirmAndScanMaterialTag();
|
||||
if (!qrInput) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user