5 Commits

3 changed files with 109 additions and 10 deletions

View File

@@ -6,9 +6,9 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:postgresql://localhost:5432/openhis?currentSchema=public&characterEncoding=UTF-8&client_encoding=UTF-8 url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=public&characterEncoding=UTF-8&client_encoding=UTF-8
username: postgres username: postgresql
password: root password: Jchl1528
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
@@ -62,13 +62,13 @@ spring:
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
host: 172.0.0.0 host: 192.168.110.252
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 6379
# 数据库索引 # 数据库索引
database: 1 database: 1
# 密码 # 密码
password: redis password: Jchl1528
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:

View File

@@ -80,6 +80,19 @@
<el-input v-model="form.countryCode" clearable :disabled="isViewMode" /> <el-input v-model="form.countryCode" clearable :disabled="isViewMode" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="出生日期" prop="birthDate">
<el-date-picker
v-model="form.birthDate"
type="date"
placeholder="请选择出生日期"
format="YYYY年MM月DD日"
:disabled="isViewMode"
value-format="YYYY-MM-DD"
@change="handleBirthDateChange"
/>
</el-form-item>
</el-col>
</el-row> </el-row>
<!-- <el-col :span="6"> <!-- <el-col :span="6">
<el-form-item label="年龄" prop="age"> <el-form-item label="年龄" prop="age">
@@ -109,7 +122,8 @@
<el-input <el-input
v-model="form.age" v-model="form.age"
:disabled="isViewMode" :disabled="isViewMode"
@input="(value) => (form.age = value.replace(/[^0-9]/g, ''))" @input="handleAgeInput"
placeholder="请输入年龄"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -286,19 +300,62 @@ const title = ref('新增患者');
const visible = ref(false); const visible = ref(false);
const emits = defineEmits(['submit']); // 声明自定义事件 const emits = defineEmits(['submit']); // 声明自定义事件
// 身份证号码校验函数
const validateIdCard = (rule, value, callback) => {
if (!value) {
callback();
return;
}
// 18位身份证正则
const reg = /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
if (!reg.test(value)) {
return callback(new Error('请输入正确的18位身份证号码'));
}
// 校验码验证第18位
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(value.charAt(i)) * factor[i];
}
const last = parity[sum % 11];
if (last !== value.charAt(17).toUpperCase()) {
return callback(new Error('身份证校验码错误'));
}
callback(); // 校验通过
}
const data = reactive({ const data = reactive({
isViewMode: false, isViewMode: false,
form: { form: {
typeCode: '08', typeCode: '08',
birthDate: undefined,
age: undefined,
}, },
rules: { rules: {
name: [{ required: true, message: '姓名不能为空', trigger: 'change' }], name: [{ required: true, message: '姓名不能为空', trigger: 'change' }],
genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }], genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }],
age: [{ required: true, message: '年龄不能为空', trigger: 'change' }], age: [{ required: true, message: '年龄不能为空', trigger: 'change' }],
phone: [{ 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' }
],
birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }],
}, },
}); });
const { queryParams, form, rules, isViewMode } = toRefs(data); const { queryParams, form, rules, isViewMode } = toRefs(data);
const props = defineProps({ const props = defineProps({
@@ -308,6 +365,46 @@ const props = defineProps({
}, },
}); });
// 处理出生日期变化,自动计算年龄
function handleBirthDateChange() {
if (form.value.birthDate) {
const birthDate = new Date(form.value.birthDate);
const today = new Date();
let age = today.getFullYear() - birthDate.getFullYear();
const monthDiff = today.getMonth() - birthDate.getMonth();
// 计算精确年龄
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
form.value.age = age + '岁';
}
}
// 处理年龄输入,自动计算出生日期
function handleAgeInput() {
// 提取数字部分
const ageMatch = form.value.age.match(/\d+/);
if (ageMatch) {
const age = parseInt(ageMatch[0]);
// 移除非数字字符,保留数字和可能的单位
form.value.age = age + '岁';
// 计算出生日期
const today = new Date();
const birthYear = today.getFullYear() - age;
const birthMonth = today.getMonth();
const birthDay = today.getDate();
const birthDate = new Date(birthYear, birthMonth, birthDay);
// 格式化为YYYY-MM-DD
const formattedBirthDate = birthDate.toISOString().split('T')[0];
form.value.birthDate = formattedBirthDate;
}
}
watch( watch(
() => form.value.idCard, () => form.value.idCard,
(newIdCard) => { (newIdCard) => {
@@ -315,7 +412,8 @@ watch(
const birthYear = parseInt(newIdCard.substring(6, 10)); const birthYear = parseInt(newIdCard.substring(6, 10));
const birthMonth = parseInt(newIdCard.substring(10, 12)); const birthMonth = parseInt(newIdCard.substring(10, 12));
const birthDay = parseInt(newIdCard.substring(12, 14)); const birthDay = parseInt(newIdCard.substring(12, 14));
// 设置出生日期
form.value.birthDate = `${birthYear}-${birthMonth.toString().padStart(2, '0')}-${birthDay.toString().padStart(2, '0')}`;
const today = new Date(); const today = new Date();
const currentYear = today.getFullYear(); const currentYear = today.getFullYear();
const currentMonth = today.getMonth() + 1; const currentMonth = today.getMonth() + 1;
@@ -331,7 +429,7 @@ watch(
age--; age--;
} }
form.value.age = age; form.value.age = age + '岁';
} }
} }
); );
@@ -424,6 +522,7 @@ function reset() {
maritalStatusEnum: undefined, maritalStatusEnum: undefined,
busNo: undefined, busNo: undefined,
organizationId: undefined, organizationId: undefined,
birthDate: undefined,
}; };
proxy.resetForm('patientRef'); proxy.resetForm('patientRef');
} }
@@ -485,7 +584,7 @@ defineExpose({
margin-right: 10px !important; margin-right: 10px !important;
} }
/* 使用深度选择器 */ /* 使用深度选择器 */
.custom-label-spacing :deep(.el-form-item__label) { .custom-label-spacing :deep(.el-form-item__label) {
line-height: 1.2; /* 调整行间距 */ line-height: 1.2; /* 调整行间距 */
margin-bottom: 4px; /* 调整 label 和输入框之间的间距 */ margin-bottom: 4px; /* 调整 label 和输入框之间的间距 */

View File

@@ -700,7 +700,7 @@ const data = reactive({
isEdit: false, isEdit: false,
isAdding: true, isAdding: true,
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
searchKey: undefined, // 供应商名称 searchKey: undefined, // 供应商名称
busNo: undefined, // 编码 busNo: undefined, // 编码