Commit 4f5c4ebf authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

RegistryAdvancedSearch

parent bfb1e271
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
.filter-close { .filter-close {
position: absolute; position: absolute;
top: 15px; top: 5px;
right: 20px; right: 15px;
width: 25px;
height: 25px;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
transition: 0.3s ease-out 0s; transition: 0.3s ease-out 0s;
...@@ -29,8 +27,8 @@ ...@@ -29,8 +27,8 @@
transform: rotate(90deg); transform: rotate(90deg);
} }
.filter-close:hover svg > line { .filter-close:hover svg > path {
stroke: #f0506e; stroke: #f0506e !important;
} }
.filter-content { .filter-content {
...@@ -42,7 +40,7 @@ ...@@ -42,7 +40,7 @@
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
background: #fff; background: #fff;
z-index: 1000; z-index: 101;
} }
.filter-header { .filter-header {
...@@ -70,9 +68,15 @@ ...@@ -70,9 +68,15 @@
} }
.filter-buttons { .filter-buttons {
display: flex;
justify-content: center;
margin: 20px 0; margin: 20px 0;
} }
.filter-buttons button {
border-radius: 6px;
}
.lock { .lock {
overflow: hidden; overflow: hidden;
} }
......
...@@ -315,10 +315,9 @@ const createPositionParamBlock = (param, uuidRow, guid) => { ...@@ -315,10 +315,9 @@ const createPositionParamBlock = (param, uuidRow, guid) => {
//Метод добавления параметра для поиска //Метод добавления параметра для поиска
const addParamRow = (param, guid, filterBody) => { const addParamRow = (param, guid, tableParamBody) => {
if(!param) return; if(!param) return;
const tableParamBody = filterBody.find('#rd-table-params tbody');
const uuidRow = guid || UTILS.generateGuid('R'); const uuidRow = guid || UTILS.generateGuid('R');
const tr = $('<tr>'); const tr = $('<tr>');
const tdFilter = $('<td>'); const tdFilter = $('<td>');
...@@ -477,6 +476,91 @@ this.RegistryAdvancedSearch = class { ...@@ -477,6 +476,91 @@ this.RegistryAdvancedSearch = class {
$('body').removeClass('lock'); $('body').removeClass('lock');
} }
selectParameter(value, key) {
console.log('selectParameter', {value, key, RD})
const tableParamBody = this.filterWindow.find('#rd-table-params tbody');
let param;
if(value == 'registryRecordStatus') {
param = {id: 'registryRecordStatus', type: 'registryRouteStatus', name: i18n.tr('Статус записи реестра')};
} else {
param = RD.formData.component[value];
}
addParamRow(param, key, tableParamBody);
}
initParamList() {
const paramList = this.filterWindow.find('#rd-form-param-list');
const tableParamBody = this.filterWindow.find('#rd-table-params tbody');
RD.paramSearch = {};
tableParamBody.empty();
paramList.empty().off()
.append(`<option disabled selected value="">${i18n.tr('Добавить условие')}</option>`)
.on('change', () => {
this.selectParameter(paramList.val());
paramList.val("");
});
for(let key in RD.formData.label) {
const x = RD.formData.label[key];
paramList.append(`<option value="${key}" title="${x.label}">${x.label}</option>`);
}
}
addButtonListener(){
this.btnFilter.off().on('click', e => {
const urlSearch = getUrlSearch();
e.preventDefault();
e.target.blur();
if(urlSearch) {
sessionStorage.setItem(`filterParam_${Cons.getCurrentPage().code}_${this._registryCode}`, JSON.stringify({
formData: RD.formData,
paramSearch: RD.paramSearch
}));
$(this._registryComponent).trigger({
type: 'filterRegistryRows',
eventParam: {
filterSearchUrl: urlSearch
}
});
this.closeFilterWindow();
} else {
showMessage('Не все условия поиска заполнены','error');
return;
}
});
this.btnFilterDrop.off().on('click', e => {
e.preventDefault();
e.target.blur();
RD.formData = null;
RD.paramSearch = {};
sessionStorage.removeItem(`filterParam_${Cons.getCurrentPage().code}_${this._registryCode}`);
this.update();
$(this._registryComponent).trigger({
type: 'filterRegistryRows',
eventParam: {
filterSearchUrl: null
}
});
});
this.buttonClose.on('click', e => {
e.preventDefault();
e.stopPropagation();
this.closeFilterWindow();
});
}
render(){ render(){
$('.filter-window').remove(); $('.filter-window').remove();
...@@ -487,9 +571,10 @@ this.RegistryAdvancedSearch = class { ...@@ -487,9 +571,10 @@ this.RegistryAdvancedSearch = class {
this.btnFilter = $('<button>', {id: 'btn-filter', class: 'uk-button uk-button-primary', text: i18n.tr('Фильтровать')}); this.btnFilter = $('<button>', {id: 'btn-filter', class: 'uk-button uk-button-primary', text: i18n.tr('Фильтровать')});
this.btnFilterDrop = $('<button>', {id: 'btn-filter-drop', class: 'uk-button uk-button-default uk-margin-small-left', text: i18n.tr('Сбросить')}); this.btnFilterDrop = $('<button>', {id: 'btn-filter-drop', class: 'uk-button uk-button-default uk-margin-small-left', text: i18n.tr('Сбросить')});
this.buttonClose = $('<div class="filter-close"><span uk-icon="icon: close; ratio: 2;"></span></div>');
filterContent.append( filterContent.append(
'<div class="filter-close"><span uk-icon="icon: close; ratio: 1.8"></span></div>', this.buttonClose,
`<div class="filter-header"><h4>${i18n.tr('Расширенный поиск')}</h4></div>`, `<div class="filter-header"><h4>${i18n.tr('Расширенный поиск')}</h4></div>`,
this.filterBody, filterButtons this.filterBody, filterButtons
); );
...@@ -504,7 +589,9 @@ this.RegistryAdvancedSearch = class { ...@@ -504,7 +589,9 @@ this.RegistryAdvancedSearch = class {
<label class="uk-form-label" for="rd-table-params">${i18n.tr('Условия')}:</label> <label class="uk-form-label" for="rd-table-params">${i18n.tr('Условия')}:</label>
<div class="uk-form-controls rd-table-params-container"> <div class="uk-form-controls rd-table-params-container">
<table id="rd-table-params" class="uk-table uk-table-justify uk-table-divider"></table> <table id="rd-table-params" class="uk-table uk-table-justify uk-table-divider">
<tbody></tbody>
</table>
</div> </div>
</div> </div>
`); `);
...@@ -514,6 +601,8 @@ this.RegistryAdvancedSearch = class { ...@@ -514,6 +601,8 @@ this.RegistryAdvancedSearch = class {
this.filterWindow.append(filterContent); this.filterWindow.append(filterContent);
$('body').append(this.filterWindow); $('body').append(this.filterWindow);
this.addButtonListener();
} }
async _parseFormData() { async _parseFormData() {
...@@ -532,13 +621,14 @@ this.RegistryAdvancedSearch = class { ...@@ -532,13 +621,14 @@ this.RegistryAdvancedSearch = class {
if (item.type === 'entity') item.entity = item.config.entity; if (item.type === 'entity') item.entity = item.config.entity;
formData.label[item.id] = columnsMap[item.id] ?? { label: item.id }; formData.label[item.id] = columnsMap[item.id] ?? { label: item.id };
formData.component[item.id] = item; formData.component[item.id] = {...item, name: formData.label[item.id]?.label};
}; };
for (const item of properties) { for (const item of properties) {
if (item.type === 'label') continue; if (['label', 'custom'].includes(item.type)) continue;
if (item.type === 'table' && item.config?.appendRows) continue;
if (item.type === 'table' && !item.config.appendRows) { if (item.type === 'table' && !item.config?.appendRows) {
for (const child of item.properties) { for (const child of item.properties) {
if (child.type !== 'label') await getItem(child); if (child.type !== 'label') await getItem(child);
} }
...@@ -564,7 +654,7 @@ this.RegistryAdvancedSearch = class { ...@@ -564,7 +654,7 @@ this.RegistryAdvancedSearch = class {
if (saveParam.formData && Object.keys(saveParam.formData.component || {}).length > 0) { if (saveParam.formData && Object.keys(saveParam.formData.component || {}).length > 0) {
RD.formData = saveParam.formData; RD.formData = saveParam.formData;
RD.paramSearch = saveParam.paramSearch; RD.paramSearch = saveParam.paramSearch;
for (const key in RD.paramSearch) selectParameter(RD.paramSearch[key].field, key); for (const key in RD.paramSearch) this.selectParameter(RD.paramSearch[key].field, key);
} else { } else {
sessionStorage.removeItem(key); sessionStorage.removeItem(key);
RD.formData = await this._parseFormData(); RD.formData = await this._parseFormData();
...@@ -581,12 +671,7 @@ this.RegistryAdvancedSearch = class { ...@@ -581,12 +671,7 @@ this.RegistryAdvancedSearch = class {
})); }));
} }
// initParamList(); this.initParamList();
console.log('RegistryAdvancedSearch', {
RDformData: RD.formData,
RDparamSearch: RD.paramSearch
})
} catch (err) { } catch (err) {
console.log(`[RegistryAdvancedSearch] ERROR: ${err.message}`); console.log(`[RegistryAdvancedSearch] ERROR: ${err.message}`);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment