349 lines
14 KiB
HTML
349 lines
14 KiB
HTML
{% extends "default.html" %}
|
||
{% load static %}
|
||
{% load mysettings %}
|
||
|
||
|
||
{% block header_link %}
|
||
<!-- DataTables -->
|
||
|
||
<style>
|
||
table {
|
||
table-layout: fixed;
|
||
width:100%
|
||
}
|
||
td {
|
||
word-wrap:break-word;
|
||
white-space: pre-wrap;
|
||
}
|
||
|
||
th {
|
||
word-wrap:break-word;
|
||
white-space: pre-wrap;
|
||
}
|
||
|
||
</style>
|
||
{% endblock header_link %}
|
||
|
||
|
||
|
||
{% block content %}
|
||
<section class="content-header">
|
||
<div class="container-fluid">
|
||
<div class="row mb-2">
|
||
<div class="col-sm-6">
|
||
<h4 class="mb-2">Новое наблюдение</h4>
|
||
{% if sector %}
|
||
<h5>{{ sector.name }}</h5>
|
||
{% endif %}
|
||
</div>
|
||
<div class="col-sm-6">
|
||
<ol class="breadcrumb float-sm-right">
|
||
<li class="breadcrumb-item"><a href="{% url 'geoproc:geoproc_main_with_arg' sector.id %}">Главная</a></li>
|
||
<li class="breadcrumb-item"><a href="{% url 'geoproc:monitoring_journal' sector.id %}">Журнал визуальных наблюдений {{element}}</a></li>
|
||
{% if element %}
|
||
<li class="breadcrumb-item active">{{element.name}} от {{date_time}} </li>
|
||
{% else %}
|
||
<li class="breadcrumb-item active">Новое наблюдение</li>
|
||
{% endif %}
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.container-fluid -->
|
||
</section>
|
||
|
||
<section class="content">
|
||
<form action="{% url 'geoproc:monitoring_journal_save' sector.id %}?id={{element.id}}" method="post" class="form-horizontal">
|
||
{% csrf_token %}
|
||
<input type="hidden" value="{{mt}}" name="mt">
|
||
<input type="hidden" value="{{element.id}}" name="id">
|
||
<input type="hidden" value="" name="count" id="count">
|
||
<div class="container-fluid">
|
||
<div class="row">
|
||
<!-- /.col -->
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<div class="form-group row">
|
||
<label for="id_date_time" class="col-sm-2 col-form-label">Дата наблюдения : </label>
|
||
<div class="col-sm-4">
|
||
<input type="date" name="date_time" value="{{date_time}}" {%if element %} readonly {%endif%} placeholder="Дата наблюдения" class="form-control pull-right " id="id_date_time">
|
||
</div>
|
||
</div>
|
||
{% if element %}
|
||
<div class="form-group row">
|
||
<label for="id_name" class="col-sm-2 col-form-label">Наименование : </label>
|
||
<div class="col-sm-4">
|
||
<input type="text" name="name" value="{{element.name}}" readonly placeholder="Наименование" class="form-control pull-right " id="id_name">
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
|
||
</div><!-- /.card-body -->
|
||
<div class="card-footer">
|
||
{% if not user.profile.isredonly %}
|
||
<a id="btnok" onclick="addRow()" class="btn bg-gradient-primary">Добавить</a>
|
||
{% endif %}
|
||
</div>
|
||
</div>
|
||
<!-- /.nav-tabs-custom -->
|
||
</div>
|
||
<!-- /.col -->
|
||
</div>
|
||
<div class="row">
|
||
<!-- /.col -->
|
||
<div class="col-12">
|
||
<div class="card" style="overflow-y: auto; overflow-x: hidden; max-height: 600px; ">
|
||
<div class="card-body table-responsive p-0" >
|
||
<table id="table_row" class="table table-head-fixed table-hover text-nowrap">
|
||
<thead>
|
||
<tr>
|
||
<th style="text-align: center;vertical-align: middle;">Номер участка, наименование выработки</th>
|
||
<th style="text-align: center;vertical-align: middle;">Результаты визуальных наблюдений</th>
|
||
<th style="text-align: center;vertical-align: middle;">Распоряжение главного инженера</th>
|
||
<th style="text-align: center;vertical-align: middle;">Отметка об ознакомлении начальника участка</th>
|
||
<th style="text-align: center;vertical-align: middle;">Отметка об ознакомлении главного инженера</th>
|
||
<!--<th>Эскиз</th>-->
|
||
</tr>
|
||
</thead>
|
||
<tbody id="tbody_journal">
|
||
{% for str_journal in journal_tables %}
|
||
<tr id="idtre_{{str_journal.nom}}">
|
||
<td id="idtde1_{{str_journal.nom}}"><textarea id="tname_{{str_journal.nom}}" name="tname_{{str_journal.nom}}" class="form-control pull-right" >{{str_journal.name}}</textarea></td>
|
||
<td id="idtde2_{{str_journal.nom}}"><textarea id="tresult_{{str_journal.nom}}" name="tresult_{{str_journal.nom}}" class="form-control pull-right" >{{str_journal.result}}</textarea></td>
|
||
<td id="idtde3_{{str_journal.nom}}"><textarea id="tteh_dir_{{str_journal.nom}}" name="tteh_dir_{{str_journal.nom}}" class="form-control pull-right" >{{str_journal.teh_dir}}</textarea></td>
|
||
<td id="idtde4_{{str_journal.nom}}" style="text-align: center;vertical-align: middle;"><input id="tsign1_{{str_journal.nom}}" type="checkbox" {% if str_journal.sign1 %} checked {% endif %} name="tsign1_{{str_journal.nom}}"></td>
|
||
<td id="idtde5_{{str_journal.nom}}" style="text-align: center;vertical-align: middle;"><input id="tsign2_{{str_journal.nom}}" type="checkbox" {% if str_journal.sign2 %} checked {% endif %} name="tsign2_{{str_journal.nom}}"></td>
|
||
</tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div><!-- /.card-body -->
|
||
<div class="card-footer">
|
||
<div class="btn-group">
|
||
{% if not user.profile.isredonly %}
|
||
<button id="btnok" type="submit" class="btn bg-gradient-primary ">Сохранить</button>
|
||
{% endif %}
|
||
</div>
|
||
<div class="btn-group">
|
||
<a href="{% url 'geoproc:monitoring_journal' sector.id %}" type="button" class="btn btn-default ">Отмена</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- /.nav-tabs-custom -->
|
||
</div>
|
||
<!-- /.col -->
|
||
</div>
|
||
<!-- /.row -->
|
||
</div><!-- /.container-fluid -->
|
||
</form>
|
||
</section>
|
||
{% endblock %}
|
||
{% block script_footer %}
|
||
<!-- table-to-json -->
|
||
<script src="{% static 'js/table-to-json/jquery.tabletojson.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||
|
||
<script>
|
||
{% if element %}
|
||
var sectionin={{element.count}}
|
||
{% else %}
|
||
var sectionin=0
|
||
{% endif %}
|
||
$('#count').val(sectionin)
|
||
$(function () {
|
||
//Date range picker with time picker
|
||
//https://ru.stackoverflow.com/questions/159303/%D0%97%D0%B0%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C-%D0%B2%D1%81%D0%B5-%D1%81%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B8%D0%BC%D0%BE%D0%B5-html-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%8B-%D0%B2-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%83-mysql
|
||
$('.datepick').daterangepicker({
|
||
showDropdowns: true,
|
||
timePicker: true,
|
||
timePickerIncrement: 5,
|
||
timePicker24Hour: true,
|
||
drops: "auto",
|
||
singleDatePicker: true,
|
||
timePicker: false,
|
||
lang: 'ru',
|
||
locale: {
|
||
format: 'DD.MM.YYYY',
|
||
separator: " - ",
|
||
applyLabel: "ОК",
|
||
cancelLabel: "Отмена",
|
||
fromLabel: "От",
|
||
toLabel: "До",
|
||
customRangeLabel: "Выбор",
|
||
|
||
daysOfWeek: [
|
||
"Вс",
|
||
"Пн",
|
||
"Вт",
|
||
"Ср",
|
||
"Чт",
|
||
"Пт",
|
||
"Сб"
|
||
],
|
||
monthNames: [
|
||
"Январь",
|
||
"Февраль",
|
||
"Март",
|
||
"Апрель",
|
||
"Май",
|
||
"Июнь",
|
||
"Июль",
|
||
"Август",
|
||
"Сентябрь",
|
||
"Октябрь",
|
||
"Ноябрь",
|
||
"Декабрь"
|
||
],
|
||
firstDay: 1
|
||
}
|
||
})
|
||
|
||
})
|
||
|
||
|
||
|
||
|
||
|
||
function newGuid() {
|
||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
||
function(c) {
|
||
var r = Math.random() * 16 | 0,
|
||
v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||
return v.toString(16);
|
||
}).toUpperCase();
|
||
}
|
||
|
||
function addRow() {
|
||
sectionin = sectionin+1
|
||
newid = newGuid()
|
||
$('#tbody_journal').append(
|
||
$('<tr>', {
|
||
'id': 'idtre_'+sectionin,
|
||
}))
|
||
|
||
$('#idtre_'+sectionin).append(
|
||
$('<td>', {
|
||
'id': 'idtde1_'+sectionin,
|
||
}))
|
||
|
||
$('#idtre_'+sectionin).append(
|
||
$('<td>', {
|
||
'id': 'idtde2_'+sectionin,
|
||
}))
|
||
|
||
$('#idtre_'+sectionin).append(
|
||
$('<td>', {
|
||
'id': 'idtde3_'+sectionin,
|
||
}))
|
||
$('#idtre_'+sectionin).append(
|
||
$('<td>', {
|
||
'id': 'idtde4_'+sectionin,
|
||
'style':'text-align: center;vertical-align: middle;',
|
||
}))
|
||
$('#idtre_'+sectionin).append(
|
||
$('<td>', {
|
||
'id': 'idtde5_'+sectionin,
|
||
'style':'text-align: center;vertical-align: middle;',
|
||
}))
|
||
$('#idtde1_'+sectionin).append(
|
||
$('<textarea>', {
|
||
'id': 'tname_'+sectionin,
|
||
'name': 'tname_'+sectionin,
|
||
'class':'form-control pull-right',
|
||
'value':'',
|
||
}))
|
||
|
||
$('#idtde2_'+sectionin).append(
|
||
$('<textarea>', {
|
||
'id': 'tresult_'+sectionin,
|
||
'name': 'tresult_'+sectionin,
|
||
'class':'form-control pull-right',
|
||
'value':'',
|
||
}))
|
||
$('#idtde3_'+sectionin).append(
|
||
$('<textarea>', {
|
||
'id': 'tteh_dir_'+sectionin,
|
||
'name': 'tteh_dir_'+sectionin,
|
||
'class':'form-control pull-right',
|
||
'value':'',
|
||
}))
|
||
|
||
|
||
$('#idtde4_'+sectionin).append(
|
||
$('<input>', {
|
||
'id': 'tsign1_'+sectionin,
|
||
'type': 'checkbox',
|
||
'name': 'tsign1_'+sectionin,
|
||
}))
|
||
|
||
$('#idtde5_'+sectionin).append(
|
||
$('<input>', {
|
||
'id': 'tsign2_'+sectionin,
|
||
'type': 'checkbox',
|
||
'name': 'tsign2_'+sectionin,
|
||
}))
|
||
|
||
$('#tname_' + sectionin).focus();
|
||
$('#count').val(sectionin)
|
||
|
||
}
|
||
|
||
|
||
|
||
function save_form() {
|
||
var myRows = [];
|
||
var $headers = $("th");
|
||
var $rows = $("tbody tr").each(function(index) {
|
||
$cells = $(this).find("td");
|
||
myRows[index] = {};
|
||
$cells.each(function(cellIndex) {
|
||
myRows[index][$($headers[cellIndex]).html()] = $(this).html();
|
||
console.log($(this))
|
||
});
|
||
});
|
||
|
||
// Let's put this in the object like you want and convert to JSON (Note: jQuery will also do this for you on the Ajax request)
|
||
var myObj = {};
|
||
myObj.myrows = myRows;
|
||
//alert(JSON.stringify(myObj));
|
||
// var table = $('#table_row').tableToJSON();
|
||
|
||
|
||
let result = [];
|
||
let table = document.getElementById("table_row").getElementsByTagName("tbody")[0];
|
||
let trs = table.getElementsByTagName("tr");
|
||
for (let i = 2; i < trs.length; i++) {
|
||
let tds = trs[i].getElementsByTagName("td");
|
||
let obj = {};
|
||
obj.name = tds[0].innerHTML;
|
||
obj.rank = tds[1].innerHTML;
|
||
obj.phone = tds[2].innerHTML;
|
||
result.push(obj);
|
||
}
|
||
table = result
|
||
|
||
|
||
$.ajax({
|
||
type: 'POST', // метод отправки
|
||
url: '{% url 'geoproc:monitoring_journal_save' sector.id %}?id={{element.id}}',
|
||
data: {
|
||
"data_table": JSON.stringify(myObj),
|
||
"element":'{{element.id}}'
|
||
},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
window.location.href ='{% url 'geoproc:monitoring_journal' sector.id %}';
|
||
},
|
||
error: function (dataerr) {
|
||
$("#reportPanelBody").html(dataerr); // при успешном получении ответа от сервера, заносим полученные данные в элемент с классом answer
|
||
},
|
||
timeout: 60000 // sets timeout to 3 seconds
|
||
});
|
||
|
||
|
||
}
|
||
|
||
</script>
|
||
|
||
{% endblock script_footer %}
|
||
|