function addEvent (o,c,h){
if(){
('on'+c,h);
}else{
(c,h,false);
}
return true;}
var selectRow;//Page-level js variable is used to store selected rows, fortunately assigning values to the row in the pop-up window
function addnode()
{
var table=("Dy_table");
var tr=();
var cell0=();
var cell1=();
var cell2=();
var cell3=();
var cell4=();
var cell5=();
var cell6=();
var cell7=();
var cell8=();
var cell9=();
var hidden1=("<input name='Dy_hd_cpdm' onpropertychange='textChange(this)' type='hidden' >");
var hidden2=("<input name='Dy_hd_sx' type='hidden' >");
var hidden3=("<input name='Dy_hd_mxid' type='hidden' >");
var hidden4=("<input name='Dy_hd_rowState' type='hidden' value='1'>");//Line status
var hidden5=("<input name='Dy_hd_dj' type='hidden' value='0'>");//Hide unit price
var input1=("<Input type='text' ondblclick='selectLj(this)' style='width:100px' name='Dy_text_ljh' >");
var input2=("<Input type='text' style='width:100px' name='Dy_text_cpmc' >");
var input3=("<Input type='text' onKeyPress='onlyNumberIn1(this)' style='width:40px' value='1' name='Dy_text_sl' >");
var input4=("<Input type='text' onKeyPress='onlyNumberIn(this)' style='width:60px' name='Dy_text_dj' >");
var input5=("<Input type='text' style='width:100px' name='Dy_text_sccj' >");
var input6=("<select name='Dy_select_clly' >");
var input7=("<Input type='text' readonly='true' style='width:40px' name='Dy_text_glf' >");
var input8=("<Input type='text' readonly='true' style='width:60px' name='Dy_text_je' >");
var input9=("<Input type='button' name='del' value='Delete' class='input-button' onclick='delnode1(this)' >")
var oOption1=("option");
var oOption2=("option");
var oOption3=("option");
var oOption4=("option");
(oOption1);
(oOption2);
(oOption3);
(oOption4);
="Contract Part";
="Contract Part";
="Foreign parts";
="Foreign parts";
="Spare Parts Part";
="Spare Parts Part";
="Manufacturer supplies parts";
="Manufacturer supplies parts";
var rowIndex;
rowIndex = -2;
var rowCount = [0].cells[0].getElementsByTagName("input")[2].value;//Number of rows visible to the user
=parseInt(rowCount)+1;
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount)+1;
= parseInt([0].cells[0].getElementsByTagName("input")[1].value) + 1;
[0].cells[0].getElementsByTagName("input")[1].value=;
(input1);
(hidden1);//Product code
(hidden2);//Internal order
(hidden3);//The Id of this line is used to modify and delete
(hidden4);//The status of this line
(input2);
(input3);
(input4);
(hidden5);
(input5);
(input6);
(input9);
(input8);
(input7);
var tt=function(obj)
{
return function(){textChange(obj);}
}
var ttt=function(obj)
{
return function(){selectChange(obj);}
}
addEvent(input1,"change",tt(input1));
addEvent(input2,"change",tt(input1));
addEvent(input3,"change",tt(input1));
addEvent(input4,"change",tt(input1));
addEvent(input5,"change",tt(input1));
addEvent(input6,"change",ttt(input6));
addEvent(input7,"change",tt(input1));
// addEvent(input8,"change",tt(input1));
}
function delnode()//Events when deletion
{
var table=("Dy_table");
var rowCount = [0].cells[0].getElementsByTagName("input")[2].value;//Number of rows visible to the user
var row;//Save the last visible row
for( var i=-1; i>=0 ;i--)
{
if([i].!="none")
{
row=[i];
break;
}
}
var rowId=[1].getElementsByTagName("input")[3].value;
if( rowCount > 1 )
{
if(rowId=="")//If the new row is not written to the database, delete it directly
{
(true);
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount) - 1;
}
else//If you need to delete it from the database, set the delete tag
{
="none";
[1].getElementsByTagName("input")[4].value = "2";
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount-1);
}
}
else
{
if(rowId == "")//When the added row is not written to the database, clear
{
(1).getElementsByTagName("input")[0].value="";
(1).getElementsByTagName("input")[1].value="";
(2).getElementsByTagName("input")[0].value="";
(3).getElementsByTagName("input")[0].value="1";
(4).getElementsByTagName("input")[0].value="";
(7).getElementsByTagName("input")[0].value="";
(5).getElementsByTagName("input")[0].value="";
(6).getElementsByTagName("select")[0].selectedIndex=0;
}
else//If you need to delete it from the database, set the delete tag
{
="none";
[1].getElementsByTagName("input")[4].value = "2";
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount) - 1;
addnode();
}
}
setClf();
}
function delnode1(o)// Events when deletion
{
var tr=;
var table=("Dy_table");
var rowCount = [0].cells[0].getElementsByTagName("input")[2].value;//Number of rows visible to the user
var rowId=[1].getElementsByTagName("input")[3].value;
if( rowCount > 1 )
{
if(rowId=="")//If the new row is not written to the database, delete it directly
{
(true);
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount) - 1;
}
else
{
="none";
[1].getElementsByTagName("input")[4].value = "2";
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount-1);
}
}
else
{
if(rowId=="")//When the new row is not written to the database, clear it directly
{
(1).getElementsByTagName("input")[0].value="";
(1).getElementsByTagName("input")[1].value="";
(2).getElementsByTagName("input")[0].value="";
(3).getElementsByTagName("input")[0].value="1";
(4).getElementsByTagName("input")[0].value="";
(7).getElementsByTagName("input")[0].value="";
(5).getElementsByTagName("input")[0].value="";
(6).getElementsByTagName("select")[0].selectedIndex=0;
}
else//If you need to delete it from the database, set the delete tag
{
="none";
[1].getElementsByTagName("input")[4].value = "2";
[0].cells[0].getElementsByTagName("input")[2].value = parseInt(rowCount) - 1;
addnode();
}
}
//The following loop is used to update the table row number when deleting from the middle
rowCount = [0].cells[0].getElementsByTagName("input")[2].value;
for( var i= 1,p = 1; i < ;i++)
{
if([i].!="none")
{
[i].cells[0].innerText = p;
p++;
}
}
setClf();
}
//Events that occur during modification
function textChange(o)
{
setClf();
var tr=;
var rowState = [1].getElementsByTagName("input")[4].value;
if( rowState == "1")
return;
else
[1].getElementsByTagName("input")[4].value = "3";
}
//Change the drop-down box option to calculate the amount, not given here
function selectChange(o)
{
var tr=;
var glf = [7].getElementsByTagName("input")[0];
var dj = [4].getElementsByTagName("input")[0];
var dj1 = [4].getElementsByTagName("input")[1];
if( ==0)//Contract
{
='0.00';
=;
setClf();
return;
}
if( ==1)//Outlined parts
{
='0.20';
=;
setClf();
return;
}
if( ==2)//Spare Parts
{
='0.00';
=;
setClf();
return;
}
if( ==3)//Product parts
{
='0.00';
='0.00';
=true;
setClf();
return;
}
}
//Verify the data before submission to ensure that there are no duplicate lines
function checkSameData()
{
var table=("Dy_table");
// var rowCount = [0].cells[0].getElementsByTagName("input")[2].value;//Number of rows visible to the user
for( var i= 1; i < ;i++)
{
if([i]. == "none"||[i].cells[1].getElementsByTagName("input")[1].value=="") continue;
for( var p= i + 1; p < ;p++)
{
if([p]. == "none") continue;
if([i].cells[1].getElementsByTagName("input")[1].(/\s+$/g,"") ==
[p].cells[1].getElementsByTagName("input")[1].(/\s+$/g,""))
{alert("There are duplicate items in the part part and cannot be saved!"); return false;}
}
}
return true;
}
//Is the parts window open
var dialogWin;
function selectLj(o)//Select parts
{
if(dialogWin == null)
{
selectRow = ;// Assign rows to global variables
dialogWin = ("../jddgl/Select_lj.aspx",window,
"center:yes;dialogWidth:550px;dialogHeight:400px;help:no;status:no;");
}
}