Java full stack development---Java ERP system development: business ERP (5) improvement of staff management

Improve employee management

(1) Remove the password when querying the page

1. Visit the emp.html page of the project created above

Password is exposed
Insert picture description here

Need to block the display of the password when displaying

2. Set the comment in Emp.java in erp_entity

Insert picture description here

3. The login password disappears when you visit again

Insert picture description here
Delete the password column in emp.html and
Insert picture description here
visit again
Insert picture description here

(2) Display of gender

Modify the gender column in emp.html and
Insert picture description here
visit the emp.html page again
Insert picture description here

(3) Date formatting

1. This display is obviously wrong when querying

Insert picture description here

2. Format the date and introduce date.js

Insert picture description here

// 对Date的扩展,将 Date 转化为指定格式的String   
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,   
// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)   
// 例子:   
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423   
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18   
Date.prototype.Format = function(fmt)   
{
    
     //author: meizz   
	if(isNaN(this.getDate()))
	{
    
    
		return "";
	}
  var o = {
    
       
    "M+" : this.getMonth()+1,                 //月份   
    "d+" : this.getDate(),                    //日   
    "h+" : this.getHours(),                   //小时   
    "m+" : this.getMinutes(),                 //分   
    "s+" : this.getSeconds(),                 //秒   
    "q+" : Math.floor((this.getMonth()+3)/3), //季度   
    "S"  : this.getMilliseconds()             //毫秒   
  };   
  if(/(y+)/.test(fmt))   
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
  for(var k in o)   
    if(new RegExp("("+ k +")").test(fmt))   
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
  return fmt;   
} 
3. Introduce the js in emp.html (put the above JS into the corresponding ui file)

Insert picture description here
Insert picture description here

(4) Improvement of department name

1. Modify the mapping file in emp.hbm.xml

Insert picture description here

2. Modify Emp, java entity class

Insert picture description here

3. Modify the content on the emp.html page (add a formatter to the department)

Insert picture description here

4. Modify the listByPage method and list method of BaseAction:DisableCircularReferenceDetect禁用循环引用保护

Insert picture description here
Insert picture description here

5. Visit emp.html again: Implementation

Insert picture description here

(5) Employee add form editing

1. Set the size of the edit box in crud.js

Insert picture description here

2. In emp.html (set the text box for the new button editing)

Change gender to radio button
Insert picture description here

3. Set the corresponding add function on the add page of emp.html (set the corresponding date format)

Insert picture description here

<td>出生年月日</td>
<td>
	<input name="t.birthday" class="easyui-datebox" editable="false" > 
</td>

Insert picture description here

4. Setting of the department drop-down list (set in emp.html)

Insert picture description here
Get the department list from the dep corresponding to the foreign key in emp

<td>部门</td><td><input name="t.dep.uuid" class="easyui-combobox" data-options="
		 url:'dep_list',textField:'name',valueField:'uuid' " > 
</td>

Insert picture description here

5. Set some other properties (add verification)

(1) Set the corresponding (validated attributes) in emp.html

<td>登陆名</td>
<td><input name="t.username" class="easyui-validatebox" data-options="
required:true,missingMessage:'登录名不能为空!' "> 
</td>
<td>邮件地址</td>
<td><input name="t.email"  class="easyui-validatebox" data-options="
required:true,validType:'email',invalidMessage:'Email格式不正确'"> 
</td>

Insert picture description here
(2) Set the corresponding (validated attribute) in crud.js to verify when clicking save.
Errors cannot be submitted
Insert picture description here

//表单验证的时候当所有字段返回true的时候,该方法使用validatebox(验证框架)插件
		var isValid = $('#editForm').form('validate');
		
		if(isValid ==  false ){
    
    
			return;
		}
		
		var formdata= $('#editForm').serializeJSON();	
		$.ajax({
    
    
			url:name+'_'+method+'.action',
			data:formdata,
			dataType:'json',
			type:'post',
			success:function(value){
    
    
				if(value.success){
    
    
					$('#editWindow').window('close');
					$('#grid').datagrid('reload');
				}
				$.messager.alert('提示',value.message);				
			}
		});

Insert picture description here
(3) Department is requiredrequired:true
Insert picture description here
Insert picture description here

6. Employee search (normal form)

(1) Modify the gender in emp.html
Insert picture description here
(2) Set the drop-down list of the corresponding department
Insert picture description here
(3) Set the query conditions according to the department in EmpDao
Insert picture description here

// 根据部门查询
if (null != emp1.getDep() && null != emp1.getDep().getUuid()) {
    
    
	dc.add(Restrictions.eq("dep", emp1.getDep()));
}

(4) The condition query is successful
Insert picture description here

7. Employee search (date of birth) to query information in a specified period

(1) Modify the date in the front-end emp.html
Insert picture description here

出生年月日:<input name="t1.birthday" class="easyui-datebox" editable="false" > 
-> <input name="t2.birthday" class="easyui-datebox" editable="false" >

(2) Modify the conditions in the back-end EmpDap
Insert picture description here
(3) The query is successfulInsert picture description here

(6) Department related format processing

1. An error will be reported when you click to modify (there is no login name, real name, gender, and date format error)

Insert picture description here
Modify the get method in BaseAction. The
Insert picture description here
page successfully displays various information, but the department does not display it
Insert picture description here

2. Display department information (modify the mapJson method in BaseAction)

Insert picture description here

private String mapJson(String jsonString, String prefix) {
    
    
		Map<String, Object> map = JSON.parseObject(jsonString);
		Map<String, Object> newmap = new HashMap();
		for (String key : map.keySet()) {
    
    
			if (map.get(key) instanceof Map) {
    
    // 判断左边的类型是否和右边相同
				// key值进行拼接
				Map<String, Object> m2 = (Map<String, Object>) map.get(key);//将map.get(key)值强制转换为map
				for (String key2 : m2.keySet()) {
    
    
					newmap.put(prefix + "." + key + "." + key2, m2.get(key2));
				}
			}else {
    
    
				newmap.put(prefix + "." + key, map.get(key));
			}
		}
		return JSON.toJSONString(newmap);
	}

Running again will automatically select the corresponding department
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44757034/article/details/109243260