main.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. function urlConfig(link) {
  2. var subDomain = $("#subDomain").val();
  3. return window.location.protocol + '//' + window.location.host + subDomain + link;
  4. }
  5. function proceduceRedirect() {
  6. var subDomain = $("#subDomain").val();
  7. var serviceName = $("#serviceName").val();
  8. window.location.href = subDomain + "/" + serviceName + "/Proceduces";
  9. }
  10. function approvesRedirect() {
  11. var subDomain = $("#subDomain").val();
  12. var serviceName = $("#serviceName").val();
  13. window.location.href = subDomain + "/" + serviceName + "/Approves";
  14. }
  15. function judgesRedirect() {
  16. var subDomain = $("#subDomain").val();
  17. var serviceName = $("#serviceName").val();
  18. window.location.href = subDomain + "/" + serviceName + "/Judges";
  19. }
  20. function categoryClick(categoryID) {
  21. console.log("categoryID: ", categoryID);
  22. $("#categoryID").val(categoryID);
  23. $("#page").val("1");
  24. $("#message-post").submit();
  25. }
  26. function refeshContentModel() {
  27. const myNode = document.getElementById("contentModel");
  28. while (myNode.lastElementChild) {
  29. myNode.removeChild(myNode.lastElementChild);
  30. }
  31. }
  32. function searchData() {
  33. $.ajax({
  34. type: "POST",
  35. url: urlConfig("/Message/Search"),
  36. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  37. data: {
  38. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  39. },
  40. success: function (data) {
  41. $('#informModel').html(data);
  42. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  43. $('#myInform').modal('show');
  44. },
  45. failure: function (data) {
  46. console.log(data);
  47. alert(data);
  48. },
  49. error: function (data) {
  50. console.log(data);
  51. alert(data);
  52. }
  53. });
  54. }
  55. function exportData(telcoID, companyID) {
  56. console.log("excel");
  57. $.ajax({
  58. type: "POST",
  59. url: urlConfig("/Report/Export"),
  60. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  61. data: {
  62. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  63. telcoID: telcoID,
  64. companyID: companyID,
  65. },
  66. success: function (data) {
  67. $('#contentModel').html(data);
  68. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  69. $('#myContent').modal('show');
  70. },
  71. failure: function (data) {
  72. console.log(data);
  73. alert(data);
  74. },
  75. error: function (data) {
  76. console.log(data);
  77. alert(data);
  78. }
  79. });
  80. }
  81. function exportAction() {
  82. // get all data
  83. var telcoID = $("#telcoExport").val();
  84. var companyID = $("#companyExport").val();
  85. var serviceID = $("#serviceExport").val();
  86. var startMonth = $("#fromDate").val();
  87. var endMonth = $("#toDate").val();
  88. $("#modeltelcoID").val(telcoID);
  89. $("#modelcompanyID").val(companyID);
  90. $("#modelserviceID").val(serviceID);
  91. $("#modelstartMonth").val(startMonth);
  92. $("#modelendMonth").val(endMonth);
  93. $("#report-export-action-form").submit();
  94. $('#myContent').modal('hide');
  95. }
  96. function addData(id) {
  97. console.log("id ", id);
  98. var serviceName = $("#serviceName").val();
  99. console.log("serviceName ", serviceName);
  100. $.ajax({
  101. type: "POST",
  102. url: urlConfig("/" + serviceName + "/Editing"),
  103. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  104. data: {
  105. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  106. id: id,
  107. action: 'add'
  108. },
  109. success: function (data) {
  110. $('#contentModel').html(data);
  111. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  112. $('#myContent').modal('show');
  113. },
  114. failure: function (data) {
  115. console.log(data);
  116. alert(data);
  117. },
  118. error: function (data) {
  119. console.log(data);
  120. alert(data);
  121. }
  122. });
  123. }
  124. function editData(id, action) {
  125. console.log("id ", id);
  126. var serviceName = $("#serviceName").val();
  127. console.log("serviceName ", serviceName);
  128. $.ajax({
  129. type: "POST",
  130. url: urlConfig("/" + serviceName + "/Editing"),
  131. data: {
  132. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  133. id: id,
  134. action: action
  135. },
  136. success: function (data) {
  137. $('#contentModel').html(data);
  138. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  139. $('#myContent').modal('show');
  140. },
  141. failure: function (data) {
  142. console.log(data);
  143. alert(data);
  144. },
  145. error: function (data) {
  146. console.log(data);
  147. alert(data);
  148. }
  149. });
  150. }
  151. function deleteData(id) {
  152. console.log("id ", id);
  153. var serviceName = $("#serviceName").val();
  154. $.ajax({
  155. type: "POST",
  156. url: urlConfig("/Partial/TreeConfirm"),
  157. data: {
  158. "message": "Are you sure ?",
  159. "id": id,
  160. "url": "/" + serviceName + "/DeletingAction"
  161. },
  162. success: function (data) {
  163. $('#informModel').html(data);
  164. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  165. $('#myInform').modal('show');
  166. },
  167. failure: function (data) {
  168. console.log(data);
  169. alert(data);
  170. },
  171. error: function (data) {
  172. console.log(data);
  173. alert(data);
  174. }
  175. });
  176. }
  177. function pasteData(action, sourceID, destinationID) {
  178. console.log("action ", action);
  179. console.log("sourceID ", sourceID);
  180. console.log("destinationID ", destinationID);
  181. var serviceName = $("#serviceName").val();
  182. $.ajax({
  183. type: "POST",
  184. url: urlConfig(action == "1" ? "/" + serviceName + "/MovingAction" : action == "2" ? "/" + serviceName + "/CopyingAction" : null),
  185. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  186. data: {
  187. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  188. sourceID: sourceID,
  189. destinationID: destinationID,
  190. },
  191. success: function (data) {
  192. $.ajax({
  193. type: "POST",
  194. url: "/Partial/TreeResponse",
  195. data: {
  196. "ids": data.ids,
  197. "message": data.message
  198. },
  199. success: function (data) {
  200. $('#informModel').html(data);
  201. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  202. $('#myInform').modal('show');
  203. },
  204. failure: function (data) {
  205. alert(data);
  206. },
  207. error: function (data) {
  208. alert(data);
  209. }
  210. });
  211. },
  212. failure: function (data) {
  213. console.log(data);
  214. alert(data);
  215. },
  216. error: function (data) {
  217. console.log(data);
  218. alert(data);
  219. }
  220. });
  221. }
  222. $(".clickable").on("click", function () {
  223. var id = $(this).attr("value");
  224. $(this).removeClass("none-parent-style");
  225. $(this).addClass("parent-style");
  226. //console.log("clickable " + id);
  227. $.ajax({
  228. type: "POST",
  229. url: urlConfig("/Tree/GetTreeData"),
  230. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  231. data: {
  232. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  233. id: id,
  234. },
  235. success: function (data) {
  236. //console.log(data);
  237. $('#child-items-' + id).html(data);
  238. getTableAction(id);
  239. },
  240. failure: function (data) {
  241. console.log(data);
  242. alert(data);
  243. },
  244. error: function (data) {
  245. console.log(data);
  246. alert(data);
  247. }
  248. });
  249. })
  250. //getTableAction("-1");
  251. function getTableAction(id) {
  252. //console.log("clickable " + id);
  253. $.ajax({
  254. type: "POST",
  255. url: urlConfig("/Tree/GetTableData"),
  256. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  257. data: {
  258. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  259. id: id,
  260. },
  261. success: function (data) {
  262. //console.log(data);
  263. $('#replaceable-table').html(data);
  264. },
  265. failure: function (data) {
  266. console.log(data);
  267. alert(data);
  268. },
  269. error: function (data) {
  270. console.log(data);
  271. alert(data);
  272. }
  273. });
  274. }
  275. function addAction() {
  276. //clickableOutClick();
  277. //var id = $("#itemID").val();
  278. //console.log("addAction " + id);
  279. //addData(id);
  280. clickableOutClick();
  281. var id = $("#itemID").val();
  282. console.log("editAction " + id);
  283. editData(id, "add");
  284. }
  285. function editAction() {
  286. clickableOutClick();
  287. var id = $("#itemID").val();
  288. console.log("editAction " + id);
  289. editData(id, "edit");
  290. }
  291. function deleteAction() {
  292. clickableOutClick();
  293. var id = $("#itemID").val();
  294. console.log("deleteAction " + id);
  295. deleteData(id);
  296. }
  297. function moveAction() {
  298. clickableOutClick();
  299. var id = $("#itemID").val();
  300. console.log("moveAction " + id);
  301. $("#sourceID").val(id);
  302. $("#action").val("1");
  303. $("#paste-button").removeClass("disable-click");
  304. }
  305. function pasteAction() {
  306. clickableOutClick();
  307. var id = $("#itemID").val();
  308. console.log("pasteAction " + id);
  309. var sourceID = $("#sourceID").val();
  310. var action = $("#action").val();
  311. if (sourceID != null && action != null) {
  312. $("#destinationID").val(id);
  313. $("#paste-button").addClass("disable-click");
  314. pasteData(action, sourceID, id);
  315. }
  316. }
  317. function copyAction() {
  318. clickableOutClick();
  319. var id = $("#itemID").val();
  320. console.log("copyAction " + id);
  321. $("#sourceID").val(id);
  322. $("#action").val("2");
  323. $("#paste-button").removeClass("disable-click");
  324. }