SceneCategory.cshtml 5.0 KB

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