importing.html 3.8 KB

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