form.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. {include file="public/header" /}
  2. <style>
  3. .type-file-preview{z-index: 99999}
  4. </style>
  5. <div class="page">
  6. <div class="fixed-bar">
  7. <div class="item-title">
  8. <div class="subject">
  9. <h3>{$Think.lang.ds_article}</h3>
  10. <h5></h5>
  11. </div>
  12. {include file="public/admin_items" /}
  13. </div>
  14. </div>
  15. <form id="article_form" method="post" enctype="multipart/form-data">
  16. <table class="ds-default-table">
  17. <tbody>
  18. <tr class="noborder">
  19. <td class="required w120">{$Think.lang.article_title}</td>
  20. <td class="vatop rowform"><input type="text" name="article_title" id="article_title" value="{$article.article_title}" class="w200"/></td>
  21. <td class="vatop tips"></td>
  22. </tr>
  23. <tr class="noborder">
  24. <td class="required">{$Think.lang.article_cate}</td>
  25. <td class="vatop rowform">
  26. <select name="ac_id">
  27. <option value="">{$Think.lang.ds_please_choose}</option>
  28. {foreach name="ac_list" item="cate"}
  29. <option value="{$cate.ac_id}" {if $cate.ac_id === $article.ac_id }selected{/if}>{if $cate.ac_parent_id > 0}&nbsp&nbsp{/if}{$cate.ac_name}</option>
  30. {/foreach}
  31. </select>
  32. </td>
  33. <td class="vatop tips"></td>
  34. </tr>
  35. <tr class="noborder">
  36. <td class="required">{$Think.lang.article_url}</td>
  37. <td class="vatop rowform"><input type="text" name="article_url" id="article_url" value="{$article.article_url}" class="w200"/></td>
  38. <td class="vatop tips"></td>
  39. </tr>
  40. <tr class="noborder">
  41. <td class="required">{$Think.lang.article_pic}: </td>
  42. <td class="vatop rowform">
  43. {notempty name="$article.article_pic"}
  44. <span class="type-file-show"> <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
  45. <div class="type-file-preview" style="display: none;"><img id="view_img" src="{:ds_get_pic(ATTACH_ARTICLE,$article.article_pic)}"></div>
  46. </span>
  47. {/notempty}
  48. <span class="type-file-box">
  49. <input type='text' name='article_pic' id='article_pic' class='type-file-text' />
  50. <input type='button' name='button' id='button' value='上传' class='type-file-button' />
  51. <input name="_pic" type="file" class="type-file-file" id="_pic" size="30" hidefocus="true" />
  52. </span>
  53. </td>
  54. <td class="vatop tips">{$Think.lang.article_add_img_wrong}</td>
  55. </tr>
  56. <tr class="noborder">
  57. <td class="required">{$Think.lang.article_show}</td>
  58. <td class="vatop rowform onoff">
  59. <label for="article_show1" class="cb-enable {if $article.article_show == '1'}selected{/if}" ><span>{$Think.lang.ds_yes}</span></label>
  60. <label for="article_show2" class="cb-disable {if $article.article_show == '0'}selected{/if}" ><span>{$Think.lang.ds_no}</span></label>
  61. <input id="article_show1" name="article_show" {if $article.article_show == '1'}checked="checked"{/if} value="1" type="radio">
  62. <input id="article_show2" name="article_show" {if $article.article_show == '0'}checked="checked"{/if} value="0" type="radio">
  63. </td>
  64. <td class="vatop tips"></td>
  65. </tr>
  66. <tr class="noborder">
  67. <td class="required">{$Think.lang.article_sort}</td>
  68. <td class="vatop rowform"><input type="text" name="article_sort" id="article_sort" value="{$article.article_sort}" class="w200"/></td>
  69. <td class="vatop tips"></td>
  70. </tr>
  71. <tr class="noborder">
  72. <td class="required">{$Think.lang.article_content}</td>
  73. {:build_editor(['name'=>'article_content','content'=>htmlspecialchars_decode($article.article_content)])}
  74. <td class="vatop rowform" colspan="2"><textarea name="article_content" id="article_content" style="width:100%;"></textarea></td>
  75. </tr>
  76. <tr>
  77. <td class="required">{$Think.lang.article_index_pic_upload}:</td>
  78. <td id="divComUploadContainer"><input type="file" multiple="multiple" id="fileupload" name="fileupload" /></td>
  79. <td class="vatop tips"></td>
  80. </tr>
  81. <tr>
  82. <td class="required">{$Think.lang.article_index_uploaded_pic}:</td>
  83. <td><div class="tdare">
  84. <table width="600px" cellspacing="0" class="dataTable">
  85. <tbody id="thumbnails">
  86. {notempty name="file_upload"}
  87. {foreach name="file_upload" item="v"}
  88. <tr id="{$v.upload_id}" class="tatr2">
  89. <input type="hidden" name="file_id[]" value="{$v.upload_id}" />
  90. <td><img width="40px" height="40px" src="{:ds_get_pic(ATTACH_ARTICLE,$v.file_name)}" /></td>
  91. <td>{$v.file_name}</td>
  92. <td><a href="javascript:insert_editor('{:ds_get_pic(ATTACH_ARTICLE,$v.file_name)}');">{$Think.lang.article_index_insert}</a> | <a href="javascript:del_file_upload('{$v.upload_id}');">{$Think.lang.ds_del}</a></td>
  93. </tr>
  94. {/foreach}
  95. {/notempty}
  96. </tbody>
  97. </table>
  98. </div></td>
  99. <td class="vatop tips"></td>
  100. </tr>
  101. </tbody>
  102. <tfoot>
  103. <tr class="tfoot">
  104. <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  105. </tr>
  106. </tfoot>
  107. </table>
  108. </form>
  109. </div>
  110. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
  111. <script type="text/javascript">
  112. $(function() {
  113. $("#_pic").change(function () {
  114. $("#article_pic").val($(this).val());
  115. });
  116. $('#article_form').validate({
  117. errorPlacement: function(error, element) {
  118. error.appendTo(element.parent().parent().find('td:last'));
  119. },
  120. rules: {
  121. article_title : {
  122. required: true
  123. },
  124. article_url :{
  125. url : true
  126. },
  127. article_sort :{
  128. number:true,
  129. range:[0,255]
  130. }
  131. },
  132. messages: {
  133. article_title : {
  134. required : '{$Think.lang.article_title_error}'
  135. },
  136. article_url :{
  137. url : '{$Think.lang.ds_url_error}'
  138. },
  139. article_sort:{
  140. number: '{$Think.lang.article_sort_error}',
  141. range:'{$Think.lang.class_sort_explain}'
  142. }
  143. }
  144. });
  145. // 图片上传
  146. $('#fileupload').each(function(){
  147. $(this).fileupload({
  148. dataType: 'json',
  149. url: "{:url('Article/article_pic_upload',['item_id'=>$article.article_id])}",
  150. done: function (e,data) {
  151. if(data != 'error'){
  152. add_uploadedfile(data.result);
  153. }
  154. }
  155. });
  156. });
  157. });
  158. function add_uploadedfile(file_data)
  159. {
  160. var newImg = '<tr id="' + file_data.file_id + '" class="tatr2"><input type="hidden" name="file_id[]" value="' + file_data.file_id + '" /><td><img width="40px" height="40px" src="' + file_data.file_path + '" /></td><td>' + file_data.file_name + '</td><td><a href="javascript:insert_editor(\'' + file_data.file_path + '\');">{$Think.lang.article_index_insert}</a> | <a href="javascript:del_file_upload(' + file_data.file_id + ');">{$Think.lang.ds_del}</a></td></tr>';
  161. $('#thumbnails').prepend(newImg);
  162. }
  163. function insert_editor(file_path){
  164. ue.execCommand('insertimage', {src:file_path});
  165. }
  166. function del_file_upload(file_id)
  167. {
  168. layer.confirm('{$Think.lang.ds_ensure_del}', {
  169. btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
  170. title: false,
  171. }, function () {
  172. $.getJSON("{:url('Article/ajax')}",{branch:'del_file_upload',file_id: + file_id}, function(result){
  173. if(result){
  174. $('#' + file_id).remove();
  175. layer.msg('{$Think.lang.ds_common_del_succ}');
  176. }else{
  177. layer.alert('{$Think.lang.article_index_del_fail}');
  178. }
  179. });
  180. });
  181. }
  182. </script>