edit_help.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_storehelp}</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="helptype_id">{$Think.lang.helptype_id}:</label></td>
  24. </tr>
  25. <tr class="noborder">
  26. <td class="vatop rowform">
  27. <select name="helptype_id" id="helptype_id">
  28. <option value="">{$Think.lang.ds_please_choose}...</option>
  29. {notempty name="helptype_list"}
  30. {foreach name="helptype_list" item="val"}
  31. <option {eq name="val.helptype_id" value="$help.helptype_id" }selected{/eq} value="{$val.helptype_id}">{$val.helptype_name}</option>
  32. {/foreach}
  33. {/notempty}
  34. </select>
  35. </td>
  36. <td class="vatop tips"></td>
  37. </tr>
  38. <tr>
  39. <td colspan="2" class="required"><label class="validation" for="help_sort">{$Think.lang.ds_sort}:</label>
  40. </td>
  41. </tr>
  42. <tr class="noborder">
  43. <td class="vatop rowform"><input type="text" value="{$help.help_sort}" name="help_sort" id="help_sort" class="txt"></td>
  44. <td class="vatop tips">{$Think.lang.helptype_sort_tips}</td>
  45. </tr>
  46. <tr>
  47. <td colspan="2" class="required"><label for="help_url">{$Think.lang.ds_link}:</label></td>
  48. </tr>
  49. <tr class="noborder">
  50. <td class="vatop rowform"><input type="text" value="{$help.help_url}" name="help_url" id="help_url" class="txt"></td>
  51. <td class="vatop tips">{$Think.lang.help_url_tips}</td>
  52. </tr>
  53. <tr>
  54. <td colspan="2"><label for="help_info">{$Think.lang.help_info}:</label></td>
  55. </tr>
  56. <tr class="noborder">
  57. <td colspan="2">
  58. {:build_editor(['name'=>'help_info','content'=>htmlspecialchars_decode($help.help_info)])}
  59. <textarea name="help_info" id="help_info"></textarea>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td colspan="2" class="required">{$Think.lang.image_upload}:</td>
  64. </tr>
  65. <tr class="noborder">
  66. <td colspan="3" id="divComUploadContainer"><input type="file" multiple="multiple" id="fileupload" name="fileupload" /></td>
  67. </tr>
  68. <tr>
  69. <td colspan="2" class="required">{$Think.lang.storehelp_image_list}:</td>
  70. <tr>
  71. <td colspan="2">
  72. <ul id="thumbnails" class="thumblists">
  73. {notempty name="pic_list"}
  74. {foreach name="pic_list" item="val"}
  75. <li id="pic_{$val.upload_id}" class="picture" >
  76. <input type="hidden" name="file_id[]" value="{$val.upload_id}" />
  77. <div class="size-64x64"><span class="thumb"><i></i>
  78. <img src="{:ds_get_pic('admin/storehelp',$val.file_name)}" onload="javascript:ResizeImage(this,64,64);"/></span></div>
  79. <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>
  80. </li>
  81. {/foreach}
  82. {/notempty}
  83. </ul>
  84. </td>
  85. </tr>
  86. </tbody>
  87. <tfoot>
  88. <tr class="tfoot">
  89. <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  90. </tr>
  91. </tfoot>
  92. </table>
  93. </form>
  94. </div>
  95. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
  96. <script>
  97. //按钮先执行验证再提交表单
  98. $(function(){
  99. $("#post_form").validate({
  100. errorPlacement: function(error, element){
  101. error.appendTo(element.parent().parent().prev().find('td:first'));
  102. },
  103. rules : {
  104. help_title : {
  105. required : true
  106. },
  107. helptype_id : {
  108. required : true
  109. },
  110. help_sort : {
  111. required : true,
  112. digits : true
  113. },
  114. help_url : {
  115. url : true
  116. }
  117. },
  118. messages : {
  119. help_title : {
  120. required : "{$Think.lang.helptype_name_required}"
  121. },
  122. helptype_id : {
  123. required : "{$Think.lang.helptype_id_required}"
  124. },
  125. help_sort : {
  126. required : "{$Think.lang.helptype_sort_digits}",
  127. digits : "{$Think.lang.helptype_sort_digits}"
  128. },
  129. help_url : {
  130. url : "{$Think.lang.ds_url_error}"
  131. }
  132. }
  133. });
  134. // 图片上传
  135. $('#fileupload').each(function(){
  136. $(this).fileupload({
  137. dataType: 'json',
  138. url: "{:url('Storehelp/upload_pic',['item_id'=>$help.help_id])}",
  139. done: function (e,data) {
  140. if(data != 'error'){
  141. add_uploadedfile(data.result);
  142. }
  143. }
  144. });
  145. });
  146. });
  147. function add_uploadedfile(file){
  148. var newImg = '<li id="pic_' + file.file_id + '" class="picture"><input type="hidden" name="file_id[]" value="' + file.file_id
  149. + '" /><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 +
  150. '\');">{$Think.lang.storejoin_insert}</a></span><span><a href="javascript:del_file_upload(' + file.file_id + ');">{$Think.lang.ds_del}</a></span></p></li>';
  151. $('#thumbnails').prepend(newImg);
  152. }
  153. function insert_editor(file_name){
  154. ue.execCommand('insertimage', {src:file_name});
  155. }
  156. function del_file_upload(file_id){
  157. layer.confirm('{$Think.lang.ds_ensure_del}', {
  158. btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
  159. title: false,
  160. }, function () {
  161. $.getJSON("{:url('Storehelp/del_pic')}",{file_id:file_id}, function(result){
  162. if(result){
  163. $('#pic_' + file_id).remove();
  164. layer.msg('{$Think.lang.ds_common_del_succ}');
  165. }else{
  166. layer.alert('{$Think.lang.ds_common_del_fail}');
  167. }
  168. });
  169. });
  170. }
  171. </script>