You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1792 lines
72 KiB
JavaScript

10 months ago
var commonGridObj_wmsin;
var comboCustomer;//货主
var comboCustomer2; //货主2
var comboOutCustomer;//出货对象
var combooutcustomer2; //货主2
var comboStorage;//仓库
var comboStorage2;//仓库2
var comboARCLIENT;
var comboTRUCKNAME;
var comboGoods;//品名
var pressRecord
var isLoad = 0;
var pressCount = 0;
var IsChangeCus=0;
var pressRecord;
function $(id){
return document.getElementById(id);
}
//ajax获得备案清单号
function Getcustomno(rId) {
var url = "WmsOutEditCBMGridSource.aspx?handle=getCustomno&id=" + rId + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var customno = loader.xmlDoc.responseText;
if (customno != "") {
$("txt_customno").value = customno;
}
else {
$("txt_customno").value = "";
}
}
function setOutInfo(rId,ischeck){
if(ischeck==true){
if ($("txt_outbsno").value == "") {
$("txt_blno").value = commonGridObj_wmsin.getGridObj().cellById(rId, 2).getValue();
$("h_blno").value = commonGridObj_wmsin.getGridObj().cellById(rId, 2).getValue();
//
var cusname=commonGridObj_wmsin.getGridObj().cellById(rId,1).getValue();
if(cusname!=""){
$("h_customer").value=cusname;
comboCustomer.setText($("h_customer").value);
if($("h_Ischange").value=="1"){
comboOutCustomer.setComboText($("h_outcustomer").value); //setText 改为 setComboText by lcx
}
else {
$("h_outcustomer").value = $("h_customer").value;
comboOutCustomer.setComboText($("h_outcustomer").value);
}
}
Getcustomno(rId);//获得备案清单号
$("h_goods").value=commonGridObj_wmsin.getGridObj().cellById(rId,7).getValue();
if($("h_goods").value!=""){
comboGoods.setText($("h_goods").value);
}
$("txt_goodsmodel").value=commonGridObj_wmsin.getGridObj().cellById(rId,8).getValue();
$("h_goodsmodel").value = $("txt_goodsmodel").value;
//仓库
if($("h_storage").value==""){
$("h_storage").value=commonGridObj_wmsin.getGridObj().cellById(rId,22).getValue();
if($("h_storage").value!=""){
comboStorage.setText($("h_storage").value);
}
}
}
}
else{
if ($("txt_outbsno").value == "") {
$("txt_blno").value = "";
$("h_blno").value = "";
$("h_customer").value="";
$("h_outcustomer").value="";
comboCustomer.setText("");
if($("h_Ischange").value=="1"){
comboOutCustomer.setComboText("");
}
else {
comboOutCustomer.setComboText("");
}
$("h_goods").value="";
comboGoods.setText("");
$("txt_goodsmodel").value="";
$("h_goodsmodel").value="";
$("h_storage").value="";
comboStorage.setText("");
$("hd_comboARCLIENT").value = "";
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
$("hd_comboTRUCKNAME").value = "";
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
}
}
}
//初始化界面
function initTj(){
$("txt_blno").value = "";
$("h_blno").value = "";
$("txt_blno2").value = "";
$("h_blno2").value = "";
$("txt_wmsno2").value = "";
$("h_customer").value="";
comboCustomer.setText("");
$("h_customer2").value = "";
comboCustomer2.setText("");
$("h_storage").value="";
comboStorage.setText("");
$("h_storage2").value = "";
comboStorage2.setText("");
$("hd_comboARCLIENT").value = "";
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
$("hd_comboTRUCKNAME").value = "";
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
$("txt_outbsno").value = ""
$("h_outcustomer").value="";
if($("h_Ischange").value=="1"){
comboOutCustomer.setComboText("");
}
else {
comboOutCustomer.setComboText("");
}
$("h_goods").value="";
comboGoods.setText("");
$("txt_goodsmodel").value="";
$("h_goodsmodel").value="";
//$("txt_goodspfsl").value="";
//$("txt_packnum").value="";
$("h_goodspfsl").value = "";
$("txt_goodsmodel2").value = "";
$("txt_GOODSSTANDARD2").value = "";
//
createOrder();
}
function ReShowLabel_2(gridObj) {
var columnCount = gridObj.getGridObj().getColumnsNum();
var rowCount = gridObj.getGridObj().getRowsNum();
if (rowCount > 0) {
for (var i = 0; i < rowCount; i++) {
for (var j = 0; j < columnCount; j++) {
if (j == 8 ) {
var cellCurVal = gridObj.getGridObj().cellByIndex(i, j).getValue();
gridObj.getGridObj().cellByIndex(i, j).setLabel(cellCurVal);
}else if( j == 15 || j == 16 ){
var cellCurVal = gridObj.getGridObj().cellByIndex(i, j).getValue();
gridObj.getGridObj().cellByIndex(i, j).setValue(cellCurVal);
}
}
}
}
}
function SetRate(){
var openSet = "height=490, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
if($("h_opseaibsno").value!=null && $("h_opseaibsno").value!="" && $("h_newcust").value!=null && $("h_newcust").value!="" ){
var openUrl = "../SeaiFee/WmsRateEdit.aspx?handle=edit&id="+$("h_opseaibsno").value+"&cust="+escape($("h_newcust").value);
window.open (openUrl,openType,openSet);
}
else {
alert("货权转移之前,不能编辑仓储费率!");
return;
}
}
function createOrder(){
if ($("h_Handle").value == "edit")
{
$("dvtable_outtj").style.display="none";
}
else
{
$("dvtable_outtj").style.display="";
}
//
if($("h_IsSetRate").value=="0"){
$("btn_IsSetRate").style.display = "none";
}
else{
if($("h_opseaibsno").value!=null && $("h_opseaibsno").value!="" && $("h_newcust").value!=null && $("h_newcust").value!="" ){
$("btn_IsSetRate").style.display="";
}
else
{
$("btn_IsSetRate").style.display="none";
}
}
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
// var headerArgs_wmsin = new Array("", "货主", "提单号", "入库单号", "入库日期", "开始计费日期", "等级", "品名", "品牌", "规格", "片数/件", "剩余件数", "剩余库存", "出库件数", "立方米", "应收出库费", "应付出库费", "车号", "备注", "仓库名称", "进口委托单号", "单件立方数", "原货主", "入库GID", "出库明细GID", "应付开始计费日期", "剩余件数_EDIT", "剩余库存_EDIT");
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
var headerArgs_wmsin = new Array("", "货主", "提单号", "入库单号", "入库日期", "开始计费日期", "等级", "品名", "品牌", "规格", "厚度", "宽度", "长度", "片数/件", "剩余件数", "剩余库存", "出库件数", "立方米", "应收出库费", "应付出库费", "车号", "备注", "仓库名称", "进口委托单号", "单件立方数", "原货主", "入库GID", "出库明细GID", "应付开始计费日期", "剩余件数_EDIT", "剩余库存_EDIT");
//width
var widthArgs_wmsin = new Array("40", "100", "130", "120", "80", "100", "40", "60", "60", "70", "70", "70", "70", "70", "70", "70", "70", "70", "70", "70", "190", "200", "0", "0", "0", "0", "0", "0", "0", "0", "0");
//column align
var colAlignArgs_wmsin = new Array("center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center");
//column sort
var colSortArgs_wmsin = new Array("na", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str");
//column type
var colTypeArgs_wmsin = new Array("ch", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ed", "ed", "ed", "ed", "txt", "ed", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro");
commonGridObj_wmsin = new TGridCommon("mygrid_container_wmsin","form1",headerArgs_wmsin,widthArgs_wmsin,colAlignArgs_wmsin,colSortArgs_wmsin,colTypeArgs_wmsin);
commonGridObj_wmsin.setResponseUrl("../SeaiFee/WmsOutEditCBMGridSource.aspx");
if ($("h_Handle").value == "edit") {
if ($("h_searchJson").value != "") {
commonGridObj_wmsin.setRequest("../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=wmsinlistedit&search=" + escape($("h_searchJson").value) + "&wmsoutbsno=" + $("h_wmsoutbsno").value.trim());
} else {
commonGridObj_wmsin.setRequest("../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=wmsinlistedit&bsno=" + $("h_opseaibsno").value + "&wmsoutbsno=" + $("h_wmsoutbsno").value.trim());
}
}
else {
if ($("h_searchJson").value != "") {
commonGridObj_wmsin.setRequest("../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=wmsinlist&search=" + escape($("h_searchJson").value));
} else {
commonGridObj_wmsin.setRequest("../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=wmsinlist&bsno=" + $("h_opseaibsno").value);
}
}
commonGridObj_wmsin.setSourceType("json");
commonGridObj_wmsin.setSkin("xp");
commonGridObj_wmsin.setImageUrl("../images/");
commonGridObj_wmsin.initGrid();
commonGridObj_wmsin.bind();
commonGridObj_wmsin.getGridObj().enableEditEvents(true, false, true);
commonGridObj_wmsin.getGridObj().enableKeyboardSupport(true);
commonGridObj_wmsin.getGridObj().enableMultiselect(true);
var txtEdit;
commonGridObj_wmsin.getGridObj().attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
if ($("h_isdisabled").value == "true") {
return false;
}
//初始化状态
if (stage == 0) {
txtEdit = "";
return true;
} //stage == 0
if (stage == 1) {
txtEdit = "";
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
} //stage == 1
if (cInd == 16) {
if ($("h_Handle").value.trim() != "edit") {
var Num_Out = commonGridObj_wmsin.getGridObj().cellById(rId, cInd).getValue();
if (Num_Out != 0) {
var Num_Kc = parseFloat(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellById(rId, 29).getValue()));
if (Num_Out > Num_Kc) {
commonGridObj_wmsin.getGridObj().cellById(rId, cInd).setLabel(Num_Kc);
}
setOutInfo(rId, true);
//totalDynamicOutNum();
}
}
}
else if (cInd == 20) {
if (txtEdit != null) {
if (txtEdit.value != null) {
if (txtEdit.value != "") {
commonGridObj_wmsin.getGridObj().cellById(rId, cInd).setValue(txtEdit.value);
}
}
}
}
if (stage == 2) {//编辑结束
if (cInd == 20) {
if (txtEdit != null) {
if (txtEdit.value != null && txtEdit.value != "") {
var sdf = txtEdit.value;
commonGridObj_wmsin.getGridObj().cellById(rId, cInd).setValue(txtEdit.value);
}
}
else {
return true;
}
}
else if (cInd == 21) {
commonGridObj_wmsin.getGridObj().cellById(rId, cInd).setValue(nValue);
}
else if (cInd == 16) {
commonGridObj_wmsin.getGridObj().cellById(rId, cInd).setLabel(nValue);
totalDynamicOutNum();
}
else if (oValue == null || oValue == "" || oValue == "0") {
return true;
}
return true;
} //stage == 2
}); //onEditCell end
//键盘操作事件
commonGridObj_wmsin.getGridObj().attachEvent("onKeyPress", function (code, cFlag, sFlag) {
if ($("h_isdisabled").value == "true") {
return false;
}
//onKeyPress begin
//获取当前RowID
var selectedId = commonGridObj_wmsin.getGridObj().getSelectedRowId();
//获取当前RowIndex
var RowIndex = commonGridObj_wmsin.getGridObj().getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = commonGridObj_wmsin.getGridObj().getSelectedCellIndex();
//触发操作事件前获取单元值
var oldVal = commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
break;
}
}
//enter 键
if (code == 13) {
if (ind == 16 || ind == 17 || ind == 18 || ind == 19 || ind == 20 || ind == 21) {
return true;
}
} //enter 键 end
//Tab键
else if (code == 9) {
//code9 begin
var colCount = commonGridObj_wmsin.getGridObj().getColumnsNum();
//获取当前RowIndex
//触发操作事件前获取单元值
if (ind < colCount) {
isExchange = false;
if (ind == 16) {
var oldVal = commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).getValue();
commonGridObj_wmsin.getGridObj().editStop(true);
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setLabel(oldVal);
//
setOutInfo(selectedId, true);
totalDynamicOutNum();
//
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind + 1, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
else if (ind == 17 || ind == 18 || ind == 19) {
var oldVal = commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).getValue();
commonGridObj_wmsin.getGridObj().editStop(true);
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setLabel(oldVal);
setOutInfo(selectedId, true);
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind + 1, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
else if (ind == 20) {
commonGridObj_wmsin.getGridObj().editStop(true);
if (txtEdit.value != null && txtEdit.value != "") {
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setValue(txtEdit.value);
}
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind + 1, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
else if (ind == 21) {
commonGridObj_wmsin.getGridObj().editStop(true);
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setValue(oldVal);
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind + 1, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
}
} //cdoe9 end
//向下方向键
else if (code == 40) {
//code40 begin
if (ind == 16 || ind == 17 || ind == 18 || ind == 19 || ind == 20 || ind == 21) {
var rowCount = commonGridObj_wmsin.getGridObj().getRowsNum();
commonGridObj_wmsin.getGridObj().editStop(true);
if (RowIndex != (rowCount - 1)) {
commonGridObj_wmsin.getGridObj().selectCell(RowIndex + 1, ind, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
}
else {
return true;
}
} //code40 end
//向上箭头
else if (code == 38) {
//code38 begin
if (ind == 16 || ind == 17 || ind == 18 || ind == 19 || ind == 20 || ind == 21) {
if (RowIndex > 0) {
commonGridObj_wmsin.getGridObj().clearSelection();
commonGridObj_wmsin.getGridObj().editStop(true);
commonGridObj_wmsin.getGridObj().selectCell(RowIndex - 1, ind, true, true);
commonGridObj_wmsin.getGridObj().editCell();
}
} else {
return true;
}
} //code38 end
//左箭头
else if (code == 37) {
//code37 begin
commonGridObj_wmsin.getGridObj().clearSelection();
commonGridObj_wmsin.getGridObj().editStop(true);
if (ind == 16) {
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, 21, true, true);
}
else {
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind - 1, true, true);
}
commonGridObj_wmsin.getGridObj().editCell();
return true;
} //code37 end
//右箭头
else if (code == 39) {
//code39 begin
commonGridObj_wmsin.getGridObj().clearSelection();
commonGridObj_wmsin.getGridObj().editStop(true);
if (ind == 21) {
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, 16, true, true);
}
else {
commonGridObj_wmsin.getGridObj().selectCell(RowIndex, ind + 1, true, true);
}
commonGridObj_wmsin.getGridObj().editCell();
return true;
} //code39 end
else if (code == 46) {
if (ind == 16 || ind == 17 || ind == 18 || ind == 19) {
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setLabel("");
}
else if (ind == 20 || ind == 21) {
commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex, ind).setValue("");
}
} //end code == 46
//delete
else if (code == 8) {
//code8 begin
if (ind == 16 || ind == 17 || ind == 18 || ind == 19 || ind == 20 || ind == 21) {
var start = 0;
var end = 0;
if (document.selection) {
var range = document.selection.createRange();
if (range.parentElement().className == txtEdit.className) {
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
range_all.moveStart('character', 1);
}
for (var i = 0; i <= start; i++) {
if (txtEdit.value.charAt(i) == '\n')
start++;
}
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++)
range_all.moveStart('character', 1);
for (var i = 0; i <= end; i++) {
if (txtEdit.value.charAt(i) == '\n')
end++;
}
}
}
//未选中多个字符
if (start == end) {
if (start != 0) {
if (pressRecord != null) {
var firstVal = pressRecord.substring(0, start - 1);
var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
pressRecord = firstVal;
}
}
}
//选中多个字符
if (start != end) {
if (pressRecord != null) {
var firstVal = pressRecord.substring(0, start);
var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
pressRecord = firstVal + endVal;
}
}
setTimeout(function () {
if (pressRecord != null) {
if (pressRecord.trim().length > 0) {
var combo = commonGridObj_wmsin.getGridObj().getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var count = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(pressRecord) == 0) {
count++;
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
pressCount = 3;
commonGridObj_wmsin.getGridObj().editStop(true);
commonGridObj_wmsin.getGridObj().cellByIndex(rowIndex, ind).setValue(oldVal);
commonGridObj_wmsin.getGridObj().selectCell(rowIndex, ind, true, true);
commonGridObj_wmsin.getGridObj().editCell();
var old_length = oldLab.length;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
var rt = txtEdit.createTextRange();
rt.collapse();
rt.select(); //光标置最前
var r = document.selection.createRange();
r.collapse(false);
r.moveStart("character", pressRecord.length); //从m位开始
r.moveEnd("character", old_length); //选取n位
//txtEdit.focus();
r.select();
}
}
break;
}
}
}
}
}, 500);
return true;
} else {
return true;
}
} //code8 end
//键盘输入数字
else if (code >= 48 && code <= 57 || code >= 96 && code <= 105 || code == 188 || code == 110 || code == 190 || code == 229) {
if (ind == 16 || ind == 17 || ind == 18 || ind == 19 || ind == 20 || ind == 21) {
return true;
}
}
else if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 20 || ind == 21) {
return true;
}
}
else {
return true;
}
});
//}
isLoad = 1;
}// createOrder() end
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round(number*100) /100;
if(number<0)
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
function RecreateOrder(){
createOrder();
} //RecreateOrder() end
var newGuid = function(){
var guid = "";
for (var i = 1; i <= 32; i++){
var n = Math.floor(Math.random()*16.0).toString(16);
guid += n;
if((i==8)||(i==12)||(i==16)||(i==20))
guid += "-";
}
return guid.toUpperCase();
};
function doCheck(clickObj){
// alert($(clickObj).checked);
//// if($(clickObj).checked){
// $(clickObj).checked = 0;
// return ;
// }else{
// $(clickObj).checked = 1;
// return ;
// }
}
//初始化Combo
function initCombos()
{
if($("h_Mode").value=="0"){
if($("sel_customer")!=null){
initComboCustomer();//货主
}
if($("sel_customer2")!=null){
initComboCustomer2();//货主
}
if($("sel_storage")!=null){
initComboStorage();//仓库名称
}
if ($("sel_storage2") != null) {
initComboStorage2(); //仓库名称
}
if($("sel_goods")!=null){
initComboGoods();//品名ok
}
initcomboOutCustomer2();
initComboARCLIENT2();
initComboTRUCKNAME2();
}
else if($("h_Mode").value=="1"){
if ($("sel_customer") != null) {
initComboCustomer(); //货主
}
if ($("sel_storage") != null) {
initComboStorage(); //仓库名称
}
if($("sel_goods")!=null){
initComboGoods();//品名ok
}
initcomboOutCustomer2();
comboOutCustomer.setComboText($("h_outcustomer").value);
initComboARCLIENT2();
initComboTRUCKNAME2();
}
// finishLoading();
}
function initComboCustomer(){//货主
comboCustomer = new TCombo("sel_customer", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0", true, true, false, true, "h_customer");
comboCustomer.initComboEvent();
comboCustomer.bind();
if($("h_customer").value!="" && $("h_customer").value!=null)
{
comboCustomer.setText($("h_customer").value);
}
}
function initComboCustomer2() {//货主2
comboCustomer2 = new TCombo("sel_customer2", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0", true, true, false, true, "h_customer2");
comboCustomer2.initComboEvent();
comboCustomer2.bind();
if ($("h_customer2").value != "" && $("h_customer2").value != null) {
comboCustomer2.setText($("h_customer2").value);
}
}
//storage
function initComboStorage() {//仓库名称
comboStorage = new TCombo("sel_storage", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE", true, true, false, true, "h_storage");
comboStorage.initComboEvent();
comboStorage.bind();
if($("h_storage").value!="" && $("h_storage").value!=null)
{
comboStorage.setText($("h_storage").value);
}
}
//storage
function initComboStorage2() {//仓库名称
comboStorage2 = new TCombo("sel_storage2", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE", true, true, false, true, "h_storage2");
comboStorage2.initComboEvent();
comboStorage2.bind();
if($("h_storage2").value!="" && $("h_storage2").value!=null)
{
comboStorage2.setText($("h_storage2").value);
}
}
function initComboTRUCKNAME() {//应付
comboTRUCKNAME = new TCombo("ddlTRUCKNAME", "../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE&strIS2=ISTRUCK", true, true, false, true, "hd_comboTRUCKNAME");
comboTRUCKNAME.initComboEvent();
comboTRUCKNAME.bind();
if ($("hd_comboTRUCKNAME").value != "" && $("hd_comboTRUCKNAME").value != null)
{
comboTRUCKNAME.setText($("hd_comboTRUCKNAME").value);
}
}
function initComboGoods() {//品名ok
comboGoods = new TCombo("sel_goods", "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=goodslist", true, true, false, true, "h_goods");
//
comboGoods.initComboEvent();
comboGoods.bind();
if($("h_goods").value!="" && $("h_goods").value!=null)
{
comboGoods.setText($("h_goods").value);
}
}
function initcomboOutCustomer()//货主
{
comboOutCustomer = dhtmlXComboFromSelect("sel_outcustomer");
comboOutCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER ");
}
function initcomboOutCustomer2()//货主
{
if ($("h_isdisabled").value == "true" || $("h_Handle").value == "edit") {
comboOutCustomer.disable(true);
}
//
comboOutCustomer.attachEvent("onChange", function() {
comboOutCustomer.setComboText($("h_outcustomer").value);
});
comboOutCustomer.attachEvent("onBlur", function() {
var s1 = comboOutCustomer.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("h_outcustomer").value = "";
comboOutCustomer.setComboText($("h_outcustomer").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboOutCustomer.setComboText(s3);
$("h_outcustomer").value = s3;
}
else {
comboOutCustomer.setComboText($("h_outcustomer").value);
}
}
});
comboOutCustomer.setOptionWidth(200);
comboOutCustomer.setComboText($("h_outcustomer").value);
comboOutCustomer.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("h_outcustomer").value.trim();
if ("" != comboOutCustomer.getComboText().trim()) {
while ("undefined" != typeof comboOutCustomer.getOptionByIndex(filterCount)) {
var comboValue = comboOutCustomer.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboOutCustomer.getComboText().trim().toUpperCase();
$("h_outcustomer").value = comboOutCustomer.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboOutCustomer.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
var sklj = $("h_Ischange").value;
if ($("h_Ischange").value == "1") {
$("h_outcustomer").value = ishd;
alert("无此内容,请重新选择!");
}
//
}
}
}, 10);
}
});
comboOutCustomer.attachEvent("onSelectionChange", function() {
$("h_outcustomer").value = comboOutCustomer.getComboText().trim();
});
}
function initComboARCLIENT()//应收账款客户名称
{
comboARCLIENT = dhtmlXComboFromSelect("ddlARCLIENT");
comboARCLIENT.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE&strIS2=ISCONTROLLER");
}
function initComboARCLIENT2()//应收账款客户名称
{
if ($("h_isdisabled").value == "true") {
comboARCLIENT.disable(true);
}
//
comboARCLIENT.setOptionWidth(200);
comboARCLIENT.attachEvent("onChange", function () {
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
});
comboARCLIENT.attachEvent("onBlur", function () {
var s1 = comboARCLIENT.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboARCLIENT").value = "";
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboARCLIENT.setComboText(s3);
$("hd_comboARCLIENT").value = s3;
}
else {
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
}
}
});
comboARCLIENT.setComboText($("hd_comboARCLIENT").value);
comboARCLIENT.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboARCLIENT").value.trim();
if ("" != comboARCLIENT.getComboText().trim()) {
while ("undefined" != typeof comboARCLIENT.getOptionByIndex(filterCount)) {
var comboValue = comboARCLIENT.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboARCLIENT.getComboText().trim().toUpperCase();
$("hd_comboARCLIENT").value = comboARCLIENT.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboARCLIENT.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboARCLIENT").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboARCLIENT.attachEvent("onSelectionChange", function () {
$("hd_comboARCLIENT").value = comboARCLIENT.getComboText().trim();
});
}
function initComboTRUCKNAME()//应付账款客户名称
{
comboTRUCKNAME = dhtmlXComboFromSelect("ddlTRUCKNAME");
comboTRUCKNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISWAREHOUSE&strIS2=ISTRUCK");
}
function initComboTRUCKNAME2()//应付账款客户名称
{
if ($("h_isdisabled").value == "true") {
comboTRUCKNAME.disable(true);
}
//
comboTRUCKNAME.setOptionWidth(200);
comboTRUCKNAME.attachEvent("onChange", function () {
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
});
comboTRUCKNAME.attachEvent("onBlur", function () {
var s1 = comboTRUCKNAME.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboTRUCKNAME").value = "";
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboTRUCKNAME.setComboText(s3);
$("hd_comboTRUCKNAME").value = s3;
}
else {
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
}
}
});
comboTRUCKNAME.setComboText($("hd_comboTRUCKNAME").value);
comboTRUCKNAME.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboTRUCKNAME").value.trim();
if ("" != comboTRUCKNAME.getComboText().trim()) {
while ("undefined" != typeof comboTRUCKNAME.getOptionByIndex(filterCount)) {
var comboValue = comboTRUCKNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboTRUCKNAME.getComboText().trim().toUpperCase();
$("hd_comboTRUCKNAME").value = comboTRUCKNAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboTRUCKNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboTRUCKNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboTRUCKNAME.attachEvent("onSelectionChange", function () {
$("hd_comboTRUCKNAME").value = comboTRUCKNAME.getComboText().trim();
});
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round(number*100) /100;
if(number<0)
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
function outputDollars(number)
{
if (number.length<= 3)
return (number == '' ? '0' : number);
else
{
var mod = number.length%3;
var output = (mod == 0 ? '' : (number.substring(0,mod)));
for (i=0 ; i< Math.floor(number.length/3) ; i++)
{
if ((mod ==0) && (i ==0))
output+= number.substring(mod+3*i,mod+3*i+3);
else
output+= ',' + number.substring(mod+3*i,mod+3*i+3);
}
return (output);
}
}
function outputCents(amount)
{
amount = Math.round( ( (amount) - Math.floor(amount) ) *100);
return (amount<10 ? '.0' + amount : '.' + amount);
}
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
function clearNoNum(valObj)
{
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
if(valObj.indexOf(".") == valObj.length-1){
valObj += "0";
}
return valObj;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function search(){//查询入库wms_in信息
//sel_customer
var opseaibsno=$("h_opseaibsno").value;
var cus = $("h_customer2").value;
var blno = $("txt_blno2").value;
var store = $("h_storage2").value;
var gmodel = $("txt_goodsmodel2").value;
var wmsno = $("txt_wmsno2").value;
var GOODSSTANDARD = $("txt_GOODSSTANDARD2").value;
if(blno!=null && blno!=""){
$("h_blno2").value=blno;
}
var searchJson = "";
searchJson +="{";
searchJson += "[";
searchJson += "\"opseaibsno\":\""+opseaibsno+"\",";
searchJson += "\"cus\":\""+cus+"\",";
searchJson += "\"blno\":\""+blno+"\",";
searchJson += "\"goodsmodel\":\"" + gmodel + "\",";
searchJson += "\"GOODSSTANDARD\":\"" + GOODSSTANDARD + "\",";
searchJson += "\"wmsno\":\"" + wmsno + "\",";
searchJson += "\"store\":\""+store+"\"";
searchJson += "]";
searchJson +="}";
$("h_searchJson").value = searchJson;
// createOrder();
RecreateOrder();
}
function ChangeStorage(){ //货权转移
IsChangeCus=1;
if($("h_outbsno").value!="" && $("h_outbsno").value!=null)
{
alert("出库单已经生成!");
return;
}
var WoState=0;
WoState=saveWoChange();
var WoDetailState=0;
WoDetailState=saveWoDetailChange();
if($("WoContainer").value.trim() == "" || $("WoDetailContainer").value.trim() == ""){
return;
}
if (WoState==1 && WoDetailState==1){
msgBox();
//定时发送数据
setTimeout(postEnterFee,200);
$("h_post").value = 3;
}
}
function OutStorage() {//生成出库单
IsChangeCus=parseInt($("h_Ischange").value);
//保存后录入的数据
var truck;
var id;
for (var i = 0; i < commonGridObj_wmsin.getGridObj().getRowsNum(); i++) {
if ($("h_Handle").value.trim() != "edit") {
var Num_Out = commonGridObj_wmsin.getGridObj().cellByIndex(i, 16).getValue();
if (Num_Out != 0) {
var Num_Kc = parseFloat(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(i, 29).getValue()));
if (Num_Out > Num_Kc) {
commonGridObj_wmsin.getGridObj().cellByIndex(i, 16).setLabel(Num_Kc);
}
id = commonGridObj_wmsin.getGridObj().getRowId(i);
setOutInfo(id, true);
//totalDynamicOutNum();
}
}
truckno = commonGridObj_wmsin.getGridObj().cellByIndex(i,20).getValue();
}
var WoState=0;
WoState=saveWoChange();
var WoDetailState=0;
WoDetailState=saveWoDetailChange();
if($("WoContainer").value.trim() == "" || $("WoDetailContainer").value.trim() == ""){
return;
}
if (WoState==1 && WoDetailState==1){
msgBox();
//定时发送数据
setTimeout(postEnterFee,200);
if(IsChangeCus==1){
$("h_post").value = 3;
}
else{
$("h_post").value = 2;
}
}
}
function dateF(sdate) {
var ih = sdate.toString().trim().indexOf(" ");
if (ih > -1) {
sdate = sdate.substr(0, ih);
}
return sdate;
}
function saveWoChange(){
var jsonFeeObj = null;
var outdate = dateF($("txt_outdate").value);
if(outdate==""){
alert("出库日期不能为空!");
return;
}
//
var oldcustfeedate = dateF($("txt_oldcustFeeDate").value.trim());
if (oldcustfeedate == "") {
alert("结束计费日期不能为空!");
return;
}
//
var cust="";
try
{
cust=comboCustomer.comboObj.getComboText().trim();
}
catch(e)
{
cust=$("txt_customer").value;
}
if(cust==""){
alert("货主不能为空!");
return;
}
//
var goodsname = $("h_goods").value;
if(goodsname==""){
alert("品名不能为空!");
return;
}
var goodsmodel = $("txt_goodsmodel").value;
if(goodsname==""){
alert("品牌不能为空!");
return;
}
//
var outcus = ""; //转移对象
if($("h_Ischange").value=="1"){
outcus = comboOutCustomer.getComboText().trim(); //comboObj. by lcx
if(cust==outcus)
{
alert("货主和货权转移对象不能相同");
return;
}
}
else {
outcus=comboOutCustomer.getComboText().trim();
}
if(IsChangeCus==1)
{
if(outcus==""){
alert("货权转移对象不能为空!");
return;
}
}
var isJsFee=$("ck_jsfee").checked;
var outnum=0 ;//本次出库量
outnum = parseFloat($("h_goodspfsl").value); //$("txt_goodspfsl").value;
if (outnum == 0) {
alert("出库量不能为零!");
return;
}
else {
outnum = 1; //本次出库量
}
var outpacknum = 0; //本次出库件数
outpacknum = parseInt($("h_packnum").value);//$("txt_packnum").value;
if(outpacknum==""){
alert("出库件数不能为零!");
return;
}
else {
outpacknum = 1; //本次出库量
}
var arclient = $("hd_comboARCLIENT").value.trim();
var truckname = $("hd_comboTRUCKNAME").value.trim();
//
var remark = $("txt_remark").value.replace(/,/ig, '');
var totalno = $("txt_totalno").value;
var inspectionno = $("txt_inspectionno").value;
var customno = $("txt_customno").value;
var custparent="";//原货主
var opseaibsno="";
var storage="";
var truckno = "";
if(storage==""){
for(var i=0;i<commonGridObj_wmsin.getGridObj().getRowsNum();i++){
// var checkState = commonGridObj_wmsin.getGridObj().cellByIndex(i,0).getValue();
var outnumdetail=clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(i,16).getValue())));
if(outnumdetail>0){
// if(checkState==1){
if(opseaibsno==""){
opseaibsno=commonGridObj_wmsin.getGridObj().cellByIndex(i,23).getValue();
storage=commonGridObj_wmsin.getGridObj().cellByIndex(i,22).getValue();
truckno = commonGridObj_wmsin.getGridObj().cellByIndex(i,20).getValue().replace(/,/ig, '');
}
else if(opseaibsno!=commonGridObj_wmsin.getGridObj().cellByIndex(i,23).getValue())
{
alert("不能选择两个进口委托单出库");
return 0;
}
if (cust!=commonGridObj_wmsin.getGridObj().cellByIndex(i,1).getValue()){
alert("不能选择两个货主的货物出库");
return 0;
}
}
}
}
//
if (truckno.trim() != "") {
while (truckno.indexOf(" ") > 0) {
truckno = truckno.replace(" ", "");
}
while (truckno.indexOf("\r\n") > 0) {
truckno = truckno.replace("\r\n", "");
}
}
//
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"cust\":\""+cust+"\",";
cacheBuffer += "\"outcus\":\""+outcus+"\",";
cacheBuffer += "\"outdate\":\""+outdate+"\",";
cacheBuffer += "\"goodsname\":\""+goodsname+"\",";
cacheBuffer += "\"goodsmodel\":\""+goodsmodel+"\",";
cacheBuffer += "\"outnum\":\""+outnum+"\","; //outpacknum
cacheBuffer += "\"outpacknum\":\"" + outpacknum + "\",";
cacheBuffer += "\"truckno\":\"" + truckno + "\",";
cacheBuffer += "\"storage\":\""+storage+"\",";
cacheBuffer += "\"opseaibsno\":\""+opseaibsno+"\",";
cacheBuffer += "\"isJsFee\":\""+isJsFee+"\",";
cacheBuffer += "\"totalno\":\"" + totalno + "\",";
cacheBuffer += "\"remark\":\""+remark+"\",";
cacheBuffer += "\"inspectionno\":\"" + inspectionno + "\",";
cacheBuffer += "\"customno\":\"" + customno + "\",";
cacheBuffer += "\"arclient\":\"" + arclient + "\",";
cacheBuffer += "\"truckname\":\"" + truckname + "\",";
cacheBuffer += "\"oldcustfeedate\":\"" + oldcustfeedate + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
$("WoContainer").value=JSON.stringify(jsonFeeObj);
return 1;
}
function saveWoDetailChange(){
var jsonFeeObj = null;
//
var cust = "";
try {
cust = comboCustomer.comboObj.getComboText().trim();
}
catch (e) {
cust = $("txt_customer").value;
}
if (cust == "") {
alert("货主不能为空!");
return;
}
//
var outcus = ""; //转移对象
if ($("h_Ischange").value == "1") {
outcus = comboOutCustomer.getComboText().trim(); //comboObj. by lcx
if (cust == outcus) {
alert("货主和货权转移对象不能相同");
return;
}
}
else {
outcus = comboOutCustomer.getComboText().trim();
}
//
var farfee = 0;
var fapfee = 0;
var wmsoutdetailgid = "";
//
for(var i=0;i<commonGridObj_wmsin.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_wmsin.getGridObj().getRowId(i);
var RowIndex = commonGridObj_wmsin.getGridObj().getRowIndex(rowId);
//
var inbsno = rowId; //wms_in.bsno
if ($("h_Handle").value.trim() == "edit") {
inbsno = commonGridObj_wmsin.getGridObj().cellByIndex(i,23).getValue(); //入库GID
wmsoutdetailgid = commonGridObj_wmsin.getGridObj().cellByIndex(i,27).getValue(); //出库明细GID
}
var indate = commonGridObj_wmsin.getGridObj().cellByIndex(i,4).getValue(); //入库日期
var startbillingdate = commonGridObj_wmsin.getGridObj().cellByIndex(i,5).getValue();//计费开始日期
var goodsname = commonGridObj_wmsin.getGridObj().cellByIndex(i,7).getValue();
var goodsmodel = commonGridObj_wmsin.getGridObj().cellByIndex(i,8).getValue();
var outnum = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex,17).getValue())));
var outpacknum = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex,16).getValue())));
var arfee = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex,18).getValue())));
var apfee = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(RowIndex,19).getValue())));
farfee = parseFloat(farfee) + parseFloat(arfee);
fapfee = parseFloat(fapfee) + parseFloat(apfee);
var truckno = commonGridObj_wmsin.getGridObj().cellByIndex(i,20).getValue().replace(/,/ig, '');
var remark = commonGridObj_wmsin.getGridObj().cellByIndex(i,21).getValue().replace(/,/ig, '');
var storage=commonGridObj_wmsin.getGridObj().cellByIndex(i,22).getValue();
var opseaibsno=commonGridObj_wmsin.getGridObj().cellByIndex(i,23).getValue();
var custparent=commonGridObj_wmsin.getGridObj().cellByIndex(i,25).getValue();
var checkState = commonGridObj_wmsin.getGridObj().cellByIndex(i,0).getValue();
var goodsgrade = commonGridObj_wmsin.getGridObj().cellByIndex(i,6).getValue();
var goodsstandard = commonGridObj_wmsin.getGridObj().cellByIndex(i,9).getValue();
var goodsslice = commonGridObj_wmsin.getGridObj().cellByIndex(i,13).getValue();
var startbillingdateap = commonGridObj_wmsin.getGridObj().cellByIndex(i,28).getValue(); //计费开始日期
//
if(outnum>0){
//if(checkState==1){
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"cust\":\"" + cust + "\",";
cacheBuffer += "\"outcus\":\"" + outcus + "\",";
cacheBuffer += "\"inbsno\":\""+inbsno+"\",";
cacheBuffer += "\"wmsoutdetailgid\":\"" + wmsoutdetailgid + "\",";
cacheBuffer += "\"indate\":\""+indate+"\",";
cacheBuffer += "\"startbillingdate\":\"" + startbillingdate + "\",";
cacheBuffer += "\"startbillingdateap\":\"" + startbillingdateap + "\",";
cacheBuffer += "\"goodsname\":\""+goodsname+"\",";
cacheBuffer += "\"goodsmodel\":\"" + goodsmodel + "\",";
//
if (truckno.trim() != "") {
while (truckno.indexOf(" ") > 0) {
truckno = truckno.replace(" ", "");
}
while (truckno.indexOf("\r\n") > 0) {
truckno = truckno.replace("\r\n", "");
}
}
//
cacheBuffer += "\"truckno\":\""+truckno+"\",";
cacheBuffer += "\"storage\":\""+storage+"\",";
cacheBuffer += "\"opseaibsno\":\""+opseaibsno+"\",";
cacheBuffer += "\"outnum\":\""+outnum+"\",";
cacheBuffer += "\"outpacknum\":\"" + outpacknum + "\",";
cacheBuffer += "\"arfee\":\"" + arfee + "\",";
cacheBuffer += "\"apfee\":\"" + apfee + "\",";
cacheBuffer += "\"remark\":\"" + remark + "\",";
cacheBuffer += "\"goodsgrade\":\"" + goodsgrade + "\",";
cacheBuffer += "\"goodsstandard\":\"" + goodsstandard + "\",";
cacheBuffer += "\"goodsslice\":\"" + goodsslice + "\",";
cacheBuffer += "\"custparent\":\"" + custparent + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = { cust: cust, outcus: outcus, inbsno: inbsno, wmsoutdetailgid: wmsoutdetailgid, indate: indate, startbillingdate: startbillingdate, goodsname: goodsname, goodsmodel: goodsmodel, truckno: truckno, storage: storage, opseaibsno: opseaibsno, outnum: outnum, outpacknum: outpacknum, arfee: arfee, apfee: apfee, remark: remark, goodsgrade: goodsgrade, goodsstandard: goodsstandard, goodsslice: goodsslice, custparent: custparent, startbillingdateap: startbillingdateap };
jsonFeeObj.fees.push(newFeeRow);
}
}
}
if(jsonFeeObj!=null) {
if ($("hd_comboARCLIENT").value.trim() == "" && farfee != 0) {
$("WoDetailContainer").value = "";
alert("应收客户不能为空!");
return 3;
}
if ($("hd_comboTRUCKNAME").value.trim() == "" && fapfee != 0) {
$("WoDetailContainer").value = "";
alert("应付客户不能为空!");
return 3;
}
//
$("WoDetailContainer").value=JSON.stringify(jsonFeeObj);
return 1;
}
else
{
$("WoDetailContainer").value="";
alert("请输入本次出库重量!");
return 0;
}
}
//信息提示
function msgBox(){
var dg=new dialog();
dg.html="费用正在保存中,请稍等……";//"<input type=button onclick='new dialog().close();' value='确定'>";
dg.width=200;
dg.height=100;
dg.title="";
dg.show();
}
//对话框
function dialog()
{
// alert("打开dialog");
this.width=450;
this.height=360;
this.title_height=20;
this.html='';
this.title='';
var self = this;
var bgObj,msgObj,titleObj;
this.close=function()
{
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show=function()
{
var msgw,msgh,bordercolor;
msgw=self.width;
msgh=self.height;
bordercolor="#336699";
titlecolor="#99CCFF";
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=screen.height;
bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";
msgObj.style.zIndex = "10001";
titleObj=document.createElement("h4");
titleObj.setAttribute("id","msgTitle");
titleObj.setAttribute("align","center");
titleObj.style.margin="0";
titleObj.style.padding="3px";
titleObj.style.background=bordercolor;
titleObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity="0.75";
titleObj.style.border="1px solid " + bordercolor;
titleObj.style.height=self.title_height+"px";
titleObj.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color="white";
titleObj.style.cursor="pointer";
titleObj.innerHTML=self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt=document.createElement("div");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
function fomatFloat(src,pos){
return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
}
function initLoading(){
$("progressBar").style.display = "";
}
function finishLoading(){
$("progressBar").style.display = "none";
}
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round(number*100) /100;
if(number<0)
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
//动态计算本次出库重量信息
function totalDynamicOutNum(){
//获取出库列表行数
var rowCount_WmsOut = commonGridObj_wmsin.getGridObj().getRowsNum();
var Sum_Out = 0.0;//总吨数合计
var Sum_packOut = 0.0;//
var checkBox = 0;
var amount = 0;
var amountpack = 0;//件数合计
var rownum=0;//明细重量
var djds=0;//单件吨数
//计算应收费用
for(var i = 0;i<rowCount_WmsOut;i++){
// checkBox = commonGridObj_wmsin.getGridObj().cellByIndex(i,0).getValue();
rownum = parseFloat(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(i,16).getValue()));
djds=parseFloat(ConvertToMoney(commonGridObj_wmsin.getGridObj().cellByIndex(i,24).getValue()));
if(rownum.toString().toLowerCase() == "nan"){
rownum = 0.0;
}
if(djds.toString().toLowerCase() == "nan"){
djds = 0.0;
}
if(rownum>0){
// if(checkBox == 1){
//获取总金额
if(amountpack.toString().toLowerCase() == "nan"){
amountpack = 0.0;
}
if(amount.toString().toLowerCase() == "nan"){
amount = 0.0;
}
if(Sum_Out.toString().toLowerCase() == "nan"){
Sum_Out = 0.0;
}
var Num_Out = commonGridObj_wmsin.getGridObj().cellByIndex(i,16).getValue();
if(Num_Out != 0) {
var Num_Kc =parseFloat(ConvertToMoney( commonGridObj_wmsin.getGridObj().cellByIndex(i,29).getValue()));
if(Num_Out>Num_Kc)
{
commonGridObj_wmsin.getGridObj().cellByIndex(i,16).setLabel(Num_Kc);
rownum=Num_Kc;
}
}
amountpack=amountpack+rownum;
amount = rownum * djds;
Sum_Out = Sum_Out + amount;
var tmpjs=rownum * djds;
tmpjs=tmpjs.toFixed(3);
commonGridObj_wmsin.getGridObj().cellByIndex(i,17).setLabel(tmpjs.toString());
}
}
//$("txt_goodspfsl").value = outputMoney(Sum_Out.toString());
$("h_goodspfsl").value = outputMoney(Sum_Out.toString());
//$("txt_packnum").value = outputMoney(amountpack.toString());
$("h_packnum").value = outputMoney(amountpack.toString());
}
function AddWmsOut() { //添加出库单
reloadParentEdit($("h_outgid").value, 'add', 0, $("h_bsno").value);
}
function DeleteWmsOut(){ //删除出库单
if($("txt_outbsno").value == ""){
return;
}
if(window.confirm("您确定要将选中的出库单删除")){
//
var urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getislock&gids=" + $("txt_outbsno").value + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alert("已入账的信息,不允许删除!");
return;
}
else {
var strREMARK = commonGridObj_wmsin.getGridObj().cellByIndex(0, 28).getValue();
if (strREMARK.trim() == "货权转移") {
urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getiswmsin&gids=" + $("txt_outbsno").value + "&val=" + newGuid();
loader = dhtmlxAjax.getSync(urlVal);
ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alert("有已入库的货权转移信息,不允许删除!");
return;
}
}
//
var url = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=deletewmsout&wmsoutgid=" + $("h_outgid").value;
var loader = dhtmlxAjax.getSync(url);
var deleteState = parseInt(loader.xmlDoc.responseText);
if (deleteState == 1) {
alert("成功删除出库单:" + $("txt_outbsno").value);
//AddWmsOut();
window.parent.opener.location.href = window.parent.opener.location.href;
window.close();
}
else {
alert("删除出库单,失败!");
}
}
}
}
function reloadParentEdit(strBSNO, strHandle, ischangecust, sASSOCIATEDNO) {
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
//
var isdisabled = false;
var urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getislock&gids=" + strBSNO + "&bsno=" + sASSOCIATEDNO + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alt = "已入账的信息,不允许修改!";
isdisabled = true;
}
else {
if (ischangecust == 1) {
urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getiswmsin&gids=" + strBSNO + "&bsno=" + sASSOCIATEDNO + "&val=" + newGuid();
loader = dhtmlxAjax.getSync(urlVal);
ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alt = "已入库的货权转移信息,不允许修改!";
isdisabled = true;
}
}
}
//
var newUrl = "";
if (strHandle == "addwmsout") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=edit&ischangecust=" + ischangecust + "&outgid=" + strBSNO + "&isdisabled=" + isdisabled;
alert('操作成功!');
}
else if (strHandle == "edit") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=edit&ischangecust=" + ischangecust + "&outgid=" + strBSNO + "&isdisabled=" + isdisabled;
alert('操作成功!');
}
else if (strHandle == "add") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=addwmsout&ischangecust=0&bsno=" + $("h_bsno").value;
}
}
function reloadParent(strBSNO, strHandle, sINBSNO, sASSOCIATEDNO) {
var parentObj = window.parent.location;
var oldUrl = parentObj.href;
//
var isdisabled = false;
var urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getislock&gids=" + strBSNO + "&bsno=" + sASSOCIATEDNO + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alt = "已入账的信息,不允许修改!";
isdisabled = true;
}
else {
urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getiswmsin&gids=" + strBSNO + "&bsno=" + sASSOCIATEDNO + "&val=" + newGuid();
loader = dhtmlxAjax.getSync(urlVal);
ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alt = "已入库的货权转移信息,不允许修改!";
isdisabled = true;
}
}
//
var newUrl = "";
if (strHandle == "addwmsout") {
var handleIndex = oldUrl.indexOf("handle=");
newUrl = oldUrl.substring(0, handleIndex);
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl + "handle=edit&ischangecust=1&outgid=" + strBSNO + "&isdisabled=" + isdisabled; ;
}
else if (strHandle == "edit") {
window.parent.opener.location.href = window.parent.opener.location.href;
}
alert('货权转移成功');
//
var URLs = "../SeaiInfo/WmsInfoCBM.aspx?handle=edit&id=" + sINBSNO + "&associatedno=" + sASSOCIATEDNO + "&val=" + newGuid();
window.open(URLs, "_blank", "height=630px, width=1100px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no,Top= " + (screen.height / 2 - 400) + ",Left= " + (screen.width / 2 - 600));
}
function setislock() {
var checked = $("h_outgid").value;
if (checked != null && checked != "") {
var urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getislock&gids=" + checked + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() != "0") {
alert("已入账的信息,不允许操作!");
return;
}
//
if (confirm('费用确定入账吗?(入账后将不允许修改删除数据!)')) {
var urlVal = "WmsOutEditCBMGridSource.aspx?handle=islock&gids=" + checked + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var strDel = loader.xmlDoc.responseText;
if (strDel.trim() != "") {
alert(strDel);
return;
}
// createOrder();
// window.parent.opener.location.href = window.parent.opener.location.href;
if ($("h_Ischange").value == "1") //货权转移
{
reloadParentEdit($("h_outgid").value, 'edit', 1, $("h_opseaibsno").value);
}
else {
reloadParentEdit($("h_outgid").value, 'edit', 0, $("h_opseaibsno").value);
}
}
}
else {
alert('未选中要操作的数据!');
return;
}
}
function setnotlock() {
var checked = $("h_outgid").value;
if (checked != null && checked != "") {
var urlVal = "../SeaiFee/WmsOutEditCBMGridSource.aspx?handle=getislock&gids=" + checked + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var ls = loader.xmlDoc.responseText;
if (ls.trim() == "0") {
alert("未入账的信息,不允许操作!");
return;
}
//
if (confirm('确定取消入账吗?(只有“未申请开票、未开发票、未对帐”的入账数据允许取消!)')) {
var urlVal = "WmsOutEditCBMGridSource.aspx?handle=notlock&gids=" + checked + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var strDel = loader.xmlDoc.responseText;
if (strDel.trim() != "") {
alert(strDel);
return;
}
//createOrder();
//window.parent.opener.location.href = window.parent.opener.location.href;
if ($("h_Ischange").value == "1") //货权转移
{
reloadParentEdit($("h_outgid").value, 'edit', 1, $("h_opseaibsno").value);
}
else {
reloadParentEdit($("h_outgid").value, 'edit', 0, $("h_opseaibsno").value);
}
}
}
else {
alert('未选中要操作的数据!');
return;
}
}
function setoldcustFeeDate() {
$("txt_oldcustFeeDate").value = $("txt_outdate").value;
}
function PrintWmsOut(){
var strOutBsno = "";
strOutBsno = $("h_outbsno").value;
if(strOutBsno == ""){
return;
}
var strBSNO = "";
strBSNO = $("h_outbsno").value;
var printUrl = "";
var companyID = "";
var typeName = "WMSOUTREPORT";
var dbSourceID = "";
var userID = "";
var url = "../Reports/ReportService.aspx?handle=printwmsout&bsno="+strBSNO+"&val="+newGuid();
typeName = "WMSOUTREPORT";
var loader = dhtmlxAjax.getSync(url);
var reportVal = loader.xmlDoc.responseText;
var reportObj = null;
if(reportVal != ""){
reportObj = eval('(' + reportVal + ')');
if(reportObj.reports.length > 0){
if(reportObj.reports[0].compid != ""){
companyID = reportObj.reports[0].compid;
}
if(reportObj.reports[0].sourceid != ""){
dbSourceID = reportObj.reports[0].sourceid;
}
if(reportObj.reports[0].compid != ""){
userID = reportObj.reports[0].userid;
}
printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
}
}else{
alert("没有要打印的报表");
return;
}
}