当输入患者的姓名和身份号码两个字段的值已经存在时,提醒挂号工作人员该患者档案已经存在
This commit is contained in:
@@ -44,6 +44,9 @@ import TreeSelect from '@/components/TreeSelect'
|
||||
// 字典标签组件
|
||||
import DictTag from '@/components/DictTag'
|
||||
|
||||
// 导入请求工具
|
||||
import request from './utils/request'
|
||||
|
||||
import { ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import {registerComponents} from './template';
|
||||
@@ -64,6 +67,9 @@ app.config.globalProperties.handleTree = handleTree
|
||||
app.config.globalProperties.addDateRange = addDateRange
|
||||
app.config.globalProperties.selectDictLabel = selectDictLabel
|
||||
app.config.globalProperties.selectDictLabels = selectDictLabels
|
||||
|
||||
// 全局挂载请求实例
|
||||
app.config.globalProperties.$http = request
|
||||
// 全局组件挂载
|
||||
app.component('DictTag', DictTag)
|
||||
app.component('Pagination', Pagination)
|
||||
|
||||
@@ -300,6 +300,36 @@ const title = ref('新增患者');
|
||||
const visible = ref(false);
|
||||
const emits = defineEmits(['submit']); // 声明自定义事件
|
||||
|
||||
const validateUniquePatient = (rule, value, callback) => {
|
||||
const { name, idCard } = form.value;
|
||||
// 确保姓名和身份证都已填写且身份证为18位
|
||||
if (!name || !idCard || idCard.length !== 18) {
|
||||
return callback(); // 不满足条件,不校验
|
||||
}
|
||||
|
||||
// 使用 axios 直接请求,避免依赖 proxy.$http
|
||||
import('@/utils/request').then(({ default: request }) => {
|
||||
request({
|
||||
url: '/patient-manage/information/check-exists',
|
||||
method: 'get',
|
||||
params: {
|
||||
name: name,
|
||||
idCardNo: idCard
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 200 && res.data === true) {
|
||||
callback(new Error('该患者档案已存在!'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('校验患者是否存在失败:', error);
|
||||
callback(); // 出错时不阻塞表单
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 身份证号码校验函数
|
||||
const validateIdCard = (rule, value, callback) => {
|
||||
@@ -338,14 +368,17 @@ const data = reactive({
|
||||
age: undefined,
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '姓名不能为空', trigger: 'change' }],
|
||||
name: [{ required: true, message: '姓名不能为空', trigger: 'change' },
|
||||
{ validator: validateUniquePatient, trigger: 'blur' }
|
||||
],
|
||||
genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }],
|
||||
age: [{ required: true, message: '年龄不能为空', trigger: 'change' }],
|
||||
phone: [{ required: true, message: '联系方式不能为空', trigger: 'change' }],
|
||||
identifierNo: [{ required: true, message: '就诊卡号不能为空', trigger: 'change' }],
|
||||
idCard: [
|
||||
{ required: true, message: '证件号码不能为空', trigger: 'change' },
|
||||
{ validator: validateIdCard, trigger: 'blur' }
|
||||
{ validator: validateIdCard, trigger: 'blur' },
|
||||
{ validator: validateUniquePatient, trigger: 'blur' }
|
||||
],
|
||||
birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user