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.

347 lines
13 KiB
JavaScript

10 months ago
var commonGridObj_invoiceApp;
var comboCustomer;//委托单位
var pressRecord;
function $(id){
return document.getElementById(id);
}
//全选框
function checkall() {
var checkStatus = $("ck_all").checked;
if (checkStatus == 1) {
var iCount = commonGridObj_invoiceApp.getGridObj().getRowsNum();
for (var i = 0; i < iCount; i++) {
commonGridObj_invoiceApp.getGridObj().cellByIndex(i, 0).setValue(1);
}
}
else {
var iCount = commonGridObj_invoiceApp.getGridObj().getRowsNum();
for (var i = 0; i < iCount; i++) {
commonGridObj_invoiceApp.getGridObj().cellByIndex(i, 0).setValue(0);
}
}
}
function createGrid(){
//header
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
var headerArgs_invoiceapp = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkall()\" />", "货主", "提单号", "备案清单号", "入库单号", "入库日期", "计费日期", "仓库名称", "品名", "型号", "剩余库存", "剩余件数", "仓储天数", "计费天数", "仓储费", "开单人", "开单时间", "进口委托单号", "是否有出库单");
//width
var widthArgs_invoiceapp = new Array("20","100","120","120","120","120","120","100","100","100","80","80","80","80","80","100","120","0","0");
//column align
var colAlignArgs_invoiceapp = new Array("center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_invoiceapp = new Array("na","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_invoiceapp = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_invoiceApp = new TGridCommon("mygrid_container_invoiceapp","form1",headerArgs_invoiceapp,widthArgs_invoiceapp,colAlignArgs_invoiceapp,colSortArgs_invoiceapp,colTypeArgs_invoiceapp);
commonGridObj_invoiceApp.setResponseUrl("../SeaiInfoLCL/WmsRateGridSource.aspx");
GetSearchJoin();
var search="";
search=$("h_searchJson").value;
//if (search != null && search != "")
if ($("h_issearch").value.trim() == "1")
{
commonGridObj_invoiceApp.setRequest("../SeaiInfoLCL/WmsRateGridSource.aspx?handle=WmsFeeQuery&show_page=15&cur_page=1&search="+escape($("h_searchJson").value));
}
else
{
commonGridObj_invoiceApp.setRequest("../SeaiInfoLCL/WmsRateGridSource.aspx?handle=WmsFeeQuery&show_page=0&cur_page=0");
}
commonGridObj_invoiceApp.setSourceType("json");
commonGridObj_invoiceApp.setSkin("xp");
commonGridObj_invoiceApp.setImageUrl("../images/");
commonGridObj_invoiceApp.initGrid();
commonGridObj_invoiceApp.bind();
if (search!=null){
commonGridObj_invoiceApp.setSearch(search);
}
commonGridObj_invoiceApp.initPageByHandle("WmsFeeQuery");
setTimeout(function(){
markStatusColor(commonGridObj_invoiceApp.getGridObj());
}, 500);
// commonGridObj_invoiceApp.getGridObj().attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
// if (cInd == 0) {
// return true;
// }
// return false;
// });
}// createGrid() end
function initCombo(){
createComboCustomer();//结算单位
}
function refreshList(){
createGrid();
}
//根据条件查询付费申请信息
function search() {
$("h_issearch").value = "1";
GetSearchJoin();//检查查询条件
createGrid();
}
function GetSearchJoin(){
var outdate = $("txt_outDate").value.trim();
if(outdate.trim() != ""){
if(!validateDateTime(outdate)){
alert("计费时间格式错误");
return;
}
}
else{
$("h_searchJson").value="";
return;
}
var isout= $("ck_isout").checked;
$("h_outDate").value = $("txt_outDate").value;
$("h_blno").value = $("txt_blno").value;
var cus = $("h_customer").value;
var blno = $("h_blno").value;
var customno = $("txt_customno").value;
var searchJson = "";
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+cus+"\",";
searchJson += "\"outdate\":\""+outdate+"\",";
searchJson += "\"isout\":\""+isout+"\",";
searchJson += "\"customno\":\"" + customno + "\",";
searchJson += "\"blno\":\""+blno+"\"";
searchJson += "]";
searchJson +="}";
$("h_searchJson").value=searchJson;
}
//校验时间格式
function validateDateTime(dateTimeObj){
var isValid = false;
var parseToObj = new Date(dateTimeObj.replace(/-/g, "/"));
if(!isNaN(parseToObj)){
isValid = true;
}
return isValid;
}
function DateTimeEqual(beginObj,endObj){
var isEqual = 0;
var begin = new Date(beginObj.replace(/-/g, "/"));
var end = new Date(endObj.replace(/-/g, "/"));
if(Date.parse(begin) - Date.parse(end) > 0){
isEqual = -1;//起始时间大于结束时间
}else if(Date.parse(begin) - Date.parse(end) == 0){
isEqual = -2;//起始时间与结束时间相等
}
return isEqual;
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function createComboCustomer(){//委托单位
comboCustomer = dhtmlXComboFromSelect("sel_customer");
comboCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");
comboCustomer.attachEvent("onChange", function(){
comboCustomer.setComboText($("h_customer").value);
});
comboCustomer.attachEvent("onBlur", function(){
var s1 = comboCustomer.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboCustomer.setComboText(s3);
$("h_customer").value=s3;
}
else
{
comboCustomer.setComboText($("h_customer").value);
}
});
comboCustomer.setComboText($("h_customer").value);
comboCustomer.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_customer").value.trim();
if("" != comboCustomer.getComboText().trim()){
while("undefined" != typeof comboCustomer.getOptionByIndex(filterCount)){
var comboValue = comboCustomer.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboCustomer.getComboText().trim().toUpperCase();
$("h_customer").value = comboCustomer.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboCustomer.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_customer").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboCustomer.attachEvent("onSelectionChange", function(){
$("h_customer").value = comboCustomer.getComboText().trim();
});
}
function initComboGoods(){//货物描述类型ok
comboCustomer = new TCombo("sel_goods", "../SeaiInfoLCL/WmsRateGridSource.aspx?handle=goodslist", true, true, false, true, "h_goods");
comboCustomer.initComboEvent();
comboCustomer.bind();
}
function createComboGoods(){//货物描述类型ok
comboGoods = dhtmlXComboFromSelect("sel_goods");
comboGoods.loadXML("../SeaiInfoLCL/WmsRateGridSource.aspx?handle=goodslist");
comboGoods.setOptionWidth(200);
comboGoods.attachEvent("onChange", function(){
comboGoods.setComboText($("h_goods").value);
});
comboGoods.attachEvent("onBlur", function(){
var s1 = comboGoods.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboGoods.setComboText(s3);
$("h_goods").value=s3;
}
else
{
comboGoods.setComboText($("h_goods").value);
}
});
comboGoods.setComboText($("h_goods").value);
comboGoods.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_goods").value.trim();
if("" != comboGoods.getComboText().trim()){
while("undefined" != typeof comboGoods.getOptionByIndex(filterCount)){
var comboValue = comboGoods.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboGoods.getComboText().trim().toUpperCase();
$("h_goods").value = comboGoods.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboGoods.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_goods").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboGoods.attachEvent("onSelectionChange", function(){
$("h_goods").value = comboGoods.getComboText().trim();
});
}
//初始化界面
function initGrid(){
$("h_customer").value = "";
comboCustomer.setComboText($("h_customer").value);
$("txt_outDate").value = "";
$("txt_blno").value = "";
$("txt_customno").value = "";
$("h_searchJson").value="";
createGrid();//重新填充数据
}
//依据费用状态设置对应行的背景颜色
function markStatusColor(gridObj){
var count = gridObj.getRowsNum();
for(var i = 0;i<count-1;i++){
var rowId = gridObj.getRowId(i);
var status = gridObj.cellById(rowId,20).getValue();
if(status=="1"){
gridObj.setRowColor(rowId,"#7FDF00");
}
}
}
//是否为数字
function IsNum(val){
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)){
return false;
}else{
return true;
}
}
//去除“,”
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
function printFee() {
GetSearchJoin();//查询条件
var strBSNO = "";
strBSNO = commonGridObj_invoiceApp.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
var printUrl = "";
var companyID = "";
var typeName = "printwmsfeequery";
var dbSourceID = "";
var userID = "";
GetSearchJoin();
var url = "../Reports/ReportService.aspx?handle=printwmsfeequery&bsno=" + strBSNO + "&search=" + escape($("h_searchJson").value) + "&val=" + commonGridObj_invoiceApp.newGuid();
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;
}
}