edit.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <style>
  2. .form {
  3. font-size: 14px;
  4. font-weight: bold;
  5. color: #999999;
  6. margin: 20px;
  7. }
  8. .form-item {
  9. margin-bottom: 20px;
  10. white-space: nowrap;
  11. }
  12. .form-item-label {
  13. width: 110px;
  14. text-align: right;
  15. display: inline-block;
  16. margin-right: 5px;
  17. vertical-align: top;
  18. }
  19. .form-item-input {
  20. width: 230px;
  21. height: 28px;
  22. text-indent: 5px;
  23. border: 1px solid #aeaeae;
  24. border-radius: 3px;
  25. outline: none;
  26. box-sizing: border-box;
  27. }
  28. .form-item-con > div {
  29. margin-bottom: 5px;
  30. }
  31. .form-item-con .checkbox {
  32. display: inline-block;
  33. margin-right: 5px;
  34. }
  35. .form .date {
  36. display: inline-block;
  37. width: 100px;
  38. }
  39. .form .date span {
  40. color: #333333;
  41. }
  42. .form .classes {
  43. color: #666;
  44. }
  45. button {
  46. border: none;
  47. background: #2977ff;
  48. width: 111px;
  49. height: 36px;
  50. border-radius: 3px;
  51. font-size: 14px;
  52. color: #fff;
  53. outline: none;
  54. cursor: pointer;
  55. }
  56. button.save {
  57. width:100px;
  58. }
  59. .confirmbox .confirmbox-btns {
  60. margin-top: 40px;
  61. }
  62. .confirmbox .confirmbox-btns button {
  63. margin-right: 10px;
  64. }
  65. .tooltip1:hover .tooltip-con{
  66. display: block;
  67. }
  68. .classes div{
  69. display: inline-block;
  70. vertical-align: top;
  71. max-width: 500px;
  72. }
  73. .classes span{
  74. word-break: keep-all;
  75. display: inline-block;
  76. }
  77. .class-box>p{
  78. margin-bottom: 10px;
  79. }
  80. .class-box>ul{
  81. width: 500px;
  82. height: 200px;
  83. padding: 10px 20px;
  84. background-color: #FAFAFA;
  85. box-sizing: border-box;
  86. border:1px solid #ddd;
  87. }
  88. .class-box>ul>li{
  89. float: left;
  90. margin-right: 15px;
  91. margin-bottom: 10px;
  92. cursor: pointer;
  93. }
  94. .class-box>ul>li>img{
  95. vertical-align: middle;
  96. margin-left: 3px;
  97. }
  98. .icon-change{
  99. margin: 0 37px;
  100. margin-top: 110px;
  101. }
  102. .red-tips{
  103. color: red;
  104. }
  105. button.save {
  106. height: 40px;
  107. }
  108. .selected-box li{
  109. color:#2977ff;
  110. }
  111. textarea{
  112. width:650px;
  113. height:320px;
  114. }
  115. /*修改样式结束*/
  116. .upload{
  117. display: inline-block;
  118. }
  119. .upload-btn{
  120. display: inline-block;
  121. }
  122. #file-upload-1{border:0;padding-left:0;}
  123. </style>
  124. <div class="main-content-inner">
  125. <div class="page-content">
  126. <form action="<?php echo $this->createUrl('notification/edit')?>" class="form" method="post">
  127. <div class="form-item">
  128. <label class="form-item-label">
  129. 标题
  130. </label>
  131. <input type="text" name="title" class="form-item-input" placeholder="不超过20个字符" value="<?php if(isset($title)) echo $title;?>">
  132. </div>
  133. <div class="form-item">
  134. <label class="form-item-label">
  135. 通知内容
  136. </label>
  137. <textarea name="content" id="content"><?php if(isset($content)) echo $content;?></textarea>
  138. </div>
  139. <div class="form-item">
  140. <label class="form-item-label">
  141. 添加附件
  142. </label>
  143. <div class="upload">
  144. <span class="red-tips">注:最多可上传3个文件,支持Word、Excel、PDF格式,单个文件大小不得超过10M,选择文件后需点击【上传】按钮</span>
  145. <div>
  146. <table>
  147. <tr>
  148. <td><input type="file" class="form-item-input" name="file-upload-1" id="file-upload-1"></td>
  149. <td><button class="upload-btn " style="width:70px;height:25px;margin-left:10px;font-size:12px;">上传</button></td>
  150. </tr>
  151. <tr>
  152. <td colspan="2" class="file_list">
  153. <?php
  154. if(isset($file_list) && $file_list){
  155. foreach ($file_list as $item){
  156. echo '<p url="'.$item['url'].'" name="'.$item['file_name'].'">'.$item['file_name'].' <span class="red-tips del-file">删除</span></p>';
  157. }
  158. }
  159. ?>
  160. </td>
  161. </tr>
  162. </table>
  163. </div>
  164. </div>
  165. </div>
  166. <div class="form-item">
  167. <label class="form-item-label">
  168. </label>
  169. <button type="button" class="save" id="save">保存</button>
  170. <input type="hidden" name="eid" value="<?php if(isset($id)) echo $id;?>">
  171. <input type="hidden" name="files" value="<?php if(isset($file_list)) echo json_encode($file_list)?>">
  172. </div>
  173. </form>
  174. </div>
  175. </div>
  176. <script src="/js/jquery.ajaxfileupload.js"></script>
  177. <script>
  178. $(function(){
  179. $('#save').click(function(){
  180. if($('input[name=title]').val()==''){
  181. layer.msg('请输入标题');
  182. return false;
  183. }
  184. if($('input[name=title]').val().length>20){
  185. layer.msg('标题最多不超过20个字符');
  186. return false;
  187. }
  188. if($('#content').val()==''){
  189. layer.msg('请输入通知内容');
  190. return false;
  191. }
  192. var fileArr=[];
  193. $fileListLength=$('.file_list').find('p');
  194. $fileListLength.each(function(){
  195. var file={url:$(this).attr('url'),file_name:$(this).attr('name')};
  196. fileArr.push(file);
  197. })
  198. $("input[name=files]").val(JSON.stringify(fileArr))
  199. $('.form').submit();
  200. });
  201. $('.upload-btn').click(function(){
  202. _file=$(this).closest('div').find('.form-item-input').val();
  203. fileElementId=$(this).closest('div').find('.form-item-input').attr('id');
  204. if (!_file) {
  205. layer.msg('请选择上传文件');
  206. return false;
  207. }
  208. $fileListLength=$('.file_list').find('p').length;
  209. if($fileListLength>=3){
  210. layer.msg('最多可上传3个文件');
  211. return false;
  212. }
  213. var extStart = _file.lastIndexOf('.');
  214. var extName = _file.substring(extStart,_file.length).toLowerCase();
  215. if (extName != ".docx" && extName != ".dotx" && extName != ".dotm" && extName != ".pdf" && extName != ".xlsx" && extName != ".xls") {
  216. layer.msg('模板格式有误,请上传PDF、WORD、EXCEl!');
  217. return false;
  218. }
  219. $.ajaxFileUpload({
  220. url: "<?php echo $this->createUrl('notification/upload');?>", //用于文件上传的服务器端请求地址
  221. secureuri: false, //是否需要安全协议,一般设置为false
  222. fileElementId: fileElementId, //文件上传域的ID
  223. dataType: 'text', //返回值类型 一般设置为json
  224. success: function (data, status){
  225. var obj = JSON.parse(data);
  226. if (obj.success == 1) {
  227. layer.msg(obj.message,{
  228. icon: 1,
  229. }, function(){
  230. // layer.closeAll();
  231. // location.reload();
  232. });
  233. html='<p url="'+obj.url+'" name="'+obj.file_name+'">'+obj.file_name+' <span class="red-tips del-file">删除</span></p>'
  234. $('.file_list').append(html)
  235. } else {
  236. layer.msg(obj.message,{
  237. icon: 2,
  238. }, function(){
  239. // layer.closeAll();
  240. // location.reload();
  241. });
  242. }
  243. }
  244. });
  245. return false;
  246. });
  247. $('.file_list').on('click','.del-file',function(){
  248. $(this).parent().remove();
  249. })
  250. })
  251. </script>