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.

720 lines
26 KiB
JavaScript

10 months ago
var commonGridObj_invoicelist;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
$("hdNAMES").value = "类别\t收费\t废除\t业务编号\t发票号码\t客户名称\t发票抬头\t金额\t币别\t开票人\t开票日期\t开出人\t开出时间";
var headerArgs_invoicelist = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll()\" />","类别","收费","废除","业务编号","发票号码","客户名称","发票抬头","金额","币别","开票人","开票日期","开出人","开出时间");
//width
var widthArgs_invoicelist = new Array("40","150","60","60","120","120","150","150","70","70","70","150","100","150");
//column align
var colAlignArgs_invoicelist = new Array("center","center","center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_invoicelist = new Array("na","str","str","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_invoicelist = new Array("ch","ro","ch","ch","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_invoicelist = new TGridCommon("mygrid_container_invoicelist","form1",headerArgs_invoicelist,widthArgs_invoicelist,colAlignArgs_invoicelist,colSortArgs_invoicelist,colTypeArgs_invoicelist);
commonGridObj_invoicelist.setResponseUrl("InvoiceApplicationGridSource.aspx");
commonGridObj_invoicelist.setRequest("InvoiceApplicationGridSource.aspx?handle=makeoutlist&show_page=15&cur_page=1&uid="+commonGridObj_invoicelist.newGuid());
commonGridObj_invoicelist.setSourceType("json");
commonGridObj_invoicelist.setSkin("xp");
commonGridObj_invoicelist.setImageUrl("../images/");
commonGridObj_invoicelist.initGrid();
commonGridObj_invoicelist.bind();
commonGridObj_invoicelist.initPageByHandle("makeoutlist");
commonGridObj_invoicelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
if(cInd == 2 || cInd == 3){
return false;
}else{
return true;
}
}
});
commonGridObj_invoicelist.isOnEditCell = true;
commonGridObj_invoicelist.onEditCellEvent = function(){
commonGridObj_invoicelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
if(cInd == 2 || cInd == 3){
return false;
}else{
return true;
}
}
});
}
commonGridObj_invoicelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=510, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-510)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "InvoiceMakeOutEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
commonGridObj_invoicelist.dbclickEvent = function(){
commonGridObj_invoicelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=510, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-510)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "InvoiceMakeOutEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
}
}
function initCombo(){
createComboCustomer();//结算单位
}
//删除发票
function deleteInvoice(){
var iCount = 0;
var iSuccess = 0;
var iError = 0;
var iIsPrint = 0;
var iNoPower = 0;
var strNotes = "";
if (commonGridObj_invoicelist != null) {
var dlkj = commonGridObj_invoicelist.getGridObj().getRowsNum();
for(var i = 0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoicelist.getGridObj().getRowId(i);
var chBox = commonGridObj_invoicelist.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则将保存的开发票申请提交,提交前先判断当前发票申请是否已经提交申请
if(chBox == 1){
iCount++;
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?invoiceid="+rowId+"&handle=deleteinvoice&uid="+commonGridObj_invoicelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
strNotes = "发票删除成功";
iSuccess++;
break;
case -1:
strNotes = "发票已经打印,不能删除,只能废除操作";
iIsPrint++;
break;
case -2:
strNotes = "处理异常";
iError++;
break;
case -3:
strNotes = "没有权限删除发票";
iNoPower++;
break;
}
}
}
if(iCount == 0){
alert("您没有选择要提交的开票申请");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 异常"+iError+"条 已打印不能删除"+iIsPrint+"条 无权限"+iNoPower+"条");
}
createGrid();
}
}
//作废发票
function voidInvoice(){
var iCount = 0;
var iSuccess = 0;
var iError = 0;
var iReDo = 0;
var iNoPower = 0;
var strNotes = "";
var iCount = 0;
var selArg = new Array();
if(commonGridObj_invoicelist != null){
for(var i = 0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoicelist.getGridObj().getRowId(i);
var chBox = commonGridObj_invoicelist.getGridObj().cellByIndex(i,0).getValue();
if(chBox == 1){
selArg.push(rowId);
iCount++;
}
}
}
if(iCount > 0){
if(window.confirm("您确定要将选择的发票进行废除操作")){
for(var i = 0;i<selArg.length;i++){
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?invoiceid="+selArg[0]+"&handle=voidinvoice&uid="+commonGridObj_invoicelist.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 = "发票废除异常";
iError++;
break;
case -2:
strNotes = "发票已经废除,不能重复操作";
iReDo++;
break;
case -3:
strNotes = "没有权限作废发票";
iNoPower++;
break;
}
}
if(iCount == 0){
alert("您没有选择要废除的发票");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 异常"+iError+"条 禁止重复操作"+iReDo+"条 无权限"+iNoPower+"条");
}
}
}
}
//引入申请数据
function importApplication(){
alert();
}
//直接开出发票
function makeOutDirected(){
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?handle=validatemakeout&uid="+commonGridObj_invoicelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if(status > 0){
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";
var openUrl = "InvoiceMakeOutModify.aspx?handle=directmake";
window.open (openUrl,openType,openSet);
}else{
alert("没有权限开发票");
return;
}
}
//开出申请发票
function makeOutApplication(){
//异步执行操作
var url = "InvoiceApplicationGridSource.aspx?handle=validatemakeout&uid="+commonGridObj_invoicelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if(status > 0){
var openSet = "height=470, width=1250, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 470) / 2 + ",Left=10px";
var openType = "_blank";
var openUrl = "InvoiceMakeOutList.aspx";
window.open (openUrl,openType,openSet);
}else{
alert("没有权限开发票");
return;
}
}
////打印发票
//function printInvoice(){
// var iCount = 0;
// var iSuccess = 0;
// var iError = 0;
// var iIsPrint = 0;
// var iNoPower = 0;
//
// var strNotes = "";
// if(commonGridObj_invoicelist != null){
// for(var i = 0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
// var rowId = commonGridObj_invoicelist.getGridObj().getRowId(i);
// var chBox = commonGridObj_invoicelist.getGridObj().cellByIndex(i,0).getValue();
// //如果选中,则将保存的开发票申请提交,提交前先判断当前发票申请是否已经提交申请
// if(chBox == 1){
// iCount++;
// //异步执行操作
// var url = "InvoiceApplicationGridSource.aspx?invoiceid="+rowId+"&handle=print&uid="+commonGridObj_invoicelist.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 = "处理异常";
// iError++;
// break;
// case -2:
// strNotes = "发票已经废除不能打印";
// iIsPrint++;
// break;
// case -3:
// strNotes = "没有权限打印发票";
// iNoPower++;
// break;
// }
// }
// }
//
// if(iCount == 0){
// alert("您没有选择要打印的发票");
// }else if(iCount == 1){
// alert(strNotes);
// }else if(iCount > 1){
// alert("共操作"+iCount+"条 成功"+iSuccess+"条 异常"+iError+"条 已打印不能重复"+iIsPrint+"条 无权限"+iNoPower+"条");
// }
// }
//}
//生成税控
function invoiceAdapter(){
var strInvoiceID = "";
var typeName = "";
var selArg = new Array();
var iCount = 0;
for(var i=0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_invoicelist.getGridObj().cellByIndex(i,0).getValue();
var rId = commonGridObj_invoicelist.getGridObj().getRowId(i);
if(checkState == 1){
iCount++;
selArg.push(rId);
}
}
if(iCount == 1){
strInvoiceID = selArg[0];
var printUrl = "";
var companyID = "";
var typeName = "QDSK";
var dbSourceID = "";
var userID = "";
var url = "";
url = "../Reports/ReportService.aspx?handle=printinvoice&invoiceid="+strInvoiceID+"&val="+commonGridObj_invoicelist.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 = "qdsk://?comp="+companyID+"&type="+typeName+"&dbid="+strInvoiceID+"&uid="+userID;//alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
}
}else{
alert("没有要打印的报表");
return;
}
}else{
alert("每次只能打印一条发票信息");
}
}
//发票明细打印
function printInvoiceDetail(){
var strBillNO = "";
var typeName = "";
var selArg = new Array();
var iCount = 0;
for(var i=0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_invoicelist.getGridObj().cellByIndex(i,0).getValue();
var rId = commonGridObj_invoicelist.getGridObj().getRowId(i);
if(checkState == 1){
iCount++;
selArg.push(rId);
}
}
if(iCount == 1){
var rowIndex = commonGridObj_invoicelist.getGridObj().getRowIndex(selArg[0]);
strBillNO = commonGridObj_invoicelist.getGridObj().cellByIndex(rowIndex,4).getValue();
if(strBillNO.trim() != ""){
var printUrl = "";
var companyID = "";
var typeName = "INVOICEDETAIL";
var dbSourceID = "";
var userID = "";
var url = "";
url = "../Reports/ReportService.aspx?handle=printinvoicedetail&billno="+strBillNO+"&val="+commonGridObj_invoicelist.newGuid();
typeName = "INVOICEDETAIL";
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;
}
}
}else{
alert("每次只能打印一条发票信息");
}
}
function refreshList(){
createGrid();
}
//根据条件查询付费申请信息
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 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 += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson += "}"; //alert(searchJson);
$("hdSearch").value = searchJson;
commonGridObj_invoicelist.initGrid();
commonGridObj_invoicelist.setRequest("InvoiceApplicationGridSource.aspx?handle=makeoutlist&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_invoicelist.newGuid());
commonGridObj_invoicelist.bind();
commonGridObj_invoicelist.setSearch(searchJson);
commonGridObj_invoicelist.initPageByHandle("makeoutlist");
commonGridObj_invoicelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
if(cInd == 2 || cInd == 3){
return false;
}else{
return true;
}
}
});
commonGridObj_invoicelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var rId = commonGridObj_invoicelist.getGridObj().getSelectedRowId();
var openSet = "height=500, width=960, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-960)/2
var openType = "_blank";
var openUrl = "InvoiceMakeOutEdit.aspx?id="+rId+"&handle=edit";
window.open (openUrl,openType,openSet);
});
}
//校验时间格式
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 = "";
$("hdSearch").value = "";
$("txt_amount1").value = "";
$("txt_amount2").value = "";
createGrid();
}
function checkInfo(){
var checkRowID = "";
var iCheckCount = 0;
for(var i=0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoicelist.getGridObj().getRowId(i);
var rowIndex = commonGridObj_invoicelist.getGridObj().getRowIndex(rowId);
var checkState = commonGridObj_invoicelist.getGridObj().cellByIndex(rowIndex,0).getValue();
if(checkState == 1){
if(iCheckCount > 0){
commonGridObj_invoicelist.getGridObj().cellByIndex(rowIndex,0).setValue(0);
}else{
iCheckCount++;
checkRowID = rowId;
}
}
}
if(checkRowID != ""){
var openSet = "height=510, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-510)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "InvoiceMakeOutEdit.aspx?handle=edit&id="+checkRowID;
var tempWin = window.open ("about:blank",openType,openSet);
tempWin.location = openUrl;
}
}
function checkAll(){
if(commonGridObj_invoicelist != null){
for(var i=0;i<commonGridObj_invoicelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_invoicelist.getGridObj().getRowId(i);
var rowIndex = commonGridObj_invoicelist.getGridObj().getRowIndex(rowId);
if($("ck_all").checked){
commonGridObj_invoicelist.getGridObj().cellByIndex(rowIndex,0).setValue(1);
}else{
commonGridObj_invoicelist.getGridObj().cellByIndex(rowIndex,0).setValue(0);
}
}
}
}
function setExcel() {
if (confirm('确定要导出报表吗?')) {
var searchJson = $("hdSearch").value.trim();
var loader = dhtmlxAjax.getSync("InvoiceApplicationGridSource.aspx?handle=makeoutlistexcel&search=" + escape(searchJson) + "&uid=" + newGuid());
$("hdSQL").value = loader.xmlDoc.responseText;
document.getElementById("ibExcel").click();
}
}
//获取GUID
function newGuid() {
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 IsNumFormat(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
}
else {
if (val.toString().indexOf(".") > 0) {
val.toString().replace("-", "");
val.toString().replace("+", "");
if (val.toString().substr(0, 1) == "0" && val.toString().substr(0, 2) != "0.") {
return false;
}
}
else {
var re1 = /^[-\+]+[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
re1 = /^[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
return false;
}
}
}
return true;
}
}
//
function getIsNum(x) {
var str = x.value.trim();
if (str == "0") {
return;
}
else if (str == "") {
return;
// str = 0;
// x.value = 0;
}
else {
var bl = IsNumFormat(str);
if (!bl) {
alert("数值格式错误!");
x.focus();
x.select();
}
}
}