importing.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. {extend name="public/layout" /} {block name="title"}素材库{/block} {block name="body"}
  2. <style type="text/css">
  3. html,
  4. body {
  5. display: block;
  6. width: 100%;
  7. background-color: #fff;
  8. }
  9. .layui-icon{font-size:20px !important;line-height: 38px;}
  10. .layui-table-view .layui-table th,
  11. .layui-table-view .layui-table td {
  12. text-align: center;
  13. border-color: #B6CADE;
  14. }
  15. .upload-img .area i {
  16. font-size: 50px;
  17. color: #009688;
  18. }
  19. .evi-block {
  20. float: left;
  21. margin-right: 10px;
  22. }
  23. /*///*/
  24. .addImages {
  25. display: inline-block;
  26. width: 140px;
  27. height: 125px;
  28. -webkit-box-sizing: border-box;
  29. -moz-box-sizing: border-box;
  30. box-sizing: border-box;
  31. border: 1px dashed darkgray;
  32. background: #f8f8f8;
  33. position: relative;
  34. overflow: hidden;
  35. }
  36. .text-detail {
  37. margin-top: 40px;
  38. text-align: center;
  39. }
  40. .text-detail>span {
  41. font-size: 40px;
  42. }
  43. .imageDiv div {
  44. width: 100%;
  45. height: 100%;
  46. position: absolute;
  47. top: 0px;
  48. background-color: #e6e6e600;
  49. }
  50. .imageDiv div i {
  51. display: none;
  52. font-size: 31px;
  53. position: absolute;
  54. top: 37%;
  55. left: 40%;
  56. }
  57. .imageDiv div:hover {
  58. background-color: #e6e6e680;
  59. }
  60. .imageDiv div:hover i {
  61. display: block;
  62. cursor: pointer;
  63. }
  64. .layui-card-header p a:hover{
  65. text-decoration-line: underline;
  66. }
  67. </style>
  68. <body>
  69. <div class="layui-fluid">
  70. <div class="layui-card">
  71. <div class="layui-card-header" style="display: flex;justify-content: flex-start;">
  72. <a href="../../static/questionlisttemp.xlsx" download><span style="float:right;">下载信息模版</span></a>
  73. </div>
  74. <div class="layui-card-body">
  75. <form enctype="multipart/form-data" action="" method="post" class="layui-form">
  76. <div class="layui-upload">
  77. <div class="picDiv" style="margin: 20px">
  78. <div class="addImages" id="excelfile" style="cursor: pointer">
  79. <div class="text-detail">
  80. <span>+</span>
  81. <p>支持xlsx、xls格式</p>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="layui-form-item ">
  87. <button type="button" class="layui-btn" id="uploadbtn" style="float:right">开始上传</button>
  88. </div>
  89. </form>
  90. </div>
  91. </div>
  92. </div>
  93. </body>
  94. {/block} {block name="js"}
  95. <script type="text/javascript" src="__STATIC__/js/plupload/js/plupload.full.min.js"></script>
  96. <script>
  97. layui.config({
  98. base: '__LAYUI__/' //静态资源所在路径
  99. ,
  100. urlbase: '/sys'
  101. }).extend({
  102. index: 'lib/index' //主入口模块
  103. }).use(['index', 'table', 'layedit', 'element', 'upload'], function() {
  104. var $ = layui.$,
  105. upload = layui.upload,
  106. loadingIndex = 0;
  107. upload.render({
  108. elem: '#excelfile'
  109. , url:'{:url("exam/importing")}'//控制器的路径
  110. , accept: 'file'
  111. , auto: false
  112. , bindAction: '#uploadbtn'//一起绑定事件的按钮
  113. , exts: 'xls|excel|xlsx|csv'
  114. , done: function (res) {
  115. if (res.code == 0) {
  116. layer.close(loadingIndex);
  117. layer.alert("导入成功", {icon: 6}, function () {
  118. var index = parent.layer.getFrameIndex(window.name);
  119. parent.layui.table.reload('LAY-exam-question-list'); //重载表格
  120. parent.layer.close(index); //再执行关闭
  121. });
  122. } else {
  123. layer.close(loadingIndex);
  124. layer.alert(res.msg, {icon: 5});
  125. }
  126. }
  127. });
  128. $("#uploadbtn").click(function() {
  129. loadingIndex = layer.load('Loading...', {
  130. shade: [0.6,'#000'] //0.1透明度的白色背景
  131. });
  132. })
  133. });
  134. </script>
  135. {/block}