解决商品不能录入的问题

This commit is contained in:
季圣华
2018-12-26 23:36:02 +08:00
parent 9790eb6308
commit 00933e4241
5 changed files with 44 additions and 14 deletions

View File

@@ -349,7 +349,7 @@
for (var i = 0; i < materialCategoryList.length; i++) {
var materialCategory = materialCategoryList[i];
if (0 == i) {
materialID = materialCategory.id;
mcId = materialCategory.id;
}
options += '<option value="' + materialCategory.id + '">' + materialCategory.name + '</option>';
if (lei == "search_second" || lei == "type_second" || lei == "search_three") {
@@ -1276,7 +1276,8 @@
priceStrategy.push(basic);
priceStrategy.push(other);
var objInfo = JSON.stringify($("#materialFM").serializeObject());
var objInfo = $("#materialFM").serializeObject();
objInfo.UnitId = $("#manyUnit").val();
objInfo.CategoryId = parent;
objInfo.PriceStrategy = JSON.stringify(priceStrategy); //价格列表
$.ajax({
@@ -1285,7 +1286,7 @@
dataType: "json",
async: false,
data: ({
info: objInfo
info: JSON.stringify(objInfo)
}),
success: function(res) {
if(res && res.code === 200) {
@@ -1384,8 +1385,8 @@
$("#Unit").val(materialInfo[4] == "undefined" ? "" : materialInfo[4]);
$("#RetailPrice").val(materialInfo[5] == "undefined" ? "" : materialInfo[5]);
$("#LowPrice").val(materialInfo[6] == "undefined" ? "" : materialInfo[6]);
$("#PresetPriceOne").val(materialInfo[7]);
$("#PresetPriceTwo").val(materialInfo[8]);
$("#PresetPriceOne").val(materialInfo[7] == "undefined" ? "" : materialInfo[7]);
$("#PresetPriceTwo").val(materialInfo[8] == "undefined" ? "" : materialInfo[8]);
$("#Remark").val(materialInfo[9]);
$("#manyUnit").val(materialInfo[16]);
if (materialInfo[16] != "undefined") {

View File

@@ -31,7 +31,7 @@ public class MaterialController {
private MaterialService materialService;
@GetMapping(value = "/checkIsExist")
public String checkIsExist(@RequestParam("materialId") Long id, @RequestParam("name") String name,
public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name,
@RequestParam("model") String model, @RequestParam("color") String color,
@RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
@RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,

View File

@@ -118,4 +118,7 @@ public interface MaterialMapper {
List<MaterialVo4Unit> findBySelect();
int updatePriceNullByPrimaryKey(Long id);
int updateUnitIdNullByPrimaryKey(Long id);
}

View File

@@ -72,13 +72,21 @@ public class MaterialService {
public int insertMaterial(String beanJson, HttpServletRequest request) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setEnabled(true);
return materialMapper.insertSelective(material);
}
public int updateMaterial(String beanJson, Long id) {
Material material = JSONObject.parseObject(beanJson, Material.class);
material.setId(id);
return materialMapper.updateByPrimaryKeySelective(material);
int res = materialMapper.updateByPrimaryKeySelective(material);
Long unitId = material.getUnitid();
if(unitId != null) {
materialMapper.updatePriceNullByPrimaryKey(id); //将价格置空
} else {
materialMapper.updateUnitIdNullByPrimaryKey(id); //将多单位置空
}
return res;
}
public int deleteMaterial(Long id) {
@@ -102,17 +110,18 @@ public class MaterialService {
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
String otherField1, String otherField2, String otherField3, String unit, Long unitId) {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
if (id > 0) {
example.createCriteria().andIdNotEqualTo(id);
criteria.andIdNotEqualTo(id);
}
example.createCriteria().andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
if (unit !=null) {
example.createCriteria().andUnitEqualTo(unit);
if (!StringUtil.isEmpty(unit)) {
criteria.andUnitEqualTo(unit);
}
if (unitId !=null) {
example.createCriteria().andUnitidEqualTo(unitId);
criteria.andUnitidEqualTo(unitId);
}
List<Material> list = materialMapper.selectByExample(example);
return list.size();

View File

@@ -60,4 +60,21 @@
<select id="findBySelect" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.UName from jsh_material m left join jsh_unit u on m.UnitId=u.id where m.enabled=1 ORDER BY Id asc
</select>
<update id="updatePriceNullByPrimaryKey" parameterType="java.lang.Long">
update jsh_material
set
RetailPrice = null,
LowPrice = null,
PresetPriceOne = null,
PresetPriceTwo = null
where Id = #{id,jdbcType=BIGINT}
</update>
<update id="updateUnitIdNullByPrimaryKey" parameterType="java.lang.Long">
update jsh_material
set
UnitId = null
where Id = #{id,jdbcType=BIGINT}
</update>
</mapper>