<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>编辑</title>
<%@ include file="/include/header.jsp"%>
<link type="text/css" rel="stylesheet" href="${ctx}/css/baseFrame.css" />
<style>
	
</style>
</head>
<body>
	<div class="b_box">
		<input type="hidden" name="CSRFToken" value="${csrfToken}" />
		<table class="c_table m_t10">
			<tr>
				<td class="t_tit star">P13账号</td>
				<td><input type="text" id="sysuserAccount" name="username" data-validaterole="sysuserAccount" data-rule="sysuserAccount" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>' /></td>
			</tr>
			<tr>
				<td class="t_tit star">姓名</td>
				<td><input type="text" id="sysuserName" name="userCnName" data-validaterole="sysuserName" data-rule="sysuserName" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit star">分公司名称</td>
				<td><input type="text" id="sysbranchComName" name="branchComName" data-validaterole="sysbranchComName" data-rule="sysbranchComName" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit star">分公司代码</td>
				<td><input type="text" id="sysbranchComCode" name="branchComCode" data-validaterole="sysbranchComCode" data-rule="sysbranchComCode" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit">部门名称</td>
				<td><input type="text" id="sysdeptName" name="deptName" data-validaterole="sysdeptName" data-rule="sysdeptName" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit">部门代码</td>
				<td><input type="text" id="sysdeptCode" name="deptCode" data-validaterole="sysdeptCode" data-rule="sysdeptCode" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit">公司名称</td>
				<td><input type="text" id="syscompanyName" name="companyName" data-validaterole="syscompanyName" data-rule="syscompanyName" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>'  /></td>
			</tr>
			<tr>
				<td class="t_tit star">用户角色</td>
				<td><select name="status">
					<c:forEach items="${roles}" varStatus="i" var="item">
					<option value="1" data-id="${item.roleId}">${item.roleName}</option>
					</c:forEach>
				</select></td>
			</tr>
		</table>
	</div>
	<div class="m_t10 t_c">
		<input type="button" class="b_btn" id="addUser" value="确定" />
	</div>
	
	<script type="text/javascript">	
		$(function(){
			$("#addUser").click(function(){
				var username=$("#sysuserAccount").val();
				var userCnName=$("#sysuserName").val();
				var deptName=$("#sysdeptName").val();
				var deptCode=$("#sysdeptCode").val();
				var branchComName=$("#sysbranchComName").val();
				var branchComCode=$("#sysbranchComCode").val();
				var companyName=$("#syscompanyName").val();
				var roleId=$("select[name='status']").find("option:selected").data('id');
				var roleName=$("select[name='status']").find("option:selected").text();
				if(username.trim() == ""||userCnName.trim() == ""||branchComName.trim()==""||branchComCode.trim()==""){
					alert("必输项不能为空！");
					return;
				}
				$.ajax({
					type:"post",
					data:{username:username,userCnName:userCnName,roleId:roleId,roleName:roleName,deptName:deptName,
					deptCode:deptCode,branchComName:branchComName,branchComCode:branchComCode,companyName:companyName
					},
					url:"${ctx}/sysUser/addUserByOne.do",
					success:function(result){
							if(result=="该系统已存在该用户！"){
								alert(result);
								return;
							}else{
								alert("添加成功！");
								parent.location.replace("${ctx}/sysUser/list.do.do?ts=" + new Date().getTime());
							}
					}
				})
			});
			
			/*$.ajax({
			type:"POST",
			data: {markUser:markUser,caseName:caseName,applyReasonList:applyReasonList,markMess:markMess,groupNo:id},
			url:"${ctx}/outService/sendResearch.do",//请求接口
			success:function(result){
				if(result.status=="err"){
					alert(result.mess);
					return;
				}else{
					
				}						
			}*/			
		});	
	</script>
</body>
</html>