📄 setconorder.asp
字号:
<style type="text/css">
#HideDiv {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 ID="DataDictArray" LANGUAGE="javascript">
<!--
var OldPriors;
//读取父界面传过来的参数,按照该模块的要求设置各Array数组:
var ItemCount=0
var ItemID=new Array();
var ItemCode=new Array();
var ItemName=new Array();
var ItemSonCount=new Array();
var ItemAllSonCount=new Array();
function GetItem()
{
OldPriors="";
if (window.dialogArguments != null)
{
OldPriors=window.dialogArguments;
}
if(OldPriors!="")
{
var parts
parts=OldPriors.split(",");
if(parts.length>0)
{
ItemCount=parts.length;
for(var i=1;i<=ItemCount;i++)
{
ItemID[i-1]=parts[i-1];
ItemName[i-1]=parts[i-1];
ItemCode[i-1]='100'; //由于不会是层次结构,以下几个设置为哑数据即可
ItemSonCount[i-1]=0;
ItemAllSonCount[i-1]=0;
}
}
}
}
//-->
</SCRIPT>
<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
var ParentSelectedID;
var Item,ItemListIndex;
var HasChanged;
ns4=(document.layers)?true:false
ie4=(document.all)?true:false
function ItemDef(){
this.ID=0;
this.Code="";
this.Name="";
this.SonCount=0;
this.AllSonCount=0;
}
function InitArray()
{
if (ItemCount>0)
{
Item=new Array();
for (var i=0;i<ItemCount;i++)
{
Item[i]=new ItemDef();
Item[i].ID=ItemID[i];
Item[i].Code=ItemCode[i];
Item[i].Name=ItemName[i];
Item[i].SonCount=ItemSonCount[i];
Item[i].AllSonCount=ItemAllSonCount[i];
}
}
}
function ParentList_onchange()
{
if(ParentList.selectedIndex==0)
{
ParentSelectedID=0
}
else
{
ParentSelectedID=Item[parseInt(ParentList[ParentList.selectedIndex].value)].ID;
}
SetList();
}
function SetSelect()
{
var v,t,indent
var ParentListLength;
ParentListLength=0;
ParentList.options[0]=new Option("",0);
for(var i=0;i<ItemCount;i++)
{
if(Item[i].SonCount>0)
{
indent = ""
if (Item[i].Code.length > 3)
{
for (var j=1; j<=Item[i].Code.length-3;j++)
{
indent = indent + " "
}
}
v=i;
t=indent+Item[i].Name;
ParentList.options[ParentListLength+1]=new Option(t,v);
ParentListLength=ParentListLength+1;
}
}
ParentList.length=ParentListLength+1;
if(ParentSelectedID==0)
{
ParentList.selectedIndex =0;
}
else
{
for(var i=1;i<=ParentListLength;i++)
{
if(ParentSelectedID==Item[ParentList[i].value].ID)
{
ParentList.selectedIndex =i;
break;
}
}
}
}
function SetList()
{
var Index,ParentCode,ParentCodeLen;
var v,t
var SonListLength;
SonListLength=0
Index=ParentList.selectedIndex;
if(Index>0)
{
ParentCode=Item[ParentList[Index].value].Code
ParentCodeLen=ParentCode.length;
for (var i=0;i<ItemCount;i++)
{
if(Item[i].Code.substr(0,ParentCodeLen)==ParentCode && Item[i].Code.length==ParentCodeLen+3)
{
v=i;
t=Item[i].Name;
SonList.options[SonListLength]=new Option(t,v);
SonListLength=SonListLength+1;
}
}
}
else if(Index==0)
{
for (var i=0;i<ItemCount;i++)
{
if(Item[i].Code.length==3)
{
v=i;
t=Item[i].Name;
SonList.options[SonListLength]=new Option(t,v);
SonListLength=SonListLength+1;
}
}
}
SonList.length=SonListLength;
}
function MoveUP()
{
var TempText,TempValue,Diff
if(CheckItemList()==true)
{
if (ItemListIndex>0)
{
ItemListIndex=ItemListIndex-1
Diff=Item[SonList[ItemListIndex+1].value].AllSonCount-Item[SonList[ItemListIndex].value].AllSonCount
TempText=SonList[ItemListIndex].text
SonList[ItemListIndex].text=SonList[ItemListIndex+1].text
SonList[ItemListIndex+1].text=TempText
SonList.selectedIndex=ItemListIndex
TempValue=parseInt(SonList[ItemListIndex+1].value)+Diff
Exchange(SonList[ItemListIndex].value,SonList[ItemListIndex+1].value)
SonList[ItemListIndex+1].value=TempValue
SetSelect();
HasChanged=true
}
}
else
{
alert("要调整哪个条件公式的顺序?请选择。");
}
}
function MoveDown()
{
var TempText,TempValue,Diff
if(CheckItemList()==true)
{
if (ItemListIndex<SonList.length-1)
{
Diff=Item[SonList[ItemListIndex+1].value].AllSonCount-Item[SonList[ItemListIndex].value].AllSonCount
ItemListIndex=ItemListIndex+1
TempText=SonList[ItemListIndex].text
SonList[ItemListIndex].text=SonList[ItemListIndex-1].text
SonList[ItemListIndex-1].text=TempText
TempValue=parseInt(SonList[ItemListIndex].value)+Diff
SonList.selectedIndex=ItemListIndex
Exchange(SonList[ItemListIndex].value,SonList[ItemListIndex-1].value)
SonList[ItemListIndex].value=TempValue
SetSelect();
HasChanged=true
}
}
else
{
alert("要调整哪个条件公式的顺序?请选择。");
}
}
function CheckItemList()
{
ItemListIndex=SonList.selectedIndex
if(ItemListIndex == -1)
return false;
else
return true;
}
function Exchange(index1,index2)
{
index1=parseInt(index1)
index2=parseInt(index2)
//index1、index2的合法性检查
if (index1==index2||index1<0||index1>=ItemCount||index2<0||index2>=ItemCount)
{
return false;
}
else
{
//确保index1在index2的上面
if (index1>index2)
{
var indextmp
indextmp=index1;
index1=index2;
index2=indextmp;
}
//备份被移动的数据
var itemtmp1,SonCounttmp1,itemtmp2,SonCounttmp2
itemtmp1=new Array();
itemtmp2=new Array();
SonCounttmp1=parseInt(Item[index1].AllSonCount);
SonCounttmp2=parseInt(Item[index2].AllSonCount);
for (var i=0;i<=SonCounttmp1;i++)
{
itemtmp1[i]=new ItemDef();
itemtmp1[i]=Item[index1+i];
}
for (var i=0;i<=SonCounttmp2;i++)
{
itemtmp2[i]=new ItemDef();
itemtmp2[i]=Item[index2+i];
}
var start,end,diff
//处理中间数据
start=index1+SonCounttmp1+1;
end=index2-1;
diff=SonCounttmp2-SonCounttmp1;
if (end>=start)
{
if(diff>=0)
{
//index2对应的数量多,中间数据往下推,需要自下往上逐个下移
for (var i=end;i>=start;i--)
{
Item[i+diff]=Item[i];
}
}
else
{
//index2对应的数量少,中间数据往上推,需要自上往下逐个上移
for (var i=start;i<=end;i++)
{
Item[i+diff]=Item[i];
}
}
}
//拿回index2的数据到原index1处
start=index1;
end=start+SonCounttmp2;
for (var i=start;i<=end;i++)
{
Item[i]=itemtmp2[i-start];
}
//拿回index1的数据到新位置
start=index2+diff;
end=start+SonCounttmp1;
for (var i=start;i<=end;i++)
{
Item[i]=itemtmp1[i-start];
}
return true;
}
}
function Save()
{
if(HasChanged==true)
{
var Result
Result="1"
for(var i=0;i<ItemCount;i++)
{
Result=Result+","+Item[i].ID
}
window.returnValue = Result;
window.close();
}
else
{
discard=confirm("您未调整了任何顺序,退出吗?");
if(discard==true)
{
window.returnValue = "0";
window.close();
}
}
}
function Cancel()
{
if(HasChanged==true)
{
discard=confirm("您已经调整了顺序,但尚未保存。放弃您所作的输入吗?");
if(discard==true)
{
window.returnValue = "0";
window.close();
}
}
else
{
window.returnValue = "0";
window.close();
}
}
function window_onload()
{
GetItem();
ParentSelectedID=0;
InitArray();
SetSelect();
SetList();
MOVEUPP.disabled =false;
MOVEDOWNP.disabled =false;
btnSave.disabled =false;
btnCancel.disabled =false;
return true;
}
//-->
</script>
<html>
<head>
<title>设置公式</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" LANGUAGE=javascript onload="return window_onload()">
<table width=100% border=0>
<tr height="35" valign="center">
<td align="center">
<b>
调整优先级顺序
</b>
</td>
</tr>
<tr>
<td align="center">
<select id="SonList" name="SonList" size="12" style="width:200px;">
</select>
</td>
<td width="40" nowrap>
<INPUT TYPE="BUTTON" disabled VALUE="↑" ID = "MOVEUPP" NAME = "MOVEUPP" style="cursor:hand;" language="javascript" OnClick = "MoveUP();">
<br><img src="../images/space.gif" height="10"><br>顺序<br>
<br><INPUT TYPE="BUTTON" disabled VALUE="↓" ID = "MOVEDOWNP" NAME = "MOVEDOWNP" style="cursor:hand;" language="javascript" OnClick = "MoveDown();">
</td>
</tr>
<tr height=40 valign="bottom">
<td colspan="4">
<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>
<!--
ParentList在此页面用不上,但为了省得改程序,保留之,不显示出即可。
//-->
<div id=HideDiv>
<select id="ParentList" name="ParentList" size="1" style="width:200px;" LANGUAGE=javascript onchange="return ParentList_onchange()">
</select>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -