用户登录问题修改
This commit is contained in:
parent
cb7c8ca427
commit
85477dbeb9
|
|
@ -97,7 +97,8 @@ export default {
|
|||
{ required: true, message: '名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
idCard: [
|
||||
{ required: true, message: '身份证号不能为空', trigger: 'blur' }
|
||||
{ required: true, message: '身份证号不能为空', trigger: 'blur' },
|
||||
{ validator: this.validateIdCard, trigger: 'blur' } // 添加自定义校验
|
||||
]
|
||||
},
|
||||
file: null // 用于存储选中的文件
|
||||
|
|
@ -113,6 +114,30 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
validateIdCard(rule, value, callback) {
|
||||
if (!value) {
|
||||
return callback(new Error('身份证号不能为空'))
|
||||
}
|
||||
const idCardPattern = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/
|
||||
if (!idCardPattern.test(value)) {
|
||||
return callback(new Error('身份证号格式不正确'))
|
||||
}
|
||||
// 验证最后一位校验码
|
||||
if (!this.checkIdCardCode(value)) {
|
||||
return callback(new Error('身份证校验码错误'))
|
||||
}
|
||||
callback() // 校验通过
|
||||
},
|
||||
checkIdCardCode(idCard) {
|
||||
const factors = [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']
|
||||
const idCardArray = idCard.split('')
|
||||
const sum = idCardArray
|
||||
.slice(0, 17)
|
||||
.reduce((acc, cur, idx) => acc + cur * factors[idx], 0)
|
||||
const lastChar = idCardArray[17].toUpperCase() // 最后一位可能是小写 x
|
||||
return parity[sum % 11] === lastChar
|
||||
},
|
||||
triggerFileInput() {
|
||||
this.$refs.fileInput.click() // 触发文件选择框
|
||||
},
|
||||
|
|
@ -142,7 +167,7 @@ export default {
|
|||
// 添加表单数据
|
||||
formData.append('name', this.form.name)
|
||||
formData.append('idCard', this.form.idCard)
|
||||
formData.append('otherInfo', this.form.otherInfo)
|
||||
formData.append('otherInfo', this.form.otherInfo || '')
|
||||
formData.append('groupCode', this.groupCode)
|
||||
|
||||
// 根据是否是更新操作来调用不同的 API
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@
|
|||
icon="el-icon-close"
|
||||
size="mini"
|
||||
@click="handleClose"
|
||||
>关闭</el-button>
|
||||
>关闭
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
|
@ -76,7 +77,11 @@
|
|||
<el-table-column type="index" label="序号" :index="indexMethod" width="50"/>
|
||||
<el-table-column label="名称" align="center" prop="name"/>
|
||||
<el-table-column label="身份证号" align="center" prop="idCard"/>
|
||||
<el-table-column label="其他信息" align="center" prop="otherInfo"/>
|
||||
<el-table-column label="其他信息" align="center" prop="otherInfo">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.otherInfo.replace(/^["']|["']$/g, '') }}</span>/
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="人脸图片" align="center" prop="imagePath">
|
||||
<template slot-scope="scope">
|
||||
<img v-if="scope.row.imagePath" :src="scope.row.imagePath" alt="图片预览"
|
||||
|
|
@ -254,9 +259,9 @@ export default {
|
|||
this.open = false
|
||||
},
|
||||
handleClose() {
|
||||
const obj = { path: "/face/faceGroups" };
|
||||
this.$tab.closeOpenPage(obj);
|
||||
},
|
||||
const obj = { path: '/face/faceGroups' }
|
||||
this.$tab.closeOpenPage(obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export default {
|
|||
watch: {
|
||||
isOpen(newVal, oldVal) {
|
||||
if (this.groupId && newVal) {
|
||||
this.form.groupId = this.groupId
|
||||
getGroups(this.groupId).then(response => {
|
||||
this.form = response.data
|
||||
})
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
@pagination="getList"
|
||||
/>
|
||||
<!-- 添加或修改对话框-->
|
||||
<custom-dialog :title="title" :group-id="groupId" :key="new Date().getTime()" :get-list="getList" :open="open"
|
||||
<custom-dialog :title="title" :group-id="groupId" :get-list="getList" :open="open"
|
||||
@dialog-cancel="handleCancel"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue