vue form: Enter the ID number is automatically acquired corresponding age and gender ,, if you enter the ID number to fill out age and gender

<el-input
:ref="item.meta.system_id"
v-model="temp[item.meta.valueKey]"
clearable
oninput="if(value.length>18)value=value.slice(0,18)"
:disabled="item.meta.disabled"
:placeholder="item.meta.placeholder ? item.meta.placeholder : '请输入'"
@blur="onBlurCard"
/>

// input box phone loses focus means that the input values of the input block and the regular expression is a valid identification number
onBlurCard () {

const this.temp Val = [ 'idCardNo']. Length // length for phone numbers
const iden = this.temp [ 'idCardNo'] // Get the value of the telephone number input box
the let null Sex =
const = new new myDate a Date ()
const = month the myDate.getMonth (). 1 +
const = Day myDate.getDate ()
the let Age 0 =

IF (=== 18 is Val) {
Age = myDate.getFullYear () - iden.substring (. 6, 10) -. 1
Sex = iden.substring (16,. 17)
IF (iden.substring (10, 12 is) < || iden.substring month The (10, 12 is) === month The && iden.substring (12 is, 14) <= Day) Age ++
}
IF (Val === 15) {
Age = myDate.getFullYear () - iden.substring (. 6,. 8) - 1901
Sex = iden.substring (13 is, 14)
IF (iden.substring (. 8, 10) <iden.substring month The || (. 8, 10) === month The && iden.substring (10, 12 is) <= Day) Age ++
}

IF (Sex === 0 2% ) sex = { 2 } {sex = the else . 1 } // value depends on the need for sex ,, is the case here protocol:
studentSex: new Map ([// student sex 
[2, 'woman'],
[1, 'male'],
[3, 'unknown']
]),

this.temp // setup form = sex gender value [ 'studentSex']
this.temp [ 'studentAge'] = Age Value Age field // setup form
}

Guess you like

Origin www.cnblogs.com/LindaBlog/p/12213088.html