WebView.tt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <#@ template language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ import namespace="System.Linq" #>
  4. <#@ import namespace="System.Text" #>
  5. <#@ import namespace="System.Collections.Generic" #>
  6. @using <#=Model.ProjectName#>.Web.Models.Input
  7. @using <#=Model.ProjectName#>.Web.Models.Modals
  8. @using <#=Model.ProjectName#>.Web.Models.Search
  9. @using <#=Model.ProjectName#>.Web.Models.Table
  10. @using VberZero
  11. @{
  12. ViewBag.Title = "<#=Model.HtmlPageTitle#>";
  13. string activeMenu = PermissionNames.Vber<#=Model.ParentPath#><#=Model.FileName#>Mg; //The menu item will be active for this page.
  14. ViewBag.ActiveMenu = activeMenu;
  15. var searchForm = new VmSearch(new List<VmSearchItem>()
  16. {
  17. <# foreach (var item in Model.Columns)
  18. {
  19. if(!item.IsGenreated) continue;
  20. if(item.IsSearch)
  21. {
  22. var typeStr= item.AttrType=="int"?"FType.I": item.AttrType=="int"?"FType.In": item.AttrType=="DateTime"?"FType.D": item.AttrType=="DateTime?"?"FType.Dn":"";
  23. typeStr= string.IsNullOrEmpty(typeStr)?"":".WithFieldType("+typeStr+")";
  24. #> new VmSearchItem("<#=item.CamelColumnName#>","<#=item.Comment#>")<#=typeStr#>,
  25. <# }
  26. }
  27. #>
  28. });
  29. var table = new VmTable(VzConsts.ApiAppUrl + "<#=Model.FileName#>/GetAll", activeMenu, searchForm)
  30. .AddItems(new List<VmTableItem>()
  31. {
  32. <# foreach (var item in Model.Columns)
  33. {
  34. if(!item.IsGenreated) continue;
  35. if(item.IsTable)
  36. {
  37. #> new VmTableItem("<#=item.CamelColumnName#>", "<#=item.Comment#>"),
  38. <# }
  39. }
  40. #>
  41. });
  42. var modalBody = new VmModalBody()
  43. .AddInputs(new List<VmInputBase>
  44. {
  45. new VmInputHidden("id"),
  46. })
  47. .AddGroup(new List<VmInputBase>
  48. {
  49. <# foreach (var item in Model.Columns)
  50. {
  51. if(!item.IsGenreated) continue;
  52. if(!item.IsModal) continue;
  53. var inputType=item.AttrType=="int"?"VmInputNumber": item.AttrType=="int?"?"VmInputNumber": item.AttrType=="DateTime"?"VmInputDate": item.AttrType=="DateTime?"?"VmInputDate":"VmInput";
  54. if(item.IsRequired) {
  55. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>").WithRequired(),
  56. <#
  57. }else{
  58. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>"),
  59. <#
  60. }
  61. #>
  62. <# }
  63. #>
  64. },2);
  65. var modal = new VmModal().WithHeaderAndFooter("<#=Model.HtmlModalTitle#>","").WithBody(modalBody);
  66. }
  67. @section styles{
  68. }
  69. @await Html.PartialAsync("_Table", table)
  70. <!--Modal Start-->
  71. @await Html.PartialAsync("_Modal", modal)
  72. <!--Modal End-->
  73. @section scripts
  74. {
  75. <script type="text/javascript">
  76. var $table = $('#table');
  77. $(function () {
  78. var funs = LoadTable();
  79. funs["btnCreate"] = function() { BtnCreate({ data: { id: "" } }); }
  80. funs["btnUpdate"] = function () {
  81. //var row = $table.VbTable("getSelection");
  82. BtnUpdate({ disabled: "" });
  83. };
  84. });
  85. </script>
  86. <!--格式化-->
  87. <script id="formatter-script" type="text/javascript">
  88. function TypeFormatter(v) {
  89. var name = $('#hid-type option[value="' + v + '"]').text();
  90. switch (v) {
  91. case 0:
  92. return '<span class="label label-danger">' + name +'</span>';
  93. default:
  94. return '<span class="label label-info">' + name +'</span>';
  95. }
  96. }
  97. </script>
  98. }
  99. <section style="display: none">
  100. <select id="hid-type">
  101. <option value=""></option>
  102. </select>
  103. </section>