Function.cshtml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. @using VberZero
  2. @using VberAdmin.Web.Models.Table
  3. @using VberZero.Session
  4. @using VberAdmin.Web.Models.Input
  5. @using VberAdmin.Web.Models.Modals
  6. @{
  7. string activeMenu = PermissionNames.VberSystemMgFunctionMg;
  8. ViewBag.ActiveMenu = activeMenu;
  9. string functionType = ViewBag.FunctionType;
  10. var table = new VmTable(VzConsts.ApiAppUrl + "Function/GetAll", activeMenu)
  11. .WithTree()
  12. .AddItems(new List<VmTableItem>()
  13. {
  14. new VmTableItem("displayName", L("functionName")),
  15. new VmTableItem("functionType", L("functionType"), "TypeFormatter"),
  16. new VmTableItem("url", L("functionUrl")),
  17. new VmTableItem("icon", L("functionIcon"), "IconFormatter"),
  18. new VmTableItem("sort", L("functionSort")),
  19. //new VmTableItem("", L("Actions"), "ActionsFormatter"),
  20. });
  21. var inputs = new List<VmInputBase>()
  22. {
  23. new VmInputHidden("id"),
  24. new VmInputHidden("parentNo"),
  25. new VmInput("parentName", L("functionParent")).WithDisabled(),
  26. //new Input("functionNo", L("functionNo")),
  27. new VmInput("displayName", L("functionName")).WithRequired(),
  28. new VmInputNumber("sort", L("functionSort")).WithRange(0,1000),
  29. new VmInput("icon", L("functionIcon")),
  30. };
  31. if (AbpSession.GetUserName() == VberZero.BaseSystem.Users.User.AdminUserName)
  32. {
  33. inputs.AddRange(new List<VmInputBase>
  34. {
  35. new VmInput("functionType", L("functionType")).WithSelect(ViewBag.FunctionType),
  36. new VmInput("url", L("functionUrl")),
  37. new VmInput("class", L("functionClass")),
  38. new VmInput("script", L("functionScript")),
  39. });
  40. }
  41. var modal = new VmModal( )
  42. .WithHeaderAndFooter(L("function"),"")
  43. .WithBody(new VmModalBody().AddInputs(inputs));
  44. }
  45. @await Html.PartialAsync("_Table",table)
  46. @await Html.PartialAsync("_Modal", modal)
  47. @section scripts
  48. {
  49. <script>
  50. $(function() {
  51. let funs= LoadTable();
  52. funs['btnRefresh'] = function (url) {
  53. console.log("Refresh");
  54. $.vbAjax1({ url: url });
  55. };
  56. });
  57. </script>
  58. <script>
  59. function IconFormatter(v) {
  60. if (v !== "") {
  61. return '<span class=" ' + v + '"></span>';
  62. }
  63. return v;
  64. }
  65. function TypeFormatter(v) {
  66. let functionTypeName = $('#hid-functionType option[value="' + v + '"]').text();
  67. switch (v) {
  68. case 9:
  69. return '<span class="badge badge-light-warning">' + functionTypeName + '</span>';
  70. case 1:
  71. return '<span class="badge badge-light-danger">' + functionTypeName + '</span>';
  72. case 2:
  73. return '<span class="badge badge-light-info">' + functionTypeName + '</span>';
  74. case 3:
  75. return '<span class="badge badge-light-success">' + functionTypeName + '</span>';
  76. default:
  77. return v;
  78. }
  79. }
  80. </script>
  81. }
  82. <section style="display:none">
  83. <select id="hid-functionType">
  84. @Html.Raw(functionType)
  85. </select>
  86. </section>