Добавил выбор дня рождения
This commit is contained in:
		
							parent
							
								
									0d8b349015
								
							
						
					
					
						commit
						a44b2ea816
					
				
							
								
								
									
										5
									
								
								popup/src/classes/DTO/Birthday.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								popup/src/classes/DTO/Birthday.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| export class Birthday { | ||||
|   day: bigint | null = null | ||||
|   month: bigint | null = null | ||||
|   year: bigint | null = null | ||||
| } | ||||
| @ -1,7 +1,9 @@ | ||||
| import { Country } from '@/classes/Enum/Country' | ||||
| import { Gender } from '@/classes/Enum/Gender' | ||||
| import { Birthday } from '@/classes/DTO/Birthday' | ||||
| 
 | ||||
| export class Person { | ||||
|   birthday: Birthday = new Birthday() | ||||
|   country: Country = Country.ESTONIA | ||||
|   gender: Gender = Gender.RANDOM | ||||
| } | ||||
|  | ||||
| @ -1,29 +1,19 @@ | ||||
| import randomGenerator from './RandomGenerator' | ||||
| import { Country } from '../../Enum/Country' | ||||
| import { Gender } from '../../Enum/Gender' | ||||
| import { Person } from '@/classes/DTO/Person' | ||||
| 
 | ||||
