人员登记校验及pdf下载位置修改

ln_ry20250512
dshclm 1 week ago
parent ba9695f4d9
commit 225b3b8ffe

@ -439,6 +439,25 @@
})
return;
}
// 验证联系方式(仅检查位数)
if (this.formData.phone.length !== 11) {
this.$message({
message: '联系方式应为11位数字',
type: 'warning'
})
return;
}
// 验证身份证号
if (!this.validateCerno(this.formData.cerno)) {
this.$message({
message: '请输入有效的身份证号码',
type: 'warning'
})
return;
}
// 准备表单数据
let formData = new FormData();
if (this.formData.name) formData.append("name", this.formData.name);
@ -497,6 +516,25 @@
alert('请上传一寸照片');
return;
}
// 验证联系方式(仅检查位数)
if (this.formData.phone.length !== 11) {
this.$message({
message: '联系方式应为11位数字',
type: 'warning'
})
return;
}
// 验证身份证号
if (!this.validateCerno(this.formData.cerno)) {
this.$message({
message: '请输入有效的身份证号码',
type: 'warning'
})
return;
}
this.$confirm('确认保存吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -514,6 +552,35 @@
});
});
},
// 身份证号验证函数
validateCerno(cerno) {
// 身份证号码正则表达式
const pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
// 基本格式验证
if (!pattern.test(cerno)) {
return false;
}
// 18位身份证号码的验证包括校验位计算
if (cerno.length === 18) {
const idCardArray = cerno.split('');
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const parity = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
let sum = 0;
for (let i = 0; i < 17; i++) {
sum += parseInt(idCardArray[i]) * factor[i];
}
const lastChar = idCardArray[17].toUpperCase();
if (lastChar !== parity[sum % 11]) {
return false;
}
}
return true;
},
// 新增获取下拉框数据的方法
fetchPostOptions() {
this.isLoadingPosts = true;
@ -553,4 +620,4 @@
</script>
</body>
</html>
</html>

@ -497,6 +497,25 @@
})
return;
}
// 验证联系方式(仅检查位数)
if (this.formData.phone.length !== 11) {
this.$message({
message: '联系方式应为11位数字',
type: 'warning'
})
return;
}
// 验证身份证号
if (!this.validateCerno(this.formData.cerno)) {
this.$message({
message: '请输入有效的身份证号码',
type: 'warning'
})
return;
}
this.$confirm('确认保存吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -514,6 +533,35 @@
});
});
},
// 身份证号验证函数
validateCerno(cerno) {
// 身份证号码正则表达式
const pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
// 基本格式验证
if (!pattern.test(cerno)) {
return false;
}
// 18位身份证号码的验证包括校验位计算
if (cerno.length === 18) {
const idCardArray = cerno.split('');
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
const parity = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
let sum = 0;
for (let i = 0; i < 17; i++) {
sum += parseInt(idCardArray[i]) * factor[i];
}
const lastChar = idCardArray[17].toUpperCase();
if (lastChar !== parity[sum % 11]) {
return false;
}
}
return true;
},
// 新增获取下拉框数据的方法
fetchPostOptions() {
this.isLoadingPosts = true;

@ -276,13 +276,30 @@
</div>
</div>
<!-- 按钮 -->
<div class="row">
<div class="row" style="display: ruby;">
<button type="submit" class="group relative w-full max-w-xs flex justify-center py-3 px-6 border border-transparent text-base font-medium rounded-lg text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-all duration-300">
<span class="absolute left-0 inset-y-0 flex items-center pl-3" style="margin-right: 5px;">
<i class="fa-solid fa-file-pdf text-white transform group-hover:translate-x-0.5 transition-transform duration-200"></i>
</span>
生成PDF文件
生成涉密人员审查表
</button>
<a v-if="showResult" :href="pdfUrl" download="涉密人员审查表.pdf" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">
<i class="fa-solid fa-download mr-2"></i> 下载PDF
</a>
<!-- 结果区域 -->
<!-- <div class="bg-white rounded-xl shadow-soft p-6 mb-8 transform hover:shadow-lg transition-all duration-300">-->
<!-- <div class="flex items-start">-->
<!-- <div class="ml-4">-->
<!-- <h3 class="text-lg font-medium text-gray-800">PDF生成成功</h3>-->
<!-- <div class="mt-4 flex flex-wrap gap-3">-->
<!-- -->
<!-- <button @click="showResult = false" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">-->
<!-- <i class="fa-solid fa-times mr-2"></i> 关闭-->
<!-- </button>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</form>
<h4 class="form-header h4">材料上传</h4>
@ -348,26 +365,6 @@
</div>
</div>
</div>
<!-- 结果区域 -->
<div v-if="showResult" class="bg-white rounded-xl shadow-soft p-6 mb-8 transform hover:shadow-lg transition-all duration-300">
<div class="flex items-start">
<div class="flex-shrink-0 bg-green-100 p-3 rounded-lg">
<i class="fa-solid fa-check text-green-500 text-xl"></i>
</div>
<div class="ml-4">
<h3 class="text-lg font-medium text-gray-800">PDF生成成功</h3>
<p class="mt-1 text-sm text-gray-600">您的PDF表单已成功填写可以点击下方按钮下载。</p>
<div class="mt-4 flex flex-wrap gap-3">
<a :href="pdfUrl" download="涉密人员审查表.pdf" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-primary hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">
<i class="fa-solid fa-download mr-2"></i> 下载PDF
</a>
<button @click="showResult = false" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-colors duration-200">
<i class="fa-solid fa-times mr-2"></i> 关闭
</button>
</div>
</div>
</div>
</div>
<!-- 加载中 -->
<div v-if="isLoading" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-xl p-6 shadow-lg max-w-md w-full">
@ -550,7 +547,7 @@
// 创建下载URL
let blob = new Blob([response.data], { type: 'application/pdf' });
this.pdfUrl = window.URL.createObjectURL(blob);
this.$message.success('生成pdf成功请点击下载');
// 隐藏加载状态,显示结果
this.isLoading = false;
this.showResult = true;

Loading…
Cancel
Save