ceshi.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {extend name="common/base"/}
  2. {block name="style"}
  3. <style>
  4. .footer{
  5. display: none;
  6. }
  7. .layui-input-block{
  8. padding: 15px;
  9. }
  10. .note{
  11. padding: 0 0 0 15px;
  12. }
  13. .button{
  14. text-align: center;
  15. }
  16. </style>
  17. {/block}
  18. <!-- 主体 -->
  19. {block name="body"}
  20. <div id="ID-test-layer-wrapper" >
  21. <div style="height: 100px;display: flex;align-items: center;padding-left: 15px;">
  22. <button class="layui-btn layui-btn layui-bg-blue" style="float: center;" type="button"
  23. id="uploadBtn" >选择附件
  24. <div>
  25. </div>
  26. </div>
  27. <form class="layui-form layui-form-pane" action="">
  28. <div class="layui-form-item">
  29. <div class="layui-form-item layui-form-text">
  30. <div class="note">附件说明:</div>
  31. <div class="layui-input-block">
  32. <textarea name="remark" placeholder="请输入附件说明" class="layui-textarea"></textarea>
  33. </div>
  34. </div>
  35. <div class="layui-form-item button">
  36. <button class="layui-btn" lay-submit lay-filter="demo2" onclick="parent.location.reload();" value="刷新父页面">确认</button>
  37. <button id="closeIframe" class="layui-btn layui-btn-primary">取消</button>
  38. </div>
  39. </form>
  40. </div>
  41. {/block}
  42. {block name="script"}
  43. <script>
  44. const moduleInit = ['tool', 'oaTool'];
  45. function gouguInit() {
  46. var table = layui.table, tool = layui.tool, form = layui.form, oaTool = layui.oaTool;
  47. let formData;
  48. oaTool.addFile({
  49. type: 1,
  50. isSave: true,
  51. ajaxSave: function (res) {
  52. formData = res
  53. if(res.code == 0 ){
  54. layer.msg(res.msg)
  55. }
  56. }
  57. });
  58. var index = parent.layer.getFrameIndex(window.name);
  59. $('#closeIframe').click(function(){
  60. parent.layer.close(index);
  61. });
  62. form.on('submit(demo2)', function(data){
  63. var field = data.field;
  64. let callback = function (e) {
  65. if("msg" in e){
  66. layer.msg(e.msg);
  67. }else{
  68. layer.msg('上传成功!')
  69. }
  70. setTimeout(function () {
  71. parent.layer.close(index);
  72. $("#filesBox2").load(location.href+" #filesBox>*","type=2")
  73. }, 500)
  74. }
  75. // console.log(field)
  76. tool.post("/admin/project.api/add_file", { // 上传附件
  77. 'topic_id': "{$detailId}",
  78. 'file_id': formData.data.id,
  79. 'file_name': formData.data.name,
  80. 'module': 'project',
  81. 'remark': field.remark
  82. }, callback);
  83. return false; // 阻止默认 form 跳转
  84. });
  85. }
  86. </script>
  87. {/block}