PageZap.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {{define "PageZap"}}
  2. <i onclick="printTable()" class="fas fa-print prnt"></i></button>
  3. <table id="ManageOrderPacient"></table>
  4. <div class="filt">
  5. <p> Выберите дату для отображения списка
  6. </p>
  7. <p>
  8. <input type="date" id="OrderListDate">
  9. </div>
  10. <script>
  11. let times = [
  12. "13:00",
  13. "13:36",
  14. "14:12",
  15. "14:48",
  16. "15:24",
  17. ];
  18. document.addEventListener("DOMContentLoaded", function() {
  19. /**
  20. *
  21. * @type {HTMLInputElement}
  22. */
  23. let OrderListDate = document.querySelector("#OrderListDate");
  24. if (OrderListDate) {
  25. OrderListDate.onchange = getOrderList;
  26. OrderListDate.value = (new Date()).toISOString().slice(0, 10);
  27. OrderListDate.dispatchEvent(new MouseEvent("change"));
  28. }
  29. });
  30. function getOrderList() {
  31. VKKOWork.XHR.POST(function (data) {
  32. /**
  33. * @type {HTMLTableElement}
  34. */
  35. var ManageOrderPacient = document.querySelector(
  36. "#ManageOrderPacient"
  37. );
  38. while (ManageOrderPacient.children.length > 0) {
  39. ManageOrderPacient.children[0].remove();
  40. }
  41. if (data != null && "Data" in data && data.Data != null) {
  42. data = data.Data;
  43. } else {
  44. VKKOWork.Messenger.Show("Данные не были получены");
  45. return;
  46. }
  47. //o."ID", o."Name", o."Passport", o."Phone", o."Cause", a."Date", a."Time"
  48. ManageOrderPacient.innerHTML =
  49. "<tr><th>Дата</th><th>Время</th><th>Причина обращения</th><th>Посетитель</th><th>Телефон</th><th>Паспорт</th></tr>";
  50. for (const order of data) {
  51. let row = document.createElement("tr");
  52. row.innerHTML =
  53. "<td>" +
  54. order.Date.slice(0, 10) +
  55. "</td><td>" +
  56. times[order.Time] +
  57. "</td><td>" +
  58. order.Cause +
  59. "</td><td>" +
  60. order.Name +
  61. "</td><td>" +
  62. order.Phone +
  63. "</td><td>" +
  64. order.Passport +
  65. "</td>";
  66. ManageOrderPacient.append(row);
  67. }
  68. ManageOrderPacient.selectedIndex = -1;
  69. }, "/order-select", {Date: this.value});
  70. }
  71. </script>
  72. {{end}}