📄 setconditionfieldcolor.asp
字号:
<style type="text/css">
#FieldToConditionSelect {position:absolute;visibility:hidden;left:0;top:0;width:0;height:0;z-index:-1}
#AllConditionDetail {position:absolute;visibility:hidden;left:0;top:0;width:0;height:0;z-index:-1}
#ConditionListRow {position:absolute;visibility:hidden;left:0;top:0;width:0;height:0;z-index:-1}
</style>
<link href="../../../include/main.css" rel="stylesheet" type="text/css">
<script src="../../../include/function.js" type="text/javascript"></script>
<script src="../../../include/formulaedit.js" type="text/javascript"></script>
<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
var FieldColorStr; //颜色设置内部结构串,Condition ItemSep ColorSQLDesc ItemSep FormulaSep Condition ItemSep ColorSQLDesc FormulaSep .....
//其中的Condition,采用与查询条件类似的结构:Fldxxx ConItemSep Value GroupSep Fldxxx ConItemSep Value
var FieldColorType; //颜色设置的类型,目前只支持一种类型:FieldColorType_Condition
var FieldToConditionSelectStr; //颜色设置中的条件字段选择框
var FieldToConditionDataTypeStr; //颜色设置中各条件字段的数据类型
var ConditionDataType;
var AllConditionDetailStr;
var FormulaChanged;
//初始化
function Init()
{
ReadArgs();
InitFormula();
}
//读取父窗口传来的公式数据
function ReadArgs()
{
var parts;
FieldColorStr=JTrim(window.dialogArguments[0]);
parts=FieldColorStr.split(FormulaSep); //传上来的格式为FieldColorType FormulaSep ...
FieldColorType=parts[0];
FieldColorStr=FieldColorStr.substr(parts[0].length+1);
FieldToConditionSelectStr=window.dialogArguments[1];
FieldToConditionDataTypeStr=window.dialogArguments[2];
AllConditionDetailStr=window.dialogArguments[3];
}
//初始化公式
function InitFormula()
{
FieldToConditionSelect.innerHTML =FieldToConditionSelectStr;
AllConditionDetail.innerHTML = AllConditionDetailStr;
ConditionDataType=FieldToConditionDataTypeStr.split(",");
DrawList();
FormulaChanged=false;
frmData.btnAdd.disabled=false;
frmData.btnDel.disabled=false;
frmData.btnSetOrder.disabled=false;
frmData.btnSave.disabled=false;
frmData.btnCancel.disabled=false;
}
//根据公式数据,初始化公式的数据界面,条件List,计数
function DrawList()
{
var ConList;
var Count;
ConList="";
Count=0;
if(FieldColorStr!='')
{
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
if(Count>0)
{
for(var i=1;i<=Count;i++)
{
var Cols,CurRow;
Cols=parts[i-1].split(ItemSep);
CurRow=ConditionListRow.innerHTML;
CurRow=replace(CurRow,"[RowNum]",i);
if(!isEmpty(Cols[0]))
{
//如果选择了条件
CurRow=replace(CurRow,"[ConditionDesc]",FormatConditionToCaption(Cols[0]));
}
else
{
//如果未选择条件
CurRow=replace(CurRow,"[ConditionDesc]","");
}
CurRow=replace(CurRow,"[FieldColorDesc]",ShowColor(Cols[1]));
ConList=ConList + CurRow
}
}
}
ConCount.innerHTML ="目前共有" + Count + "种颜色";
ConditionList.innerHTML = "<table width=100% cellspacing=1 bgcolor=999999>"+ConList+"</table>";
}
//将条件中的字段id还原成字段名称[XXX],用于在页面中显示
function FormatToCaption(Desc)
{
var Count,Caption,FieldID;
Count=FieldToCondition.length
for(var i=1;i<=Count-1;i++) //抛弃了最前面的空选项
{
Caption=FieldToCondition[i].text;
Caption='['+Caption+']';
FieldID=FieldToCondition[i].value;
FieldID='[Fld'+FieldID+']';
Desc=replace(Desc,FieldID,Caption);
}
return(Desc);
}
//颜色值用该颜色的方块字来显示
function ShowColor(Desc)
{
Desc="<FONT color='" + Desc + "'>█</FONT>"
return(Desc);
}
function AddRecord()
{
var myScreen,myTop,myLeft;
myTop=window.screenTop-45;
myLeft=window.screenLeft+15;
var Args=new Array(4)
Args[0]="";
Args[1]=FieldToConditionSelectStr;
Args[2]=FieldToConditionDataTypeStr;
Args[3]=AllConditionDetailStr;
myScreen="dialogwidth:500px;dialogheight:235px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
var ret;
ret=window.showModalDialog("setfieldcolor.asp",Args,myScreen);
if(typeof(ret)!="undefined")
{
if(ret.charAt(0)=="1")
{
AddFormula(ret.substr(2))
FormulaChanged="1";
DrawList();
}
}
}
function AddFormula(formula)
{
if(FieldColorStr=="")
FieldColorStr=formula;
else
FieldColorStr=FieldColorStr+FormulaSep+formula;
}
function DelRecord()
{
var parts,newFormula,Count,DelCount;
newFormula="";
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
DelCount=0;
if(JTrim(FieldColorStr)!='' && Count>0)
{
for(var i=1;i<=Count;i++)
{
var chkDel;
eval("chkDel=frmData.chk"+i+".status")
if(chkDel==true)
{
FormulaChanged="1";
DelCount=DelCount+1;
}
else
{
if(newFormula=="")
newFormula=parts[i-1];
else
newFormula=newFormula+FormulaSep+parts[i-1];
}
}
if(DelCount>0)
{
FieldColorStr=newFormula;
DrawList();
}
else
{
alert("您要删除哪项条件颜色?请选择。")
}
}
else
{
alert("不存在任何条件颜色可删除。")
}
}
//index should be 1 based
function EditFormula(index)
{
var myScreen,myTop,myLeft;
myTop=window.screenTop-45;
myLeft=window.screenLeft+15;
var Args=new Array(4)
Args[0]=GetFormula(index);
Args[1]=FieldToConditionSelectStr;
Args[2]=FieldToConditionDataTypeStr;
Args[3]=AllConditionDetailStr;
myScreen="dialogwidth:500px;dialogheight:235px;dialogtop:"+myTop+"px;dialogleft:"+myLeft+"px;Status:0;center:1;resizable=1;"
var ret;
ret=window.showModalDialog("setfieldcolor.asp",Args,myScreen);
if(typeof(ret)!="undefined")
{
if(ret.charAt(0)=="1")
{
ReplaceFormula(index,ret.substr(2))
FormulaChanged="1";
DrawList();
}
}
}
//index should be 1 based
function GetFormula(index)
{
var parts,Formula,Count;
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
if(index<=Count)
{
for(var i=1;i<=Count;i++)
{
if(i==index)
{
Formula=parts[i-1];
}
}
}
else
{
Formula="";
}
return(Formula);
}
//index should be 1 based
function ReplaceFormula(index,formula)
{
var parts,newFormula,curpart;
newFormula="";
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
if(index<=Count)
{
for(var i=1;i<=Count;i++)
{
if(i!=index)
curpart=parts[i-1];
else
curpart=formula;
if(newFormula=="")
newFormula=curpart;
else
newFormula=newFormula+FormulaSep+curpart;
}
FieldColorStr=newFormula;
}
}
function SetOrder()
{
var parts,Priors,Count;
Priors="";
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
if(Count>1)
{
for(var i=1;i<=Count;i++)
{
if(Priors=="")
Priors=i.toString();
else
Priors=Priors+","+i.toString();
}
}
else
{
alert("具有多个条件颜色时才有必要调整顺序。")
return(false);
}
var ret;
ret=window.showModalDialog("setconorder.asp",Priors,"dialogwidth:360px;dialogheight:350px;Status:0;center:1;resizable=1;");
if(typeof(ret)!="undefined")
{
//ret返回值,公式内部结构串,ConFieldID,ConRangeFrom,ConRangeTo,SQLDesc,Divisor
if(ret.charAt(0)=="1")
{
ret=ret.substr(2);
parts=ret.split(",");
Count=parts.length;
if(Count>0)
{
var newformula;
newformula="";
for(var i=1;i<=Count;i++)
{
if(newformula=="")
newformula=GetFormula(parts[i-1]);
else
newformula=newformula + FormulaSep + GetFormula(parts[i-1]);
}
FormulaChanged="1";
FieldColorStr=newformula;
DrawList();
}
}
}
}
function SelectAll()
{
var FlipTo;
var parts,Count;
if(frmData.chkAll.status==true)
FlipTo="true";
else
FlipTo="false";
parts=FieldColorStr.split(FormulaSep);
Count=parts.length;
if(JTrim(FieldColorStr)!='' && Count>0)
{
for(var i=1;i<=Count;i++)
{
eval("frmData.chk"+i+".status="+FlipTo);
}
}
}
function Save()
{
if(FormulaChanged==true)
{
FieldColorStr=JTrim(FieldColorStr);
if(FieldColorStr.length>0)
window.returnValue = "1," + FieldColorType + FormulaSep + FieldColorStr;
else
window.returnValue = "1";
}
else
window.returnValue = "0";
window.close();
}
function Cancel()
{
window.returnValue = "0";
window.close();
}
//-->
</script>
<html>
<head>
<title>颜色设置</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" LANGUAGE=javascript onload="return Init()">
<form METHOD="post" name="frmData">
<table width="95%" border=0 align=center CELLSPACING=0 CELLPADDING="0">
<tr height="35">
<td colspan=2>
<b id=myTitle>
按条件确定字段值的显示颜色
</b>
</td>
</tr>
<tr height=20>
<td width="50%">
<p align="left" id="ConCount">
</p>
</td>
<td width="50%">
<p align="right">
<input type="button" name="btnAdd" disabled value="新增" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return AddRecord()">
<input type="button" name="btnDel" disabled value="删除" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return DelRecord()">
<input type="button" name="btnSetOrder" disabled value="调整顺序" style="cursor:hand; WIDTH: 80px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return SetOrder()">
</p>
</td>
</tr>
<tr>
<td colspan=2>
<table width=100% cellspacing=1 bgcolor=999999>
<tr>
<td bgcolor=white width=1% title='全选/全清'><INPUT name=chkAll onClick=SelectAll() type=checkbox></td>
<td bgcolor=white width=15%>优先级</td>
<td bgcolor=white width=75%>条件</td>
<td bgcolor=white width=10%>颜色</td>
</tr>
</table>
</td>
</tr>
<tr height=207 valign="top">
<td colspan=2>
<p align="left" id="ConditionList">
</p>
</td>
</tr>
<tr height=40 valign=bottom>
<td colspan="2">
<table width="100%">
<tr>
<td width="25%"></td>
<td width="25%"><input id="btnSave" type="button" disabled value="确定" name="btnSave" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Save()"></td>
<td width="25%"><input id="btnCancel" type="button" disabled value="取消" name="btnCancel" style="cursor:hand; WIDTH: 50px; HEIGHT: 24px" LANGUAGE="javascript" onclick="return Cancel()"></td>
<td width="25%"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<div id=ConditionListRow>
<tr>
<td bgcolor=white width=1%><INPUT name=chk[RowNum] type=checkbox></td>
<td bgcolor=white width=15%><a LANGUAGE=javascript onclick="EditFormula('[RowNum]')" style="TEXT-DECORATION: underline;cursor:hand" )>[RowNum]</a></td>
<td bgcolor=white width=75%>[ConditionDesc]</td>
<td bgcolor=white width=10%>[FieldColorDesc]</td>
</tr>
</div>
<div id=FieldToConditionSelect>
</div>
<div id=AllConditionDetail>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -