Commit ef570214 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

записи реестра - добавлена проверка прав на фильтры

parent f9ef354b
...@@ -262,7 +262,7 @@ const registryTable = { ...@@ -262,7 +262,7 @@ const registryTable = {
openDocument: function(dataRow, updateData = false) { openDocument: function(dataRow, updateData = false) {
Cons.setAppStore({dataRow: dataRow}); Cons.setAppStore({dataRow: dataRow});
if(this.allRights.indexOf('rr_read') !== -1) { if(this.allRights.includes('rr_read') || this.allRights.includes('rr_edit')) {
if(updateData) { if(updateData) {
openFormPlayer(dataRow.dataUUID, null, () => { openFormPlayer(dataRow.dataUUID, null, () => {
this.createBody(); this.createBody();
...@@ -370,18 +370,26 @@ const registryTable = { ...@@ -370,18 +370,26 @@ const registryTable = {
}, },
createBody: function() { createBody: function() {
rest.synergyGet(this.getUrl(), data => { try {
this.tBody.empty(); this.updateRigths();
if(data.errorCode && data.errorCode != 0) { if(!this.allRights.includes("rr_list")) throw new Error(`Нет прав на просмотр данного реестра`);
Paginator.rows = 0;
} else { rest.synergyGet(this.getUrl(), data => {
data.result.forEach(item => this.tBody.append(this.createRow(item))); this.tBody.empty();
Paginator.rows = data.recordsCount; if(data.errorCode && data.errorCode != 0) {
} Paginator.rows = 0;
this.calcSum(); } else {
Paginator.update(); data.result.forEach(item => this.tBody.append(this.createRow(item)));
tableContainer.scrollTop(0); Paginator.rows = data.recordsCount;
}); }
this.calcSum();
Paginator.update();
tableContainer.scrollTop(0);
});
} catch (err) {
console.log('ERROR registryList createBody', err);
showMessage(err.message, 'error');
}
}, },
resetHeaderLabel: function(){ resetHeaderLabel: function(){
...@@ -553,39 +561,66 @@ const registryTable = { ...@@ -553,39 +561,66 @@ const registryTable = {
} }
}, },
updateRigths: function(){
if(this.filterCode) {
const selectFilter = this.registryFilters.find(x => x.code == this.filterCode);
if(selectFilter) {
this.allRights = [...selectFilter.rights];
} else {
this.allRights = [];
}
} else {
this.allRights = [...this.registryRights];
}
},
init: async function(params){ init: async function(params){
this.reset(); try {
const registryList = await getRegistryList(); this.reset();
const info = await appAPI.getRegistryInfo(params.registryCode); const registryList = await getRegistryList();
const info = await appAPI.getRegistryInfo(params.registryCode);
this.registryInfo = info;
this.heads = info.columns.filter(item => item.visible != '0') if(!info || (info.hasOwnProperty('rights') && info.rights == "no")) throw new Error(`Нет прав на просмотр данного реестра`);
.sort((a, b) => {
if (a.order == 0) return 0;
return a.order - b.order;
})
.map(item => {
return {label: item.label, columnID: item.columnID}
});
this.registryID = info.registryID; this.registryInfo = info;
this.registryName = info.name; this.heads = info.columns.filter(item => item.visible != '0')
this.registryCode = params.registryCode; .sort((a, b) => {
this.allRights = registryList.find(x => x.registryCode == this.registryCode).rights; if (a.order == 0) return 0;
this.formCode = info.formCode; return a.order - b.order;
})
.map(item => {
return {label: item.label, columnID: item.columnID}
});
if(params.filterCode) this.filterCode = params.filterCode; this.registryID = info.registryID;
if(params.searchString) this.searchString = params.searchString; this.registryName = info.name;
this.registryCode = params.registryCode;
this.registryRights = registryList.find(x => x.registryCode == this.registryCode).rights;
this.registryFilters = await appAPI.getRegistryFilters(this.registryCode);
this.formCode = info.formCode;
if(params.massActions) this.createMenuActions(params.massActions); if(this.registryFilters && this.registryFilters.hasOwnProperty('errorCode') && this.registryFilters.errorCode != 0) throw new Error(this.registryFilters.errorMessage);
if(params.hasOwnProperty('sum') && params.sum) { if(params.filterCode) this.filterCode = params.filterCode;
this.sum = params.sum; if(params.searchString) this.searchString = params.searchString;
fire({type: 'change_label', text: localizedText('0', '0', '0', '0')}, this.sum.resultLabel);
} if(params.massActions) this.createMenuActions(params.massActions);
this.createHeader(); if(params.hasOwnProperty('sum') && params.sum) {
Paginator.init(); this.sum = params.sum;
fire({type: 'change_label', text: localizedText('0', '0', '0', '0')}, this.sum.resultLabel);
}
this.updateRigths();
if(!this.allRights.includes("rr_list")) throw new Error(`Нет прав на просмотр данного реестра`);
this.createHeader();
Paginator.init();
} catch (err) {
Cons.hideLoader();
console.log('ERROR init registry list', err);
showMessage(err.message, 'error');
}
} }
} }
...@@ -598,13 +633,9 @@ compContainer.off() ...@@ -598,13 +633,9 @@ compContainer.off()
if(!registryTable.registryCode) return; if(!registryTable.registryCode) return;
if(Paginator.currentPage != 1) return; if(Paginator.currentPage != 1) return;
if(e.hasOwnProperty('eventParam')) { if(e.hasOwnProperty('eventParam')) {
let param = e.eventParam; const {filterCode = null, filterSearchUrl = null} = e.eventParam;
if(param.hasOwnProperty('filterCode')) { if(filterCode) registryTable.filterCode = filterCode;
registryTable.filterCode = param.filterCode; if(filterSearchUrl) registryTable.filterSearchUrl = filterSearchUrl;
}
if(e.eventParam.hasOwnProperty('filterSearchUrl')) {
registryTable.filterSearchUrl = null;
}
} }
Paginator.currentPage = 1; Paginator.currentPage = 1;
registryTable.createBody(); registryTable.createBody();
......
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