JS方法如下:
function spdService_DataChanged(e) {
var cell;
var WKROW;
if (e.row > 0) {
//订正时
if ((Number(e.row) - 11) % 10 == 0) {
WKROW = e.row;
fncZaiKoSum(e.spread, WKROW);
//更新FLG
cell = e.spread.GetCellByRowCol(Number(WKROW) + 2 - 3, 50);
cell.removeAttribute("FpCellType");
e.spread.SetValue(Number(WKROW) + 2 - 3, 50, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
//更新FLG set
cell = e.spread.GetCellByRowCol(e.spread.RowCount - 1, e.col);
cell.removeAttribute("FpCellType");
e.spread.SetValue(e.spread.RowCount - 1, e.col, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
}
//生产数量1
if ((Number(e.row) - 6) % 10 == 0) {
WKROW = Number(e.row) + 5;
fncZaiKoSum(e.spread, WKROW);
//更新FLG
cell = e.spread.GetCellByRowCol(Number(WKROW) + 2 - 3, 50);
cell.removeAttribute("FpCellType");
e.spread.SetValue(Number(WKROW) + 2 - 3, 50, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
//更新FLG set
cell = e.spread.GetCellByRowCol(e.spread.RowCount - 1, e.col);
cell.removeAttribute("FpCellType");
e.spread.SetValue(e.spread.RowCount - 1, e.col, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
}
//生产数量2
if ((Number(e.row) - 7) % 10 == 0) {
WKROW = Number(e.row) + 4;
fncZaiKoSum(e.spread, WKROW);
//更新FLG
cell = e.spread.GetCellByRowCol(Number(WKROW) + 2 - 3, 50);
cell.removeAttribute("FpCellType");
e.spread.SetValue(Number(WKROW) + 2 - 3, 50, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
//更新FLG set
cell = e.spread.GetCellByRowCol(e.spread.RowCount - 1, e.col);
cell.removeAttribute("FpCellType");
e.spread.SetValue(e.spread.RowCount - 1, e.col, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
}
//取得数量1
if ((Number(e.row) - 3) % 10 == 0) {
WKROW = Number(e.row) + 8;
fncZaiKoSum(e.spread, WKROW);
//更新FLG
cell = e.spread.GetCellByRowCol(Number(WKROW) + 2 - 3, 50);
cell.removeAttribute("FpCellType");
e.spread.SetValue(Number(WKROW) + 2 - 3, 50, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
//更新FLG set
cell = e.spread.GetCellByRowCol(e.spread.RowCount - 1, e.col);
cell.removeAttribute("FpCellType");
e.spread.SetValue(e.spread.RowCount - 1, e.col, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
}
//取得数量2
if ((Number(e.row) - 4) % 10 == 0) {
WKROW = e.row + 7;
fncZaiKoSum(Number(e.spread), WKROW);
//更新FLG
cell = e.spread.GetCellByRowCol(Number(WKROW) + 2 - 3, 50);
cell.removeAttribute("FpCellType");
e.spread.SetValue(Number(WKROW) + 2 - 3, 50, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
//更新FLG set
cell = e.spread.GetCellByRowCol(e.spread.RowCount - 1, e.col);
cell.removeAttribute("FpCellType");
e.spread.SetValue(e.spread.RowCount - 1, e.col, "99999", true);
cell.setAttribute("FpCellType", "readonly");
e.spread.UpdatePostbackData();
}
}
}
function fncZaiKoSum(spd, intRow) {
var SEISANSU1 = 0;
var SEISANSU2 = 0;
var HATSU1 = 0;
var HATSU2 = 0;
var HATSUTOTAL = 0;
var HIRUZAIKO = 0;
var YORUZAIKO = 0;
var TEISEISU = 0;
var ZAIKOINDX = 0;
var SYUKOSU = 0;
var cell;
var Zenzan = Number(spd.GetValue(intRow, 1));
var INDX = Number(intRow) + 2;
for (var iCol = 3; iCol < 49; iCol++) {
if (spd.GetValue(Number(INDX) - 2, iCol) == "") {
TEISEISU = 0;
}
else {
TEISEISU = Number(spd.GetValue(Number(INDX) - 2, iCol));
}
if (spd.GetValue(Number(INDX) - 7, iCol) == "") {
SEISANSU1 = 0;
}
else {
SEISANSU1 = Number(spd.GetValue(Number(INDX) - 7, iCol));
}
if (spd.GetValue(Number(INDX) - 6, iCol) == "") {
SEISANSU2 = 0;
}
else {
SEISANSU2 = Number(spd.GetValue(Number(INDX) - 6, iCol));
}
if (spd.GetValue(Number(INDX) - 10, iCol) == "") {
HATSU1 = 0;
}
else {
HATSU1 = Number(spd.GetValue(Number(INDX) - 10, iCol));
}
if (spd.GetValue(Number(INDX) - 9, iCol) == "") {
HATSU2 = 0;
}
else {
HATSU2 = Number(spd.GetValue(Number(INDX) - 9, iCol));
}
//if (spd.GetValue(Number(INDX) - 6, iCol) == "") {
// SYUKOSU = 0;
//}
//else {
// SYUKOSU = Number(spd.GetValue(Number(INDX) - 6, iCol));
//}
//确定数合计
HATSUTOTAL = HATSU1 + HATSU2;
cell = spd.GetCellByRowCol(Number(INDX) - 8, iCol);
cell.removeAttribute("FpCellType");
if (HATSUTOTAL == 0) {
spd.SetValue(Number(INDX) - 8, iCol, "", true);
}
else {
spd.SetValue(Number(INDX) - 8, iCol, HATSUTOTAL, true);
}
cell.setAttribute("FpCellType", "readonly");
spd.UpdatePostbackData();
//昼在库数量
HIRUZAIKO = Zenzan - HATSU1 + TEISEISU;
cell = spd.GetCellByRowCol(Number(INDX) - 4, iCol);
cell.removeAttribute("FpCellType");
if (HIRUZAIKO == 0) {
spd.SetValue(Number(INDX) - 4, iCol, "", true);
}
else {
spd.SetValue(Number(INDX) - 4, iCol, HIRUZAIKO, true);
}
if (HIRUZAIKO < 0) {
spd.Cells(Number(INDX) - 4, iCol).SetForeColor("#FF0000");
}
else {
spd.Cells(Number(INDX) - 4, iCol).SetForeColor("#000000");
}
cell.setAttribute("FpCellType", "readonly");
spd.UpdatePostbackData();
//夜在库数量
YORUZAIKO = HIRUZAIKO - HATSU2 + SEISANSU1;
cell = spd.GetCellByRowCol(Number(INDX) - 3, iCol);
cell.removeAttribute("FpCellType");
if (YORUZAIKO == 0) {
spd.SetValue(Number(INDX) - 3, iCol, "", true);
}
else {
spd.SetValue(Number(INDX) - 3, iCol, YORUZAIKO, true);
}
if (YORUZAIKO < 0) {
spd.Cells(Number(INDX) - 3, iCol).SetForeColor("#FF0000");
}
else {
spd.Cells(Number(INDX) - 3, iCol).SetForeColor("#000000");
}
cell.setAttribute("FpCellType", "readonly");
spd.UpdatePostbackData();
Zenzan = YORUZAIKO + SEISANSU2;
}
} |