edit.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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_document}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. </div>
  11. </div>
  12. <form id="doc_form" method="post">
  13. <input type="hidden" name="document_id" value="{$doc.document_id}" />
  14. <table class="ds-default-table">
  15. <tbody>
  16. <tr>
  17. <td class="required"><label class="validation">{$Think.lang.document_index_title}: </label></td>
  18. </tr>
  19. <tr class="noborder">
  20. <td class="vatop rowform"><input type="text" value="{$doc.document_title}" name="document_title" id="document_title" class="infoTableInput w300"></td>
  21. </tr>
  22. <tr>
  23. <td class="required"><label class="validation">{$Think.lang.document_index_content}: </label></td>
  24. </tr>
  25. <tr class="noborder">
  26. <td class="vatop rowform">
  27. {:build_editor(['name'=>'document_content','content'=>htmlspecialchars_decode($doc.document_content)])}
  28. <textarea name="document_content" id="document_content" style="width:100%"></textarea>
  29. </td>
  30. </tr>
  31. <tr>
  32. <td class="required">{$Think.lang.document_index_pic_upload}:</td>
  33. </tr>
  34. <tr class="noborder">
  35. <td id="divComUploadContainer"><input type="file" multiple="multiple" id="fileupload" name="fileupload" /></td>
  36. </tr>
  37. <tr>
  38. <td class="required">{$Think.lang.document_index_uploaded_pic}:</td>
  39. </tr>
  40. <tr>
  41. <td><div class="tdare">
  42. <table width="600px" cellspacing="0" class="dataTable">
  43. <tbody id="thumbnails">
  44. {notempty name="file_upload"}
  45. {foreach name="file_upload" item="v"}
  46. <tr id="{$v.upload_id}" class="tatr2">
  47. <input type="hidden" name="file_id[]" value="{$v.upload_id}" />
  48. <td><img width="40px" height="40px" src="{:ds_get_pic(ATTACH_ARTICLE,$v.upload_path)}" /></td>
  49. <td>{$v.file_name}</td>
  50. <td><a href="javascript:insert_editor('{:ds_get_pic(ATTACH_ARTICLE,$v.upload_path)}');">{$Think.lang.document_index_insert}</a> | <a href="javascript:del_file_upload('{$v.upload_id}');">{$Think.lang.ds_del}</a></td>
  51. </tr>
  52. {/foreach}
  53. {/notempty}
  54. </tbody>
  55. </table>
  56. </div></td>
  57. </tr>
  58. </tbody>
  59. <tfoot>
  60. <tr class="tfoot">
  61. <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
  62. </tr>
  63. </tfoot>
  64. </table>
  65. </form>
  66. </div>
  67. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
  68. <script>
  69. $(document).ready(function(){
  70. $('#doc_form').validate({
  71. errorPlacement: function(error, element){
  72. error.appendTo(element.parent().parent().prev().find('td:first'));
  73. },
  74. rules : {
  75. document_title : {
  76. required : true
  77. },
  78. document_content : {
  79. required : true
  80. }
  81. },
  82. messages : {
  83. document_title : {
  84. required : '{$Think.lang.document_index_title_null}'
  85. },
  86. document_content : {
  87. required : '{$Think.lang.document_index_content_null}'
  88. }
  89. }
  90. });
  91. // 图片上传
  92. $('#fileupload').each(function(){
  93. $(this).fileupload({
  94. dataType: 'json',
  95. url: "{:url('Document/document_pic_upload',['item_id'=>$doc.document_id])}",
  96. done: function (e,data) {
  97. if(data != 'error'){
  98. add_uploadedfile(data.result);
  99. }
  100. }
  101. });
  102. });
  103. });
  104. function add_uploadedfile(file_data)
  105. {
  106. 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.document_index_insert}</a> | <a href="javascript:del_file_upload(' + file_data.file_id + ');">{$Think.lang.ds_del}</a></td></tr>';
  107. $('#thumbnails').prepend(newImg);
  108. }
  109. function insert_editor(file_path){
  110. ue.execCommand('insertimage', {src:file_path});
  111. }
  112. function del_file_upload(file_id)
  113. {
  114. layer.confirm('{$Think.lang.ds_ensure_del}', {
  115. btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
  116. title: false,
  117. }, function () {
  118. $.getJSON("{:url('Document/ajax')}",{branch:'del_file_upload',file_id: + file_id}, function(result){
  119. if(result){
  120. $('#' + file_id).remove();
  121. layer.msg('{$Think.lang.ds_common_del_succ}');
  122. }else{
  123. layer.alert('{$Think.lang.document_index_del_fail}');
  124. }
  125. });
  126. });
  127. }
  128. </script>