|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.excel.EasyExcel; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.entity.MatCode; | 
|---|
|  |  |  | import com.zy.asrs.service.MatCodeService; | 
|---|
|  |  |  | import com.zy.common.utils.excel.EnInitData; | 
|---|
|  |  |  | import com.zy.common.utils.excel.EnInitDataListener; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 导出 | 
|---|
|  |  |  | @RequestMapping(value = "/matCode/export/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R export(@RequestBody JSONObject param){ | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(exportSupport(list, fields)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 导入 | 
|---|
|  |  |  | @RequestMapping(value = "/matCode/import/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R matCodeImport(MultipartFile file) throws IOException { | 
|---|
|  |  |  | EasyExcel.read(file.getInputStream(), EnInitData.class, new EnInitDataListener()).sheet().doRead(); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/matCodeQuery/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R query(String condition) { | 
|---|
|  |  |  | 
|---|
|  |  |  | var pageCurr; | 
|---|
|  |  |  | layui.use(['table','laydate', 'form'], function(){ | 
|---|
|  |  |  | layui.use(['table','laydate', 'form','upload'], function(){ | 
|---|
|  |  |  | var table = layui.table; | 
|---|
|  |  |  | var $ = layui.jquery; | 
|---|
|  |  |  | var layer = layui.layer; | 
|---|
|  |  |  | var layDate = layui.laydate; | 
|---|
|  |  |  | var upload = layui.upload; | 
|---|
|  |  |  | var form = layui.form; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 数据渲染 | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 导入excel | 
|---|
|  |  |  |  | 
|---|
|  |  |  | upload.render({ | 
|---|
|  |  |  | elem: '#uploadEx' | 
|---|
|  |  |  | , url: baseUrl + '/matCode/import/auth' //改成您自己的上传接口 | 
|---|
|  |  |  | , headers: {token: localStorage.getItem('token')} | 
|---|
|  |  |  | , accept: 'file' //普通文件 | 
|---|
|  |  |  | , exts: 'xls|excel|xlsx' //只允许的文件后缀 | 
|---|
|  |  |  | , done: function (res) { | 
|---|
|  |  |  | layer.msg('上传成功'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 监听头工具栏事件 | 
|---|
|  |  |  | table.on('toolbar(matCode)', function (obj) { | 
|---|
|  |  |  | var checkStatus = table.checkStatus(obj.config.id); | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 'intoData': | 
|---|
|  |  |  | layer.open({ | 
|---|
|  |  |  | type: 1, | 
|---|
|  |  |  | title: '数据导入', | 
|---|
|  |  |  | maxmin: true, | 
|---|
|  |  |  | shadeClose: true, | 
|---|
|  |  |  | content: $('#importDataDiv'), | 
|---|
|  |  |  | success: function(layero, index){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <script type="text/html" id="toolbar"> | 
|---|
|  |  |  | <div class="layui-btn-container"> | 
|---|
|  |  |  | <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">新增</button> | 
|---|
|  |  |  | <button class="layui-btn layui-btn-sm" id="btn-delete" lay-event="deleteData">删除</button> | 
|---|
|  |  |  | <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData">导出</button> | 
|---|
|  |  |  | <button class="layui-btn layui-btn-normal" id="btn-export" lay-event="exportData" style="float: inherit">导出</button> | 
|---|
|  |  |  | <button class="layui-btn " id="btn-into" lay-event="intoData">导入</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <iframe id="detail-iframe" scrolling="auto" style="display:none;"></iframe> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div id="importDataDiv" style="display: none"> | 
|---|
|  |  |  | <form id="uploadExcel" class="layui-form"> | 
|---|
|  |  |  | <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"> | 
|---|
|  |  |  | <legend>请上传合法规范的Excel文件</legend> | 
|---|
|  |  |  | </fieldset> | 
|---|
|  |  |  | <div class="layui-form-item"> | 
|---|
|  |  |  | <div class="layui-input-block"> | 
|---|
|  |  |  | <button type="button" class="layui-btn" id="uploadEx"><i class="layui-icon"></i>上传文件</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-form-item"> | 
|---|
|  |  |  | <div class="layui-input-block"> | 
|---|
|  |  |  | <button class="layui-btn" lay-submit lay-filter="upload">上传</button> | 
|---|
|  |  |  | <button type="reset" class="layui-btn layui-btn-primary">重置</button> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </form> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </body> | 
|---|
|  |  |  | </html> | 
|---|
|  |  |  |  | 
|---|