pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户信息管理</title>
<link rel="stylesheet" type="text/css"
href="<%=basePath%>js/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css"
href="<%=basePath%>js/themes/icon.css" />
<script type="text/javascript" src="<%=basePath%>js/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
<script type="text/javascript" src='<%=basePath%>js/index.js'> </script>
src="<%=basePath%>js/jquery.easyui.1.2.6.min.js"></script>
<script type="text/javascript">
$(function(){
$("#grid").datagrid({
url:"<%=basePath%>/customer_customerJson",
columns : [[ {
field : 'custName',
title : '客户名称',
width : 200
}, {
field : 'custSource',
title : '客户来源',
width : 150
}, {
field : 'custPhone',
title : '固定电话',
width : 150
}, {field:'custMobile',title:'移动电话',width:100},
{field:'custLevel',title:'客戶級別',width:100,formatter:function(value,row,index){
if(row.dictCustLevel){
return row.dictCustLevel.dname;
}
}},{field:'-',title:'操作',width:100,formatter:function(value,row,index)
{
return "<a href='#' onclick='edit("+row.cid+")'>修改</a> <a href='#' onclick='del("+row.cid+")'>删除</a>";
}}
]],
pagination:true,
singleSelect:true,
toolbar: [{
iconCls: 'icon-add',
text:'增加',
handler: add
}]
});
});
//操作方法
var method;
//保存客户
function save(){
if(method == 'add'){
//添加客户提交
addsubmit();
}else{
//修改客户提交
editsubmit();
}
}
/**
* 修改 页面
*/
function edit(cid)
{
$('#customerForm').form('clear');
$('#customerForm').form('load','<%=basePath%>/customer_showCustomerDatagrid.action?cid='+cid);
//$('#customerForm').form('load',{"baseDictByCustIndustry":{"dictEnable":"1","dictId":"2","dictItemName":"电子商务","dictSort":2,"dictTypeCode":"001","dictTypeName":"客户行业"},"baseDictByCustLevel":{"dictEnable":"1","dictId":"22","dictItemName":"普通客户","dictSort":1,"dictTypeCode":"006","dictTypeName":"客户级别"},"baseDictByCustSource":{"dictEnable":"1","dictId":"7","dictItemName":"网络营销","dictSort":2,"dictTypeCode":"002","dictTypeName":"客户信息来源"},"custId":23,"custLinkman":"王总","custMobile":"1333333","custName":"山东黑马程序员","custPhone":"32432432"});
//$('#customerForm').form('load','../customer_update');
$('#customerWindow').window({modal: true});
$('#customerWindow').window('open');
method="update";
}
//添加客户
function add(){
$('#customerForm').form('clear');
$('#customerWindow').window({modal: true});
$('#customerWindow').window('open');
//当前操作方法为添加
method="add";
}
function addSubmit(){
$('#customerForm').form('submit',{
url:'../customer/add.action',
onSubmit: function(){
// do some check
// return false to prevent submit;
},
success:function(data){
var data = eval('(' + data + ')'); // 将json串转为js对象
if(data.success)
{
$('#customerWindow').window('close');
$('#grid').datagrid('reload');
}
$.messager.alert('提示',data.message);
}
});
}
function editSubmit(){
$('#customerForm').form('submit',{
url:'/customer_updateDatagrid.action',
onSubmit: function(){
// do some check
// return false to prevent submit;
},
success:function(data){
var data = eval('(' + data + ')'); // 将json串转为js对象
if(data.success)
{
$('#customerWindow').window('close');
$('#grid').datagrid('reload');
}
$.messager.alert('提示',data.message);
}
});
}
</script>
</head>
<body>
<table id="grid"></table>
<div id="customerWindow" class="easyui-window" close="true" title="客户信息"
style="width: 550px;height: 300px" data-options="closed:true">
<form id="customerForm" method="post">
<input name="cid" type="hidden">
<table cellpadding="5">
<tr>
<td>客户名称:</td>
<td><input type="text" name="custName" ></input></td>
<td>客户来源:</td>
<td>
<!-- <input name="baseDictByCustSource.dictId" class="easyui-combobox" data-options="url:'../system/dictListByType.action?typecode=002',textField:'dictItemName',valueField:'dictId',editable:false"/> -->
<input type="text" name="custSource">
</td>
</tr>
<tr>
<!-- <td>联系人:</td>
<td><input name="custLinkman" /></td> -->
<td>固定电话:</td>
<td><input name="custPhone" /></td>
</tr>
<tr>
<td>移动电话:</td>
<td><input name="custMobile" /></td>
<!-- <td>邮政编码:</td>
<td><input name="customerDetailVo.custZip" /></td> -->
</tr>
<!-- <tr>
<td>联系地址:</td>
<td colspan="3"><input name="customerDetailVo.custAddress" style="width:430px;"/></td>
</tr> -->
<td>客户级别:</td>
<td><input name="dictCustLevel.did" class="easyui-combobox" data-options="url:'../customer_customerLevel.action?,textField:'dname',valueField:'did',editable:false"/></td>
<tr>
<td colspan="4">
<button id="customerBtn" type="button" onclick="save()">保存</button>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
2 个解决方案
#1
<input name="dictCustLevel.did" class="easyui-combobox" data-options="url:'../customer_customerLevel.action?,textField:'dname',valueField:'did',editable:false"/>
是不是少个单引号
<input name="dictCustLevel.did" class="easyui-combobox" data-options="url:'../customer_customerLevel.action?',textField:'dname',valueField:'did',editable:false"/>
#2
没用应该是对这框架标签没搞懂
#1
<input name="dictCustLevel.did" class="easyui-combobox" data-options="url:'../customer_customerLevel.action?,textField:'dname',valueField:'did',editable:false"/>
是不是少个单引号
<input name="dictCustLevel.did" class="easyui-combobox" data-options="url:'../customer_customerLevel.action?',textField:'dname',valueField:'did',editable:false"/>
#2
没用应该是对这框架标签没搞懂