<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="GB2312">
  <title></title>
  <link href="css/style.css" title="style" rel="stylesheet" type="text/css" />
  <script src="js/jquery-1.6.3.min.js"></script>
</head>
<body style="background: #F3F3F3">
<div>
  <div class='list2' style='margin: 10px;'>
    <a class='you_p' href='#' style='color: #fff'>用户信息管理</a>
  </div>
  <div style='border: #B0B7BF 1px solid'>
    <table id='tbUsr' width='100%'>
    <tr bgcolor='#E5E9EC'><th><span>UID</span></th><th>登陆名</th><th>名称</th><th>编号</th><th>手机</th><th>电话</th><th>邮件</th><th>操作</th></tr>
    </table>
  </div>
</div>
<div>
  <table width='100%'><tr>
    <th><a href='javascript:history.back()' class='back' style='color: #fff'>返回</a></th>
  </tr></table>
</div>

<script>
var itype=<% write(type); %>;

<% db_Open("/NandFlash/dbCfg.db3"); %>
var jusr=<% db_QryAdv("select * from tbUser order by UID",0); %>;
<% db_Close(); %>

$(function(){
  listUsr();
});

function listUsr(){
  if (jusr.reccnt==0){
    return;
  }
  var stbl="<tr bgcolor='#E5E9EC'><th><span>UID</span></th><th>登陆名</th><th>名称</th><th>编号</th><th>手机</th><th>电话</th><th>邮件</th><th>操作</th></tr>";
  $.each(jusr.recs,function(i,n){
    stbl+="<tr id='tr"+i+"'><th>"+n.UID+"</th><th><input id='dnote"+n.Fld+"' style='width:100px' value='"+n.Note;
    stbl+="'/></th><th><input id='dfac"+n.Fld+"' style='width:40px' value='"+n.vfactor
    stbl+="'/></th><th><select id='dmode"+n.Fld+"'><option value='-1'>不做告警参数<option value='0'>不检测<option value='1'>等于<option value='2'>不等于<option value='3'>大于<option value='4'>小于<option value='10'>双值 不检测<option value='11'>双值 范围内<option value='12'>双值 范围外";
    stbl+="</select></th><th><input id='dref"+n.Fld+"' style='width:60px' value='"+n.vref
    stbl+="''/></th><th><input id='drefb"+n.Fld+"' style='width:60px' value='"+n.vref2
    stbl+="'/></th><th><input id='dtip"+n.Fld+"' style='width:120px' value='"+n.vtip;
    stbl+="'></th><th><input id='dtipb"+n.Fld+"' style='width:120px' value='"+n.vtip2;
    stbl+="'/></th><th>"+getOps(n)+"</th><tr>";
  })
  $("#tbUsr").html(stbl);
}
function getOps(n){
  sv="<a href='javascript:updUsr("+n.UID+")'>更新</a>&nbsp;&nbsp;<a href='javascript:delUsr("+n.UID+")'>删除</a>";
  return sv;
}

function saveFld(ifld){
  var sfac=$("#dfac"+ifld).attr("value");
  if(sfac=="") sfac="1";
  var sref=$("#dref"+ifld).attr("value");
  if(sref=="") sref="0";
  var sref2=$("#drefb"+ifld).attr("value");
  if(sref2=="") sref2="0";
  var spost="";
  spost+="&setval=Note='"+$("#dnote"+ifld).attr("value");
  spost+="',vfactor="+sfac;
  spost+=",vmode="+$("#dmode"+ifld).val();
  spost+=",vref="+sref;
  spost+=",vref2="+sref2;
  spost+=",vtip='"+$("#dtip"+ifld).attr("value");
  spost+="',vtip2='"+$("#dtipb"+ifld).attr("value")+"'";
  $.ajax({
    type: "POST",
    url: "omdev/smdef.asp",
    data: "op=upd2&type="+itype+"&fld="+ifld+spost,
    dataType:"json",
    success: function(msg){
      if(msg.op=="ok")
        alert("保存定义项 "+itype+"-"+ifld+" 成功!");
      else
        alert("保存定义项 "+itype+"-"+ifld+" 失败!");
    }
  });
}
</script>
</body>
</html>