easyui-combobox三级联动

<tr height="40">
	<td class="value" width="10%"><label class="Validform_label">所在单位/公司<br>(必填):</label></td>
	<td class="txt_value" width="20%">
		<input class="easyui-combotree" style="width:190px;height:28px;"
			data-options="editable:true,prompt:'请选择',url:'<%=path%>/client/treeList',method:'get',required:true,panelHeight:'300',onBeforeSelect:function(node){checkLeaf(node);},onSelect:function(node){initClient(node);}"/>
		<input type="hidden" id="c_org" name="workTask.client_org"/>
	</td>
	<td class="value" width="10%"><label class="Validform_label">申请人姓名:</label></td>
	<td class="txt_value" width="20%"><input type="text" id="c_name" name="workTask.client_name" style="width:190px;height:28px;"
		class="easyui-textbox" /><span></span></td>
	<td class="value" width="10%"><label class="Validform_label">联系电话:</label></td>
	<td class="txt_value" width="20%"><input type="text" id="c_tel" name="workTask.client_tel" style="width:190px;height:28px;"
		class="easyui-textbox"/><span></span></td>
</tr>
<tr height="40">
	<td class="value" width="10%"><label class="Validform_label">选择对应合同:</label></td>
	<td class="txt_value" width="20%">
		<select class="easyui-combobox" style="width:190px;height:28px;" 
		id="contract" name="workTask.contract_id" data-options="valueField:'ID',textField:'NAME', onSelect: function(node){initService(node);}">
		</select>
	<span></span></td>
	<td class="value" width="10%"><label class="Validform_label">服务范围:</label></td>
	<td class="txt_value" width="20%" colspan="3">
		<select class="easyui-combobox" style="width:190px;height:28px;" id="service" name="workTask.service_id" data-options="valueField:'ID',textField:'NAME'">
		</select>
	<span></span></td>
</tr>
//点击后获取联系人信息
function initClient(node){
	if(node.id){
		$('#c_name').textbox('setValue', node.attributes.contacts);
		$('#c_tel').textbox('setValue', node.attributes.tel);
		$('#c_qq').textbox('setValue', node.attributes.qq);
		$('#c_org').val(node.text);
		// 选择具体单位后,获取该单位下的所有合同
		var org_name = node.text;
		var url = "<%=path%>/contract/getContractListByOrgName?name="+org_name;
		$("#contract").combobox('reload',url);
		<%-- $.ajax({
			url:"<%=path%>/contract/getContractListByOrgName?name="+org_name,
			type:'post',
			dataType:'json',
			success:function(data){
				if(data.result=='0'){
					console.log(data.data);
					$("#contract").append(data.data);
				}else{
					alert("你选择的单位还没有合同,请添加该单位的合同后再派发工单");
				}
			},
			error:function(res){
				
			}
		}); --%>
	}
}

// 点击合同,加载服务范围
function initService(node){
	var service_id = node.ID;
	console.log("service_id="+service_id);
	var url = "<%=path%>/contract/getServiceListByContractId?id="+service_id;
	$("#service").combobox('reload',url);
}

页面效果,涉及到三个下拉框联动
在这里插入图片描述

发布了1184 篇原创文章 · 获赞 272 · 访问量 203万+

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/104701014
今日推荐