用户登录问题修改

This commit is contained in:
jiang 2024-12-15 16:44:52 +08:00
parent cb7c8ca427
commit 85477dbeb9
4 changed files with 39 additions and 8 deletions

View File

@ -97,7 +97,8 @@ export default {
{ required: true, message: '名称不能为空', trigger: 'blur' } { required: true, message: '名称不能为空', trigger: 'blur' }
], ],
idCard: [ idCard: [
{ required: true, message: '身份证号不能为空', trigger: 'blur' } { required: true, message: '身份证号不能为空', trigger: 'blur' },
{ validator: this.validateIdCard, trigger: 'blur' } //
] ]
}, },
file: null // file: null //
@ -113,6 +114,30 @@ export default {
} }
}, },
methods: { 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() { triggerFileInput() {
this.$refs.fileInput.click() // this.$refs.fileInput.click() //
}, },
@ -142,7 +167,7 @@ export default {
// //
formData.append('name', this.form.name) formData.append('name', this.form.name)
formData.append('idCard', this.form.idCard) formData.append('idCard', this.form.idCard)
formData.append('otherInfo', this.form.otherInfo) formData.append('otherInfo', this.form.otherInfo || '')
formData.append('groupCode', this.groupCode) formData.append('groupCode', this.groupCode)
// API // API

View File

@ -66,7 +66,8 @@
icon="el-icon-close" icon="el-icon-close"
size="mini" size="mini"
@click="handleClose" @click="handleClose"
>关闭</el-button> >关闭
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -76,7 +77,11 @@
<el-table-column type="index" label="序号" :index="indexMethod" width="50"/> <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="name"/>
<el-table-column label="身份证号" align="center" prop="idCard"/> <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"> <el-table-column label="人脸图片" align="center" prop="imagePath">
<template slot-scope="scope"> <template slot-scope="scope">
<img v-if="scope.row.imagePath" :src="scope.row.imagePath" alt="图片预览" <img v-if="scope.row.imagePath" :src="scope.row.imagePath" alt="图片预览"
@ -254,9 +259,9 @@ export default {
this.open = false this.open = false
}, },
handleClose() { handleClose() {
const obj = { path: "/face/faceGroups" }; const obj = { path: '/face/faceGroups' }
this.$tab.closeOpenPage(obj); this.$tab.closeOpenPage(obj)
}, }
} }
} }
</script> </script>

View File

@ -69,6 +69,7 @@ export default {
watch: { watch: {
isOpen(newVal, oldVal) { isOpen(newVal, oldVal) {
if (this.groupId && newVal) { if (this.groupId && newVal) {
this.form.groupId = this.groupId
getGroups(this.groupId).then(response => { getGroups(this.groupId).then(response => {
this.form = response.data this.form = response.data
}) })

View File

@ -109,7 +109,7 @@
@pagination="getList" @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" @dialog-cancel="handleCancel"
/> />
</div> </div>