SysFunctions.cshtml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @using WeApp
  2. @using WeApp.Authorization
  3. @using WeApp.Configuration
  4. @using WeApp.Views.Shared.Modals
  5. @using WeApp.Views.Shared.Table
  6. @{
  7. ViewBag.Title = L("FunctionTitle");
  8. string activeMenu = PermissionNames.PagesSystemMgFunctionMg; //The menu item will be active for this page.
  9. ViewBag.ActiveMenu = activeMenu; //The menu item will be active for this page.
  10. List<SelectListItem> functionType = ViewBag.FunctionType;
  11. //CurrentUserViewModel currentUser = ViewBag.CurrentUser;
  12. var table = new TableViewModel(IwbConsts.ApiAppUrl + "Functions/GetAll", activeMenu).SetFields(new List<FieldItem>()
  13. {
  14. new FieldItem("functionName", L("functionName"),align:"left"),
  15. new FieldItem("functionType", L("functionType"),"TypeFormatter"),
  16. new FieldItem("url", L("functionUrl")),
  17. new FieldItem("icon", L("functionIcon"),"IconFormatter"),
  18. new FieldItem("sort", L("functionSort")),
  19. new FieldItem("", L("Actions"),"ActionsFormatter"),
  20. }).SetPageArray(1000).SetOther(" data-row-attributes=\"RowAttributes\" ");
  21. }
  22. <style>
  23. .pagination-detail {
  24. display: none;
  25. }
  26. </style>
  27. @Html.Partial("Table/_Table", table)
  28. @section modal {
  29. @{
  30. var inputs = new List<Input>()
  31. {
  32. new InputHide("id"),
  33. new InputHide("depth"),
  34. new InputHide("permissionName"),
  35. new InputHide("functionPath"),
  36. new Input("parentNo", L("functionParent"), InputTypes.List),
  37. new Input("functionNo", L("functionNo")),
  38. new Input("functionName", L("functionName")),
  39. new InputNumber("sort", L("functionSort")).SetRange(0,1000),
  40. new Input("icon", L("functionIcon")).SetNotRequired(),
  41. };
  42. if (AbpSession.UserType == UsersAndRolesTypeDefinition.Supper)
  43. {
  44. inputs.AddRange(new List<Input>
  45. {
  46. new Input("functionType", L("functionType")).SetSelectOptions((List<SelectListItem>) ViewBag.FunctionType),
  47. new Input("controller", L("functionController")).SetNotRequired(),
  48. new Input("action", L("functionAction")).SetNotRequired(),
  49. new Input("url", L("functionUrl")).SetNotRequired(),
  50. new Input("class", L("functionClass")).SetNotRequired(),
  51. new Input("script", L("functionScript")).SetNotRequired(),
  52. });
  53. }
  54. var modal = new ModalViewModel(L("function"), new ModalBodyViewModel(inputs));
  55. @Html.Partial("Modals/_Modal", modal)
  56. }
  57. }
  58. @section scripts
  59. {
  60. <script type="text/javascript">
  61. var $table = $("#table");
  62. var actions = [], funs = [];
  63. $(function () {
  64. funs = LoadTreeTable({
  65. idField: 'functionNo',
  66. treeShowField: 'functionName',
  67. parentIdField: 'parentNo',
  68. customDataField: ['functionPath']
  69. }) ||
  70. { none: function() { console.log("No type"); } };
  71. var btnCreate = funs['btnCreate'];
  72. funs['btnCreate']= function(url,id) {
  73. console.log("Add", id);
  74. var row;
  75. if (typeof id === "string" && id !== "") {
  76. row = $table.bootstrapTable("getRowByUniqueId", id);
  77. }
  78. if (row) {
  79. $.iwbAjax4({
  80. url: "/api/services/app/Functions/GetSelectStr",
  81. success: function (res) {
  82. $("#parentNo").empty().html(res);
  83. btnCreate(url,id);
  84. //BtnCreate({
  85. // data: { parentNo: row.functionNo, depth: row.depth + 1, functionPath: row.functionPath },
  86. // url: url,
  87. // disabled: "parentNo"
  88. //});
  89. }
  90. });
  91. } else {
  92. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  93. }
  94. }
  95. var btnUpdate = funs['btnUpdate'];
  96. funs['btnUpdate']= function(url,id) {
  97. console.log("Edit", id);
  98. var row;
  99. if (typeof id === "string" && id !== "") {
  100. row = $table.bootstrapTable("getRowByUniqueId", id);
  101. }
  102. if (row) {
  103. $.iwbAjax4({
  104. url: "/api/services/app/Functions/GetSelectStr",
  105. success: function (res) {
  106. $("#parentNo").empty().html(res);
  107. btnUpdate(url,id);
  108. //BtnUpdate({
  109. // url: url,
  110. // disabled: "parentNo,functionNo"
  111. //});
  112. }
  113. });
  114. } else {
  115. abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
  116. }
  117. }
  118. });
  119. //自定义属性
  120. function RowAttributes(r) {
  121. return {
  122. "data-no": r.functionNo,
  123. "data-parent": r.parentNo
  124. };
  125. }
  126. </script>
  127. <script>
  128. function FunctionCall(type, url, id, that) {
  129. funs[type] ? funs[type].call(this, url, id, that) : funs["none"].call(this);
  130. }
  131. </script>
  132. <script>
  133. //格式化图标
  134. function IconFormatter(v) {
  135. if (v !== "") {
  136. return '<span class=" ' + v + '"></span>';
  137. }
  138. return v;
  139. }
  140. //操作按钮
  141. function ActionsFormatter(v, r) {
  142. var str = '<div class="btn-tool">';
  143. for (var i = 0; i < actions.length; i++) {
  144. //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>';
  145. 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>';
  146. }
  147. str += '</div>';
  148. return str;
  149. }
  150. // 格式化类型
  151. function TypeFormatter(v) {
  152. var functionTypeName = $('#hid-functionType option[value="' + v + '"]').text();
  153. switch (v) {
  154. case 9:
  155. return '<span class="label label-warning">' + functionTypeName + '</span>';
  156. case 1:
  157. return '<span class="label label-danger">' + functionTypeName + '</span>';
  158. case 2:
  159. return '<span class="label label-info">' + functionTypeName + '</span>';
  160. case 3:
  161. return '<span class="label label-success">' + functionTypeName + '</span>';
  162. default:
  163. return v;
  164. }
  165. }
  166. </script>
  167. }
  168. <section style="display:none">
  169. @Html.DropDownList("hid-functionType", functionType)
  170. </section>