<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_FreeField.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action, ChannelId
ChannelId = Easp.Get("ChannelId:n:0")
If ChannelId = 0 Then
    CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
End If
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, Alias, FieldName, IsNotNull, FieldType, IsSys
    Dim ListVal, FieldNull, Px
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "FreeField:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        Alias = oRs("Alias")
        FieldName = oRs("FieldName")
        IsNotNull = CmsFun.ChkNumEric(oRs("IsNotNull"))
        FieldType = CmsFun.ChkNumEric(oRs("FieldType"))
        ListVal = Server.HTMLEncode(oRs("ListVal") & "")
        FieldNull = Server.HTMLEncode(oRs("FieldNull") & "")
        Px = CmsFun.ChkNumEric(oRs("Px"))
        IsSys = CmsFun.ChkNumEric(oRs("IsSys"))
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/free.field.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain&ChannelId=<%=ChannelId%>">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Field.List.Asp?ChannelId=<%=ChannelId%>" class="back">自定义字段管理</a> 控制面板 &gt; 自定义字段管理 &gt; 编辑字段</div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑字段</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th>字段别名：</th>
            <td class="td2"><input type="text" name="Alias" id="Alias" class="txtInput w200" autocomplete="off" value="<%=Alias%>"<%=Easp.IIF(IsSys = 1," readonly=""readonly""","")%> datatype="*2-20" nullmsg="字段别名必须填写" errormsg="至少2个字符,最多20个字符!" />
              <span class="Validform_checktip">*,如：新闻标题</span></td>
          </tr>
          <tr>
            <th>字段名称：</th>
            <td class="td2"><input type="text" name="FieldName" id="FieldName" class="txtInput w200" autocomplete="off" value="<%=FieldName%>" readonly="readonly" datatype="zd" nullmsg="不可修改" errormsg="至少2个字符,最多20个字符!" />
              <span class="Validform_checktip">*,不可修改</span></td>
          </tr>
          <tr>
            <th>是否必填：</th>
            <td class="td2"><span id="cblItem">
              <input id="IsNotNull001" type="radio" name="IsNotNull" value="1"<%=Easp.IIF(IsNotNull = 1," checked=""checked""","")%> datatype="n0-1" />
              <label for="IsNotNull001">是</label>
              <input id="IsNotNull002" type="radio" name="IsNotNull" value="0"<%=Easp.IIF(IsNotNull = 0," checked=""checked""","")%> />
              <label for="IsNotNull002">否</label>
              </span><span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th>字段类型：</th>
            <td class="td2"><%=objFreeField.LoadFieldType(FieldType, 1)%><span class="Validform_checktip"></span></td>
          </tr>
          <tr id="FieldType1" style="display:none;">
            <th>下拉|多选|单选项：</th>
            <td class="td2"><textarea name="ListVal" id="ListVal" class="w350" datatype="*4-200" nullmsg="注:复选框、单选按钮、选择（列表菜单）的格式为：选项1=值1,选项2=值2,每个选项之间用半角英文逗号分割" errormsg="至少4个字符,最多200个字符!"><%=ListVal%></textarea>
              <span class="Validform_checktip">注:复选框、单选按钮、选择（列表菜单）的格式为：选项1=值1,选项2=值2,每个选项之间用半角英文逗号分割</span></td>
          </tr>
          <tr id="FieldType2">
            <th>为空时提示显示：</th>
            <td class="td2"><input type="text" name="FieldNull" id="FieldNull" class="txtInput w350" autocomplete="off" value="<%=FieldNull%>" datatype="*2-100" nullmsg="为空时提示显示必须填写" errormsg="至少2个字符,最多100个字符!" />
              <span class="Validform_checktip"></span></td>
          </tr>
          <tr>
            <th> 显示顺序： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="Px" id="Px" autocomplete="off" value="<%=Px%>" datatype="px" nullmsg="排序必须填写" errormsg="只能是数字越小越排前,不可为：0,最多5位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<script>
ShowType(<%=FieldType%>);
ShowIsNotNull();
</script>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_free", "edit"
    '=====================================================================
    Dim Id, Alias, IsNotNull, ListVal
    Dim FieldNull, Px, ToUrl
    '=====================================================================
    Id = Easp.Post("id:n:0")
    Alias = Trim(Easp.Post("Alias:s"))
    IsNotNull = Easp.Post("IsNotNull:n:0")
    ListVal = Trim(Easp.Post("ListVal:s"))
    FieldNull = Trim(Easp.Post("FieldNull:s"))
    Px = Easp.Post("Px:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    If Easp.IsN(Alias) Then
        CmsAdmin.JscriptMsg "字段别名必须填写！", "back", "Error", "null"
    End If
    If Px = 0 Then
        CmsAdmin.JscriptMsg "显示顺序必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("Alias") = Alias
    List("IsNotNull") = IsNotNull
    List("ListVal") = ListVal
    List("FieldNull") = FieldNull
    List("Px") = Px
    ResultVal = Easp.db.UR(TablePrefix & "FreeField", " Id = "& Id &" ", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.JscriptMsg "编辑自定义字段成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Field.List.Asp?ChannelId="& ChannelId &"", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
