WebView.tt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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#>.Authorization.Permissions
  8. @using <#=Model.ProjectName#>.Models.Layout
  9. @using <#=Model.ProjectName#>.Views.Shared.New.Modals
  10. @using <#=Model.ProjectName#>.Views.Shared.New.Table
  11. <#
  12. string isMuiltSearch= "false";
  13. #>
  14. @{
  15. Layout = "~/Views/Shared/_Master_New.cshtml";
  16. ViewBag.Title = "<#=Model.HtmlPageTitle#>";
  17. string activeMenu = PermissionNames.Pages<#=Model.ParentPath#>Mg<#=Model.ClassName#>Mg; //The menu item will be active for this page.
  18. ViewBag.ActiveMenu = activeMenu;
  19. var searchForm = new SearchFormViewModal(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( "/api/services/app/<#=Model.ClassName#>/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. }
  47. @section css{
  48. }
  49. @Html.Partial("New/Table/_Table", table)
  50. @section modal{
  51. <!--Main Modal-->
  52. @{
  53. var modal = new ModalViewModel("<#=Model.HtmlModalTitle#>", new ModalBodyViewModel(new List<Input>()
  54. {
  55. new InputHide("id"),
  56. <# foreach (var item in Model.Columns)
  57. {
  58. if(!item.IsGenreated) continue;
  59. if(!item.IsModal) continue;
  60. var inputType=item.AttrType=="int"?"InputNumber": item.AttrType=="int?"?"InputNumber": item.AttrType=="DateTime"?"InputDateTime": item.AttrType=="DateTime?"?"InputDateTime":"Input";
  61. if(item.IsRequired) {
  62. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>"),
  63. <#
  64. }else{
  65. #> new <#=inputType#>("<#=item.CamelColumnName#>", "<#=item.Comment#>").SetNotRequired(),
  66. <#
  67. }
  68. #>
  69. <# }
  70. #>
  71. }));
  72. }
  73. @Html.Partial("New/Modals/_Modal", modal)
  74. }
  75. @section scripts
  76. {
  77. <script src="~/Content/Scripts/MyScript/iwb.js"></script>
  78. <script src="~/Content/Scripts/MyScript/util.js"></script>
  79. <script type="text/javascript">
  80. var $table;
  81. $(function () {
  82. $table = LoadTable();
  83. var funs = window.iwbfuns || { none: function () { console.log("No type"); } };
  84. funs["btnCreate"] = function() { BtnCreate({ data: { id: "" } }); }
  85. funs["btnUpdate"] = function () { BtnUpdate({ disabled: "" }); };
  86. });
  87. </script>
  88. <!--格式化-->
  89. <script id="formatter-script" type="text/javascript">
  90. function TypeFormatter(v) {
  91. var name = $('#hid-type option[value="' + v + '"]').text();
  92. switch (v) {
  93. case 0:
  94. return '<span class="label label-danger">' + name +'</span>';
  95. default:
  96. return '<span class="label label-info">' + name +'</span>';
  97. }
  98. }
  99. </script>
  100. }
  101. <section style="display: none">
  102. <select id="hid-type">
  103. <option value=""></option>
  104. </select>
  105. @*@Html.DropDownList("hid-type", type)*@
  106. </section>