ClassifyManage.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. function viewModel() {
  2. this.init = function () {
  3. $('#Classfy').treegrid({
  4. idField: 'ID',
  5. treeField: '名称',
  6. url: '/ClassifyManage/GetTreeGrid',
  7. method: 'GET',
  8. fit: true,
  9. toolbar: '#btn_func',
  10. singleSelect: true,
  11. border: false,
  12. rownumbers: true,
  13. columns: [[
  14. { field: '编码', title: '编码', width: 100, align: 'center' },
  15. { field: '名称', title: '名称', width: 200, align: 'center' },
  16. { field: '说明', title: '说明', width: 600, align: 'center', halign: 'center' },
  17. {
  18. field: '分值', title: '分值', width: 70, align: 'center', halign: 'center', formatter: function (val, row, index) {
  19. return (val || 0) + "分";
  20. }
  21. }
  22. ]],
  23. onSelect: function (row) {
  24. },
  25. onLoadSuccess(row, data) {
  26. }
  27. });
  28. $("#btn_add").bind("click", function () {
  29. top.ZLPMS.OpenNewWindow("新建问题分类", "/ClassifyManage/Add_Window", "800px", "450px", function () {
  30. $("#Classfy").treegrid("load")
  31. })
  32. })
  33. $("#btn_edit").bind("click", function () {
  34. var data = $("#Classfy").treegrid("getSelected");
  35. if (data == null) {
  36. top.ZLPMS.Msg("请选择一行记录!!");
  37. return
  38. }
  39. top.ZLPMS.OpenNewWindow("修改问题分类", "/ClassifyManage/Edit_Window/" + data["ID"], "800px", "450px", function () {
  40. $("#Classfy").treegrid("load")
  41. })
  42. })
  43. $("#btn_del").bind("click", function () {
  44. var data = $("#Classfy").treegrid("getSelected");
  45. if (data == null) {
  46. top.ZLPMS.Msg("请选择一行记录!!");
  47. return
  48. }
  49. top.ZLPMS.Confirm("确认删除该记录?", 3, function () {
  50. $.get("/ClassifyManage/DelClass/" + data["ID"], function (data) {
  51. if (data == 1) {
  52. top.ZLPMS.Msg("删除成功!", 1);
  53. $("#Classfy").treegrid("reload");
  54. }
  55. })
  56. })
  57. })
  58. $("#btn_refresh").bind("click", function () {
  59. $("#Classfy").treegrid("reload");
  60. })
  61. }
  62. this.Add_Init = function () {
  63. $('#parentid').combotree({
  64. url: '/ClassifyManage/GetClassTree',
  65. method: 'GET',
  66. editable: false,
  67. onLoadSuccess: function () {
  68. }
  69. });
  70. $("#remove").bind("click", function () {
  71. $('#parentid').combotree('clear')
  72. })
  73. $("#Add_Class").bind("click", function () {
  74. var r = $('#insert_Class').form('validate');
  75. if (r) {
  76. var param = ZLPMS.FormToObject('insert_Class');
  77. $.post("/ClassifyManage/Add_Class", param, function (data) {
  78. if (data == 1) {
  79. top.ZLPMS.Msg("添加成功!", 1);
  80. ZLPMS.CloseTopWindow(true);
  81. }
  82. else {
  83. ZLPMS.CloseTopWindow(true)
  84. top.ZLPMS.Msg("数据异常请重新填写!", 2)
  85. }
  86. });
  87. }
  88. })
  89. }
  90. this.Edit_Init = function (ID) {
  91. $('#parentid').combotree({
  92. url: '/ClassifyManage/GetClassTree',
  93. method: 'GET',
  94. editable: false,
  95. onLoadSuccess: function () {
  96. }
  97. });
  98. $("#remove").bind("click", function () {
  99. $('#parentid').combotree('clear')
  100. })
  101. $("#Edit_Class").bind('click', function () {
  102. var r = $('#insert_Class').form('validate');
  103. if (r) {
  104. var param = ZLPMS.FormToObject('insert_Class');
  105. param.ID = ID;
  106. $.post("/ClassifyManage/EditClass", param, function (data) {
  107. if (data == "1") {
  108. top.ZLPMS.Msg("修改成功!", 1);
  109. ZLPMS.CloseTopWindow(true);
  110. }
  111. else {
  112. top.ZLPMS.Msg("数据异常请重新填写!", 2)
  113. }
  114. });
  115. }
  116. })
  117. $.get("/ClassifyManage/GetProblemClassByID/" + ID, function (data) {
  118. if (data) {
  119. $("#Coding").textbox("setValue", data[0].编码)
  120. $("#name").textbox("setValue", data[0].名称)
  121. $("#parentid").combotree("setValue", data[0].上级ID || '')
  122. $("#ClassCore").numberspinner("setValue", data[0].分值)
  123. $("#Deatil").html(data[0].说明);
  124. }
  125. })
  126. }
  127. }
  128. //关闭
  129. function Close() {
  130. ZLPMS.CloseTopWindow();
  131. }