WebView.tt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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#>
  7. @using <#=Model.ProjectName#>.Configuration
  8. @using <#=Model.ProjectName#>.Authorization
  9. @using <#=Model.ProjectName#>.Web.Views.Shared.Modals
  10. @using <#=Model.ProjectName#>.Web.Views.Shared.SearchForm
  11. @using <#=Model.ProjectName#>.Web.Views.Shared.Table
  12. <#
  13. string isMuiltSearch= Model.IsMultipleSearch?"false":"true";
  14. #>
  15. @{
  16. ViewBag.Title = "<#=Model.HtmlPageTitle#>";
  17. string activeMenu = PermissionNames.Pages<#=Model.ParentPath#><#=Model.FileName#>Mg; //The menu item will be active for this page.
  18. ViewBag.ActiveMenu = activeMenu;
  19. var searchForm = new SearchFormViewModel(new List<SearchItem>()
  20. {
  21. <# foreach (var item in Model.Columns)
  22. {
  23. if(!item.IsGenreated) continue;
  24. if(item.IsSearch)
  25. {
  26. var typeStr= item.AttrType=="int"?"FieldType.I": item.AttrType=="int"?"FieldType.In": item.AttrType=="DateTime"?"FieldType.D": item.AttrType=="DateTime?"?"FieldType.Dn":"";
  27. typeStr= string.IsNullOrEmpty(typeStr)?"":","+typeStr;
  28. #> new SearchItem("<#=item.CamelColumnName#>","<#=item.Comment#>"<#=typeStr#>),
  29. <# }
  30. }
  31. #>
  32. },"search-form",<#=isMuiltSearch#>);
  33. var table = new TableViewModel(IwbConsts.ApiAppUrl + "<#=Model.FileName#>/GetAll", activeMenu, searchForm)
  34. .SetFields(new List<FieldItem>()
  35. {
  36. <# foreach (var item in Model.Columns)
  37. {
  38. if(!item.IsGenreated) continue;
  39. if(item.IsTable)
  40. {
  41. #> new FieldItem("<#=item.CamelColumnName#>", "<#=item.Comment#>"),
  42. <# }
  43. }
  44. #>
  45. });
  46. var inputs = new List<Input>()
  47. {
  48. new InputHide("id"),
  49. <# foreach (var item in Model.Columns)
  50. {
  51. if(!item.IsGenreated) continue;
  52. if(!item.IsModal) continue;
  53. var inputType=item.AttrType=="int"?"InputNumber": item.AttrType=="int?"?"InputNumber": item.AttrType=="DateTime"?"InputDateTime": item.AttrType=="DateTime?"?"InputDateTime":"Input";
  54. if(item.IsRequired) {
  55. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>"),
  56. <#
  57. }else{
  58. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>").SetNotRequired(),
  59. <#
  60. }
  61. #>
  62. <# }
  63. #>
  64. };
  65. var modalBody = new ModalBodyViewModel().AddInputs(inputs);
  66. var modal = new ModalViewModel().SetHeader("<#=Model.HtmlModalTitle#>").SetBody(modalBody);
  67. }
  68. @section styles{
  69. }
  70. @await Html.PartialAsync("Table/_Table", table)
  71. @section modal{
  72. <!--Modal Start-->
  73. @await Html.PartialAsync("Modals/_Modal", modal)
  74. <!--Modal End-->
  75. }
  76. @section scripts
  77. {
  78. <script type="text/javascript">
  79. var $table;
  80. $(function () {
  81. $table = LoadTable();
  82. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  83. funs["btnCreate"] = function() { BtnCreate({ data: { id: "" } }); }
  84. funs["btnUpdate"] = function () { BtnUpdate({ disabled: "" }); };
  85. });
  86. </script>
  87. <!--格式化-->
  88. <script id="formatter-script" type="text/javascript">
  89. function TypeFormatter(v) {
  90. var name = $('#hid-type option[value="' + v + '"]').text();
  91. switch (v) {
  92. case 0:
  93. return '<span class="label label-danger">' + name +'</span>';
  94. default:
  95. return '<span class="label label-info">' + name +'</span>';
  96. }
  97. }
  98. </script>
  99. }
  100. <section style="display: none">
  101. <select id="hid-type">
  102. <option value=""></option>
  103. </select>
  104. @*@Html.DropDownList("hid-type", type)*@
  105. </section>