Browse Source

[update]:物料信息增加料号校验

erp、
youjianchi 1 year ago
parent
commit
86989ba87e
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java
  2. 2
      ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpMaterialMapper.java
  3. 2
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpMaterialService.java
  4. 13
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java
  5. 14
      ruoyi-admin/src/main/resources/mapper/erp/ErpMaterialMapper.xml
  6. 7
      ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js
  7. 34
      ruoyi-admin/src/main/resources/templates/erp/material/add.html
  8. 31
      ruoyi-admin/src/main/resources/templates/erp/material/edit.html

12
ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java

@ -1,6 +1,8 @@
package com.ruoyi.erp.controller; package com.ruoyi.erp.controller;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -123,4 +125,14 @@ public class ErpMaterialController extends BaseController
{ {
return toAjax(erpMaterialService.deleteErpMaterialByIds(ids)); return toAjax(erpMaterialService.deleteErpMaterialByIds(ids));
} }
/**
* 校验用户名
*/
@PostMapping("/checkMaterialNoUnique")
@ResponseBody
public String checkMaterialNoUnique(ErpMaterial material)
{
return erpMaterialService.checkMaterialNoUnique(material.getMaterialNo());
}
} }

2
ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpMaterialMapper.java

@ -58,4 +58,6 @@ public interface ErpMaterialMapper
* @return 结果 * @return 结果
*/ */
public int deleteErpMaterialByIds(String[] ids); public int deleteErpMaterialByIds(String[] ids);
int checkMaterialNoUnique(String materialNo);
} }

2
ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpMaterialService.java

@ -58,4 +58,6 @@ public interface IErpMaterialService
* @return 结果 * @return 结果
*/ */
public int deleteErpMaterialById(Long id); public int deleteErpMaterialById(Long id);
String checkMaterialNoUnique(String materialNo);
} }

13
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java

@ -1,6 +1,9 @@
package com.ruoyi.erp.service.impl; package com.ruoyi.erp.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -94,4 +97,14 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
{ {
return erpMaterialMapper.deleteErpMaterialById(id); return erpMaterialMapper.deleteErpMaterialById(id);
} }
@Override
public String checkMaterialNoUnique(String materialNo) {
int count = erpMaterialMapper.checkMaterialNoUnique(materialNo);
if (count > 0)
{
return "1";
}
return "0";
}
} }

14
ruoyi-admin/src/main/resources/mapper/erp/ErpMaterialMapper.xml

@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectErpMaterialVo"> <sql id="selectErpMaterialVo">
select id, del_flag, create_by, create_time, update_by, update_time, remark, material_no, material_name, audit_status, use_status, hava_product_tem, material_type, process_method, unit, brand, describe, warehouse_dept from erp_material select id, del_flag, create_by, create_time, update_by, update_time, remark, material_no, material_name, audit_status, use_status, hava_product_tem, material_type, process_method, unit, brand, `describe`, warehouse_dept from erp_material
</sql> </sql>
<select id="selectErpMaterialList" parameterType="ErpMaterial" resultMap="ErpMaterialResult"> <select id="selectErpMaterialList" parameterType="ErpMaterial" resultMap="ErpMaterialResult">
@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="processMethod != null and processMethod != ''"> and process_method = #{processMethod}</if> <if test="processMethod != null and processMethod != ''"> and process_method = #{processMethod}</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if> <if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="brand != null and brand != ''"> and brand = #{brand}</if> <if test="brand != null and brand != ''"> and brand = #{brand}</if>
<if test="describe != null and describe != ''"> and describe = #{describe}</if> <if test="describe != null and describe != ''"> and `describe` = #{describe}</if>
<if test="warehouseDept != null and warehouseDept != ''"> and warehouse_dept = #{warehouseDept}</if> <if test="warehouseDept != null and warehouseDept != ''"> and warehouse_dept = #{warehouseDept}</if>
</where> </where>
</select> </select>
@ -52,7 +52,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectErpMaterialVo"/> <include refid="selectErpMaterialVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="checkMaterialNoUnique" resultType="java.lang.Integer">
select count(1) from erp_material where material_no = #{materialNo} limit 1
</select>
<insert id="insertErpMaterial" parameterType="ErpMaterial" useGeneratedKeys="true" keyProperty="id"> <insert id="insertErpMaterial" parameterType="ErpMaterial" useGeneratedKeys="true" keyProperty="id">
insert into erp_material insert into erp_material
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -71,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="processMethod != null">process_method,</if> <if test="processMethod != null">process_method,</if>
<if test="unit != null">unit,</if> <if test="unit != null">unit,</if>
<if test="brand != null">brand,</if> <if test="brand != null">brand,</if>
<if test="describe != null">describe,</if> <if test="describe != null">`describe`,</if>
<if test="warehouseDept != null">warehouse_dept,</if> <if test="warehouseDept != null">warehouse_dept,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -113,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="processMethod != null">process_method = #{processMethod},</if> <if test="processMethod != null">process_method = #{processMethod},</if>
<if test="unit != null">unit = #{unit},</if> <if test="unit != null">unit = #{unit},</if>
<if test="brand != null">brand = #{brand},</if> <if test="brand != null">brand = #{brand},</if>
<if test="describe != null">describe = #{describe},</if> <if test="describe != null">`describe` = #{describe},</if>
<if test="warehouseDept != null">warehouse_dept = #{warehouseDept},</if> <if test="warehouseDept != null">warehouse_dept = #{warehouseDept},</if>
</trim> </trim>
where id = #{id} where id = #{id}

