| | |
| | | import com.zy.asrs.entity.param.LocDetlAdjustParam; |
| | | import com.zy.asrs.service.ManLocDetlService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.common.utils.RoleUtils; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @RequestMapping(value = "/manLocDetl/export/auth") |
| | | @ManagerAuth(memo = "库位明细导出") |
| | | public R export(@RequestBody JSONObject param){ |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | EntityWrapper<ManLocDetl> wrapper = new EntityWrapper<>(); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("locDetl")); |
| | | String row = ""; |
| | | if (map.get("row") != null) { |
| | | String chooseRow = (String) map.get("row"); |
| | | if (chooseRow.length() == 1) { |
| | | row = "0" + chooseRow; |
| | | map.remove("row"); |
| | | }else { |
| | | row = chooseRow; |
| | | map.remove("row"); |
| | | } |
| | | } |
| | | convert(map, wrapper); |
| | | if (!row.equals("")){ |
| | | wrapper.and() |
| | | .where("loc_no like '" +row +"%'"); |
| | | } |
| | | List<ManLocDetl> list = manLocDetlService.selectList(wrapper); |
| | | List<String> fields = param.getJSONArray("fields") == null |
| | | ? Collections.emptyList() |
| | | : JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> searchParam = param.getJSONObject("locDetl") == null |
| | | ? new HashMap<>() |
| | | : excludeTrash(param.getJSONObject("locDetl")); |
| | | String condition = searchParam.get("condition") == null ? null : String.valueOf(searchParam.remove("condition")); |
| | | List<ManLocDetl> list = manLocDetlService.selectList(buildWrapper(searchParam, condition)); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | | |
| | |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | |
| | | EntityWrapper<ManLocDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(ManLocDetl.class, param.keySet(), wrapper, condition); |
| | | EntityWrapper<ManLocDetl> wrapper = buildWrapper(param, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | |
| | | return R.ok(manLocDetlService.selectPage(new Page<>(curr, limit), wrapper)); |
| | |
| | | } |
| | | } |
| | | |
| | | private EntityWrapper<ManLocDetl> buildWrapper(Map<String, Object> param, String condition) { |
| | | EntityWrapper<ManLocDetl> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(ManLocDetl.class, param.keySet(), wrapper, condition); |
| | | return wrapper; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(locDetl)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | var searchData = getSearchData(); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'locDetl': exportData, |
| | | 'fields': fields |
| | | }; |
| | | var loadIndex = layer.msg('正在导出...', {icon: 16, shade: 0.01, time: false}); |
| | | $.ajax({ |
| | | url: baseUrl+"/locDetl/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }); |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(confirmIndex){ |
| | | layer.close(confirmIndex); |
| | | exportTableData(obj.config.cols[0], baseUrl+"/manLocDetl/export/auth", table, layer); |
| | | }); |
| | | break; |
| | | } |
| | |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = { |
| | | }; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | var searchData = getSearchData(); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | | where: searchData, |
| | | page: { |
| | |
| | | $("#search").click(); |
| | | } |
| | | }); |
| | | |
| | | function getSearchData() { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | return searchData; |
| | | } |
| | | |
| | | function getExportColumns(cols) { |
| | | var titles = []; |
| | | var fields = []; |
| | | cols.map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | return { |
| | | titles: titles, |
| | | fields: fields |
| | | }; |
| | | } |
| | | |
| | | function exportTableData(cols, exportUrl, table, layer) { |
| | | var exportColumns = getExportColumns(cols); |
| | | var loadIndex = layer.msg('正在导出...', {icon: 16, shade: 0.01, time: false}); |
| | | $.ajax({ |
| | | url: exportUrl, |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | 'locDetl': getSearchData(), |
| | | 'fields': exportColumns.fields |
| | | }), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | table.exportFile(exportColumns.titles, res.data, 'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, |
| | | error: function () { |
| | | layer.msg('导出失败,请稍后重试'); |
| | | }, |
| | | complete: function () { |
| | | layer.close(loadIndex); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | // 监听排序事件 |
| | | table.on('sort(locDetl)', function (obj) { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | var searchData = getSearchData(); |
| | | searchData['orderByField'] = obj.field; |
| | | searchData['orderByType'] = obj.type; |
| | | tableIns.reload({ |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | var exportData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | exportData[this.name] = this.value; |
| | | }); |
| | | var param = { |
| | | 'locDetl': exportData, |
| | | 'fields': fields |
| | | }; |
| | | var loadIndex = layer.msg('正在导出...', {icon: 16, shade: 0.01, time: false}); |
| | | $.ajax({ |
| | | url: baseUrl+"/locDetl/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify(param), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | layer.closeAll(); |
| | | if (res.code === 200) { |
| | | table.exportFile(titles,res.data,'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg) |
| | | } |
| | | } |
| | | }); |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(confirmIndex){ |
| | | layer.close(confirmIndex); |
| | | exportTableData(obj.config.cols[0], baseUrl+"/manLocDetl/export/auth", table, layer); |
| | | }); |
| | | break; |
| | | } |
| | |
| | | }); |
| | | |
| | | function tableReload(child) { |
| | | var searchData = { |
| | | }; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | var searchData = getSearchData(); |
| | | (child ? parent.tableIns : tableIns).reload({ |
| | | where: searchData, |
| | | page: { |
| | |
| | | $("#search").click(); |
| | | } |
| | | }); |
| | | |
| | | function getSearchData() { |
| | | var searchData = {}; |
| | | $.each($('#search-box [name]').serializeArray(), function() { |
| | | searchData[this.name] = this.value; |
| | | }); |
| | | return searchData; |
| | | } |
| | | |
| | | function getExportColumns(cols) { |
| | | var titles = []; |
| | | var fields = []; |
| | | cols.map(function (col) { |
| | | if (col.type === 'normal' && col.hide === false && col.toolbar == null) { |
| | | titles.push(col.title); |
| | | fields.push(col.field); |
| | | } |
| | | }); |
| | | return { |
| | | titles: titles, |
| | | fields: fields |
| | | }; |
| | | } |
| | | |
| | | function exportTableData(cols, exportUrl, table, layer) { |
| | | var exportColumns = getExportColumns(cols); |
| | | var loadIndex = layer.msg('正在导出...', {icon: 16, shade: 0.01, time: false}); |
| | | $.ajax({ |
| | | url: exportUrl, |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: JSON.stringify({ |
| | | 'locDetl': getSearchData(), |
| | | 'fields': exportColumns.fields |
| | | }), |
| | | dataType:'json', |
| | | contentType:'application/json;charset=UTF-8', |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | table.exportFile(exportColumns.titles, res.data, 'xls'); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg); |
| | | } |
| | | }, |
| | | error: function () { |
| | | layer.msg('导出失败,请稍后重试'); |
| | | }, |
| | | complete: function () { |
| | | layer.close(loadIndex); |
| | | } |
| | | }); |
| | | } |
| | |
| | | </div> |
| | | <script type="text/html" id="toolbar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="margin-top: 10px">导出</button> |
| | | <button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="exportData" style="margin-top: 10px">导出</button> |
| | | </div> |
| | | </script> |
| | | |