<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 580Web @2010-2014 f02
'URL:http://www.580Web.Cn/
'EMail:wsok85@qq.com
'QQ:253819801
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"o_Field",0)

Dim Fk_Field_Name,Fk_Field_Remark,Fk_Field_Label,Fk_Field_Help,Fk_Field_Type,Fk_Field_Option,Fk_Field_Use

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call FieldList() '自定义字段列表
	Case 2
		Call FieldAddForm() '添加自定义字段表单
	Case 3
		Call FieldAddDo() '执行添加自定义字段
	Case 4
		Call FieldEditForm() '修改自定义字段表单
	Case 5
		Call FieldEditDo() '执行修改自定义字段
	Case 6
		Call FieldDelDo() '执行删除自定义字段
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：FieldList()
'作    用：自定义字段列表
'==========================================
Sub FieldList()
%>
		<div id="rightNav">
			<ul>
				<li><a href="Field.asp?Type=2" target="dialog" width="800">添加自定义字段</a></li>
			</ul>
		</div>
		<div id="searchLine" class="font_bold">
			站点设置及菜单项自定义字段管理
		</div>
		<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th align="center">序号</th>
				<th align="center">名称</th>
				<th align="center">字段标识</th>
				<th align="center">输入类型</th>
				<th align="center">用途</th>
				<th align="center">操作</th>
			</tr>
<%
	Sqlstr="Select Fk_Field_Id,Fk_Field_Name,Fk_Field_Label,Fk_Field_Type,Fk_Field_Use From [Fk_Field] Order By Fk_Field_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1
		While Not Rs.Eof
%>
			<tr>
				<td height="20" align="center"><%=i%></td>
				<td align="center"><%=Rs("Fk_Field_Name")%></td>
				<td align="center"><%=Rs("Fk_Field_Label")%></td>
				<td align="center"><%=FKFun.GetFieldTypeName(Rs("Fk_Field_Type"))%></td>
				<td align="center"><%=FKFun.GetFieldUseName(Rs("Fk_Field_Use"))%></td>
				<td align="center"><a href="Field.asp?Type=4&Id=<%=Rs("Fk_Field_Id")%>" target="dialog" width="800">修改</a> <a href="Field.asp?Type=6&Id=<%=Rs("Fk_Field_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_Field_Name")%>”？此操作不可逆！" refreshUrl="Field.asp?Type=1" showStr="名称删除成功！">删除</a></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">&nbsp;</td>
			</tr>
		</table>
		<div id="rightBottom">
		
		</div>
<%
End Sub

'==========================================
'函 数 名：FieldAddForm()
'作    用：添加自定义字段表单
'==========================================
Sub FieldAddForm()
%>
<form id="FieldAdd" name="FieldAdd" method="post" target="ajax" action="Field.asp?Type=3" showStr="新自定义字段添加成功！" refreshUrl="Field.asp?Type=1" boxClose="1">
<div id="title">添加新自定义字段</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="15%" height="30" align="right">名称：</td>
			<td width="85%">&nbsp;<input name="Fk_Field_Name" type="text" class="input" id="Fk_Field_Name" /><span class="help" title="<p>自定义字段名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">用途：</td>
            <td>&nbsp;<select name="Fk_Field_Use" class="input" id="Fk_Field_Use">
					<option value="1">站点设置</option>
					<option value="2">菜单项</option>
				</select><span class="help" title="<p>自定义字段用途。</p>"></span>
			</td>
		</tr>
	    <tr>
	        <td height="30" align="right">备注：</td>
	        <td>&nbsp;<input name="Fk_Field_Remark" type="text" class="input" id="Fk_Field_Remark" size="40" /><span class="help" title="<p>用于识别自定义字段的用途，此段文字仅显示在自定义字段列表上，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
	    </tr>
        <tr>
            <td height="30" align="right">字段标识：</td>
            <td>&nbsp;<input name="Fk_Field_Label" type="text" class="input" id="Fk_Field_Label" size="20" /><span class="help" title="<p>自定义字段标识，配置后请尽量不要修改，请输入字母或数字，请输入1-50个字符。</p>"></span></td>
        </tr>
	    <tr>
	        <td height="30" align="right">帮助语句：</td>
	        <td>&nbsp;<input name="Fk_Field_Help" type="text" class="input" id="Fk_Field_Help" size="40" /><span class="help" title="<p>帮助语句，显示在输入框边上，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
	    </tr>
        <tr>
            <td height="30" align="right">输入类型：</td>
            <td>&nbsp;<select name="Fk_Field_Type" class="input" id="Fk_Field_Type" onchange="if($(this).val()==3){$('#Option').show();}else{$('#Option').hide();}">
                    <option value="0">文本框</option>
                    <option value="1">编辑器框</option>
                    <option value="2">上传框</option>
                    <option value="3">下拉框</option>
            </select><span class="help" title="<p>选择输入类型。</p>"></span></td>
        </tr>
        <tr id="Option" class="dis">
            <td height="30" align="right">选项：</td>
            <td>&nbsp;<textarea name="Fk_Field_Option" class="textarea" cols="60" rows="5" id="Fk_Field_Option"></textarea><span class="help" title="<p>选项每行一个：选项值||选项字符串。</p>"></span></td>
        </tr>
	</table>