7
ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js

@ -4,7 +4,12 @@ $(document).ready(function(){
submitHandler: function(form) { submitHandler: function(form) {
form.submit(); form.submit();
} }
}); });
//校验整数
jQuery.validator.addMethod("isInteger",function(value,element){
var isInteferRegExp = /^\d+$/;
return this.optional(element) || (isInteferRegExp).test(value);
},"请输入10位整数");
//手机号码验证身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$) //手机号码验证身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$)
jQuery.validator.addMethod("isPhone",function(value,element){ jQuery.validator.addMethod("isPhone",function(value,element){
var length = value.length; var length = value.length;

34
ruoyi-admin/src/main/resources/templates/erp/material/add.html

@ -9,13 +9,13 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">料号:</label> <label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="materialNo" class="form-control" type="text"> <input id = "materialNo" name="materialNo" class="form-control" type="text" required>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label> <label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="materialName" class="form-control" type="text"> <input name="materialName" class="form-control" type="text" required>
</div> </div>
</div> </div>
<!--<div class="form-group"> <!--<div class="form-group">
@ -92,7 +92,37 @@
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "erp/material" var prefix = ctx + "erp/material"
$("#form-material-add").validate({ $("#form-material-add").validate({
onkeyup: false,
rules:{
materialNo:{
isInteger: true,
minlength: 10,
maxlength: 10,
remote: {
url: prefix + "/checkMaterialNoUnique",
type: "post",
dataType: "json",
data: {
"materialNo": function() {
console.log($("#materialNo").val())
return $.common.trim($("#materialNo").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"materialNo": {
remote: "料号已经存在",
minlength: "请输入10位整数",
maxlength: "请输入10位整数",
},
},
focusCleanup: true focusCleanup: true
}); });

31
ruoyi-admin/src/main/resources/templates/erp/material/edit.html

@ -10,7 +10,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">料号:</label> <label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="materialNo" th:field="*{materialNo}" class="form-control" type="text"> <input id="materialNo" name="materialNo" th:field="*{materialNo}" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -94,6 +94,35 @@
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "erp/material"; var prefix = ctx + "erp/material";
$("#form-material-edit").validate({ $("#form-material-edit").validate({
onkeyup: false,
rules:{
materialNo:{
isInteger: true,
minlength: 10,
maxlength: 10,
remote: {
url: prefix + "/checkMaterialNoUnique",
type: "post",
dataType: "json",
data: {
"materialNo": function() {
console.log($("#materialNo").val())
return $.common.trim($("#materialNo").val());
}
},
dataFilter: function(data, type) {
return $.validate.unique(data);
}
}
},
},
messages: {
"materialNo": {
remote: "料号已经存在",
minlength: "请输入10位整数",
maxlength: "请输入10位整数",
},
},
focusCleanup: true focusCleanup: true
}); });

Loading…
Cancel
Save