|
|
|
@ -453,7 +453,7 @@ |
|
|
|
<input type="date" id="date" name="date" required> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label>手写签名:<span style="color: red;">*</span></label> |
|
|
|
<label>手写签名:</label> |
|
|
|
<div class="signature-container"> |
|
|
|
<canvas id="signatureCanvas" width="350" height="200"></canvas> |
|
|
|
<div class="signature-actions"> |
|
|
|
@ -503,6 +503,23 @@ |
|
|
|
return sessionId; |
|
|
|
} |
|
|
|
|
|
|
|
// 填充表单数据 |
|
|
|
function populateForm(certificate) { |
|
|
|
if (!certificate) return; |
|
|
|
|
|
|
|
// 填充基本信息 |
|
|
|
document.getElementById('subjectName').value = certificate.subjectName || ''; |
|
|
|
document.getElementById('productName').value = certificate.productName || ''; |
|
|
|
document.getElementById('weight').value = certificate.weight || ''; |
|
|
|
document.getElementById('basis').value = certificate.basis || ''; |
|
|
|
document.getElementById('origin').value = certificate.origin || ''; |
|
|
|
document.getElementById('contact').value = certificate.contact || ''; |
|
|
|
document.getElementById('date').value = formatDate(certificate.date) || ''; |
|
|
|
|
|
|
|
// 签名部分保持空白,等待补填 |
|
|
|
clearSignature(); |
|
|
|
} |
|
|
|
|
|
|
|
// 从服务器加载最新的合格证信息 |
|
|
|
function loadCertificate() { |
|
|
|
const sessionId = getSessionId(); |
|
|
|
@ -511,7 +528,18 @@ |
|
|
|
.then(response => response.json()) |
|
|
|
.then(data => { |
|
|
|
if (data.success && data.certificate) { |
|
|
|
// 检查是否包含签名 |
|
|
|
if (data.certificate.signature) { |
|
|
|
// 有签名,显示只读模式 |
|
|
|
displayCertificate(data.certificate); |
|
|
|
// 标记为已完成 |
|
|
|
sessionStorage.setItem('certificateSubmitted_' + sessionId, 'true'); |
|
|
|
} else { |
|
|
|
// 无签名,保持可编辑状态并填充已有数据 |
|
|
|
populateForm(data.certificate); |
|
|
|
// 标记为部分完成 |
|
|
|
sessionStorage.setItem('certificatePartiallyCompleted_' + sessionId, 'true'); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
@ -925,10 +953,11 @@ |
|
|
|
alert('请选择开具日期'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!signature) { |
|
|
|
alert('请进行手写签名'); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 签名改为选填项 |
|
|
|
// if (!signature) { |
|
|
|
// alert('请进行手写签名'); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
|
|
|
|
// 收集表单数据 |
|
|
|
const formData = new FormData(this); |
|
|
|
@ -976,17 +1005,19 @@ |
|
|
|
.then(response => response.json()) |
|
|
|
.then(data => { |
|
|
|
if (data.success) { |
|
|
|
// 标记为已提交 |
|
|
|
const sessionId = getSessionId(); |
|
|
|
sessionStorage.setItem('certificateSubmitted_' + sessionId, 'true'); |
|
|
|
|
|
|
|
// 显示结果 |
|
|
|
// 检查是否包含签名 |
|
|
|
if (data.certificate.signature) { |
|
|
|
// 有签名,标记为已完成并切换到只读模式 |
|
|
|
sessionStorage.setItem('certificateSubmitted_' + sessionId, 'true'); |
|
|
|
displayCertificate(data.certificate); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 显示成功提示 |
|
|
|
alert('提交成功!合格证信息已保存到数据库。'); |
|
|
|
} else { |
|
|
|
// 无签名,标记为部分完成,保持可编辑状态 |
|
|
|
sessionStorage.setItem('certificatePartiallyCompleted_' + sessionId, 'true'); |
|
|
|
alert('基本信息提交成功!请继续完成手写签名。'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
alert('保存失败: ' + data.error); |
|
|
|
} |
|
|
|
|