Form.cshtml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. @{
  2. ViewBag.Title = "新闻管理";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/scripts/plugins/simditor/css/simditor.css" rel="stylesheet" />
  6. <script src="~/Content/scripts/plugins/simditor/js/module.min.js"></script>
  7. <script src="~/Content/scripts/plugins/simditor/js/uploader.min.js"></script>
  8. <script src="~/Content/scripts/plugins/simditor/js/hotkeys.min.js"></script>
  9. <script src="~/Content/scripts/plugins/simditor/js/simditor.min.js"></script>
  10. <script>
  11. var keyValue = request('keyValue');
  12. var category = request('category');
  13. var editor = null;
  14. $(function () {
  15. editor = new Simditor({
  16. textarea: $('#NewsContent'),
  17. placeholder: '这里输入文章内容...',
  18. toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent']
  19. });
  20. initControl();
  21. })
  22. //初始化控件
  23. function initControl() {
  24. //栏目
  25. $("#Category").ComboBox({
  26. param: { EnCode: "NewsCategory" },
  27. url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
  28. description: "==请选择==",
  29. id: "ItemValue",
  30. text: "ItemName",
  31. height: "230px"
  32. });
  33. //获取表单
  34. if (!!keyValue) {
  35. $.SetForm({
  36. url: "../../PublicInfoManage/News/GetFormJson",
  37. param: { keyValue: keyValue },
  38. success: function (data) {
  39. $("#form1").SetWebControls(data);
  40. editor.setValue(data.NewsContent);
  41. }
  42. });
  43. } else {
  44. $("#Category").ComboBoxTreeSetValue(category);
  45. }
  46. }
  47. //保存表单
  48. function AcceptClick() {
  49. if (!$('#form1').Validform()) {
  50. return false;
  51. }
  52. var postData = {
  53. FullHead: $("#FullHead").val(),
  54. Category: $("#Category").attr('data-value'),
  55. ReleaseTime: $("#ReleaseTime").val(),
  56. AuthorName: $("#AuthorName").val(),
  57. CompileName: $("#CompileName").val(),
  58. TagWord: $("#TagWord").val(),
  59. Keyword: $("#Keyword").val(),
  60. NewsContent: editor.getValue()
  61. }
  62. $.SaveForm({
  63. url: "../../PublicInfoManage/News/SaveForm?keyValue=" + keyValue,
  64. param: postData,
  65. loading: "正在保存数据...",
  66. success: function () {
  67. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  68. }
  69. })
  70. }
  71. </script>
  72. <div style="margin-top: 20px; margin-right: 30px;">
  73. <table class="form" style="table-layout: auto;">
  74. <tr>
  75. <td class="formTitle">标题<font face="宋体">*</font></td>
  76. <td class="formValue" colspan="3">
  77. <input id="FullHead" type="text" class="form-control" placeholder="请输入标题" isvalid="yes" checkexpession="NotNull" />
  78. </td>
  79. </tr>
  80. <tr>
  81. <td class="formTitle">栏目<font face="宋体">*</font></td>
  82. <td class="formValue">
  83. <div id="Category" type="select" class="ui-select"></div>
  84. </td>
  85. <td class="formTitle">发布时间<font face="宋体">*</font></td>
  86. <td class="formValue">
  87. <input id="ReleaseTime" type="text" class="form-control" value="@LeaRun.Util.Time.GetToday("yyyy/MM/dd HH:mm")" />
  88. </td>
  89. </tr>
  90. <tr>
  91. <td class="formTitle">作者<font face="宋体">*</font></td>
  92. <td class="formValue">
  93. <input id="AuthorName" type="text" class="form-control" placeholder="请输入作者" isvalid="yes" checkexpession="NotNull" />
  94. </td>
  95. <td class="formTitle">编辑<font face="宋体">*</font></td>
  96. <td class="formValue">
  97. <input id="CompileName" type="text" class="form-control" placeholder="请输入编辑" isvalid="yes" checkexpession="NotNull" />
  98. </td>
  99. </tr>
  100. <tr>
  101. <td class="formTitle">Tag标签</td>
  102. <td class="formValue">
  103. <input id="TagWord" type="text" class="form-control" placeholder="多个标签之间用“,”分隔,最多不超过10个" />
  104. </td>
  105. <td class="formTitle">关键字</td>
  106. <td class="formValue">
  107. <input id="Keyword" type="text" class="form-control" placeholder="多个关键字之间用“,”分隔,最多不超过10个" />
  108. </td>
  109. </tr>
  110. <tr>
  111. <th class="formTitle" valign="top" style="padding-top: 4px;">内容</th>
  112. <td class="formValue" colspan="3">
  113. <textarea id="NewsContent" class="form-control" rows="5"></textarea>
  114. </td>
  115. </tr>
  116. </table>
  117. </div>