</div>
<div id="bottom">
	<input type="submit" class="button" name="Enter" id="Enter" value="添 加" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：FieldAddDo
'作    用：执行添加自定义字段
'==============================
Sub FieldAddDo()
	Fk_Field_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Name")))
	Fk_Field_Remark=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Remark")))
	Fk_Field_Label=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Label")))
	Fk_Field_Help=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Help")))
	Fk_Field_Option=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Option")))
	Fk_Field_Type=Trim(Request.Form("Fk_Field_Type"))
	Fk_Field_Use=Trim(Request.Form("Fk_Field_Use"))
	Fk_Field_Option=Replace(Fk_Field_Option,"<br />","|-|")
	Call FKFun.JsonString(Fk_Field_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Call FKFun.JsonString(Fk_Field_Remark,1,255,0,"请输入备注！","备注不能大于255个字符！")
	Call FKFun.JsonString(Fk_Field_Label,1,50,0,"请输入标签！","标签不能大于50个字符！")
	Call FKFun.JsonString(Fk_Field_Help,1,255,0,"请输入帮助语句！","帮助语句不能大于255个字符！")
	Call FKFun.JsonNum(Fk_Field_Type,"请选择输入类型！")
	Call FKFun.JsonNum(Fk_Field_Use,"请选择用途！")
	If Fk_Field_Type=3 Then
		Call FKFun.JsonString(Fk_Field_Option,1,255,0,"请输入选项！","选项不能大于255个字符！")
	End If
	Sqlstr="Select Fk_Field_Id,Fk_Field_Name,Fk_Field_Remark,Fk_Field_Label,Fk_Field_Help,Fk_Field_Type,Fk_Field_Option,Fk_Field_Use From [Fk_Field] Where (Fk_Field_Name='"&Fk_Field_Name&"' Or Fk_Field_Label='"&Fk_Field_Label&"') And Fk_Field_Use="&Fk_Field_Use&""
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_Field_Name")=Fk_Field_Name
		Rs("Fk_Field_Remark")=Fk_Field_Remark
		Rs("Fk_Field_Label")=Fk_Field_Label
		Rs("Fk_Field_Help")=Fk_Field_Help
		Rs("Fk_Field_Type")=Fk_Field_Type
		Rs("Fk_Field_Option")=Fk_Field_Option
		Rs("Fk_Field_Use")=Fk_Field_Use
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该自定义标签已经存在！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：FieldEditForm()
'作    用：修改自定义字段表单
'==========================================
Sub FieldEditForm()
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_Field_Name,Fk_Field_Remark,Fk_Field_Label,Fk_Field_Help,Fk_Field_Type,Fk_Field_Option,Fk_Field_Use From [Fk_Field] Where Fk_Field_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_Field_Name=Rs("Fk_Field_Name")
		Fk_Field_Remark=Rs("Fk_Field_Remark")
		Fk_Field_Label=Rs("Fk_Field_Label")
		Fk_Field_Help=Rs("Fk_Field_Help")
		Fk_Field_Type=Rs("Fk_Field_Type")
		Fk_Field_Option=Replace(Rs("Fk_Field_Option"),"|-|",Chr(10))
		Fk_Field_Use=Rs("Fk_Field_Use")
	Else
		Rs.Close
		Call FKFun.ShowErr("自定义字段不存在！",1)
	End If
	Rs.Close
%>
<form id="FieldEdit" name="FieldEdit" method="post" target="ajax" action="Field.asp?Type=5" showStr="自定义字段修改成功！" refreshUrl="Field.asp?Type=1" boxClose="1">
<div id="title">修改自定义字段</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="15%" height="30" align="right">名称：</td>
			<td width="85%">&nbsp;<input name="Fk_Field_Name" type="text" class="input" id="Fk_Field_Name" value="<%=Fk_Field_Name%>" /><span class="help" title="<p>自定义字段名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">用途：</td>
            <td>&nbsp;<select name="Fk_Field_Use" class="input" id="Fk_Field_Use">
					<option value="1"<%=FKFun.BeSelect(Fk_Field_Use,1)%>>站点设置</option>
					<option value="2"<%=FKFun.BeSelect(Fk_Field_Use,2)%>>菜单项</option>
				</select><span class="help" title="<p>自定义字段用途。</p>"></span>
			</td>
		</tr>
	    <tr>
	        <td height="30" align="right">备注：</td>
	        <td>&nbsp;<input name="Fk_Field_Remark" type="text" class="input" id="Fk_Field_Remark" value="<%=Fk_Field_Remark%>" size="40" /><span class="help" title="<p>用于识别自定义字段的用途，此段文字仅显示在自定义字段列表上，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
	    </tr>
        <tr>
            <td height="30" align="right">字段标识：</td>
            <td>&nbsp;<input name="Fk_Field_Label" type="text" class="input" id="Fk_Field_Label" value="<%=Fk_Field_Label%>" size="20" /><span class="help" title="<p>自定义字段标识，配置后请尽量不要修改，请输入字母或数字，请输入1-50个字符。</p>"></span></td>
        </tr>
	    <tr>
	        <td height="30" align="right">帮助语句：</td>
	        <td>&nbsp;<input name="Fk_Field_Help" type="text" class="input" id="Fk_Field_Help" value="<%=Fk_Field_Help%>" size="40" /><span class="help" title="<p>帮助语句，显示在输入框边上，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
	    </tr>
        <tr>
            <td height="30" align="right">输入类型：</td>
            <td>&nbsp;<select name="Fk_Field_Type" class="input" id="Fk_Field_Type" onchange="if($(this).val()==3){$('#Option').show();}else{$('#Option').hide();}">
                    <option value="0"<%=FKFun.BeSelect(Fk_Field_Type,0)%>>文本框</option>
                    <option value="1"<%=FKFun.BeSelect(Fk_Field_Type,1)%>>编辑器框</option>
                    <option value="2"<%=FKFun.BeSelect(Fk_Field_Type,2)%>>上传框</option>
                    <option value="3"<%=FKFun.BeSelect(Fk_Field_Type,3)%>>下拉框</option>
            </select><span class="help" title="<p>选择输入类型。</p>"></span></td>
        </tr>
        <tr id="Option"<%If Fk_Field_Type<>3 Then%> class="dis"<%End If%>>
            <td height="30" align="right">选项：</td>
            <td>&nbsp;<textarea name="Fk_Field_Option" class="textarea" cols="60" rows="5" id="Fk_Field_Option"><%=Fk_Field_Option%></textarea><span class="help" title="<p>选项每行一个：选项值||选项字符串。</p>"></span></td>
        </tr>
	</table>
</div>
<div id="bottom">
	<input type="hidden" name="Id" value="<%=Id%>" />
	<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：FieldEditDo
'作    用：执行修改自定义字段
'==============================
Sub FieldEditDo()
	Fk_Field_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Name")))
	Fk_Field_Remark=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Remark")))
	Fk_Field_Label=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Label")))
	Fk_Field_Help=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Help")))
	Fk_Field_Option=FKFun.HTMLEncode(Trim(Request.Form("Fk_Field_Option")))
	Fk_Field_Type=Trim(Request.Form("Fk_Field_Type"))
	Fk_Field_Use=Trim(Request.Form("Fk_Field_Use"))
	Fk_Field_Option=Replace(Fk_Field_Option,"<br />","|-|")
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_Field_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Call FKFun.JsonString(Fk_Field_Remark,1,255,0,"请输入备注！","备注不能大于255个字符！")
	Call FKFun.JsonString(Fk_Field_Label,1,50,0,"请输入标签！","标签不能大于50个字符！")
	Call FKFun.JsonString(Fk_Field_Help,1,255,0,"请输入帮助语句！","帮助语句不能大于255个字符！")
	Call FKFun.JsonNum(Fk_Field_Type,"请选择输入类型！")
	Call FKFun.JsonNum(Fk_Field_Use,"请选择用途！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	If Fk_Field_Type=3 Then
		Call FKFun.JsonString(Fk_Field_Option,1,255,0,"请输入选项！","选项不能大于255个字符！")
	End If
	Sqlstr="Select Fk_Field_Id,Fk_Field_Name,Fk_Field_Remark,Fk_Field_Label,Fk_Field_Help,Fk_Field_Type,Fk_Field_Option,Fk_Field_Use From [Fk_Field] Where Fk_Field_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs("Fk_Field_Name")=Fk_Field_Name
		Rs("Fk_Field_Remark")=Fk_Field_Remark
		Rs("Fk_Field_Label")=Fk_Field_Label
		Rs("Fk_Field_Help")=Fk_Field_Help
		Rs("Fk_Field_Type")=Fk_Field_Type
		Rs("Fk_Field_Option")=Fk_Field_Option
		Rs("Fk_Field_Use")=Fk_Field_Use
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要修改的自定义字段不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：FieldDelDo
'作    用：执行删除自定义字段
'==============================
Sub FieldDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Field_Id From [Fk_Field] Where Fk_Field_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("要删除的自定义字段不存在！")
	End If
	Rs.Close
End Sub

Call FKFun.PageEnd()
%>
