| | |
| | | // 导入 |
| | | @RequestMapping(value = "/matCode/import/auth") |
| | | @ManagerAuth |
| | | public R matCodeImport(MultipartFile file) throws IOException { |
| | | EasyExcel.read(file.getInputStream(), EnInitData.class, new EnInitDataListener()).sheet().doRead(); |
| | | public R matCodeImport(MultipartFile file) throws IOException, InterruptedException { |
| | | Thread.sleep(2000); |
| | | // EasyExcel.read(file.getInputStream(), EnInitData.class, new EnInitDataListener()).sheet().doRead(); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | }); |
| | | }); |
| | | |
| | | // 导入excel |
| | | upload.render({ |
| | | elem: '#uploadEx' |
| | | , url: baseUrl + '/matCode/import/auth' |
| | | , headers: {token: localStorage.getItem('token')} |
| | | , accept: 'file' |
| | | , exts: 'xls|excel|xlsx' |
| | | , auto: false |
| | | , bindAction: '#uploadDo' |
| | | , choose: function(obj){ |
| | | layui.$('#uploadDemoView').removeClass('layui-hide'); |
| | | obj.preview(function(index, file, result){ |
| | | console.log(file.name); //得到文件名称 |
| | | }); |
| | | } |
| | | , done: function (res) { |
| | | layer.msg('上传成功'); |
| | | limit(); |
| | | } |
| | | }) |
| | | |
| | | // 监听头工具栏事件 |
| | | table.on('toolbar(matCode)', function (obj) { |
| | | var checkStatus = table.checkStatus(obj.config.id); |
| | |
| | | layer.open({ |
| | | type: 1, |
| | | title: '数据导入', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: $('#importDataDiv'), |
| | | success: function(layero, index){ |
| | | |
| | | uploader.reload(); |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 导入excel |
| | | var uploader = upload.render({ |
| | | elem: '#uploadEx' |
| | | , url: baseUrl + '/matCode/import/auth' |
| | | , headers: {token: localStorage.getItem('token')} |
| | | , accept: 'file' |
| | | , exts: 'xls|excel|xlsx' |
| | | , auto: false |
| | | , bindAction: '#uploadDo' |
| | | , before: function(obj){ |
| | | layer.closeAll(); |
| | | layer.load(1, {shade: [0.1,'#fff']}); |
| | | } |
| | | , choose: function(obj){ |
| | | $('#uploadDesc').hide(); |
| | | $('#uploadDemoView').show(); |
| | | obj.preview(function(index, file, result){ |
| | | $('#fileMame').html(file.name); |
| | | }); |
| | | } |
| | | , done: function (res) { |
| | | limit(); |
| | | $('#uploadDesc').show(); |
| | | $('#uploadDemoView').hide(); |
| | | $('#fileMame').html(""); |
| | | layer.closeAll('loading'); |
| | | layer.msg(res.msg); |
| | | } |
| | | , error: function(index, upload){ |
| | | layer.closeAll('loading'); |
| | | } |
| | | }) |
| | | |
| | | // 监听行工具事件 |
| | | table.on('tool(matCode)', function(obj){ |
| | | var data = obj.data; |
| | |
| | | <iframe id="detail-iframe" scrolling="auto" style="display:none;"></iframe> |
| | | |
| | | <!-- 导入操作弹窗 --> |
| | | <div id="importDataDiv" style="display: none"> |
| | | <div class="layui-upload-drag" id="uploadEx"> |
| | | <i class="layui-icon"></i> |
| | | <p>点击添加,或将文件拖拽到此处</p> |
| | | <div class="layui-hide" id="uploadDemoView"> |
| | | <hr> |
| | | <img src="../../static/image/Excel.png" alt="上传成功后渲染" style="max-width: 196px"> |
| | | <div id="importDataDiv" style="display: none;padding: 20px"> |
| | | <div class="layui-upload-drag" id="uploadEx" style="width: 200px; font-size: x-small; padding: 10px; text-align: center; box-sizing: border-box"> |
| | | <div id="uploadDesc" style="display: inline-block; "> |
| | | <i class="layui-icon"></i> |
| | | <p>点击添加,或将文件拖拽到此处</p> |
| | | </div> |
| | | <div id="uploadDemoView" style="display: none"> |
| | | <img src="../../static/image/Excel.png" alt="上传成功后渲染" style="max-width: 196px; padding: 20px 0 10px 0"> |
| | | <span id="fileMame" style="display: block; font-size: small; color: #333"></span> |
| | | </div> |
| | | </div> |
| | | <button class="layui-btn" id="uploadDo">开始导入</button> |
| | | <div style="text-align: center; margin-top: 20px"> |
| | | <button class="layui-btn" id="uploadDo">开始导入</button> |
| | | </div> |
| | | </div> |
| | | |
| | | </body> |