reprint, to Gao Wu (ALFA.WU)
Thank!
/******************************************************** is mainly used for the calculation of the table field between Start ********************************** ********************/
/**
* The Bindgridevent () function is placed in the Schedule table, the new row or edit row event after the call, because the field name of each business form, and the algorithm is inconsistent, so only in a single module implementation, other modules need to be able to copy this code to modify
* @author WUYF
* @date 2014-03-22
*/
/**
* Bind table Event
* @author WUYF
*/
function Bindgridevent ()
{
Try
{
var Objgrid = $ ("#customerStock"); Table Object
var Invqtyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invqty '}); Number
var Invsalecostedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invsalecost '}); Product price
var Discountedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' discount '}); Discount Amount Object
var Depositedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Deposit '}); Discount Rate Object
var Invmoneyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Invmoney '}); Amount Object
Number binding Leave event
$ (Invqtyedt.target). bind ("Blur", function () {
Calcmoney (); Calculate amount based on quantity or unit price change
});
Unit Price binding Leave event
$ (Invsalecostedt.target). bind ("Blur", function () {
Calcmoney (); Calculate amount based on quantity or unit price change
});
Discount Amount Bound Leave event
$ (Discountedt.target). bind ("Blur", function () {
CalcDiscount (); Calculate discount rate based on discount amount change
});
Discount Rate binding Leave event
$ (Depositedt.target). bind ("Blur", function () {
Calcdeposit (); Calculate discount amount based on discount rate change
});
Amount Bound Leave event
$ (Invmoneyedt.target). bind ("Blur", function () {
Calcmoneychange (); Recalculate unit price, discount amount, discount rate after change
});
}
catch (E)
{
Alert (e);
}
}
/**
* Recalculate unit price, discount amount, discount rate after change
*/
function Calcmoneychange ()
{
var Objgrid = $ ("#customerStock"); Table Object
var Invqtyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invqty '}); Quantity Object
var Invsalecostedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invsalecost '}); Unit Price Object
var Invmoneyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Invmoney '}); Amount Object
var Discountedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' discount '}); Discount Amount Object
var Invqtyvalue = $ (invqtyedt.target). Val (); Quantity value
var Invmoneyvalue = $ (invmoneyedt.target). Val (); Amount value
var invsalecostvalue = invmoneyvalue/(invqtyvalue*1.0); Single value
var Discountvalue = $ (discountedt.target). Val (); Discount Amount Value
$ (invsalecostedt.target). Numberbox ("SetValue", Invsalecostvalue); Assign a value to the unit price
if (Discountvalue = = 0) {
$ (discountedt.target). Numberbox ("SetValue", Invmoneyvalue); Assign value to discount amount
}
CalcDiscount (); Calculate discount rate based on discount amount
}
/**
* Calculated amount based on quantity or unit price
* @author WUYF
*/
Function Calcmoney ()
{
var Objgrid = $ ("#c Ustomerstock "); Table Object
var Invqtyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invqty '});//Quantity Object
Var Invsalecostedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invsalecost '}); Unit Price Object
var Invmoneyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Invmoney '});//Amount Object
var Discountedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' discount '}); Discount Amount Object
var invqtyvalue = $ (invqtyedt.target). Val ();//Quantity value
var invsalecostvalue = $ (invsalecostedt.target) . Val (); Single value
var invmoneyvalue = invqtyvalue * invsalecostvalue;//Amount value
var discountvalue = $ (discountedt.target). Val ( ); Discount Value
$ (invmoneyedt.target). Numberbox ("SetValue", invmoneyvalue);//Assign value to amount
if (Discountvalue = = 0) {
$ (discountedt.target). Numberbox ("SetValue", Invmoneyvalue); Assign value to discount amount
CalcDiscount ();
}
else{
CalcDiscount ();
}
}
/**
* discount rate is calculated based on the change in discount amount
* @author WUYF
*/
function CalcDiscount () {
var Objgrid = $ ("#customerStock"); Table Object
var Invmoneyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invmoney '}); Amount Object
var Discountedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' discount '}); Discount Amount Object
var Depositedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Deposit '}); Discount Rate Object
var Invmoneyvalue = $ (invmoneyedt.target). Val (); Amount value
var Discountvalue = $ (discountedt.target). Val (); Discount Amount Value
var depositvalue = discountvalue/(Invmoneyvalue * 1.0); Discount Rate value
$ (depositedt.target). Numberbox ("SetValue", Depositvalue); Assign a value to the discount rate
}
/**
* Discount amount calculated based on discount rate change
* @author WUYF
*/
function Calcdeposit () {
var Objgrid = $ ("#customerStock"); Table Object
var Invmoneyedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' Invmoney '}); Amount Object
var Discountedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex,field: ' discount '}); Discount Amount Object
var Depositedt = Objgrid.datagrid (' Geteditor ', {index:iseditingrowindex, field: ' Deposit '}); Discount Rate Object
var Invmoneyvalue = $ (invmoneyedt.target). Val (); Amount value
var Depositvalue = $ (depositedt.target). Val (); Discount Rate value
var discountvalue = Invmoneyvalue * Depositvalue; Discount Amount Value
$ (discountedt.target). Numberbox ("SetValue", Discountvalue); Discount Value Assignment
}
/******************************************************** is primarily used to calculate the End of a table between fields ************************************ ******************/
Easyui DataGrid Calculation