fix:出生日期不能选择未来
Showing
4 changed files
with
15 additions
and
9 deletions
| ... | @@ -46,7 +46,7 @@ | ... | @@ -46,7 +46,7 @@ |
| 46 | </el-form-item> | 46 | </el-form-item> |
| 47 | </el-col> | 47 | </el-col> |
| 48 | <el-col :lg="12"> | 48 | <el-col :lg="12"> |
| 49 | <el-form-item :label="language==0?'出生日期1':'Date of Birth'" prop="birth" required> | 49 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" prop="birth" required> |
| 50 | <el-date-picker | 50 | <el-date-picker |
| 51 | v-model="form.birth" :disabled="editgay&&form.labelArr.indexOf('0')>-1" | 51 | v-model="form.birth" :disabled="editgay&&form.labelArr.indexOf('0')>-1" |
| 52 | style="width: 100%;" | 52 | style="width: 100%;" |
| ... | @@ -250,9 +250,8 @@ function reset(){ | ... | @@ -250,9 +250,8 @@ function reset(){ |
| 250 | }) | 250 | }) |
| 251 | } | 251 | } |
| 252 | } | 252 | } |
| 253 | function disabledBirth(date) { | 253 | function disabledBirth(time) { |
| 254 | const today = dayjs().format('YYYY-MM-DD') | 254 | return time.getTime() > new Date().getTime() |
| 255 | return (date.getTime() >= dayjs(today).valueOf()) | ||
| 256 | } | 255 | } |
| 257 | function getCountryList() { | 256 | function getCountryList() { |
| 258 | match.countryList().then(res => { | 257 | match.countryList().then(res => { | ... | ... |
| ... | @@ -90,12 +90,12 @@ | ... | @@ -90,12 +90,12 @@ |
| 90 | :required="!form.wdsfMin&&form.labelArr.indexOf('0')>-1"> | 90 | :required="!form.wdsfMin&&form.labelArr.indexOf('0')>-1"> |
| 91 | <el-input v-model="form.idcCode" :disabled="editgay" @blur="giveBirthDay"/> | 91 | <el-input v-model="form.idcCode" :disabled="editgay" @blur="giveBirthDay"/> |
| 92 | </el-form-item> | 92 | </el-form-item> |
| 93 | <el-form-item :label="language==0?'2出生日期':'Date of Birth'" prop="birth" | 93 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" prop="birth" |
| 94 | :required="!form.wdsfMin&&form.labelArr.indexOf('0')>-1" | 94 | :required="!form.wdsfMin&&form.labelArr.indexOf('0')>-1" |
| 95 | :disabled-date="disabledBirth"> | 95 | > |
| 96 | <el-date-picker | 96 | <el-date-picker |
| 97 | v-model="form.birth" :disabled="form.idcType=='0'" | 97 | v-model="form.birth" :disabled="form.idcType=='0'" |
| 98 | style="width: 100%;" | 98 | style="width: 100%;" :disabled-date="disabledBirth" |
| 99 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" | 99 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" |
| 100 | /> | 100 | /> |
| 101 | </el-form-item> | 101 | </el-form-item> | ... | ... |
| ... | @@ -60,7 +60,7 @@ | ... | @@ -60,7 +60,7 @@ |
| 60 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" prop="birth"> | 60 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" prop="birth"> |
| 61 | <el-date-picker | 61 | <el-date-picker |
| 62 | v-model="form.birth" :disabled="form.idcType=='0'" | 62 | v-model="form.birth" :disabled="form.idcType=='0'" |
| 63 | style="width: 100%;" | 63 | style="width: 100%;" :disabled-date="disabledBirth" |
| 64 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" | 64 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" |
| 65 | /> | 65 | /> |
| 66 | </el-form-item> | 66 | </el-form-item> |
| ... | @@ -390,6 +390,9 @@ function submitForm() { | ... | @@ -390,6 +390,9 @@ function submitForm() { |
| 390 | function cancel() { | 390 | function cancel() { |
| 391 | show.value = false | 391 | show.value = false |
| 392 | } | 392 | } |
| 393 | function disabledBirth(time) { | ||
| 394 | return time.getTime() > new Date().getTime() | ||
| 395 | } | ||
| 393 | </script> | 396 | </script> |
| 394 | 397 | ||
| 395 | <style lang="scss"> | 398 | <style lang="scss"> | ... | ... |
| ... | @@ -76,7 +76,7 @@ | ... | @@ -76,7 +76,7 @@ |
| 76 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" required> | 76 | <el-form-item :label="language==0?'出生日期':'Date of Birth'" required> |
| 77 | <el-date-picker | 77 | <el-date-picker |
| 78 | v-model="form.birth" | 78 | v-model="form.birth" |
| 79 | style="width: 100%;" | 79 | style="width: 100%;" :disabled-date="disabledBirth" |
| 80 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" | 80 | type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" |
| 81 | /> | 81 | /> |
| 82 | </el-form-item> | 82 | </el-form-item> |
| ... | @@ -359,6 +359,10 @@ function codeSuccess(msg) { | ... | @@ -359,6 +359,10 @@ function codeSuccess(msg) { |
| 359 | } | 359 | } |
| 360 | }) | 360 | }) |
| 361 | } | 361 | } |
| 362 | |||
| 363 | function disabledBirth(time) { | ||
| 364 | return time.getTime() > new Date().getTime() | ||
| 365 | } | ||
| 362 | </script> | 366 | </script> |
| 363 | 367 | ||
| 364 | <style lang="scss"> | 368 | <style lang="scss"> | ... | ... |
-
Please register or sign in to post a comment