agent.js 1.66 KB
/**
 * 机构角色管理
 */
var agent = function() {

	return {

		/** 添加准备 */
		beforeAdd : function() {
			$("#add-form").form("clear");
			$('#add_dialog').dialog("open");
		},
		
		
		/** 修改用户 */
		beforeUpdate : function() {
			var row = $("#data-grid").datagrid("getSelected");
			if (row) {
				$("#add-form").form("load", row);
				$("#add_dialog").dialog("setTitle", "修改机构角色").dialog("open");
			}
		}

	}
}();

$(function() {
	
	$("#roleId").combobox({ 
		url:'/role/searchAgentRole',
		valueField: 'id',
        textField: 'roleName',
        onLoadSuccess: function (data) {
            if (data) {
                $('#roleId').combobox('setValue',data[0].id);
            }
        }
	})
        
	

	$('#add_dialog').dialog({
		title : '添加机构角色',
		width : 400,
		height : 'auto',
		closed : true,
		top : 100,
		buttons : [ {
			text : '提交',
			iconCls : 'icon-ok',
			handler : function() {
				$("#add-form").form('submit', {
					url : '/admin/agent/addAndUpdateAgentRole',
					onSubmit : function() {
						return $("#add-form").form("validate");
					},
					success : function(data) {
						if(data == "0"){
							$.messager.show({
								title : '信息',
								msg : '操作成功'
							});
							    $("#add_dialog").dialog("close");
								$('#data-grid').datagrid('reload');
						}else if(data == "1"){
							$.messager.show({
								title : '信息',
								msg : '操作失败'
								
							});
							$("#add_dialog").dialog("close");
						}else{
							$.messager.show({
								title : '信息',
								msg : '该会员不是机构会员'
							});
						}
						

					}

				})

			}
		} ]

	});
})