WebView.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. // ------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // 此代码由工具生成。
  4. // 运行时版本: 17.0.0.0
  5. //
  6. // 对此文件的更改可能导致不正确的行为,如果
  7. // 重新生成代码,这些更改将会丢失。
  8. // </auto-generated>
  9. // ------------------------------------------------------------------------------
  10. namespace VberAdmin.Templates.V4
  11. {
  12. using System.Linq;
  13. using System.Text;
  14. using System.Collections.Generic;
  15. using System;
  16. /// <summary>
  17. /// Class to produce the template output
  18. /// </summary>
  19. #line 1 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  20. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
  21. public partial class WebView : WebViewBase
  22. {
  23. #line hidden
  24. /// <summary>
  25. /// Create the template output
  26. /// </summary>
  27. public virtual string TransformText()
  28. {
  29. this.Write("@using ");
  30. #line 6 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  31. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ProjectName));
  32. #line default
  33. #line hidden
  34. this.Write(".Web.Models.Input\r\n@using ");
  35. #line 7 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  36. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ProjectName));
  37. #line default
  38. #line hidden
  39. this.Write(".Web.Models.Modals\r\n@using ");
  40. #line 8 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  41. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ProjectName));
  42. #line default
  43. #line hidden
  44. this.Write(".Web.Models.Search\r\n@using ");
  45. #line 9 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  46. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ProjectName));
  47. #line default
  48. #line hidden
  49. this.Write(".Web.Models.Table\r\n\r\n@using VberZero\r\n\r\n@{\r\n ViewBag.Title = \"");
  50. #line 14 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  51. this.Write(this.ToStringHelper.ToStringWithCulture(Model.HtmlPageTitle));
  52. #line default
  53. #line hidden
  54. this.Write("\";\r\n string activeMenu = PermissionNames.Vber");
  55. #line 15 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  56. this.Write(this.ToStringHelper.ToStringWithCulture(Model.ParentPath));
  57. #line default
  58. #line hidden
  59. #line 15 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  60. this.Write(this.ToStringHelper.ToStringWithCulture(Model.FileName));
  61. #line default
  62. #line hidden
  63. this.Write("Mg; //The menu item will be active for this page.\r\n ViewBag.ActiveMenu = activ" +
  64. "eMenu;\r\n\tvar searchForm = new VmSearch(new List<VmSearchItem>()\r\n {\r\n");
  65. #line 19 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  66. foreach (var item in Model.Columns)
  67. {
  68. if(!item.IsGenreated) continue;
  69. if(item.IsSearch)
  70. {
  71. var typeStr= item.AttrType=="int"?"FType.I": item.AttrType=="int"?"FType.In": item.AttrType=="DateTime"?"FType.D": item.AttrType=="DateTime?"?"FType.Dn":"";
  72. typeStr= string.IsNullOrEmpty(typeStr)?"":".WithFieldType("+typeStr+")";
  73. #line default
  74. #line hidden
  75. this.Write(" new VmSearchItem(\"");
  76. #line 27 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  77. this.Write(this.ToStringHelper.ToStringWithCulture(item.CamelColumnName));
  78. #line default
  79. #line hidden
  80. this.Write("\",\"");
  81. #line 27 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  82. this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));
  83. #line default
  84. #line hidden
  85. this.Write("\")");
  86. #line 27 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  87. this.Write(this.ToStringHelper.ToStringWithCulture(typeStr));
  88. #line default
  89. #line hidden
  90. this.Write(", \r\n");
  91. #line 28 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  92. }
  93. }
  94. #line default
  95. #line hidden
  96. this.Write(" });\r\n\r\n var table = new VmTable(VzConsts.ApiAppUrl + \"");
  97. #line 33 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  98. this.Write(this.ToStringHelper.ToStringWithCulture(Model.FileName));
  99. #line default
  100. #line hidden
  101. this.Write("/GetAll\", activeMenu, searchForm)\r\n\t.AddItems(new List<VmTableItem>()\r\n {\r\n");
  102. #line 36 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  103. foreach (var item in Model.Columns)
  104. {
  105. if(!item.IsGenreated) continue;
  106. if(item.IsTable)
  107. {
  108. #line default
  109. #line hidden
  110. this.Write(" new VmTableItem(\"");
  111. #line 41 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  112. this.Write(this.ToStringHelper.ToStringWithCulture(item.CamelColumnName));
  113. #line default
  114. #line hidden
  115. this.Write("\", \"");
  116. #line 41 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  117. this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));
  118. #line default
  119. #line hidden
  120. this.Write("\"),\r\n");
  121. #line 42 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  122. }
  123. }
  124. #line default
  125. #line hidden
  126. this.Write(" });\r\n var modalBody = new VmModalBody() \r\n .AddInputs(new List<VmIn" +
  127. "putBase>\r\n {\r\n new VmInputHidden(\"id\"),\r\n })\r\n ." +
  128. "AddGroup(new List<VmInputBase>\r\n {\r\n");
  129. #line 53 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  130. foreach (var item in Model.Columns)
  131. {
  132. if(!item.IsGenreated) continue;
  133. if(!item.IsModal) continue;
  134. var inputType=item.AttrType=="int"?"VmInputNumber": item.AttrType=="int?"?"VmInputNumber": item.AttrType=="DateTime"?"VmInputDate": item.AttrType=="DateTime?"?"VmInputDate":"VmInput";
  135. if(item.IsRequired) {
  136. #line default
  137. #line hidden
  138. this.Write(" new ");
  139. #line 59 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  140. this.Write(this.ToStringHelper.ToStringWithCulture(inputType));
  141. #line default
  142. #line hidden
  143. this.Write("(\"");
  144. #line 59 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  145. this.Write(this.ToStringHelper.ToStringWithCulture(item.CamelColumnName));
  146. #line default
  147. #line hidden
  148. this.Write("\", \"");
  149. #line 59 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  150. this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));
  151. #line default
  152. #line hidden
  153. this.Write("\").WithRequired(), \r\n");
  154. #line 60 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  155. }else{
  156. #line default
  157. #line hidden
  158. this.Write(" new ");
  159. #line 62 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  160. this.Write(this.ToStringHelper.ToStringWithCulture(inputType));
  161. #line default
  162. #line hidden
  163. this.Write("(\"");
  164. #line 62 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  165. this.Write(this.ToStringHelper.ToStringWithCulture(item.CamelColumnName));
  166. #line default
  167. #line hidden
  168. this.Write("\", \"");
  169. #line 62 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  170. this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));
  171. #line default
  172. #line hidden
  173. this.Write("\"), \r\n");
  174. #line 63 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  175. }
  176. #line default
  177. #line hidden
  178. #line 66 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  179. }
  180. #line default
  181. #line hidden
  182. this.Write(" },2);\r\n var modal = new VmModal().WithHeaderAndFooter(\"");
  183. #line 69 "D:\02Study\ABP\VberAdminBaseSystem\Template\VberAdminTemplate\CodeGenerator\Templates\V4\WebView.tt"
  184. this.Write(this.ToStringHelper.ToStringWithCulture(Model.HtmlModalTitle));
  185. #line default
  186. #line hidden
  187. this.Write(@""","""").WithBody(modalBody);
  188. }
  189. @section styles{
  190. }
  191. @await Html.PartialAsync(""_Table"", table)
  192. <!--Modal Start-->
  193. @await Html.PartialAsync(""_Modal"", modal)
  194. <!--Modal End-->
  195. @section scripts
  196. {
  197. <script type=""text/javascript"">
  198. var $table = $('#table');
  199. $(function () {
  200. var funs = LoadTable();
  201. funs[""btnCreate""] = function() { BtnCreate({ data: { id: """" } }); }
  202. funs[""btnUpdate""] = function () {
  203. //var row = $table.VbTable(""getSelection"");
  204. BtnUpdate({ disabled: """" });
  205. };
  206. });
  207. </script>
  208. <!--格式化-->
  209. <script id=""formatter-script"" type=""text/javascript"">
  210. function TypeFormatter(v) {
  211. var name = $('#hid-type option[value=""' + v + '""]').text();
  212. switch (v) {
  213. case 0:
  214. return '<span class=""label label-danger"">' + name +'</span>';
  215. default:
  216. return '<span class=""label label-info"">' + name +'</span>';
  217. }
  218. }
  219. </script>
  220. }
  221. <section style=""display: none"">
  222. <select id=""hid-type"">
  223. <option value=""""></option>
  224. </select>
  225. </section>");
  226. return this.GenerationEnvironment.ToString();
  227. }
  228. }
  229. #line default
  230. #line hidden
  231. #region Base class
  232. /// <summary>
  233. /// Base class for this transformation
  234. /// </summary>
  235. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
  236. public class WebViewBase
  237. {
  238. #region Fields
  239. private global::System.Text.StringBuilder generationEnvironmentField;
  240. private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
  241. private global::System.Collections.Generic.List<int> indentLengthsField;
  242. private string currentIndentField = "";
  243. private bool endsWithNewline;
  244. private global::System.Collections.Generic.IDictionary<string, object> sessionField;
  245. #endregion
  246. #region Properties
  247. /// <summary>
  248. /// The string builder that generation-time code is using to assemble generated output
  249. /// </summary>
  250. protected System.Text.StringBuilder GenerationEnvironment
  251. {
  252. get
  253. {
  254. if ((this.generationEnvironmentField == null))
  255. {
  256. this.generationEnvironmentField = new global::System.Text.StringBuilder();
  257. }
  258. return this.generationEnvironmentField;
  259. }
  260. set
  261. {
  262. this.generationEnvironmentField = value;
  263. }
  264. }
  265. /// <summary>
  266. /// The error collection for the generation process
  267. /// </summary>
  268. public System.CodeDom.Compiler.CompilerErrorCollection Errors
  269. {
  270. get
  271. {
  272. if ((this.errorsField == null))
  273. {
  274. this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
  275. }
  276. return this.errorsField;
  277. }
  278. }
  279. /// <summary>
  280. /// A list of the lengths of each indent that was added with PushIndent
  281. /// </summary>
  282. private System.Collections.Generic.List<int> indentLengths
  283. {
  284. get
  285. {
  286. if ((this.indentLengthsField == null))
  287. {
  288. this.indentLengthsField = new global::System.Collections.Generic.List<int>();
  289. }
  290. return this.indentLengthsField;
  291. }
  292. }
  293. /// <summary>
  294. /// Gets the current indent we use when adding lines to the output
  295. /// </summary>
  296. public string CurrentIndent
  297. {
  298. get
  299. {
  300. return this.currentIndentField;
  301. }
  302. }
  303. /// <summary>
  304. /// Current transformation session
  305. /// </summary>
  306. public virtual global::System.Collections.Generic.IDictionary<string, object> Session
  307. {
  308. get
  309. {
  310. return this.sessionField;
  311. }
  312. set
  313. {
  314. this.sessionField = value;
  315. }
  316. }
  317. #endregion
  318. #region Transform-time helpers
  319. /// <summary>
  320. /// Write text directly into the generated output
  321. /// </summary>
  322. public void Write(string textToAppend)
  323. {
  324. if (string.IsNullOrEmpty(textToAppend))
  325. {
  326. return;
  327. }
  328. // If we're starting off, or if the previous text ended with a newline,
  329. // we have to append the current indent first.
  330. if (((this.GenerationEnvironment.Length == 0)
  331. || this.endsWithNewline))
  332. {
  333. this.GenerationEnvironment.Append(this.currentIndentField);
  334. this.endsWithNewline = false;
  335. }
  336. // Check if the current text ends with a newline
  337. if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
  338. {
  339. this.endsWithNewline = true;
  340. }
  341. // This is an optimization. If the current indent is "", then we don't have to do any
  342. // of the more complex stuff further down.
  343. if ((this.currentIndentField.Length == 0))
  344. {
  345. this.GenerationEnvironment.Append(textToAppend);
  346. return;
  347. }
  348. // Everywhere there is a newline in the text, add an indent after it
  349. textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
  350. // If the text ends with a newline, then we should strip off the indent added at the very end
  351. // because the appropriate indent will be added when the next time Write() is called
  352. if (this.endsWithNewline)
  353. {
  354. this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
  355. }
  356. else
  357. {
  358. this.GenerationEnvironment.Append(textToAppend);
  359. }
  360. }
  361. /// <summary>
  362. /// Write text directly into the generated output
  363. /// </summary>
  364. public void WriteLine(string textToAppend)
  365. {
  366. this.Write(textToAppend);
  367. this.GenerationEnvironment.AppendLine();
  368. this.endsWithNewline = true;
  369. }
  370. /// <summary>
  371. /// Write formatted text directly into the generated output
  372. /// </summary>
  373. public void Write(string format, params object[] args)
  374. {
  375. this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
  376. }
  377. /// <summary>
  378. /// Write formatted text directly into the generated output
  379. /// </summary>
  380. public void WriteLine(string format, params object[] args)
  381. {
  382. this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
  383. }
  384. /// <summary>
  385. /// Raise an error
  386. /// </summary>
  387. public void Error(string message)
  388. {
  389. System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
  390. error.ErrorText = message;
  391. this.Errors.Add(error);
  392. }
  393. /// <summary>
  394. /// Raise a warning
  395. /// </summary>
  396. public void Warning(string message)
  397. {
  398. System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
  399. error.ErrorText = message;
  400. error.IsWarning = true;
  401. this.Errors.Add(error);
  402. }
  403. /// <summary>
  404. /// Increase the indent
  405. /// </summary>
  406. public void PushIndent(string indent)
  407. {
  408. if ((indent == null))
  409. {
  410. throw new global::System.ArgumentNullException("indent");
  411. }
  412. this.currentIndentField = (this.currentIndentField + indent);
  413. this.indentLengths.Add(indent.Length);
  414. }
  415. /// <summary>
  416. /// Remove the last indent that was added with PushIndent
  417. /// </summary>
  418. public string PopIndent()
  419. {
  420. string returnValue = "";
  421. if ((this.indentLengths.Count > 0))
  422. {
  423. int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
  424. this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
  425. if ((indentLength > 0))
  426. {
  427. returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
  428. this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
  429. }
  430. }
  431. return returnValue;
  432. }
  433. /// <summary>
  434. /// Remove any indentation
  435. /// </summary>
  436. public void ClearIndent()
  437. {
  438. this.indentLengths.Clear();
  439. this.currentIndentField = "";
  440. }
  441. #endregion
  442. #region ToString Helpers
  443. /// <summary>
  444. /// Utility class to produce culture-oriented representation of an object as a string.
  445. /// </summary>
  446. public class ToStringInstanceHelper
  447. {
  448. private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
  449. /// <summary>
  450. /// Gets or sets format provider to be used by ToStringWithCulture method.
  451. /// </summary>
  452. public System.IFormatProvider FormatProvider
  453. {
  454. get
  455. {
  456. return this.formatProviderField ;
  457. }
  458. set
  459. {
  460. if ((value != null))
  461. {
  462. this.formatProviderField = value;
  463. }
  464. }
  465. }
  466. /// <summary>
  467. /// This is called from the compile/run appdomain to convert objects within an expression block to a string
  468. /// </summary>
  469. public string ToStringWithCulture(object objectToConvert)
  470. {
  471. if ((objectToConvert == null))
  472. {
  473. throw new global::System.ArgumentNullException("objectToConvert");
  474. }
  475. System.Type t = objectToConvert.GetType();
  476. System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
  477. typeof(System.IFormatProvider)});
  478. if ((method == null))
  479. {
  480. return objectToConvert.ToString();
  481. }
  482. else
  483. {
  484. return ((string)(method.Invoke(objectToConvert, new object[] {
  485. this.formatProviderField })));
  486. }
  487. }
  488. }
  489. private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
  490. /// <summary>
  491. /// Helper to produce culture-oriented representation of an object as a string
  492. /// </summary>
  493. public ToStringInstanceHelper ToStringHelper
  494. {
  495. get
  496. {
  497. return this.toStringHelperField;
  498. }
  499. }
  500. #endregion
  501. }
  502. #endregion
  503. }