Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
synergy-components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
synergy-components
Commits
43c4d481
Commit
43c4d481
authored
Apr 25, 2022
by
Irina Oleynik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
9a53e949
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
interpreter/from_form_to_table
interpreter/from_form_to_table
+78
-0
No files found.
interpreter/from_form_to_table
0 → 100644
View file @
43c4d481
/* ФУНКЦИЯ НА КАСТОМНЫЕ ЗАПРОСЫ */
function api(method, options) {
var host = 'http://127.0.0.1:8080/Synergy/rest/api/';
if (!options) options = {};
if (!options.type) options.type = 'GET';
var client = new org.apache.commons.httpclient.HttpClient();
var creds = new org.apache.commons.httpclient.UsernamePasswordCredentials(login, password);
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(org.apache.commons.httpclient.auth.AuthScope.ANY, creds);
switch (options.type) {
case 'GET':
var api = new org.apache.commons.httpclient.methods.GetMethod(host + method);
api.setRequestHeader('Content-type', 'application/json');
client.executeMethod(api);
var result = api.getResponseBodyAsString();
break;
case 'POST':
var api = new org.apache.commons.httpclient.methods.PostMethod(host + method);
api.setRequestBody(JSON.stringify(options.body));
api.setRequestHeader("Content-type", "application/json");
var result = client.executeMethod(api);
break;
default:
}
api.releaseConnection();
return options.dataType && options.dataType == 'text' ? '' + result : JSON.parse(result);
}
try {
let currentFormData = API.getFormData(dataUUID);
let contract, paymentDate, paymentSum, docID;
/* ДОСТАЕМ ДАННЫЕ ПО dataUUID, ОБРАЩАЕМСЯ К КОНКРЕТНЫМ КОМПОНЕНТАМ И СОХРАНЯЕМ В ПЕРЕМЕННЫЕ */
for(let i=0; i<currentFormData.data.length; i++){
switch (currentFormData.data[i].id) {
case 'reglink_contract':
docID = currentFormData.data[i].key;
break;
case 'date_payment_in_graph':
paymentDate = currentFormData.data[i];
break;
case 'numericinput_sum_payment_in_graph':
paymentSum = currentFormData.data[i];
}
}
/* ДОСТАЕМ DocumentID С ПОМОЩЬЮ DataUUID */
docUUID = API.getAsfDataId(docID);
/* ДОБАВЛЯЕМ СТРОКУ В ID КОМПОНЕНТА */
paymentDate.id += "-b1";
paymentSum.id += "-b1";
/* ЗАДАЕМ ПАРАМЕТРЫ ЗАПРОСА (ВКЛЮЧАЯ КОНТЕНТ) */
var params = {
"type": 'POST',
"body": {
"uuid": docUUID,
"tableId": "table_payment",
"data": [ paymentDate, paymentSum ]
}
};
/* ДЕЛАЕМ ЗАПРОС С НАШИМИ ПАРАМЕТРАМИ*/
var appendTable = api("asforms/data/append_table", params);
var result = true;
} catch (err) {
if (typeof (err) == "object") {
console.error(JSON.stringify(err));
var message = JSON.stringify(err);
} else {
console.error(err.toString());
var message = err.toString();
}
var result = false;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment