SubjectCategory.cshtml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. @using WeOnlineApp.Authorization
  2. @using WeOnlineApp.Configuration
  3. @using WeOnlineApp.Views.Shared.Modals
  4. @using WeOnlineApp.Views.Shared.SearchForm
  5. @using WeOnlineApp.Views.Shared.Table
  6. @{
  7. ViewBag.Title = "课程类别管理";
  8. string activeMenu = PermissionNames.PagesBasicMgSubjectCategoryMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu;
  10. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  11. {
  12. new SearchItem("categoryName","类别名称"),
  13. }, "search-form", false);
  14. var table = new TableViewModel(IwbConsts.ApiAppUrl + "SubjectCategory/GetAll", activeMenu)
  15. .SetFields(new List<FieldItem>()
  16. {
  17. //new FieldItem("parentNo", "父类别"),
  18. new FieldItem("categoryName", "类别名称",align:"left"),
  19. new FieldItem("", "操作","ActionsFormatter"),
  20. })
  21. .SetPageArray(1000);
  22. }
  23. @section css{
  24. }
  25. @Html.Partial("Table/_Table", table)
  26. @section modal{
  27. <!--Main Modal-->
  28. @{
  29. var modal = new ModalViewModel("课程类别", new ModalBodyViewModel(new List<Input>()
  30. {
  31. new InputHide("id"),
  32. new Input("parentNo", "父类别").SetNotRequired().SetSelectOptions(""),
  33. new Input("categoryName", "类别名称").SetNotRequired(),
  34. new InputNumber("sort", "类别排序").SetNotRequired(),
  35. new InputTextarea("description", "类别描述").SetNotRequired(),
  36. }));
  37. }
  38. @Html.Partial("Modals/_Modal", modal)
  39. }
  40. @section scripts
  41. {
  42. <script type="text/javascript">
  43. var $table = $("#table");
  44. var actions = [], funs = [];
  45. $(function () {
  46. funs= LoadTreeTable({
  47. rootNo: null,
  48. table: "table",
  49. idField: 'id',
  50. treeShowField: 'categoryName',
  51. customDataField: ['categoryPath', 'categoryName','description','sort']
  52. }) || { none: function () { console.log("No type"); } };
  53. var btnCreate = funs['btnCreate'];
  54. funs['btnCreate'] = function (url, id) {
  55. console.log("Add", id);
  56. var row;
  57. if (typeof id === "string" && id !== "") {
  58. row = $table.bootstrapTable("getRowByUniqueId", id);
  59. }
  60. if (row) {
  61. $.iwbAjax4({
  62. url: abp.appUrl + 'SubjectCategory/GetSelectStr',
  63. success: function (res) {
  64. $("#parentNo").empty().html(res);
  65. btnCreate(url, id);
  66. }
  67. });
  68. } else {
  69. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  70. }
  71. }
  72. var btnUpdate = funs['btnUpdate'];
  73. funs['btnUpdate'] = function (url, id) {
  74. console.log("Edit", id);
  75. var row;
  76. if (typeof id === "string" && id !== "") {
  77. row = $table.bootstrapTable("getRowByUniqueId", id);
  78. }
  79. if (row) {
  80. $.iwbAjax4({
  81. url: abp.appUrl + 'SubjectCategory/GetSelectStr',
  82. success: function (res) {
  83. $("#parentNo").empty().html(res);
  84. btnUpdate(url, id);
  85. }
  86. });
  87. } else {
  88. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  89. }
  90. }
  91. });
  92. </script>
  93. <script>
  94. //操作按钮
  95. function ActionsFormatter(v, r) {
  96. r._parent = null;
  97. var str = '<div class="btn-tool">';
  98. for (var i = 0; i < actions.length; i++) {
  99. //str += '<span class="table-action" onclick="funs[' + actions[i]["type"] + '](\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
  100. str += '<span class="table-action" onclick="FunctionCall(\'' + actions[i]["type"] + '\',\'' + actions[i]["url"] + '\',\'' + r.id + '\',this)"><i class="' + actions[i]["icon"] + '"></i>' + actions[i]["name"] + ' </span>';
  101. }
  102. str += '</div>';
  103. return str;
  104. }
  105. function FunctionCall(type, url, id, that) {
  106. funs[type] ? funs[type].call(this, url, id, that) : funs["none"].call(this);
  107. }
  108. </script>
  109. <!--格式化-->
  110. <script id="formatter-script" type="text/javascript">
  111. function TypeFormatter(v) {
  112. var name = $('#hid-type option[value="' + v + '"]').text();
  113. switch (v) {
  114. case 0:
  115. return '<span class="label label-danger">' + name + '</span>';
  116. default:
  117. return '<span class="label label-info">' + name + '</span>';
  118. }
  119. }
  120. </script>
  121. }
  122. <section style="display: none">
  123. <select id="hid-type">
  124. <option value=""></option>
  125. </select>
  126. @*@Html.DropDownList("hid-type", type)*@
  127. </section>