App_Window.cshtml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. 
  2. @{
  3. ViewBag.Title = "App_Window";
  4. Layout = "~/Views/Shared/_MainLayoutPage.cshtml";
  5. }
  6. <link href="~/Content/Scripts/plugins/umeditor-1.2.3/themes/default/_css/umeditor.css?v=1.1" rel="stylesheet" />
  7. <script src="~/Content/Scripts/plugins/umeditor-1.2.3/umeditor.min.js"></script>
  8. <script src="~/Content/Scripts/plugins/umeditor-1.2.3/umeditor.config.js?v=1.41"></script>
  9. <script src="~/Content/Scripts/plugins/umeditor-1.2.3/lang/zh-cn/zh-cn.js"></script>
  10. <script src="~/Content/Scripts/plugins/easyui/easyui-lang-zh_CN.js"></script>
  11. <script src="~/ViewModels/NoticeManager.js?r=1.31"></script>
  12. <style>
  13. table {
  14. width: 97%;
  15. }
  16. table td {
  17. padding: 3px;
  18. border-bottom: solid 1px #EEE;
  19. }
  20. </style>
  21. <script type="text/javascript">
  22. $(function () {
  23. var um = UM.getEditor('MS', {
  24. toolbar: [
  25. ' undo redo | forecolor backcolor | removeformat |',
  26. 'insertorderedlist insertunorderedlist | selectall cleardoc paragraph | fontsize',
  27. '| justifyleft justifycenter justifyright justifyjustify |',
  28. '| horizontal print preview']
  29. });
  30. })
  31. </script>
  32. <form class="easyui-tabs" fit="true" lay-filter="insert_appnotice" id="insert_appnotice">
  33. <div title="<i class='fa fa-sticky-note-o'></i> 添加" style="padding:5px;display:none;">
  34. <table>
  35. <tr>
  36. <td style="width:80px;">
  37. 标题:
  38. </td>
  39. <td>
  40. <input id="BT" name="BT" autofocus class="easyui-textbox" style="width:658px" />
  41. </td>
  42. </tr>
  43. <tr>
  44. <td>信息内容:</td>
  45. <td colspan="2">
  46. <textarea id="MS" name="MS" style="width:98%;height:140px;"></textarea>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td style="border-bottom:0px">图&nbsp;&nbsp;&nbsp;&nbsp;片:</td>
  51. <td colspan="2" id="demoList" style="border-bottom:0px">
  52. <a id="ChooseFile" href="#" class="easyui-linkbutton c8" data-options="plain:true"><i class="fa fa-plus-square-o"></i> 添加图片</a>
  53. </td>
  54. </tr>
  55. </table>
  56. <div class="layui-input-inline" style="width:150px;position:fixed;bottom:10px;right:0%">
  57. <a id="Add_AppNotice" href="#" class="easyui-linkbutton c1"><i class="fa fa-pencil"></i> 确认</a>&nbsp;&nbsp;&nbsp;
  58. <a onclick="Close()" href="#" class="easyui-linkbutton c5"><i class="fa fa-power-off"></i> 关闭</a>
  59. <button id="btn_upload" style="display:none"></button>
  60. </div>
  61. </div>
  62. </form>
  63. <script type="text/javascript">
  64. //附件上传
  65. layui.use('upload', function () {
  66. var upload = layui.upload;
  67. var demoListView = $('#demoList');
  68. var uploadInst = upload.render({
  69. elem: '#ChooseFile' //文件选择按钮
  70. , url: '/Notice/FileUpload?type=1'
  71. , method: "post"
  72. , accept: 'images' //(文件类型)
  73. , multiple: true //多文件上传
  74. , auto: false //自动上传
  75. , size: 5120
  76. , bindAction: "#btn_upload"
  77. , number: 1//最大允许上传文件数量
  78. , choose: function (obj) {
  79. var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
  80. //读取本地文件
  81. obj.preview(function (index, file, result) {
  82. appOBJ.count++;
  83. var display = "none";
  84. var tr = $(['<tr id="upload-' + index + '">'
  85. , '<td class="uplad-filename">' + file.name + '</td>'
  86. , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
  87. , '<td>等待上传</td>'
  88. , '<td>'
  89. , '<button class="layui-btn layui-btn-mini demo-reload layui-hide">重传</button>'
  90. , '<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete" style="height:25px;line-height:25px">删除</button>'
  91. , '</td>'
  92. , '</tr>'].join(''));
  93. //单个重传
  94. tr.find('.demo-reload').on('click', function () {
  95. obj.upload(index, file);
  96. });
  97. //删除
  98. tr.find('.demo-delete').on('click', function () {
  99. delete files[index]; //删除对应的文件
  100. tr.remove();
  101. uploadInst.config.elem.next()[0].value = ''; //清空 input file 值,以免删除后出现同名文件不可选
  102. appOBJ.count--;
  103. });
  104. demoListView.append(tr);
  105. });
  106. }
  107. , done: function (res, index, upload) {
  108. if (res != 0) {
  109. top.ZLPMS.Msg("上传成功", 1)
  110. ZLPMS.CloseTopWindow(true)
  111. }
  112. else {
  113. top.ZLPMS.Msg("上传失败", 2);
  114. ZLPMS.CloseTopWindow(true)
  115. }
  116. }
  117. });
  118. });
  119. $("#Add_AppNotice").bind("click", function () {
  120. var r = $('#insert_appnotice').form('validate');
  121. if (r) {//post到后台
  122. var t = ZLPMS.FormToObject('insert_appnotice');
  123. if (!t.BT || !t.MS) {
  124. top.ZLPMS.Msg("请填写标题和内容!", 2)
  125. return;
  126. }
  127. if (appOBJ.count ==0)
  128. {
  129. top.ZLPMS.Msg("请上传图片!", 2)
  130. return;
  131. }
  132. if (appOBJ.count >1)
  133. {
  134. top.ZLPMS.Msg("只能上传一个文件!", 2)
  135. return;
  136. }
  137. var param = escape(JSON.stringify(t));
  138. $.post("/Notice/Add_AppPush", { text: param }, function (data) {
  139. if (data != null) {
  140. appOBJ.noticeID = data;
  141. top.ZLPMS.Msg("添加成功!", 1);
  142. document.getElementById("btn_upload").click();
  143. }
  144. else {
  145. ZLPMS.CloseTopWindow(true)
  146. top.ZLPMS.Msg("数据异常请重新填写!", 2)
  147. }
  148. });
  149. }
  150. })
  151. </script>