Commit 41cbd785 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

update appAPI (resolution)

parent 9fbe1b08
......@@ -563,6 +563,15 @@ this.appAPI = {
});
},
getDictionaryByCode: async function(code) {
return new Promise(async resolve => {
rest.synergyGet(`api/dictionary/get_by_code?dictionaryCode=${code}&locale=${AS.OPTIONS.locale}`, resolve, err => {
console.log(`ERROR [ getDictionaryByCode ]: ${JSON.stringify(err)}`);
resolve(null);
});
});
},
getFileDescription: async function(elementID) {
return new Promise(async resolve => {
rest.synergyGet(`api/storage/description?elementID=${elementID}&locale=${AS.OPTIONS.locale}`, resolve, err => {
......@@ -873,5 +882,47 @@ this.appAPI = {
}
});
}
},
resolution: {
get: async function(param) {
const {documentID, workID} = param;
return new Promise(async resolve => {
let url = `api/docflow/doc/get_resolution?locale=${AS.OPTIONS.locale}`;
if(!documentID && !workID) {
resolve(null);
console.log(`ERROR [ resolution get ]: не переданы параметры documentID или workID`);
}
if(documentID) url += `&documentID=${documentID}`;
if(workID) url += `&workID=${workID}`;
rest.synergyGet(url, resolve, err => {
console.log(`ERROR [ resolution get ]: ${JSON.stringify(err)}`);
resolve(null);
});
});
},
save: async function(body){
return new Promise(async resolve => {
try {
const {login, password} = Cons.creds;
const url = `../Synergy/rest/api/docflow/doc/save_resolution?locale=${AS.OPTIONS.locale}`;
const headers = new Headers();
headers.append("Authorization", "Basic " + btoa(unescape(encodeURIComponent(`${login}:${password}`))));
headers.append("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
const response = await fetch(url, {method: 'POST', headers, body});
resolve(response.json());
} catch (err) {
console.log(`ERROR [ saveResolution ]: ${err.message}`);
resolve({
errorCode: 666,
errorMessage: 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