fix: patch validation bypass for mandatory inspection
This commit is contained in:
@ -105,7 +105,9 @@ class BuyInboundService:
|
|||||||
# 检查检测报告:文件列表或外部链接至少有一个
|
# 检查检测报告:文件列表或外部链接至少有一个
|
||||||
# 前端会将外部链接添加到 inspection_report 数组中一起提交
|
# 前端会将外部链接添加到 inspection_report 数组中一起提交
|
||||||
inspection_report_list = data.get('inspection_report', [])
|
inspection_report_list = data.get('inspection_report', [])
|
||||||
has_report_file = inspection_report_list and len(inspection_report_list) > 0
|
# 过滤空字符串,只保留有效报告(字符串长度 > 0 且去除空格后非空)
|
||||||
|
valid_reports = [r for r in inspection_report_list if r and str(r).strip()]
|
||||||
|
has_report_file = valid_reports and len(valid_reports) > 0
|
||||||
|
|
||||||
if not has_report_file:
|
if not has_report_file:
|
||||||
raise ValueError(f"物料【{material.name}】为强管控物料,必须提供检测报告文件或外部链接")
|
raise ValueError(f"物料【{material.name}】为强管控物料,必须提供检测报告文件或外部链接")
|
||||||
@ -209,9 +211,13 @@ class BuyInboundService:
|
|||||||
existing_reports = json_module.loads(stock.inspection_report) if stock.inspection_report else []
|
existing_reports = json_module.loads(stock.inspection_report) if stock.inspection_report else []
|
||||||
except:
|
except:
|
||||||
existing_reports = []
|
existing_reports = []
|
||||||
has_report_file = existing_reports and len(existing_reports) > 0
|
# 过滤空字符串,只保留有效报告
|
||||||
|
valid_reports = [r for r in existing_reports if r and str(r).strip()]
|
||||||
|
has_report_file = valid_reports and len(valid_reports) > 0
|
||||||
else:
|
else:
|
||||||
has_report_file = inspection_report_list and len(inspection_report_list) > 0
|
# 过滤空字符串,只保留有效报告
|
||||||
|
valid_reports = [r for r in inspection_report_list if r and str(r).strip()]
|
||||||
|
has_report_file = valid_reports and len(valid_reports) > 0
|
||||||
|
|
||||||
if not has_report_file:
|
if not has_report_file:
|
||||||
raise ValueError(f"物料【{material.name}】为强管控物料,必须提供检测报告文件或外部链接")
|
raise ValueError(f"物料【{material.name}】为强管控物料,必须提供检测报告文件或外部链接")
|
||||||
|
|||||||
@ -1194,7 +1194,9 @@ const rules = computed(() => {
|
|||||||
baseRules.inspection_report = [
|
baseRules.inspection_report = [
|
||||||
{
|
{
|
||||||
validator: (rule: any, value: any, callback: any) => {
|
validator: (rule: any, value: any, callback: any) => {
|
||||||
const hasFile = form.inspection_report && form.inspection_report.length > 0
|
// 过滤空字符串,只保留有效报告
|
||||||
|
const validFiles = (form.inspection_report || []).filter((r: string) => r && r.trim())
|
||||||
|
const hasFile = validFiles.length > 0
|
||||||
const hasLink = inspection_report_url.value && inspection_report_url.value.trim() !== ''
|
const hasLink = inspection_report_url.value && inspection_report_url.value.trim() !== ''
|
||||||
if (!hasFile && !hasLink) {
|
if (!hasFile && !hasLink) {
|
||||||
callback(new Error('该物料为强管控物料,必须提供检测报告文件或链接'))
|
callback(new Error('该物料为强管控物料,必须提供检测报告文件或链接'))
|
||||||
|
|||||||
Reference in New Issue
Block a user