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.
DS7HYRD/DSWeb/js/InvoiceApplicationList.js

571 lines
22 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var commonGridObj_invoiceApp;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_invoiceapp = new Array("","申请编号","申请状态","发票号码","客户名称","发票抬头","申请金额","币别","申请人","申请时间","开出人","开出时间");
//width
var widthArgs_invoiceapp = new Array("40","150","60","120","120","200","150","70","70","150","120","120");
//column align
var colAlignArgs_invoiceapp = new Array("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");
//column type
var colTypeArgs_invoiceapp = new Array("ch","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("InvoiceApplicationGridSource.aspx");
commonGridObj_invoiceApp.setRequest("InvoiceApplicationGridSource.aspx?handle=invoiceapplist&show_page=15&cur_page=1&uid="+commonGridObj_invoiceApp.newGuid());
commonGridObj_invoiceApp.setSourceType("json");
commonGridObj_invoiceApp.setSkin("xp");
commonGridObj_invoiceApp.setImageUrl("../images/");
commonGridObj_invoiceApp.initGrid();
commonGridObj_invoiceApp.bind();
commonGridObj_invoiceApp.initPageByHandle("invoiceapplist");
// commonGridObj_invoiceApp.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
// if(stage == 0){
// return false;
// }
// });
// commonGridObj_invoiceApp.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
// var rId = commonGridObj_invoiceApp.getGridObj().getSelectedRowId();
// var openSet = "height=270, width=500, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-800)/2
// var openType = "_blank";
//
// var openUrl = "Edit.aspx?flowid="+rId+"&handle=edit";
// window.open (openUrl,openType,openSet);
// });
commonGridObj_invoiceApp.getGridObj().attachEvent("onRowDblClicked", function (id, ind) {
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
var openUrl = "InvoiceApplicationEdit.aspx?handle=edit&id="+id;
window.open (openUrl,openType,openSet);
});
commonGridObj_invoiceApp.clickEvent = function(){
commonGridObj_invoiceApp.getGridObj().attachEvent("onRowDblClicked", function (id, ind) {
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
var openUrl = "InvoiceApplicationEdit.aspx?handle=edit&id="+id;
window.open (openUrl,openType,openSet);
});
}
}
function initCombo(){
createComboCustomer();//结算单位
}
function addApplication(){
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?handle=validateinvoiceapp&uid="+commonGridObj_invoiceApp.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if(status > 0){
var rId = commonGridObj_invoiceApp.getGridObj().getSelectedRowId();
var openSet = "height=630, width=1085, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-630)/2 + ",Left= "+(screen.width-970)/2
var openType = "_blank";
//height=630, width=970,
var openUrl = "CommonInvoiceApplication.aspx?handle=add";
window.open (openUrl,openType,openSet);
}else{
alert("没有权限添加发票申请");
return;
}
}
function refreshList(){
createGrid();
}
//提交发票申请
function postApplication(){
var iCount = 0;
var iSuccess = 0;
var iNoExist = 0;
var iIsPost = 0;
var iError = 0;
var iNoPower = 0;
var strNotes = "";
if(commonGridObj_invoiceApp != null){
for(var i = 0;i<commonGridObj_invoiceApp.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoiceApp.getGridObj().getRowId(i);
var chBox = commonGridObj_invoiceApp.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则将保存的开发票申请提交,提交前先判断当前发票申请是否已经提交申请
if(chBox == 1){
iCount++;
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?appid="+rowId+"&handle=postApply&uid="+commonGridObj_invoiceApp.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
createGrid();
strNotes = "开票申请提交成功";
iSuccess++;
break;
case -1:
strNotes = "开票申请不存在";
iNoExist++;
break;
case -2:
strNotes = "开票申请已提交,不能重复提交";
iIsPost++;
break;
case -3:
strNotes = "开票申请提交异常";
iError++;
break;
case -4:
strNotes = "没有权限提交发票申请";
iNoPower++;
break;
}
}
}
if(iCount == 0){
alert("您没有选择要提交的开票申请");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 不存在记录"+iNoExist+"条 已提交不能删除"+iIsPost+"条 异常"+iError+"条 无权限删除"+iNoPower+"条");
}
}
}
function deleteUnpostApplication(){
var iCount = 0;
var iSuccess = 0;
var iNoExist = 0;
var iIsPost = 0;
var iError = 0;
var iNoPower = 0;
var strNotes = "";
if(commonGridObj_invoiceApp != null){
for(var i = 0;i<commonGridObj_invoiceApp.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoiceApp.getGridObj().getRowId(i);
var chBox = commonGridObj_invoiceApp.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则将保存的开发票申请删除,删除前先判断当前发票申请是否已经提交申请,如果已经提交,不能删除
if(chBox == 1){
iCount++;
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?appid="+rowId+"&handle=deleteApply&uid="+commonGridObj_invoiceApp.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
createGrid();
strNotes = "开票申请删除成功";
iSuccess++;
break;
case -1:
strNotes = "开票申请不存在";
iNoExist++;
break;
case -2:
strNotes = "开票申请已提交,不能删除";
iIsPost++;
break;
case -3:
strNotes = "开票申请提交异常";
iError++;
break;
case -4:
strNotes = "没有权限删除发票申请";
iNoPower++;
break;
}
}
}
if(iCount == 0){
alert("您没有选择要删除的开票申请");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 不存在记录"+iNoExist+"条 已提交不能删除"+iIsPost+"条 异常"+iError+"条 无权限删除"+iNoPower+"条");
}
}
}
//根据条件查询付费申请信息
function search() {
var _begintime = $("txt_beginDate").value.trim();
if(_begintime.trim() != ""){
if(!validateDateTime(_begintime)){
alert("起始时间格式错误");
return;
}
}
var _endtime = $("txt_endDate").value.trim();
if(_endtime.trim() != ""){
if(!validateDateTime(_endtime)){
alert("结束时间格式错误");
return;
}
}
//
var _customer = $("h_customer").value.trim();
var _checkno = $("txt_billno").value.trim();
var _invoicenum = $("txt_invoicenum").value.trim();
var _mblno = $("txt_mblno").value.trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
//如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
if(_begintime != "" && _endtime != ""){
if(_begintime.length > 9 && _endtime.length > 9){
var status = DateTimeEqual(_begintime,_endtime);
if(status == 0){
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}else if(status == -1){
alert("时间设置错误,起始时间不能大于结束时间,请修改!");
return;
}
// else if(status == -2){
// alert("时间设置错误,起始时间不能等于结束时间,请修改!");
// return;
// }
}
else{
alert("时间格式有问题,长度应大于9个字符,请修改!");
return;
}
}else{
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"no\":\"" + _checkno + "\",";
searchJson += "\"invoicenum\":\"" + _invoicenum + "\",";
searchJson += "\"mblno\":\"" + _mblno + "\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
//
var dg = new dialog();
dg.html = "程序正在执行,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
//
commonGridObj_invoiceApp.initGrid();
commonGridObj_invoiceApp.setRequest("InvoiceApplicationGridSource.aspx?handle=invoiceapplist&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_invoiceApp.newGuid());
commonGridObj_invoiceApp.bind();
commonGridObj_invoiceApp.setSearch(searchJson);
commonGridObj_invoiceApp.initPageByHandle("invoiceapplist");
//
commonGridObj_invoiceApp.getGridObj().attachEvent("onRowDblClicked", function (id, ind) {
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 490) / 2 + ",Left= " + (screen.width - 900) / 2
var openType = "_blank";
var openUrl = "InvoiceApplicationEdit.aspx?handle=edit&id=" + id;
window.open(openUrl, openType, openSet);
});
//
commonGridObj_invoiceApp.clickEvent = function () {
commonGridObj_invoiceApp.getGridObj().attachEvent("onRowDblClicked", function (id, ind) {
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 490) / 2 + ",Left= " + (screen.width - 900) / 2
var openType = "_blank";
var openUrl = "InvoiceApplicationEdit.aspx?handle=edit&id=" + id;
window.open(openUrl, openType, openSet);
});
}
//
setTimeout(function () {
dg.close();
}, 300);
}
//校验时间格式
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 initGrid(){
$("h_customer").value = "";
comboCustomer.setComboText($("h_customer").value);
$("txt_beginDate").value = "";
$("txt_endDate").value = "";
$("txt_billno").value = "";
$("txt_INVOICENUM").value = "";
$("txt_mblno").value = "";
createGrid();
}
function printInvoice() {
var strBSNO = "";
strBSNO = commonGridObj_invoiceApp.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
if (strBSNO.trim() == "") {
alert("没有要打印的报表");
return;
}
if (strBSNO.trim().indexOf(",") > 0) {
alert("每次只能打印一条发票信息");
return;
}
var printUrl = "";
var companyID = "";
var typeName = "PrintInvoiceApplicationReport";
var dbSourceID = "";
var userID = "";
var url = "../Reports/ReportService.aspx?handle=printinvoiceapplication&invoiceid=" + strBSNO + "&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;
var dfg = "";
}
} else {
alert("没有要打印的报表");
return;
}
}
function 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 msgBox() {
var dg = new dialog();
dg.html = "程序正在提交,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
}
//function getInfo()
//{
// var s = "";
// s += " 网页可见区域宽:"+ document.body.clientWidth;
// s += " 网页可见区域高:"+ document.body.clientHeight;
// s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)";
// s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)";
// s += " 网页正文全文宽:"+ document.body.scrollWidth;
// s += " 网页正文全文高:"+ document.body.scrollHeight;
// s += " 网页被卷去的高(ff)"+ document.body.scrollTop;
// s += " 网页被卷去的高(ie)"+ document.documentElement.scrollTop;
// s += " 网页被卷去的左:"+ document.body.scrollLeft;
// s += " 网页正文部分上:"+ window.screenTop;
// s += " 网页正文部分左:"+ window.screenLeft;
// s += " 屏幕分辨率的高:"+ window.screen.height;
// s += " 屏幕分辨率的宽:"+ window.screen.width;
// s += " 屏幕可用工作区高度:"+ window.screen.availHeight;
// s += " 屏幕可用工作区宽度:"+ window.screen.availWidth;
// s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色";
// s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸";
// alert (s);
//}