EasyUI 增删改查完全详细

本文详尽介绍了如何使用EasyUI进行数据操作,包括使用datagrid进行多条件分页查询,通过dialog实现添加功能并加入验证,利用window弹窗进行多条件查询,以及数据的修改。此外,还涵盖了struts配置、action代码和Dao的实现。
摘要由CSDN通过智能技术生成

本实例使用EasyUI创建表格,元素,窗口,以及各种请求。增加,修改,查询及其他知识基本涵盖完全。有用到js创建和html创建.

整体概览:

多条件的分页查询

dialog对话框实现添加功能,加入验证

window弹窗多条件分页查询

修改信息


导入:
<pre name="code" class="html"><%@ page contentType="text/html; charset=utf-8"  import="java.util.*" language="java" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<link rel="stylesheet" type="text/css"  href="/portal/css/use.css"  />
<link rel="stylesheet" type="text/css"  href="/portal/css/style.css">
<link rel="stylesheet" type="text/css"  href="/portal/js/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"  href="/portal/js/jquery-easyui/themes/icon.css">
<script type="text/javascript" 	src="/portal/js/jquery-easyui/jquery-1.6.min.js"></script>
<script type="text/javascript"  src="/portal/js/jquery-easyui/jquery.easyui.min.js"></script>


 
前端js:

