增加‘商品类别’的筛选功能

This commit is contained in:
季圣华
2019-06-23 23:47:40 +08:00
parent 83be4dca33
commit a9874a4928
9 changed files with 88 additions and 69 deletions

View File

@@ -22,6 +22,14 @@
closable="false"> closable="false">
<table id="searchTable"> <table id="searchTable">
<tr> <tr>
<td>类别:</td>
<td>
<input name="searchParentName" id="searchParentName" style="width: 100px;" readonly="readonly"/>
<a href="javascript:void(0)" class="l-btn l-btn-plain" group="" style="height: 25px;" id="lookForSelectMaterialCategory">
<span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left"></span></span></a>
<input name="searchParentId" id="searchParentId" type="hidden"/>
</td>
<td>&nbsp;</td>
<td>品名:</td> <td>品名:</td>
<td> <td>
<input name="searchName" id="searchName" style="width:80px;"/> <input name="searchName" id="searchName" style="width:80px;"/>
@@ -76,7 +84,7 @@
<td style="height:30px;">类别</td> <td style="height:30px;">类别</td>
<td style="padding:5px" colspan="3"> <td style="padding:5px" colspan="3">
<input name="parentName" id="parentName" style="width: 180px;height: 20px" readonly="readonly"/> <input name="parentName" id="parentName" style="width: 180px;height: 20px" readonly="readonly"/>
<a href="javascript:void(0)" class="l-btn l-btn-plain" group="" id="lookForSelectMaterialCategory"> <a href="javascript:void(0)" class="l-btn l-btn-plain" group="" id="lookForMaterialCategory">
<span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left"></span></span></a> <span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left"></span></span></a>
<input name="parentid" id="parentid" type="hidden"/> <input name="parentid" id="parentid" type="hidden"/>
</td> </td>
@@ -274,18 +282,14 @@
<script type="text/javascript"> <script type="text/javascript">
var materialCategoryList = null; var materialCategoryList = null;
var types = ""; var types = "";
var setCategoryId = "1";
var cid = 1;
var multiple = 0; //倍数 var multiple = 0; //倍数
var mPropertyList = null; //商品属性列表 var mPropertyList = null; //商品属性列表
var mPropertyListShort = ""; //商品属性列表-传值 var mPropertyListShort = ""; //商品属性列表-传值
var clickType = ""; //记录从哪里点击的类别弹窗
//初始化界面 //初始化界面
$(function () { $(function () {
//初始化系统基础信息 //初始化系统基础信息
initMProperty(); initMProperty();
initSystemData(1);
initSelectInfo("search_first");
initSelectInfo("edit_first");
manyUnitFun(); manyUnitFun();
priceKeyUp();//价格触发事件 priceKeyUp();//价格触发事件
initMPropertyShort(); //初始化商品属性 initMPropertyShort(); //初始化商品属性
@@ -320,7 +324,7 @@
}); });
} }
function initSystemData(parentid_search) { function initMCData(parentid_search) {
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/materialCategory/getAllList", url: "/materialCategory/getAllList",
@@ -333,6 +337,16 @@
success: function (res) { success: function (res) {
if(res && res.code === 200){ if(res && res.code === 200){
materialCategoryList = res.data; materialCategoryList = res.data;
if (materialCategoryList != null) {
options = "";
for (var i = 0; i < materialCategoryList.length; i++) {
var materialCategory = materialCategoryList[i];
types += materialCategory.id + ',';
}
types += parentid_search;
} else {
types = parentid_search;
}
} else { } else {
$.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error'); $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
return; return;
@@ -341,26 +355,6 @@
}); });
} }
//初始化页面选项卡
function initSelectInfo(lei) {
var options = "";
if (materialCategoryList != null) {
options = "";
for (var i = 0; i < materialCategoryList.length; i++) {
var materialCategory = materialCategoryList[i];
if (0 == i) {
mcId = materialCategory.id;
}
options += '<option value="' + materialCategory.id + '">' + materialCategory.name + '</option>';
if (lei == "search_second" || lei == "type_second" || lei == "search_three") {
types += materialCategory.id + ',';
}
}
}
}
//防止表单提交重复 //防止表单提交重复
function initForm() { function initForm() {
$('#materialFM').form({ $('#materialFM').form({
@@ -975,13 +969,8 @@
function setOutputFun() { function setOutputFun() {
var name = $.trim($("#searchName").val()); var name = $.trim($("#searchName").val());
var model = $.trim($("#searchModel").val()); var model = $.trim($("#searchModel").val());
if (setCategoryId != "1") {
cid = 2;
} else {
cid = 1;
}
window.location.href = "/material/exportExcel?browserType=" + getOs() window.location.href = "/material/exportExcel?browserType=" + getOs()
+ "&name=" + name + "&model=" + model + "&categoryId=" + cid + "&categoryIds=" + setCategoryId; + "&name=" + name + "&model=" + model + "&categoryIds=" + types;
} }
//增加 //增加
var url; var url;
@@ -1389,12 +1378,6 @@
function showMaterialDetails(pageNo, pageSize) { function showMaterialDetails(pageNo, pageSize) {
var name = $.trim($("#searchName").val()); var name = $.trim($("#searchName").val());
var model = $.trim($("#searchModel").val()); var model = $.trim($("#searchModel").val());
if (setCategoryId != "1") {
cid = 2;
}
else {
cid = 1;
}
$.ajax({ $.ajax({
type: "get", type: "get",
url: "/material/list", url: "/material/list",
@@ -1403,8 +1386,7 @@
search: JSON.stringify({ search: JSON.stringify({
name: name, name: name,
model: model, model: model,
categoryId: cid, categoryIds: types,
categoryIds: setCategoryId,
mpList: mPropertyListShort mpList: mPropertyListShort
}), }),
currentPage: pageNo, currentPage: pageNo,
@@ -1428,8 +1410,10 @@
//重置按钮 //重置按钮
$("#searchResetBtn").unbind().bind({ $("#searchResetBtn").unbind().bind({
click: function () { click: function () {
$("#searchParentName").val("");
$("#searchParentId").val("");
$("#searchName").val(""); $("#searchName").val("");
setCategoryId = "1"; types = ""; //清空类别
//加载完以后重新初始化 //加载完以后重新初始化
$("#searchBtn").click(); $("#searchBtn").click();
} }
@@ -1505,8 +1489,9 @@
}, 3300); }, 3300);
}); });
} }
//查询父级商品类别
$("#lookForSelectMaterialCategory").on("click", function () { //商品类别选择
function materialCategoryDlgFun() {
$('#forSelectMaterialCategoryDlg').dialog({ $('#forSelectMaterialCategoryDlg').dialog({
title: '商品类别选择', title: '商品类别选择',
width: webW/2, width: webW/2,
@@ -1517,6 +1502,16 @@
modal: true, modal: true,
resizable:true resizable:true
}); });
}
//查询父级商品类别
$("#lookForSelectMaterialCategory").on("click", function () {
clickType = "selectBtn";
materialCategoryDlgFun();
});
$("#lookForMaterialCategory").on("click", function () {
clickType = "editBtn";
materialCategoryDlgFun();
}); });
</script> </script>

View File

@@ -79,6 +79,7 @@
<script type="text/javascript"> <script type="text/javascript">
var url; var url;
var clickType = ""; //记录从哪里点击的类别弹窗
//初始化界面 //初始化界面
$(function () { $(function () {
var treeHeight=webH-35; var treeHeight=webH-35;

View File

@@ -46,8 +46,21 @@
function forSelectMaterialCategory(node) { function forSelectMaterialCategory(node) {
console.log(node); console.log(node);
$("#parentName").val(node.text); if(clickType) {
$("#parentid").val(node.id); if(clickType == "selectBtn") {
$("#searchParentName").val(node.text);
$("#searchParentId").val(node.id);
types = "";
initMCData(node.id);
} else if(clickType == "editBtn") {
$("#parentName").val(node.text);
$("#parentid").val(node.id);
}
}
else {
$("#parentName").val(node.text);
$("#parentid").val(node.id);
}
$('#forSelectMaterialCategoryDlg').dialog('close'); $('#forSelectMaterialCategoryDlg').dialog('close');
} }
}); });

View File

@@ -192,7 +192,6 @@ public class MaterialController {
* 生成excel表格 * 生成excel表格
* @param name * @param name
* @param model * @param model
* @param categoryId
* @param categoryIds * @param categoryIds
* @param request * @param request
* @param response * @param response
@@ -201,14 +200,13 @@ public class MaterialController {
@GetMapping(value = "/exportExcel") @GetMapping(value = "/exportExcel")
public BaseResponseInfo exportExcel(@RequestParam("name") String name, public BaseResponseInfo exportExcel(@RequestParam("name") String name,
@RequestParam("model") String model, @RequestParam("model") String model,
@RequestParam("categoryId") Long categoryId,
@RequestParam("categoryIds") String categoryIds, @RequestParam("categoryIds") String categoryIds,
HttpServletRequest request, HttpServletResponse response)throws Exception { HttpServletRequest request, HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String message = "成功"; String message = "成功";
try { try {
List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryId, categoryIds); List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryIds);
String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"}; String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"};
String title = "商品信息"; String title = "商品信息";
List<String[]> objects = new ArrayList<String[]>(); List<String[]> objects = new ArrayList<String[]>();

View File

@@ -20,7 +20,6 @@ public interface MaterialMapperEx {
List<MaterialVo4Unit> selectByConditionMaterial( List<MaterialVo4Unit> selectByConditionMaterial(
@Param("name") String name, @Param("name") String name,
@Param("model") String model, @Param("model") String model,
@Param("categoryId") Long categoryId,
@Param("categoryIds") String categoryIds, @Param("categoryIds") String categoryIds,
@Param("mpList") String mpList, @Param("mpList") String mpList,
@Param("offset") Integer offset, @Param("offset") Integer offset,
@@ -29,7 +28,6 @@ public interface MaterialMapperEx {
Long countsByMaterial( Long countsByMaterial(
@Param("name") String name, @Param("name") String name,
@Param("model") String model, @Param("model") String model,
@Param("categoryId") Long categoryId,
@Param("categoryIds") String categoryIds, @Param("categoryIds") String categoryIds,
@Param("mpList") String mpList); @Param("mpList") String mpList);
@@ -46,7 +44,6 @@ public interface MaterialMapperEx {
List<MaterialVo4Unit> findByAll( List<MaterialVo4Unit> findByAll(
@Param("name") String name, @Param("name") String name,
@Param("model") String model, @Param("model") String model,
@Param("categoryId") Long categoryId,
@Param("categoryIds") String categoryIds); @Param("categoryIds") String categoryIds);
/** /**
* 通过商品名称查询商品信息 * 通过商品名称查询商品信息

View File

@@ -34,11 +34,10 @@ public class MaterialComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model"); String model = StringUtil.getInfo(search, "model");
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
String categoryIds = StringUtil.getInfo(search, "categoryIds"); String categoryIds = StringUtil.getInfo(search, "categoryIds");
String mpList = StringUtil.getInfo(search, "mpList"); String mpList = StringUtil.getInfo(search, "mpList");
String order = QueryUtils.order(map); String order = QueryUtils.order(map);
return materialService.select(name, model,categoryId,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map)); return materialService.select(name, model,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
} }
@Override @Override
@@ -46,10 +45,9 @@ public class MaterialComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model"); String model = StringUtil.getInfo(search, "model");
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
String categoryIds = StringUtil.getInfo(search, "categoryIds"); String categoryIds = StringUtil.getInfo(search, "categoryIds");
String mpList = StringUtil.getInfo(search, "mpList"); String mpList = StringUtil.getInfo(search, "mpList");
return materialService.countMaterial(name, model,categoryId,categoryIds,mpList); return materialService.countMaterial(name, model,categoryIds,mpList);
} }
@Override @Override

View File

@@ -70,13 +70,13 @@ public class MaterialService {
return list; return list;
} }
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) public List<MaterialVo4Unit> select(String name, String model, String categoryIds,String mpList, int offset, int rows)
throws Exception{ throws Exception{
String[] mpArr = mpList.split(","); String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>(); List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;
try{ try{
list= materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows); list= materialMapperEx.selectByConditionMaterial(name, model,categoryIds,mpList, offset, rows);
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -117,10 +117,10 @@ public class MaterialService {
return resList; return resList;
} }
public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList)throws Exception { public Long countMaterial(String name, String model, String categoryIds,String mpList)throws Exception {
Long result =null; Long result =null;
try{ try{
result= materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList); result= materialMapperEx.countsByMaterial(name, model,categoryIds,mpList);
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -320,11 +320,11 @@ public class MaterialService {
return list; return list;
} }
public List<MaterialVo4Unit> findByAll(String name, String model, Long categoryId, String categoryIds)throws Exception { public List<MaterialVo4Unit> findByAll(String name, String model, String categoryIds)throws Exception {
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>(); List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;
try{ try{
list= materialMapperEx.findByAll(name, model, categoryId, categoryIds); list= materialMapperEx.findByAll(name, model, categoryIds);
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);

View File

@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -68,12 +69,9 @@ public class MaterialCategoryService {
} }
public List<MaterialCategory> getAllList(Long parentId)throws Exception { public List<MaterialCategory> getAllList(Long parentId)throws Exception {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
List<MaterialCategory> list=null; List<MaterialCategory> list=null;
try{ try{
list=materialCategoryMapper.selectByExample(example); list = getMCList(parentId);
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -83,6 +81,25 @@ public class MaterialCategoryService {
return list; return list;
} }
public List<MaterialCategory> getMCList(Long parentId)throws Exception {
List<MaterialCategory> res= new ArrayList<MaterialCategory>();
List<MaterialCategory> list=null;
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
list=materialCategoryMapper.selectByExample(example);
if(list!=null && list.size()>0) {
res.addAll(list);
for(MaterialCategory mc : list) {
List<MaterialCategory> mcList = getMCList(mc.getId());
if(mcList!=null && mcList.size()>0) {
res.addAll(mcList);
}
}
}
return res;
}
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{ public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{
List<MaterialCategory> list=null; List<MaterialCategory> list=null;
try{ try{

View File

@@ -22,7 +22,7 @@
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' and m.model like '%${model}%'
</if> </if>
<if test="categoryId != 1"> <if test="categoryIds != null">
and m.CategoryId in (${categoryIds}) and m.CategoryId in (${categoryIds})
</if> </if>
and ifnull(m.delete_Flag,'0') !='1' and ifnull(m.delete_Flag,'0') !='1'
@@ -45,7 +45,7 @@
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' and m.model like '%${model}%'
</if> </if>
<if test="categoryId != 1"> <if test="categoryIds != null">
and m.CategoryId in (${categoryIds}) and m.CategoryId in (${categoryIds})
</if> </if>
and ifnull(m.delete_Flag,'0') !='1' and ifnull(m.delete_Flag,'0') !='1'
@@ -102,7 +102,7 @@
<if test="model != null"> <if test="model != null">
and m.model like '%${model}%' and m.model like '%${model}%'
</if> </if>
<if test="categoryId != 1"> <if test="categoryIds != null">
and m.CategoryId in (${categoryIds}) and m.CategoryId in (${categoryIds})
</if> </if>
and ifnull(m.delete_Flag,'0') !='1' and ifnull(m.delete_Flag,'0') !='1'