Form.cshtml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 editor = null;
  13. $(function () {
  14. editor = new Simditor({
  15. textarea: $('#Content'),
  16. placeholder: '这里输入文章内容...',
  17. toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent']
  18. });
  19. initControl();
  20. });
  21. //初始化控件
  22. function initControl() {
  23. //获取表单
  24. if (!!keyValue) {
  25. $.SetForm({
  26. url: "../../BaseManage/Banner/GetFormJson",
  27. param: { keyValue: keyValue },
  28. success: function (data) {
  29. $("#form1").SetWebControls(data);
  30. editor.setValue(data.Content);
  31. }
  32. })
  33. }
  34. }
  35. //保存表单;
  36. function AcceptClick() {
  37. if (!$('#form1').Validform()) {
  38. return false;
  39. }
  40. //var postData = $("#form1").GetWebControls(keyValue);
  41. var postData = {
  42. Title: $("#Title").val(),
  43. Content: editor.getValue(),
  44. ImageUrl: $("#ImageUrl").val(),
  45. Sort: $("#Sort").val()
  46. }
  47. $.SaveForm({
  48. url: "../../BaseManage/Banner/SaveForm?keyValue=" + keyValue,
  49. param: postData,
  50. loading: "正在保存数据...",
  51. success: function () {
  52. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  53. }
  54. })
  55. }
  56. </script>
  57. <script type="text/javascript">
  58. var editorOption = {
  59. initialFrameWidth: 1000,
  60. initialFrameHeight: 200
  61. };
  62. var editor = new baidu.editor.ui.Editor(editorOption);
  63. </script>
  64. <div style="margin-top: 20px; margin-right: 30px;">
  65. <table class="form">
  66. <tr>
  67. <td class="formTitle">标题</td>
  68. <td class="formValue">
  69. <input id="Title" type="text" class="form-control" />
  70. </td>
  71. </tr>
  72. <tr>
  73. <td class="formTitle">滚动图地址</td>
  74. <td class="formValue">
  75. <table style="width: 100%">
  76. <tr>
  77. <td style="width: 90%">
  78. @*<img id="img-preview" src=""/>*@
  79. <input id="ImageUrl" type="text" class="form-control" placeholder="" readonly="readonly" />
  80. </td>
  81. <td style="text-align: center">
  82. <span><i class="fa fa-plus fa-2x" onclick="upImage()" style="cursor: pointer"></i></span>
  83. @*<button type="button" onclick="upImage()"></button>*@
  84. </td>
  85. </tr>
  86. </table>
  87. <script type="text/plain" id="j_ueditorupload" style="height: 5px; display: none;">
  88. </script>
  89. <script type="text/javascript">
  90. //实例化编辑器
  91. var o_ueditorupload = UE.getEditor('j_ueditorupload',
  92. {
  93. autoHeightEnabled: false
  94. });
  95. o_ueditorupload.ready(function () {
  96. o_ueditorupload.hide(); //隐藏编辑器
  97. //监听图片上传,地址:arg[0].src
  98. o_ueditorupload.addListener('beforeInsertImage',
  99. function (t, arg) {
  100. //alert('这是图片地址:' + arg[0].src);
  101. //这里解析你的返回类型
  102. $("#ImageUrl").val(arg[0].src);
  103. });
  104. });
  105. //弹出图片上传的对话框
  106. function upImage() {
  107. var myImage = o_ueditorupload.getDialog("insertimage");
  108. myImage.open();
  109. }
  110. </script>
  111. </td>
  112. </tr>
  113. <tr>
  114. <td class="formTitle">内容</td>
  115. <td class="formValue">
  116. <textarea id="Content" class="form-control" rows="5"></textarea>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td class="formTitle">排序码</td>
  121. <td class="formValue">
  122. <input id="Sort" type="text" class="form-control" value="99" />
  123. </td>
  124. </tr>
  125. </table>
  126. </div>