edit_help.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.ds_storejoin}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. </div>
  11. </div>
  12. <form id="post_form" method="post" name="form1">
  13. <table class="ds-default-table">
  14. <tbody>
  15. <tr class="noborder">
  16. <td colspan="2" class="required"><label class="validation" for="help_title">{$Think.lang.help_title}:</label></td>
  17. </tr>
  18. <tr class="noborder">
  19. <td class="vatop rowform"><input id="help_title" name="help_title" value="{$help.help_title}" class="txt" type="text"></td>
  20. <td class="vatop tips"></td>
  21. </tr>
  22. <tr>
  23. <td colspan="2" class="required"><label class="validation" for="help_sort">{$Think.lang.ds_sort}:</label>
  24. </td>
  25. </tr>
  26. <tr class="noborder">
  27. <td class="vatop rowform"><input type="text" value="{$help.help_sort}" name="help_sort" id="help_sort" class="txt"></td>
  28. <td class="vatop tips">{$Think.lang.help_sort_tips}</td>
  29. </tr>
  30. <tr>
  31. <td colspan="2" class="required"><label class="validation">{$Think.lang.help_info}:</label></td>
  32. </tr>
  33. <tr class="noborder">
  34. <td colspan="2" class="vatop rowform">
  35. {:build_editor(['name'=>'help_info','content'=>htmlspecialchars_decode($help.help_info)])}
  36. <textarea name="help_info" id="help_info" style="width:100%"></textarea>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td colspan="2" class="required">{$Think.lang.image_upload}:</td>
  41. </tr>
  42. <tr class="noborder">
  43. <td colspan="3" id="divComUploadContainer"><input type="file" multiple="multiple" id="fileupload" name="fileupload" /></td>
  44. </tr>
  45. <tr>
  46. <td colspan="2" class="required">{$Think.lang.help_image_list}:</td>
  47. <tr>
  48. <td colspan="2">
  49. <ul id="thumbnails" class="thumblists">
  50. {notempty name="pic_list"}
  51. {foreach name="pic_list" item="val"}
  52. <li id="pic_{$val.upload_id}" class="picture" >
  53. <input type="hidden" name="file_id[]" value="{$val.upload_id}" />
  54. <div class="size-64x64"><span class="thumb"><i></i><img src="{:ds_get_pic('admin/storehelp',$val.file_name)}" width="64px" height="64px"/></span></div>
  55. <p><span><a href="javascript:insert_editor('{:ds_get_pic('admin/storehelp',$val.file_name)}');">{$Think.lang.storejoin_insert}</a></span><span><a href="javascript:del_file_upload('{$val.upload_id}');">{$Think.lang.ds_del}</a></span></p>
  56. </li>
  57. {/foreach}
  58. {/notempty}
  59. </ul>
  60. </td>
  61. </tr>
  62. </tbody>
  63. <tfoot>
  64. <tr class="tfoot">
  65. <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  66. </tr>
  67. </tfoot>
  68. </table>
  69. </form>
  70. </div>
  71. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
  72. <script>
  73. //按钮先执行验证再提交表单
  74. $(function(){
  75. $("#post_form").validate({
  76. errorPlacement: function(error, element){
  77. error.appendTo(element.parent().parent().prev().find('td:first'));
  78. },
  79. rules : {
  80. help_title : {
  81. required : true
  82. },
  83. type_id : {
  84. required : true
  85. },
  86. help_sort : {
  87. required : true,
  88. digits : true
  89. },
  90. help_url : {
  91. url : true
  92. },
  93. help_info : {
  94. required : true
  95. }
  96. },
  97. messages : {
  98. help_title : {
  99. required : "{$Think.lang.help_title_required}"
  100. },
  101. type_id : {
  102. required : "{$Think.lang.type_id_required}"
  103. },
  104. help_sort : {
  105. required : "{$Think.lang.help_sort_required}",
  106. digits : "{$Think.lang.help_sort_digits}"
  107. },
  108. help_url : {
  109. url : "{$Think.lang.ds_url_error}"
  110. },
  111. help_info : {
  112. required : "{$Think.lang.help_info_required}"
  113. }
  114. }
  115. });
  116. // 图片上传
  117. $('#fileupload').each(function(){
  118. $(this).fileupload({
  119. dataType: 'json',
  120. url: "{:url('Storejoin/upload_pic',['item_id'=>$help.help_id])}",
  121. done: function (e,data) {
  122. if(data != 'error'){
  123. add_uploadedfile(data.result);
  124. }
  125. }
  126. });
  127. });
  128. });
  129. function add_uploadedfile(file){
  130. var newImg = '<li id="pic_' + file.file_id + '" class="picture"><input type="hidden" name="file_id[]" value="' + file.file_id
  131. + '" /><div class="size-64x64"><span class="thumb"><i></i><img src="'+ file.file_path + '" width="64px" height="64px"/></span></div><p><span><a href="javascript:insert_editor(\'' + file.file_path +
  132. '\');">{$Think.lang.storejoin_insert}</a></span><span><a href="javascript:del_file_upload(' + file.file_id + ');">{$Think.lang.ds_del}</a></span></p></li>';
  133. $('#thumbnails').prepend(newImg);
  134. }
  135. function insert_editor(file_name){
  136. ue.execCommand('insertimage', {src:file_name});
  137. }
  138. function del_file_upload(file_id){
  139. layer.confirm('{$Think.lang.ds_ensure_del}', {
  140. btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
  141. title: false,
  142. }, function () {
  143. $.getJSON(ADMINSITEURL+'/Storehelp/del_pic.html?file_id=' + file_id, function(result){
  144. if(result){
  145. $('#pic_' + file_id).remove();
  146. layer.msg('{$Think.lang.ds_common_del_succ}');
  147. }else{
  148. layer.alert('{$Think.lang.document_index_del_fail}');
  149. }
  150. });
  151. });
  152. }
  153. </script>