Добавил выбор дня рождения

master
Sipachev Igor 4 years ago
parent 0d8b349015
commit a44b2ea816
  1. 5
      popup/src/classes/DTO/Birthday.ts
  2. 2
      popup/src/classes/DTO/Person.ts
  3. 50
      popup/src/classes/Service/Generators/PersonalIdGenerator.ts
  4. 22
      popup/src/components/script.ts
  5. 5
      popup/src/components/style.scss
  6. 15
      popup/src/components/template.html

@ -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 { Country } from '@/classes/Enum/Country'
import { Gender } from '@/classes/Enum/Gender' import { Gender } from '@/classes/Enum/Gender'
import { Birthday } from '@/classes/DTO/Birthday'
export class Person { export class Person {
birthday: Birthday = new Birthday()
country: Country = Country.ESTONIA country: Country = Country.ESTONIA
gender: Gender = Gender.RANDOM gender: Gender = Gender.RANDOM
} }

@ -1,29 +1,19 @@
import randomGenerator from './RandomGenerator' import randomGenerator from './RandomGenerator'
import { Country } from '../../Enum/Country' import { Country } from '../../Enum/Country'
import { Gender } from '../../Enum/Gender' import { Gender } from '../../Enum/Gender'
import { Person } from '@/classes/DTO/Person'
export class PersonalIdGenerator { export class PersonalIdGenerator {
/** /**
* return e.generate = function (e, t) { * @param person
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
*/ */
generate (country: Country, gender: Gender) { generate (person: Person) {
const year = this.getYearPart() const year = this.getYearPart(person.birthday.year)
const month = this.getMonthPart() const month = this.getMonthPart(person.birthday.month)
const day = this.getDayPart() const day = this.getDayPart(person.birthday.day)
const o = this.getIdNumPart() const o = this.getIdNumPart()
const a = this.getGenderPart(country, gender) const a = this.getGenderPart(person.country, person.gender)
const l = this.getControlSum(country, year, month, day, o, a) const l = this.getControlSum(person.country, year, month, day, o, a)
const l2 = this.getChecksum(a + year + month + day + o) const l2 = this.getChecksum(a + year + month + day + o)
return a + year + month + day + o + l2 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) return String(Iu.generate(e - 25, e - 55)).substring(2, 4)
}, },
*/ */
getYearPart () { getYearPart (year: bigint | null) {
const e = (new Date()).getFullYear() if (!year) {
return String(randomGenerator.generate(e - 25, e - 55)).substring(2, 4) 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") return Iu.generate(1, 12).toString().padStart(2, "0")
}, },
*/ */
getMonthPart () { getMonthPart (month: bigint | null) {
return randomGenerator.generate(1, 12).toString().padStart(2, '0') 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") return Iu.generate(1, 28).toString().padStart(2, "0")
}, },
*/ */
getDayPart () { getDayPart (day: bigint | null) {
return randomGenerator.generate(1, 28).toString().padStart(2, '0') 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() person = new Person()
copyText = '' 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 () { copyPersonalId () {
console.log(JSON.stringify(this.person)) const personalId = personalIdGenerator.generate(this.person)
const personalId = personalIdGenerator.generate(this.person.country, this.person.gender)
this.copy(personalId) this.copy(personalId)
} }
copyIban () { copyIban () {
console.log(JSON.stringify(this.person))
const iban = ibanGenerator.generate(this.person.country) const iban = ibanGenerator.generate(this.person.country)
this.copy(iban) this.copy(iban)
} }
copyPhone () { copyPhone () {
console.log(JSON.stringify(this.person))
const phone = phoneGenerator.generate(this.person.country) const phone = phoneGenerator.generate(this.person.country)
this.copy(phone) this.copy(phone)
} }

@ -42,6 +42,11 @@
&__item { &__item {
flex-grow: 1; flex-grow: 1;
margin-right: 10px;
&-input {
width: 100%;
}
} }
&:last-child { &:last-child {

@ -10,6 +10,21 @@
</div> </div>
<div class="tab-page"> <div class="tab-page">
<div class="tab-page__item" :class="{'tab-page__item_show': tab === 'person'}"> <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">
<div class="form-row__item"> <div class="form-row__item">
<label> <label>

Loading…
Cancel
Save