|
@@ -97,6 +97,7 @@ import UserAPI, { UserForm } from '@/api/user'
|
|
|
import { getCurrentInstance } from 'vue'
|
|
|
import { CaseInfoVO } from '@/api/tester/case'
|
|
|
import { FormInstance } from 'element-plus'
|
|
|
+import { getGenderFromIDCard, validateIDCardStrict } from '@/utils'
|
|
|
|
|
|
const instance = getCurrentInstance()
|
|
|
const loading = ref(false) // 加载状态
|
|
@@ -115,6 +116,23 @@ const caseAddShow = ref(false) // 病例页面是否展示
|
|
|
const isAlreadyExists = ref(false) // 用户是否已经存在
|
|
|
const showEmptyCaseLog = ref(false) // 若患者不存在数据库时,查询后显示空病例区域
|
|
|
|
|
|
+const validateIdCardPass = (rule: any, value: any, callback: any) => {
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('请输入身份证号码'))
|
|
|
+ } else {
|
|
|
+ if (value.length === 15 || value.length === 18) {
|
|
|
+ if (!userFormRef.value) return
|
|
|
+ if (validateIDCardStrict(value)) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('身份证号码不合法'))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback(new Error('身份证号码长度应为 15 或者 18位'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const rules = reactive({
|
|
|
name: [
|
|
|
{ required: true, message: '请输入患者姓名', trigger: 'blur' },
|
|
@@ -126,10 +144,7 @@ const rules = reactive({
|
|
|
],
|
|
|
sex: [{ required: true, message: '请选择性别', trigger: 'blue' }],
|
|
|
code: [{ required: true, message: '请输入系统登录账号', trigger: 'blur' }],
|
|
|
- cardNo: [
|
|
|
- { required: true, message: '请输入身份证号码', trigger: 'blur' },
|
|
|
- { min: 10, max: 50, message: '长度应为 15 到 18', trigger: 'blur' }
|
|
|
- ],
|
|
|
+ cardNo: [{ required: true, validator: validateIdCardPass, trigger: 'blur' }],
|
|
|
phone: [
|
|
|
{ required: true, message: '请输入系统登录账号(手机号)', trigger: 'blur' },
|
|
|
{
|
|
@@ -204,6 +219,11 @@ const handleAutoCompleteChange = (val: string) => {
|
|
|
instance?.proxy?.$Bus.emit('case-info-log', {
|
|
|
show: false
|
|
|
})
|
|
|
+ } else {
|
|
|
+ let tempSex = getGenderFromIDCard(val)
|
|
|
+ if (tempSex) {
|
|
|
+ userForm.sex = tempSex
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|