294 lines
9.8 KiB
HTML
294 lines
9.8 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>ТАБЛИЦА</h4>
|
||
<h6>Горно-технических показателей к календарному развитию горных работ</h6>
|
||
</div>
|
||
<div class="col-sm-6">
|
||
<ol class="breadcrumb float-sm-right">
|
||
<li class="breadcrumb-item"><a href="/">Главная</a></li>
|
||
<li class="breadcrumb-item"><a href="/ogr/">Таблицы горно-технических показателей</a></li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.container-fluid -->
|
||
</section>
|
||
|
||
<section class="content">
|
||
<form action="/ogr/add/" 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-6">
|
||
<div class="card">
|
||
<div class="card-header p-2">
|
||
</div><!-- /.card-header -->
|
||
<div class="card-body">
|
||
<div class="form-group row">
|
||
<label for="id_year" class="col-sm-1 col-form-label">на : </label>
|
||
<div class="col-sm-2">
|
||
<input type="number" name="year" value="{{year}}" min="{{year_old}}" placeholder="Год" class="form-control pull-right " id="id_year">
|
||
</div>
|
||
</div>
|
||
</div><!-- /.card-body -->
|
||
<div class="card-footer">
|
||
<div class="btn-group">
|
||
<button id="btnok" type="submit" class="btn bg-gradient-primary ">Сохранить</button>
|
||
</div>
|
||
<div class="btn-group">
|
||
<a href="/ogr/" type="button" class="btn btn-default ">Отмена</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- /.nav-tabs-custom -->
|
||
</div>
|
||
<!-- /.col -->
|
||
</div>
|
||
</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: '/geoproc/monitoring/journal/save/?id={{element.id}}',
|
||
data: {
|
||
"data_table": JSON.stringify(myObj),
|
||
"element":'{{element.id}}'
|
||
},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
window.location.href ='/geoproc/monitoring/journal/';
|
||
},
|
||
error: function (dataerr) {
|
||
$("#reportPanelBody").html(dataerr); // при успешном получении ответа от сервера, заносим полученные данные в элемент с классом answer
|
||
|
||
},
|
||
timeout: 60000 // sets timeout to 3 seconds
|
||
});
|
||
|
||
|
||
}
|
||
|
||
</script>
|
||
|
||
{% endblock script_footer %}
|
||
|