123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- body.on('change','#series',function(){requestSections(this);});
- body.on('change','#sections',function(){requestSectionContent(this);});
- body.on('change','#projecttypes',function(){showSeries(this);});
- body.on('change','#letter_tasktype',function(){changeTaskTypeLetter(this);});
- body.on('click','#delete_section',function(){requestDeleteSection();});
- body.on('click','#add_new_section',function(){showAddSectionDialog();});
- body.on('click','#write_section',function(){requestAddSection();});
- body.on('click','#getsectionlist',function(){getSectionList();});
- body.on('click','#addseriestopt',function(){addSeriesToProjecttype();});
- body.on('click','#write_project_to_twx',function(){writeProjectTWX();});
- body.on('click','#project_complete',function(){projectComplete();});
- body.on('click','#project_limit',function(){projectLimit();});
- body.on('click','#get_sections_from_twx',function(){getSectionsFromTWX(this);});
- var activeproj = $("#activeproj").val();
- // body.on('click','#add_new_series',function(){requestAddSeries();});
- var chosen_section_id = 0;
- var chosen_series = '';
- var chosen_projecttype = -1;
- $(function() {
- if (page != 'projects')
- GetSeries();
- if (page == 'project_types')
- showSeries(null);
- });
- function checkAnswerTWX()
- {
- var text = $("#result").html();
- var yes = text.includes("error");
- if (!yes)
- Reload();
- }
- function getSectionsFromTWX(button) {
- // alert("activeproj "+activeproj);
- var dict = new Object(); //or Map()
- dict['get_sections_from_twx'] = activeproj;
- sendAjax('result', dict, checkAnswerTWX, 'loco_response.php');
- }
- function changeTaskTypeLetter(select) {
- var letter = select.options[select.selectedIndex].value;
- var dict = new Object(); //or Map()
- var activett = $("#active_task_type").val();
- dict['letter'] = letter;
- dict['letter_tasktype'] = activett;
- sendAjax('result', dict, Reload, 'loco_response.php');
- }
- function projectLimit()
- {
- var current = $("#project_limit").val();
- var activeproj = $("#activeproj").val();
- if (current == 'Все')
- $("#project_limit").val('20');
- else
- $("#project_limit").val('Все');
- SelectProject(activeproj);
- // window.location.reload();
- }
- function projectComplete()
- {
- var dict = new Object(); //or Map()
- var activeproj = $("#activeproj").val();
- dict['project_complete'] = activeproj;
- dict['userId'] = $("#userId").val();
- sendAjax('result', dict, Reload, 'loco_response.php');
- }
- function writeProjectTWX()
- {
- var activeproj = $("#activeproj").val();
- msgWindow=window.open("writeproject.php?id="+activeproj,"displayWindow",'width=750,height=600,screenX=100,resizable=yes,scrollbars=yes');
- // var dict = new Object(); //or Map()
- //
- // dict['write_project_to_twx'] = activeproj;
- // sendAjax('result', dict, null, 'loco_response.php');
- }
- function addSeriesToProjecttype()
- {
- var activept = $("#activeptid").val();
- var select = $("#loco_type")[0];
- series = select.options[select.selectedIndex].value;
- var dict = new Object(); //or Map()
- dict['pt_addseries'] = activept;
- dict['series'] = series;
- sendAjax('result', dict, Reload, 'loco_response.php');
- }
- function showSeries(select) {
- var series = $("#activeptid").val();
- if (select != null) {
- series = select.options[select.selectedIndex].value;
- }
- chosen_projecttype = series;
- var dict = new Object(); //or Map()
- dict['showseries'] = series;
- sendAjax('chooseseries', dict, null, 'loco_response.php');
- GetSeries();
- }
- function getSectionList() {
- var dict = new Object(); //or Map()
- dict['getsectionlist'] = 1;
- sendAjax('result', dict, null, 'loco_response.php');
- }
- function showAddSectionDialog() {
- $("#section_content").html('');
- $("#add_section_container").css("display", "inline-block");
- }
- function requestAddSection() {
- var number = $("#number").val();
- var subnumber = $("#subnumber").val();
- var section_letter = $("#section_letter").val();
- $("#section_content").html('');
- var dict = new Object(); //or Map()
- dict['addsections'] = chosen_series;
- dict['number'] = number;
- dict['subnumber'] = subnumber;
- dict['section_letter'] = section_letter;
- sendAjax('result', dict, null, 'loco_response.php');
- GetSeries();
- var seriesSelect = $("#series")[0];
- requestSections(seriesSelect);
- // alert("chosen_series "+chosen_series);
- }
- function requestDeleteSection() {
- if (chosen_section_id > 0) {
- var dict = new Object(); //or Map()
- dict['delsection'] = chosen_section_id;
- sendAjax('result', dict, DeleteSection, 'loco_response.php');
- return true;
- }
- return false;
- }
- function DeleteSection() {
- var seriesSelect = $("#series")[0];
- requestSections(seriesSelect);
- $("#section_content").html('');
- GetSeries();
- return true;
- }
- function GetSeries() {
- var dict = new Object(); //or Map()
- dict[ 'getseries' ] = -1;//chosen_projecttype;
- sendAjax('', dict, ReceiveSeries, 'loco_response.php');
- return true;
- }
- function ReceiveSeries(data) {
- // $("#result").html(data);
- // alert("page "+page);
- data = JSON.parse(data);
- var htm = "<option value='0'><Выберите серию локомотива></option>";
- Object.keys(data).forEach(function(id, i, arr) {
- var serie = data[id][0];
- var uuids = data[id][1];
- var all = data[id][2];
- var numproj = data[id][3];
- if (page == 'project_types' || page == 'projects')
- htm += "<option value='"+serie+"'>"+serie+"</option>";
- else
- htm += "<option value='"+serie+"'>"+serie+" [Секций из АСУ СГ: "+uuids+", всего секций: "+all+", проектов: "+numproj+"]</option>";
- });
- $("#series").html(htm);
- if (chosen_series != '')
- $('#series option[value="'+chosen_series+'"]').prop('selected', true);
- // $('#series option:contains("'+chosen_series+'")').prop('selected', true);
- if (page == 'projects'){
- $("#sections_load").css("display", "none");
- $("#add_new_section").css("display", "none");
- }
- }
- function requestSections(select) {
- if (page == 'projects')
- return;
- var series = select.options[select.selectedIndex];
- if (series.value == 0)
- {
- $("#sections_container").css("display", "none");
- }
- else {
- $("#sections_container").css("display", "block");
- }
- chosen_series = series.value;
- var dict = new Object(); //or Map()
- $("#result").html('');
- dict[ 'getsections' ] = series.value;
- sendAjax('', dict, ReceiveSections, 'loco_response.php');
- return true;
- }
- function ReceiveSections(data) {
- var select = $("#series")[0];
- var series = select.options[select.selectedIndex].value;
- // if (page != 'projects')
- $("#add_new_section").val('Добавить новую секцию серии: '+series);
- // else {
- //
- // $("#sections_load").css("display", "none");
- // $("#add_new_section").css("display", "none");
- // }
- $("#chosenserie").html('Список секций серии '+series);
- data = JSON.parse(data);
- if (data.length > 0) {
- var htm = "<option value='0'><Выберите секцию></option>";
- data.forEach(function(section, i, arr) {
- var uuid = "";
- if (section.uuid != null)
- {
- uuid = ' [АСУ СГ]';
- }
- htm += "<option value='"+section.id+"'>"+section.section_number+" "+section.section_subnumber+uuid+" Проектов: "+section.projectsAmount+" </option>";
- });
- $("#sections").html(htm);
- }
- else
- $("#sections").html("<option value='0'>--Нет секций--</option>");
- }
- function requestSectionContent(select) {
- if (page != 'projects') {
- var section = select.options[select.selectedIndex];
- $("#add_section_container").css("display", "none");
- if (section.value == 0) {
- $("#section_container").css("display", "none");
- }
- else
- $("#section_container").css("display", "block");
- var dict = new Object(); //or Map()
- dict['getsectioncontent'] = section.value;
- $("#result").html('');
- sendAjax('', dict, ReceiveSectionContent, 'loco_response.php');
- return true;
- }
- }
- function ReceiveSectionContent(data) {
- // $("#result").html(data);
- data = JSON.parse(data);
- var section = data[0];
- if (section.id > 0) {
- chosen_section_id = section.id;
- var DKs = data[1];
- var projects = data[2];
- $("#section_content").html(
- "<strong>["+section.id+"] "+section.section_number +" "+section.section_subnumber+"</strong><br><b>UUID:</b> "
- +section.uuid
- +"<br><b>Диагностическая карта: </b>"+section.diagnostic_map
- +"<br><b>Проекты:</b> "+projects.length
- +"<br><b>DKLen: </b>"+DKs.length
- );
- for (var i=0; i < DKs.length; i++ ) {
- $("#section_content").append("<br><b>Диагностическая карта "+(i+1)+":</b> "+DKs[i].uuid);
- }
- }
- else
- $("#section_content").html("Нет данных");
- }
|