ваше сообщение коммита
This commit is contained in:
@@ -2,8 +2,6 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const db = require('../db');
|
const db = require('../db');
|
||||||
const logger = require('../utils/logger'); // Если используете логгер
|
const logger = require('../utils/logger'); // Если используете логгер
|
||||||
const fs = require('fs');
|
|
||||||
const csv = require('csv-parser');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@@ -76,47 +74,8 @@ router.get('/codes', async (req, res) => {
|
|||||||
const offset = (page - 1) * limit;
|
const offset = (page - 1) * limit;
|
||||||
const { lang } = req.query;
|
const { lang } = req.query;
|
||||||
|
|
||||||
// Если запрошен русский язык — отдаём из CSV
|
// Убираем русский вариант и всегда используем базу данных PostgreSQL
|
||||||
if (lang === 'ru') {
|
// if (lang === 'ru') { ... } - удалено
|
||||||
const { level, parent_code } = req.query;
|
|
||||||
const results = [];
|
|
||||||
fs.createReadStream(__dirname + '/../db/data/isic_titles_ru.csv')
|
|
||||||
.pipe(csv())
|
|
||||||
.on('data', (data) => {
|
|
||||||
let pass = true;
|
|
||||||
// Фильтрация по уровню (по длине кода)
|
|
||||||
if (level) {
|
|
||||||
if (level == 1 && data.code.length !== 1) pass = false;
|
|
||||||
if (level == 2 && data.code.length !== 2) pass = false;
|
|
||||||
if (level == 3 && data.code.length !== 3) pass = false;
|
|
||||||
if (level == 4 && data.code.length !== 4) pass = false;
|
|
||||||
}
|
|
||||||
// Фильтрация по parent_code
|
|
||||||
if (parent_code && pass) {
|
|
||||||
if (level == 2 && !data.code.startsWith(parent_code)) pass = false;
|
|
||||||
if (level == 3 && !data.code.startsWith(parent_code)) pass = false;
|
|
||||||
if (level == 4 && !data.code.startsWith(parent_code)) pass = false;
|
|
||||||
}
|
|
||||||
if (pass) {
|
|
||||||
results.push({
|
|
||||||
code: data.code,
|
|
||||||
description: data.title,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('end', () => {
|
|
||||||
res.json({
|
|
||||||
totalItems: results.length,
|
|
||||||
codes: results,
|
|
||||||
totalPages: 1,
|
|
||||||
currentPage: 1,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.on('error', (err) => {
|
|
||||||
res.status(500).json({ error: 'Ошибка чтения русских кодов ISIC', details: err.message });
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const baseQuerySelect = `
|
const baseQuerySelect = `
|
||||||
SELECT c.code, c.description, c.code_level, c.explanatory_note_inclusion, c.explanatory_note_exclusion,
|
SELECT c.code, c.description, c.code_level, c.explanatory_note_inclusion, c.explanatory_note_exclusion,
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ const fetchIsicCodes = async (params = {}, optionsRef, loadingRef) => {
|
|||||||
loadingRef.value = true;
|
loadingRef.value = true;
|
||||||
optionsRef.value = []; // Очищаем перед загрузкой
|
optionsRef.value = []; // Очищаем перед загрузкой
|
||||||
try {
|
try {
|
||||||
const queryParams = new URLSearchParams({ ...params, lang: 'ru' }).toString();
|
const queryParams = new URLSearchParams(params).toString();
|
||||||
console.debug(`[BlockchainSettingsView] Fetching ISIC codes with params: ${queryParams}`);
|
console.debug(`[BlockchainSettingsView] Fetching ISIC codes with params: ${queryParams}`);
|
||||||
|
|
||||||
// Убедитесь, что базовый URL настроен правильно (например, через axios interceptors или .env)
|
// Убедитесь, что базовый URL настроен правильно (например, через axios interceptors или .env)
|
||||||
@@ -464,7 +464,8 @@ const fetchIsicCodes = async (params = {}, optionsRef, loadingRef) => {
|
|||||||
// Отображаем код и описание для ясности
|
// Отображаем код и описание для ясности
|
||||||
text: `${code.code} - ${code.description}`
|
text: `${code.code} - ${code.description}`
|
||||||
}));
|
}));
|
||||||
console.debug(`[BlockchainSettingsView] Loaded ISIC codes for level ${params.level || ('parent: '+params.parent_code)}, count:`, optionsRef.value.length);
|
console.log(`[BlockchainSettingsView] Loaded ISIC codes for level ${params.level || ('parent: '+params.parent_code)}, count:`, optionsRef.value.length);
|
||||||
|
console.log('[BlockchainSettingsView] Response data:', response.data);
|
||||||
} else {
|
} else {
|
||||||
console.error('[BlockchainSettingsView] Invalid response structure for ISIC codes:', response.data);
|
console.error('[BlockchainSettingsView] Invalid response structure for ISIC codes:', response.data);
|
||||||
}
|
}
|
||||||
@@ -513,6 +514,7 @@ const updateCurrentIsicSelection = () => {
|
|||||||
|
|
||||||
// --- Наблюдатели для каскадной загрузки и обновления текущего выбора ---
|
// --- Наблюдатели для каскадной загрузки и обновления текущего выбора ---
|
||||||
watch(selectedSection, (newVal) => {
|
watch(selectedSection, (newVal) => {
|
||||||
|
console.log('[BlockchainSettingsView] selectedSection changed to:', newVal);
|
||||||
selectedDivision.value = ''; divisionOptions.value = [];
|
selectedDivision.value = ''; divisionOptions.value = [];
|
||||||
selectedGroup.value = ''; groupOptions.value = [];
|
selectedGroup.value = ''; groupOptions.value = [];
|
||||||
selectedClass.value = ''; classOptions.value = [];
|
selectedClass.value = ''; classOptions.value = [];
|
||||||
@@ -523,6 +525,7 @@ watch(selectedSection, (newVal) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedDivision, (newVal) => {
|
watch(selectedDivision, (newVal) => {
|
||||||
|
console.log('[BlockchainSettingsView] selectedDivision changed to:', newVal);
|
||||||
selectedGroup.value = ''; groupOptions.value = [];
|
selectedGroup.value = ''; groupOptions.value = [];
|
||||||
selectedClass.value = ''; classOptions.value = [];
|
selectedClass.value = ''; classOptions.value = [];
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
@@ -532,6 +535,7 @@ watch(selectedDivision, (newVal) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedGroup, (newVal) => {
|
watch(selectedGroup, (newVal) => {
|
||||||
|
console.log('[BlockchainSettingsView] selectedGroup changed to:', newVal);
|
||||||
selectedClass.value = ''; classOptions.value = [];
|
selectedClass.value = ''; classOptions.value = [];
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
fetchIsicCodes({ parent_code: newVal }, classOptions, isLoadingClasses);
|
fetchIsicCodes({ parent_code: newVal }, classOptions, isLoadingClasses);
|
||||||
|
|||||||
Reference in New Issue
Block a user