| export class PersonalIdGenerator { | ||||
|   /** | ||||
|    * return e.generate = function (e, t) { | ||||
|     var | ||||
|       n = this.getYearPart(), | ||||
|       r = this.getMonthPart(), | ||||
|       i = this.getDayPart(), | ||||
|       o = this.getIdNumPart(), | ||||
|       a = this.getGenderPart(e, t), | ||||
|       l = this.getControlSum(e, n, r, i, o, a); | ||||
|     return "pl" === e ? n + r + i + o + a + l : a + n + r + i + o + l | ||||
|   }, | ||||
|    * @param country | ||||
|    * @param gender | ||||
|    * @param person | ||||
|    */ | ||||
|   generate (country: Country, gender: Gender) { | ||||
|     const year = this.getYearPart() | ||||
|     const month = this.getMonthPart() | ||||
|     const day = this.getDayPart() | ||||
|   generate (person: Person) { | ||||
|     const year = this.getYearPart(person.birthday.year) | ||||
|     const month = this.getMonthPart(person.birthday.month) | ||||
|     const day = this.getDayPart(person.birthday.day) | ||||
|     const o = this.getIdNumPart() | ||||
|     const a = this.getGenderPart(country, gender) | ||||
|     const l = this.getControlSum(country, year, month, day, o, a) | ||||
|     const a = this.getGenderPart(person.country, person.gender) | ||||
|     const l = this.getControlSum(person.country, year, month, day, o, a) | ||||
|     const l2 = this.getChecksum(a + year + month + day + o) | ||||
| 
 | ||||
|     return a + year + month + day + o + l2 | ||||
| @ -35,9 +25,13 @@ export class PersonalIdGenerator { | ||||
|     return String(Iu.generate(e - 25, e - 55)).substring(2, 4) | ||||
|   }, | ||||
|    */ | ||||
|   getYearPart () { | ||||
|     const e = (new Date()).getFullYear() | ||||
|     return String(randomGenerator.generate(e - 25, e - 55)).substring(2, 4) | ||||
|   getYearPart (year: bigint | null) { | ||||
|     if (!year) { | ||||
|       const e = (new Date()).getFullYear() | ||||
|       year = BigInt(randomGenerator.generate(e - 25, e - 55)) | ||||
|     } | ||||
| 
 | ||||
|     return String(year).substring(2, 4) | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
| @ -45,8 +39,11 @@ export class PersonalIdGenerator { | ||||
|     return Iu.generate(1, 12).toString().padStart(2, "0") | ||||
|   }, | ||||
|    */ | ||||
|   getMonthPart () { | ||||
|     return randomGenerator.generate(1, 12).toString().padStart(2, '0') | ||||
|   getMonthPart (month: bigint | null) { | ||||
|     if (!month) { | ||||
|       month = BigInt(randomGenerator.generate(1, 12)) | ||||
|     } | ||||
|     return month.toString().padStart(2, '0') | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
| @ -54,8 +51,11 @@ export class PersonalIdGenerator { | ||||
|     return Iu.generate(1, 28).toString().padStart(2, "0") | ||||
|   }, | ||||
|    */ | ||||
|   getDayPart () { | ||||
|     return randomGenerator.generate(1, 28).toString().padStart(2, '0') | ||||
|   getDayPart (day: bigint | null) { | ||||
|     if (!day) { | ||||
|       day = BigInt(randomGenerator.generate(1, 28)) | ||||
|     } | ||||
|     return day.toString().padStart(2, '0') | ||||
|   } | ||||
| 
 | ||||
|   /** | ||||
|  | ||||
| @ -18,20 +18,34 @@ export default class HelloWorld extends Vue { | ||||
|   person = new Person() | ||||
|   copyText = '' | ||||
| 
 | ||||
|   get allowedMonths () { | ||||
|     const result = [] | ||||
|     for (let i = 1; i <= 12; i++) { | ||||
|       result.push(i) | ||||
|     } | ||||
|     return result | ||||
|   } | ||||
| 
 | ||||
|   get allowedYears () { | ||||
|     const result = [] | ||||
|     const currentYear = (new Date()).getFullYear() | ||||
|     for (let i = 1960; i <= currentYear; i++) { | ||||
|       result.push(i) | ||||
|     } | ||||
|     return result | ||||
|   } | ||||
| 
 | ||||
|   copyPersonalId () { | ||||
|     console.log(JSON.stringify(this.person)) | ||||
|     const personalId = personalIdGenerator.generate(this.person.country, this.person.gender) | ||||
|     const personalId = personalIdGenerator.generate(this.person) | ||||
|     this.copy(personalId) | ||||
|   } | ||||
| 
 | ||||
|   copyIban () { | ||||
|     console.log(JSON.stringify(this.person)) | ||||
|     const iban = ibanGenerator.generate(this.person.country) | ||||
|     this.copy(iban) | ||||
|   } | ||||
| 
 | ||||
|   copyPhone () { | ||||
|     console.log(JSON.stringify(this.person)) | ||||
|     const phone = phoneGenerator.generate(this.person.country) | ||||
|     this.copy(phone) | ||||
|   } | ||||
|  | ||||
| @ -42,6 +42,11 @@ | ||||
| 
 | ||||
|           &__item { | ||||
|             flex-grow: 1; | ||||
|             margin-right: 10px; | ||||
| 
 | ||||
|             &-input { | ||||
|               width: 100%; | ||||
|             } | ||||
|           } | ||||
| 
 | ||||
|           &:last-child { | ||||
|  | ||||
| @ -10,6 +10,21 @@ | ||||
|         </div> | ||||
|         <div class="tab-page"> | ||||
|             <div class="tab-page__item" :class="{'tab-page__item_show': tab === 'person'}"> | ||||
|                 <div class="form-row"> | ||||
|                     <div class="form-row__item"> | ||||
|                         <input title="Day" class="form-row__item-input" type="text" v-model="person.birthday.day" placeholder="Day"> | ||||
|                     </div> | ||||
|                     <div class="form-row__item"> | ||||
|                         <select title="Month" v-model="person.birthday.month"> | ||||
|                             <option v-for="allowedMonth in allowedMonths" :value="allowedMonth">{{ allowedMonth }}</option> | ||||
|                         </select> | ||||
|                     </div> | ||||
|                     <div class="form-row__item"> | ||||
|                         <select title="Year" v-model="person.birthday.year"> | ||||
|                             <option v-for="allowedYear in allowedYears" :value="allowedYear">{{ allowedYear }}</option> | ||||
|                         </select> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div class="form-row"> | ||||
|                     <div class="form-row__item"> | ||||
|                         <label> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user