解决商品的bug

This commit is contained in:
季圣华
2018-12-24 22:55:32 +08:00
parent c0e43886a8
commit cce885fd4a
7 changed files with 117 additions and 37 deletions

View File

@@ -610,8 +610,8 @@
var str = '';
var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.model + 'AaBb' + rec.color + 'AaBb' + rec.unit + 'AaBb' + rec.retailprice
+ 'AaBb' + rec.lowprice + 'AaBb' + rec.presetpriceone + 'AaBb' + rec.presetpricetwo + 'AaBb' + rec.remark + 'AaBb' + rec.standard
+ 'AaBb' + rec.color + 'AaBb' + rec.packing + 'AaBb' + rec.safetystock + 'AaBb' + rec.categoryid + 'AaBb' + rec.categoryname
+ 'AaBb' + rec.unitid + 'AaBb' + rec.unitname + 'AaBb' + rec.firstoutunit + 'AaBb' + rec.firstinunit
+ 'AaBb' + rec.color + 'AaBb' + rec.packing + 'AaBb' + rec.safetystock + 'AaBb' + rec.categoryid + 'AaBb' + rec.categoryName
+ 'AaBb' + rec.unitid + 'AaBb' + rec.unitName + 'AaBb' + rec.firstoutunit + 'AaBb' + rec.firstinunit
+ 'AaBb' + rec.mfrs + 'AaBb' + rec.otherfield1 + 'AaBb' + rec.otherfield2 + 'AaBb' + rec.otherfield3;
str += '<img title="编辑" src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editMaterial(\'' + rowInfo + '\');"/>&nbsp;&nbsp;&nbsp;';
str += '<img title="删除" src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteMaterial(' + rec.id + ');"/>';
@@ -620,7 +620,7 @@
},
{title: '品名', field: 'name', width: 100},
{title: '型号', field: 'model', width: 80},
{title: '扩展信息', field: 'materialother', width: 150},
{title: '扩展信息', field: 'materialOther', width: 150},
{title: '单位', field: 'unit', width: 60},
{title: '安全存量', field: 'safetystock', width: 70},
{
@@ -1071,9 +1071,9 @@
//表格模板变更
$(".tb-other-info").html("");
for (var i = 0; i < mPropertyList.length; i++) {
if (mPropertyList[i].nativeName === "颜色") {
if (mPropertyList[i].nativename === "颜色") {
$(".tb-other-info").append(trColor);
$(".tr-color td").first().text(mPropertyList[i].anotherName);
$(".tr-color td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-color").show();
}
@@ -1081,9 +1081,9 @@
$(".tr-color").hide();
}
}
if (mPropertyList[i].nativeName === "规格") {
if (mPropertyList[i].nativename === "规格") {
$(".tb-other-info").append(trStandard);
$(".tr-standard td").first().text(mPropertyList[i].anotherName);
$(".tr-standard td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-standard").show();
}
@@ -1091,9 +1091,9 @@
$(".tr-standard").hide();
}
}
if (mPropertyList[i].nativeName === "制造商") {
if (mPropertyList[i].nativename === "制造商") {
$(".tb-other-info").append(trMfrs);
$(".tr-mfrs td").first().text(mPropertyList[i].anotherName);
$(".tr-mfrs td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-mfrs").show();
}
@@ -1101,9 +1101,9 @@
$(".tr-mfrs").hide();
}
}
if (mPropertyList[i].nativeName === "自定义1") {
if (mPropertyList[i].nativename === "自定义1") {
$(".tb-other-info").append(trOtherField1);
$(".tr-otherField1 td").first().text(mPropertyList[i].anotherName);
$(".tr-otherField1 td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-otherField1").show();
}
@@ -1111,9 +1111,9 @@
$(".tr-otherField1").hide();
}
}
if (mPropertyList[i].nativeName === "自定义2") {
if (mPropertyList[i].nativename === "自定义2") {
$(".tb-other-info").append(trOtherField2);
$(".tr-otherField2 td").first().text(mPropertyList[i].anotherName);
$(".tr-otherField2 td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-otherField2").show();
}
@@ -1121,9 +1121,9 @@
$(".tr-otherField2").hide();
}
}
if (mPropertyList[i].nativeName === "自定义3") {
if (mPropertyList[i].nativename === "自定义3") {
$(".tb-other-info").append(trOtherField3);
$(".tr-otherField3 td").first().text(mPropertyList[i].anotherName);
$(".tr-otherField3 td").first().text(mPropertyList[i].anothername);
if (mPropertyList[i].enabled) {
$(".tr-otherField3").show();
}
@@ -1373,7 +1373,7 @@
$("#mTypeName").text(categoryName).show(); //类型显示
$("#mTypeChange").show(); //按钮显示
$("#Packing").focus().val(materialInfo[12]);
$("#SafetyStock").focus().val(materialInfo[13]);
$("#SafetyStock").focus().val(materialInfo[13]=="undefined" ? "" : materialInfo[13]);
$("#Model").val(materialInfo[2]);
$("#Standard").val(materialInfo[10] == "undefined" ? "" : materialInfo[10]);
$("#Color").val(materialInfo[3] == "undefined" ? "" : materialInfo[3]);
@@ -1388,7 +1388,7 @@
$("#PresetPriceTwo").val(materialInfo[8]);
$("#Remark").val(materialInfo[9]);
$("#manyUnit").val(materialInfo[16]);
if (materialInfo[16]) {
if (materialInfo[16] != "undefined") {
$("#manyUnitCheck").prop("checked", true);
//当前为选中状态
$("#Unit").hide();
@@ -1430,8 +1430,9 @@
type: "get",
dataType: "json",
success: function (res) {
if (res && res.rows && res.rows[0]) {
var PriceStrategy = res.rows[0].PriceStrategy;
if (res && res.code === 200 && res.data && res.data[0]) {
var PriceStrategy = res.data[0].pricestrategy;
PriceStrategy = JSON.parse(PriceStrategy);
if (PriceStrategy && PriceStrategy[0] && PriceStrategy[1]) {
//基本单位
$("#basicUnit").text(PriceStrategy[0].basic.Unit);

View File

@@ -55,7 +55,7 @@ public class MaterialCategoryController {
}
}
res.code = 200;
res.data = dataList;
res.data = outer;
} catch(Exception e){
e.printStackTrace();
res.code = 500;

View File

@@ -50,6 +50,10 @@ public class MaterialVo4Unit {
private String unitName;
private String categoryName;
private String materialOther;
public Long getId() {
return id;
}
@@ -241,4 +245,20 @@ public class MaterialVo4Unit {
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public String getMaterialOther() {
return materialOther;
}
public void setMaterialOther(String materialOther) {
this.materialOther = materialOther;
}
}

View File

@@ -96,15 +96,21 @@ public interface MaterialMapper {
*/
int updateByPrimaryKey(Material record);
List<Material> selectByConditionMaterial(
List<MaterialVo4Unit> selectByConditionMaterial(
@Param("name") String name,
@Param("model") String model,
@Param("categoryId") Long categoryId,
@Param("categoryIds") String categoryIds,
@Param("mpList") String mpList,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
int countsByMaterial(
@Param("name") String name,
@Param("model") String model);
@Param("model") String model,
@Param("categoryId") Long categoryId,
@Param("categoryIds") String categoryIds,
@Param("mpList") String mpList);
String findUnitName(@Param("mId") Long mId);

View File

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

View File

@@ -31,12 +31,43 @@ public class MaterialService {
return materialMapper.selectByExample(example);
}
public List<Material> select(String name, String model, int offset, int rows) {
return materialMapper.selectByConditionMaterial(name, model, offset, rows);
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows) {
String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list = materialMapper.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
if (null != list) {
for (MaterialVo4Unit m : list) {
//扩展信息
String materialOther = "";
for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
materialOther = materialOther + ((m.getColor() == null || m.getColor().equals("")) ? "" : "(" + m.getColor() + ")");
}
if (mpArr[i].equals("规格")) {
materialOther = materialOther + ((m.getStandard() == null || m.getStandard().equals("")) ? "" : "(" + m.getStandard() + ")");
}
if (mpArr[i].equals("制造商")) {
materialOther = materialOther + ((m.getMfrs() == null || m.getMfrs().equals("")) ? "" : "(" + m.getMfrs() + ")");
}
if (mpArr[i].equals("自定义1")) {
materialOther = materialOther + ((m.getOtherfield1() == null || m.getOtherfield1().equals("")) ? "" : "(" + m.getOtherfield1() + ")");
}
if (mpArr[i].equals("自定义2")) {
materialOther = materialOther + ((m.getOtherfield2() == null || m.getOtherfield2().equals("")) ? "" : "(" + m.getOtherfield2() + ")");
}
if (mpArr[i].equals("自定义3")) {
materialOther = materialOther + ((m.getOtherfield3() == null || m.getOtherfield3().equals("")) ? "" : "(" + m.getOtherfield3() + ")");
}
}
m.setMaterialOther(materialOther);
resList.add(m);
}
}
return resList;
}
public int countMaterial(String name, String model) {
return materialMapper.countsByMaterial(name, model);
public int countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList) {
return materialMapper.countsByMaterial(name, model,categoryId,categoryIds,mpList);
}
public int insertMaterial(String beanJson, HttpServletRequest request) {

View File

@@ -1,20 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jsh.erp.datasource.mappers.MaterialMapper">
<resultMap extends="BaseResultMap" id="ResultMapList" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
<result column="unitName" jdbcType="VARCHAR" property="unitName" />
<result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultAndUnitMap" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
<result column="UName" jdbcType="VARCHAR" property="unitName" />
</resultMap>
<select id="selectByConditionMaterial" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
select *
FROM jsh_material
<select id="selectByConditionMaterial" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
select m.*,u.uname unitName, mc.name categoryName
FROM jsh_material m
left JOIN jsh_unit u on m.UnitId = u.id
left JOIN jsh_materialcategory mc on m.CategoryId = mc.id
where 1=1
<if test="name != null">
and name like '%${name}%'
and m.name like '%${name}%'
</if>
<if test="model != null">
and model like '%${model}%'
and m.model like '%${model}%'
</if>
<if test="categoryId != 1">
and m.CategoryId in (${categoryIds})
</if>
order by m.id asc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
@@ -22,14 +33,19 @@
<select id="countsByMaterial" resultType="java.lang.Integer">
SELECT
COUNT(id)
FROM jsh_material
COUNT(m.id)
FROM jsh_material m
left JOIN jsh_unit u on m.UnitId = u.id
left JOIN jsh_materialcategory mc on m.CategoryId = mc.id
WHERE 1=1
<if test="name != null">
and name like '%${name}%'
and m.name like '%${name}%'
</if>
<if test="model != null">
and model like '%${model}%'
and m.model like '%${model}%'
</if>
<if test="categoryId != 1">
and m.CategoryId in (${categoryIds})
</if>
</select>