Skip to content

Commit

Permalink
Проверка ОГРН (#3215)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailprivalov authored Nov 15, 2023
1 parent 830ea68 commit ec74511
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
17 changes: 16 additions & 1 deletion l2-frontend/src/pages/EDS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ import usersPoint from '@/api/user-point';
import RadioFieldById from '@/fields/RadioFieldById.vue';
import DateFieldNav2 from '@/fields/DateFieldNav2.vue';
import EDSDirection from '@/ui-cards/EDSDirection.vue';
import { convertSubjectNameToTitle } from '@/utils';
import { convertSubjectNameToTitle, subjectNameHasOGRN } from '@/utils';
const MODES = [
{ id: 'mo', label: 'Подписи медицинской организации' },
Expand Down Expand Up @@ -515,6 +515,16 @@ export default class EDS extends Vue {
signingProcess: any;
get noOGRN() {
const cert = this.certificates.find(c => c.thumbprint === this.selectedCertificate);
if (!cert) {
return false;
}
return !subjectNameHasOGRN(null, cert.subjectName);
}
get accessToMO() {
return (this.$store.getters.user_data.groups || []).includes('ЭЦП Медицинской организации');
}
Expand Down Expand Up @@ -682,6 +692,11 @@ export default class EDS extends Vue {
}
async listSign() {
if (this.noOGRN && this.selectedSignatureMode === 'Медицинская организация') {
this.$error('Отсутствует ОГРН в сертификате');
return;
}
if (this.signingProcess.active) {
return;
}
Expand Down
17 changes: 16 additions & 1 deletion l2-frontend/src/ui-cards/EDSDocument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
v-else
class="btn btn-default"
href="#"
@click="sendToVI"
@click.prevent="sendToVI"
>
Отправить в ВИМИС
</a>
Expand Down Expand Up @@ -166,6 +166,10 @@ export default {
type: Number,
required: true,
},
noOGRN: {
type: Boolean,
required: false,
},
},
data() {
return {
Expand Down Expand Up @@ -208,6 +212,13 @@ export default {
ok() {
return this.emptySignatures.length === 0;
},
invalidMessage() {
if (!this.noOGRN || this.selectedSignatureMode !== 'Медицинская организация') {
return null;
}
return 'Отсутствует ОГРН в сертификате';
},
},
watch: {
emptyAllowedSignatures: {
Expand Down Expand Up @@ -265,6 +276,10 @@ export default {
this.$root.$emit('eds:reload-document', this.direction);
},
async addSign(fast = false) {
if (this.invalidMessage) {
this.$error(this.invalidMessage);
return;
}
if (!fast) {
try {
await this.$dialog.confirm(
Expand Down
24 changes: 21 additions & 3 deletions l2-frontend/src/ui-cards/EDSSigner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
:thumbprint="selectedCertificate"
:direction="directionPk"
:executors="executors"
:no-o-g-r-n="noOGRN"
/>

<div
Expand All @@ -84,6 +85,7 @@
<button
type="button"
class="btn btn-default btn-primary-nb"
:disabled="!!invalidMessage"
@click="addSign"
>
Подписать все вложения
Expand All @@ -92,10 +94,10 @@
</div>
</div>
<div
v-if="error"
v-if="error || invalidMessage"
class="status-error"
>
<h4><strong>{{ message }}</strong></h4>
<h4><strong>{{ message || invalidMessage }}</strong></h4>
</div>
</div>
</template>
Expand All @@ -106,7 +108,7 @@ import moment from 'moment';
import { debounce } from 'lodash/function';
import * as actions from '@/store/action-types';
import { convertSubjectNameToTitle } from '@/utils';
import { convertSubjectNameToTitle, subjectNameHasOGRN } from '@/utils';
import EDSDocument from './EDSDocument.vue';
Expand Down Expand Up @@ -178,6 +180,22 @@ export default {
return Object.keys(r);
},
noOGRN() {
const cert = this.certificates.find(c => c.thumbprint === this.selectedCertificate);
if (!cert) {
return false;
}
return !subjectNameHasOGRN(null, cert.subjectName);
},
invalidMessage() {
if (!this.noOGRN || this.selectedSignatureMode !== 'Медицинская организация') {
return null;
}
return 'Отсутствует ОГРН в сертификате';
},
},
watch: {
commonRoles: {
Expand Down
6 changes: 6 additions & 0 deletions l2-frontend/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ export const convertSubjectNameToTitle = (object: any, subjectName: string | nul
return [obj.SN, obj.G, obj.SNILS, obj.T].filter(Boolean).join(' ');
};

export const subjectNameHasOGRN = (object: any, subjectName: string | null) => {
const obj = object || convertSubjectNameToCertObject(subjectName);

return String(obj['ОГРН'] || '').length === 13;
};

export const validateEmail = (email: string) => Boolean(
String(email || '')
.toLowerCase()
Expand Down

0 comments on commit ec74511

Please sign in to comment.