<script type="text/javascript">
	/* 启动时加载 */
	$(function(){
		$('#movement_ode').combobox({    
		    url:'/portal/goodsMovingTypeAction.do?type=query',    
		    valueField:'movement_types',    
		    textField:'summary'   
		});
		$("#goods_tab").datagrid({
	        title: '货品移动填报',
	        checkOnSelect: false,
	        pagination:true,
			pageSize:20,
			pageNumber:1,
			toolbar: '#tb',
	        url: '/portal/queryGoodsMovementAction.do',
	        loadMsg:'加载中...',
	        fit: true,
	        columns: [[
	            { field: 'id', checkbox: true},
	         	{ field: 'moveid', title: '编号', width:60 },
	         	{ field: 'postingdate', title: '过帐日期', width:80},
	         	{ field: 'transferreno', title: '移动单号', width:100 },
	         	{ field: 'movementcodename', title: '移动类型信息说明', width:150 },
	         	{ field: 'fromstoragelocation', title: '来源库位', width:60 },
	         	{ field: 'tostoragelocation', title: '接受库位', width:60 },
	         	{ field: 'frommaterial', title: '商品编码', width:80 },
	         	{ field: 'frombatchnumber', title: '商品批号', width:80 },
	         	{ field: 'quantity', title: '数量', width:60 },
	         	{ field: 'reasoncodename', title: '原因代码说明', width:120 },
	         	{ field: 'documentdatetime', title: '创建时间', width:80 },
	         	{ field: 'del_flag', title: '记录状态', width:80,
	         		formatter: function(value,row,index){
						if (value=='0'){							
							return '<a  href="javascript:void(0);" style="color: #000000;" οnclick="updateDelFlag('+value+','+row.moveid+');">有效</a>';
						} 
						if (value=='1'){
							return '<a  href="javascript:void(0);" style="color: #ff0000;" οnclick="updateDelFlag('+value+','+row.moveid+');">无效</a>';
						}
					}
	         	},
	         	{ field: 'exec_flag', title: '同步状态', width:80,
	         		formatter: function(value,row,index){
						if (value=='0'){
							return '未同步';
						} 
						if (value=='1'){
							return '已同步';
						}
					}
	         	}
	        ]]	        
	    }); 
		
		/* 选择ERP商品信息 */
		$("#select_erp_win").window({
			title:'选择ERP商品信息',
		    width:640,    
		    height:400,    
		    modal:true   
		}).window("close");  
		
		$("#select_erp_tab").datagrid({
			url:"/portal/queryerpgoodsAction.do",
			loadMsg:'加载中...',
			singleSelect:true,
			pagination:true,
			pageSize:10,
			pageNumber:1,
			columns:[[
				{field:'com_goods_id',title:'com_goods_id',width:100,checkbox:true},    
				{field:'goods_opcode',title:'ERP商品操作码',width:100},    
				{field:'goods_name',title:'ERP商品名称',width:100},    
				{field:'goods_desc',title:'ERP商品规格',width:100},    
				{field:'product_location',title:'ERP商品厂商',width:100},    
				{field:'unit_name',title:'ERP商品单位',width:75},    			
				{field:'package_num',title:'ERP商品包装数',width:75}     
				
			]]
		});
		
		/* 选择商品批号 */
		$("#select_batchnumber_win").window({
			title:'选择ERP商品信息',
		    width:480,    
		    height:400,    
		    modal:true   
		}).window("close");  
		
		$("#select_batchnumber_tab").datagrid({
			url:"/portal/queryerpGoodsBatchNumberAction.do",
			loadMsg:'加载中...',
			singleSelect:true,
			pagination:true,
			pageSize:10,
			pageNumber:1,
			columns:[[
				{field:'com_lot_id',title:'com_lot_id',width:100,checkbox:true},    
				{field:'lot_no',title:'商品批号',width:100},    
				{field:'produce_date',title:'生效日期',width:150},    			
				{field:'expire_date',title:'到期日期',width:150}  				
			]]
		});
		/* 移动类型改变启用原因代码 */
		$('#tb_movement_code').combobox({			
			onSelect: function(record){
				var value = $(this).combobox('getValue'); 
				$('#tb_reasoncode').combobox({    
				    url:'/portal/getAllParameterAction.do?type=reason&movement_types='+value,    
				    valueField:'reason_code',    
				    textField:'reason_name'   
				});
				$("#tb_reasoncode").combobox("enable");
			}
		});

		
	});
	
	/* 查询数据条件 */
	function checkInputQuery(){
		var startDate = $('#startDate').datebox('getValue');
		var endDate = $('#endDate').datebox('getValue');
        var movingCode = $('#movement_ode').combobox('getValue'); 
        $('#goods_tab').datagrid('options').url='/portal/queryGoodsMovementAction.do';
		$('#goods_tab').datagrid('load',{
			startDate:startDate,
			endDate:endDate,
			movingCode:movingCode,
		});        
    }
	
	/* 修改记录状态 */
	function updateDelFlag(value,row){
		$.ajax({
	        method : 'post',
	        url : '/portal/updateGoodStatusAction.do',
	        data:{ 
	        	type : "del",
	        	moveid : row,
	        	del_flag : value
	    	}, 
	        async : false,
	        dataType : 'json',
	        success : function(data) {
	            if(data){
	    			$('#goods_tab').datagrid('reload'); 
	            }else{
	            	$.messager.alert('提示',"更改记录状态失败!");
	            }
	        },
	        error : function() {
	            $.messager.alert('异常','更改记录状态异常!');
	        }
	    });
	}
	
	/* 修改同步状态,单条或多条 */
	function updateExecFlag(){
		var checkedItems = $('#goods_tab').datagrid('getSelections');
		var moveid = [];
		$.each(checkedItems, function(index, item){
			moveid.push(item.moveid);
		}); 
		var str =moveid.toString();
		if(moveid!=""){
			$.ajax({
		        method : 'post',
		        url : '/portal/updateGoodStatusAction.do',
		        data:{    
		        	type : "exec",
		        	moveids : str
		    	}, 
		 
  • 7
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 16
    评论
我可以回答这个问题。以下是一个简单的 easyui 增删改查实现的示例代码: HTML 代码: ``` <div class="easyui-layout" style="width:100%;height:100%;"> <div region="west" split="true" title="菜单" style="width:200px;"> <ul id="menu"></ul> </div> <div region="center" title="内容"> <table id="dg"></table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新增</a> <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">编辑</a> <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a> </div> </div> </div> ``` JS 代码: ``` $(function(){ $('#menu').tree({ url:'menu.json', onClick:function(node){ $('#dg').datagrid({ url:'get_users.php?menu='+node.id, fit:true, fitColumns:true, singleSelect:true, rownumbers:true, pagination:true, toolbar:'#toolbar', columns:[[ {field:'id',title:'编号',width:50}, {field:'name',title:'姓名',width:100}, {field:'sex',title:'性别',width:50}, {field:'age',title:'年龄',width:50}, {field:'phone',title:'电话',width:100}, {field:'email',title:'邮箱',width:150}, {field:'address',title:'地址',width:200}, {field:'remark',title:'备注',width:200} ]] }); } }); }); function newUser(){ $('#dlg').dialog('open').dialog('setTitle','新增'); $('#fm').form('clear'); url = 'save_user.php'; } function editUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $('#dlg').dialog('open').dialog('setTitle','编辑'); $('#fm').form('load',row); url = 'update_user.php?id='+row.id; } } function saveUser(){ $('#fm').form('submit',{ url: url, onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval('('+result+')'); if (result.errorMsg){ $.messager.show({ title: 'Error', msg: result.errorMsg }); } else { $('#dlg').dialog('close'); $('#dg').datagrid('reload'); } } }); } function destroyUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $.messager.confirm('Confirm','Are you sure you want to delete this user?',function(r){ if (r){ $.post('destroy_user.php',{id:row.id},function(result){ if (result.success){ $('#dg').datagrid('reload'); } else { $.messager.show({ title: 'Error', msg: result.errorMsg }); } },'json'); } }); } } ```
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值