View.cshtml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. @{
  2. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  3. }
  4. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Deviation.DeviationDataModel>
  5. <script>
  6. var deleteId;
  7. var gridScrollHeight;
  8. var gridScrollOffset = 240;
  9. var resizeFinished;
  10. var customFilters = {};
  11. var customFilterDelay = 800;
  12. var timer;
  13. var setFilterTimer = function (timeout, func) {
  14. if (timer != null) {
  15. clearTimeout(timer);
  16. timer = null;
  17. }
  18. if (timer == null) {
  19. timer = setTimeout(function () {
  20. func();
  21. }, timeout);
  22. }
  23. }
  24. $(document).ready(function () {
  25. gridScrollHeight = calculateGridScrollHeight();
  26. setTimeout(function () {
  27. devGridViewDeviation.PerformCallback();
  28. }, 500);
  29. });
  30. $(window).resize(function () {
  31. clearTimeout(window.resizedFinished);
  32. window.resizedFinished = setTimeout(function () {
  33. setGridScrollHeight();
  34. }, 250);
  35. });
  36. function calculateGridScrollHeight() {
  37. var windowHeight = $(window).height();
  38. var gridHeaderHeight = $("#devGridViewDeviation_DXHeadersRow0").height();
  39. var gridFooterHeight = $("#devGridViewDeviation_DXFooterRow").height();
  40. return windowHeight - gridHeaderHeight - gridFooterHeight - gridScrollOffset;
  41. }
  42. function setGridScrollHeight() {
  43. gridScrollHeight = calculateGridScrollHeight();
  44. devGridViewDeviation.PerformCallback();
  45. }
  46. function onToolbarItemClick(s, e) {
  47. if (!s || !e) return;
  48. if (e.item.name == "Print") {
  49. parent.$(".printPopupContainer").remove();
  50. $.ajax({
  51. type: "POST",
  52. url: '@Url.Action("ExportPartialDeviations", "Deviation")',
  53. data: { customFilters: JSON.stringify(customFilters), displayMode: "popup", exportFormat: "" },
  54. success: function (response) {
  55. parent.$("body").append(response);
  56. parent.exportFormat = "pdf";
  57. }
  58. });
  59. } else if (e.item.name == "ToggleColumnChooser") {
  60. if (devGridViewDeviation.IsCustomizationWindowVisible())
  61. devGridViewDeviation.HideCustomizationWindow();
  62. else
  63. devGridViewDeviation.ShowCustomizationWindow();
  64. }
  65. }
  66. function editDeviation(id) {
  67. if (!id) return;
  68. $.ajax({
  69. url: '@Url.Action("EditDeviation", "Deviation")',
  70. data: { Id: id },
  71. success: function (response) {
  72. setTimeout(function () {
  73. $(".deviationEditContainer").remove();
  74. $("body").append(response);
  75. }, 200);
  76. },
  77. error: function () {
  78. alert("error occured");
  79. }
  80. });
  81. }
  82. function confirmDelete(id) {
  83. if (!id) return;
  84. deleteId = id;
  85. $.ajax({
  86. type: "GET",
  87. url: '@Url.Action("GetDeviation", "Deviation")',
  88. data: { Id: id },
  89. success: function (response) {
  90. if (response == "notFound") return;
  91. var deviation = JSON.parse(response);
  92. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  93. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{deviation}", deviation.CustomNumber));
  94. $(".dialogText").text($(".dialogText").text().replace("{deviation}", deviation.CustomNumber));
  95. popupControl.Show();
  96. }
  97. });
  98. }
  99. function deleteDeviation() {
  100. $.ajax({
  101. type: "POST",
  102. url: '@Url.Action("DeleteDeviation", "Deviation")',
  103. data: { Id: deleteId },
  104. success: function (response) {
  105. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  106. popupControl.Hide();
  107. setTimeout(function () {
  108. devGridViewDeviation.PerformCallback();
  109. }, 200);
  110. },
  111. error: function () {
  112. alert("error occured");
  113. }
  114. });
  115. }
  116. </script>
  117. @Html.Partial("~/Views/Deviations/_DeviationGridPartial.cshtml", Model)
  118. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  119. {
  120. PopupName = "devPopupControlDeleteDeviation",
  121. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie die Vertragsabweichung \"{deviation}\" löschen möchten?</div>",
  122. HeaderText = "\"{deviation}\" löschen",
  123. YesFunction = "function (s, e) { deleteDeviation(); }"
  124. })