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

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

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