edit_log.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <style>
  2. #imgdel {
  3. font-size: 30px;
  4. position: absolute;
  5. top: -30px;
  6. right: -12px;
  7. display: none;
  8. color: red;
  9. }
  10. .wrapper{
  11. display: flex;
  12. justify-content: space-between;
  13. padding-top: 3px;
  14. }
  15. </style>
  16. <div class="log_item_top" id="comments">
  17. <div class="layui-tab-content">
  18. {volist name="$comment" id="vo"}
  19. <div class="log_top">
  20. <span>{$vo.maker}</span><span
  21. class="{if $vo.unit_type==2}log_commentary{else}log_company{/if}">{$vo.unit_name}</span><span>{$vo.create_time|date="y-m-d H:i"}</span>
  22. </div>
  23. <div class="log_content">
  24. <div style="word-wrap:break-word;padding: 5px 10px;width: fit-content;">
  25. {$vo.content}
  26. </div>
  27. {if !empty($vo.thumb)}
  28. <div class="log_content_img" style="width: fit-content;">
  29. <img src="{$vo.thumb}" alt="" class="img-responsive">
  30. <span></span>
  31. </div>
  32. {/if}
  33. </div>
  34. {/volist}
  35. </div>
  36. </div>
  37. <div class="log_item_bottom" style="border-top: 2px solid #e2e2e2;">
  38. <div class="layui-form log_bottom_left">
  39. <form class="layui-form" action="">
  40. <div class="layui-form-item layui-form-text" style="float: left;width: 95%;">
  41. <label class="layui-form-label">普通文本域</label>
  42. <div class="layui-input-block" style="margin-left: 100px;">
  43. <textarea id="text" name="content" placeholder="请输入内容" class="layui-textarea" maxlength="3000" onkeyup="setLength(this,3000,'wordsLength');"></textarea>
  44. </div>
  45. <div class="wrapper">
  46. <span></span><span class="total">0/3000字</span>
  47. </div>
  48. </div>
  49. <div class="layui-form-item" style="float: left;width: 4.5%;">
  50. <div class="layui-input-block">
  51. <button type="submit" class="layui-btn" lay-submit lay-filter="caca" type="button"
  52. style="width: 100%;height: 100% !important;background-color: #16baaa00 !important;margin-top: 30%;">
  53. <img src="/static/home/images/allupload.png" height="100"
  54. style="max-width: 40px;height: 40px;"/>
  55. </button>
  56. </div>
  57. </div>
  58. <div style="clear: both;"></div>
  59. <div class="layui-form-item" id="imgItem">
  60. <label class="layui-form-label">上传图片:</label>
  61. <div>
  62. <div class="layui-upload-drag-self">
  63. <div id="uploada" style="position:relative;">
  64. <img src="/static/home/images/upload.png" height="100"
  65. style="max-width: 100%; width: 100%;"/>
  66. <input type="hidden" name="thumb" value="">
  67. <i class="layui-icon layui-icon-clear" id="imgdel"></i>
  68. </div>
  69. </div>
  70. </div>
  71. <!--<label class="layui-form-label">通信对象:</label>-->
  72. <!--<div>-->
  73. <!-- <div class="layui-upload-drag-self">-->
  74. <!-- <div id="uploadBtn3" style="position:relative;">-->
  75. <!-- <select lay-filter="uploadBtn3" name="type">-->
  76. <!-- <option value="0">全部</option>-->
  77. <!-- <option value="1">财政局to公司</option>-->
  78. <!--<option value="2">财政局to业主</option>-->
  79. <!-- <option value="3">公司to业主</option>-->
  80. <!-- </select>-->
  81. <!-- </div>-->
  82. <!-- </div>-->
  83. <!--</div>-->
  84. </div>
  85. </form>
  86. </div>
  87. <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
  88. <div id="innerdiv" style="position:absolute;">
  89. <img id="bigimg" style="" src="" />
  90. </div>
  91. </div>
  92. </div>
  93. <!--zjl,懂的都懂-->
  94. <script>
  95. function comment() {
  96. var form = layui.form,tool=layui.tool,upload = layui.upload;
  97. //头像上传
  98. var uploadInst = upload.render({
  99. elem: '#uploada'
  100. , url: '/admin/api/upload'
  101. , done: function (e) {
  102. //如果上传失败
  103. if (e.code == 1) {
  104. return layer.msg('上传失败');
  105. }
  106. //上传成功
  107. $('#uploada input').attr('value', e.data.filepath);
  108. $('#uploada img').attr('src', e.data.filepath);
  109. $('#imgdel').show();
  110. }
  111. });
  112. $('#imgdel').click(()=>{
  113. $('#uploada input').attr('value', '');
  114. $('#uploada img').attr('src', '/static/home/images/upload.png');
  115. $('#imgdel').hide();
  116. return false;
  117. })
  118. $('#uploada').click(()=>{
  119. console.log(1)
  120. return false;
  121. })
  122. form.on('select(uploadBtn3)', function (data) {
  123. console.log(data)
  124. $("#comments").load(location.href + " #comments>*", "type=2&comment_type=" + data.value)
  125. return false;
  126. });
  127. let d = 1;
  128. //监听提交
  129. form.on('submit(caca)', function (data) {
  130. if(d){
  131. let callback = function (e) {
  132. d = 1
  133. layer.msg(e.msg);
  134. $("#text").val("");
  135. $('#uploada input').attr('value', '');
  136. $('#uploada img').attr('src', '/static/home/images/upload.png');
  137. $('#imgdel').hide();
  138. $("#comments").load(location.href + " #comments>*", "type=2&comment_type=" + data.field.type)
  139. console.log(location.href+" #comments>*","type=2");
  140. }
  141. if(data.field.content === '' && data.field.thumb === ''){
  142. console.log(data.field)
  143. layer.msg("请完善内容");
  144. }else {
  145. data.field["project_id"] = project_id;
  146. tool.post("/admin/project.comment/add_company", data.field, callback);
  147. }
  148. }
  149. d = 0
  150. return false;
  151. });
  152. }
  153. </script>
  154. <script>
  155. // 限制文本框字数
  156. function setLength(obj,maxlength,id){
  157. var num=maxlength-obj.value.length;//获取文本框输入内容的长度
  158. var leng=id;//获取右下角显示的id
  159. if(num<0){
  160. num=0;//如果文本框文字小于零则让它显示为零
  161. }
  162. document.getElementById(leng).innerHTML=num+"/50";
  163. //通过id获取到span标签在页面上的显示并对它的值进行拼接,就是把计算出来的结果+最大限制字数
  164. }
  165. </script>
  166. <script>
  167. const tx = document.querySelector('#text')
  168. const total = document.querySelector('.total')
  169. tx.addEventListener('input', function () {
  170. console.log(tx.value.length)
  171. total.innerHTML = `${tx.value.length}/3000字`
  172. })
  173. </script>
  174. <!-- 点击放大图片 -->
  175. <script src="{__MOBILE__}/js/jquery.min.js"></script>
  176. <script>
  177. $(function() {
  178. $(".img-responsive").click(function (){
  179. // debugger
  180. var _this=$(this);
  181. imgShow("#outerdiv","#innerdiv","#bigimg",_this);
  182. });
  183. });
  184. function imgShow(outerdiv,innerdiv,bigimg,_this){
  185. // debugger
  186. var src=_this.attr("src");
  187. $(bigimg).attr("src",src);
  188. $("<img/>").attr("src",src).on('load',function () {
  189. // debugger
  190. var windowW=$(window).width()
  191. var windowH=$(window).height();
  192. var realWidth=this.width;
  193. var readHeight=this.height;
  194. var imgWidth,imgHeight;
  195. var scale=0.8;
  196. if(realWidth>windowW+scale){
  197. imgHeight=windowH*scale;
  198. imgWidth=imgHeight/readHeight*realWidth;
  199. if(imgWidth>windowW*scale){
  200. imgWidth=windowW*scale;
  201. }
  202. }else if(realWidth>windowW*scale){
  203. imgWidth=windowW*scale;
  204. imgHeight=imgWidth/realWidth*readHeight;
  205. }else {
  206. imgWidth=realWidth;
  207. imgHeight=readHeight;
  208. }
  209. $(bigimg).css("width",imgWidth);
  210. var w=(windowW-imgWidth)/2;
  211. var h=(windowH-imgHeight)/2;
  212. $(innerdiv).css({"top":h,"left":w});
  213. $(outerdiv).fadeIn("fast");
  214. });
  215. $(outerdiv).click(function (){
  216. $(this).fadeOut("fast");
  217. });
  218. };
  219. </script>