View.cshtml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 = 185;
  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. $.ajaxSetup({
  30. cache: false
  31. });
  32. });
  33. $(window).resize(function () {
  34. clearTimeout(window.resizedFinished);
  35. window.resizedFinished = setTimeout(function () {
  36. setGridScrollHeight();
  37. }, 250);
  38. });
  39. function calculateGridScrollHeight() {
  40. var windowHeight = $(window).height();
  41. var gridHeaderHeight = $("#devGridViewDeviation_DXHeadersRow0").height();
  42. var gridFooterHeight = $("#devGridViewDeviation_DXFooterRow").height();
  43. return windowHeight - gridHeaderHeight - gridFooterHeight - gridScrollOffset;
  44. }
  45. function setGridScrollHeight() {
  46. gridScrollHeight = calculateGridScrollHeight();
  47. devGridViewDeviation.PerformCallback();
  48. }
  49. function onToolbarItemClick(s, e) {
  50. if (!s || !e) return;
  51. if (e.item.name == "Print") {
  52. parent.$(".printPopupContainer").remove();
  53. $.ajax({
  54. type: "POST",
  55. url: '@Url.Action("ExportPartialDeviations", "Deviation")',
  56. data: { customFilters: JSON.stringify(customFilters), displayMode: "popup", exportFormat: "" },
  57. success: function (response) {
  58. parent.$("body").append(response);
  59. parent.exportFormat = "pdf";
  60. }
  61. });
  62. } else if (e.item.name == "ToggleColumnChooser") {
  63. if (devGridViewDeviation.IsCustomizationWindowVisible())
  64. devGridViewDeviation.HideCustomizationWindow();
  65. else
  66. devGridViewDeviation.ShowCustomizationWindow();
  67. } else if (e.item.name == "ResetSettings") {
  68. $.ajax({
  69. type: "POST",
  70. url: '@Url.Action("DeleteCookiesSessionVariablesAndUserConfigs", "Global")',
  71. data: {
  72. cookies: ["deviationGridStateCookie"],
  73. sessionVariables: ["DeviationGridState", "DeviationGridViewState"],
  74. userConfigItemNames: ["DeviationGridLayoutState"]
  75. },
  76. success: function (response) {
  77. if (response == "success") {
  78. window.location = window.location;
  79. }
  80. }
  81. });
  82. }
  83. }
  84. function editDeviation(id) {
  85. if (!id) return;
  86. $.ajax({
  87. url: '@Url.Action("EditDeviation", "Deviation")',
  88. data: { Id: id },
  89. success: function (response) {
  90. setTimeout(function () {
  91. $(".deviationEditContainer").remove();
  92. $("body").append(response);
  93. }, 200);
  94. },
  95. error: function () {
  96. alert("error occured");
  97. }
  98. });
  99. }
  100. function confirmDelete(id) {
  101. if (!id) return;
  102. deleteId = id;
  103. $.ajax({
  104. type: "GET",
  105. url: '@Url.Action("GetDeviation", "Deviation")',
  106. data: { Id: id },
  107. success: function (response) {
  108. if (response == "notFound") return;
  109. var deviation = JSON.parse(response);
  110. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  111. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{deviation}", deviation.CustomNumber));
  112. $(".dialogText").text($(".dialogText").text().replace("{deviation}", deviation.CustomNumber));
  113. popupControl.Show();
  114. }
  115. });
  116. }
  117. function deleteDeviation() {
  118. $.ajax({
  119. type: "POST",
  120. url: '@Url.Action("DeleteDeviation", "Deviation")',
  121. data: { Id: deleteId },
  122. success: function (response) {
  123. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteDeviation);
  124. popupControl.Hide();
  125. setTimeout(function () {
  126. devGridViewDeviation.PerformCallback();
  127. }, 200);
  128. },
  129. error: function () {
  130. alert("error occured");
  131. }
  132. });
  133. }
  134. </script>
  135. @Html.Partial("~/Views/Deviations/_DeviationGridPartial.cshtml", Model)
  136. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  137. {
  138. PopupName = "devPopupControlDeleteDeviation",
  139. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie die Vertragsabweichung \"{deviation}\" löschen möchten?</div>",
  140. HeaderText = "\"{deviation}\" löschen",
  141. YesFunction = "function (s, e) { deleteDeviation(); }"
  142. })