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.
DS7/DSWeb/js/FeePayAudit.js

576 lines
21 KiB
JavaScript

2 years ago
var commonGridObj_payaudit;
var comboCustomer;//委托单位
var SelectRowOplb="";//选中行的业务类别
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_payaudit = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />","申请单号","申请单状态","结算单位","USD","RMB","申请人","申请日期","备注","业务类别");//,"提单号"
//width
var widthArgs_payaudit = new Array("40", "120", "70", "100", "80", "80", "80", "120", "200", "0");//, "100"
//column align
var colAlignArgs_payaudit = new Array("center","center","center","center","center","center","center","center","center","center");//,"center"
//column sort
var colSortArgs_payaudit = new Array("na","str","str","str","str","str","str","str","str","str");//,"str"
//column type
var colTypeArgs_payaudit = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro");//,"ro"
commonGridObj_payaudit = new TGridCommon("mygrid_container_payaudit","form1",headerArgs_payaudit,widthArgs_payaudit,colAlignArgs_payaudit,colSortArgs_payaudit,colTypeArgs_payaudit);
commonGridObj_payaudit.setResponseUrl("PaySettlementGridSource.aspx");
var dd = $("h_searchJson").value.trim();
commonGridObj_payaudit.setSearch($("h_searchJson").value.trim());
// var uid = "";
// uid = $("h_userid").value;alert(uid);
commonGridObj_payaudit.setRequest("PaySettlementGridSource.aspx?handle=payappauditlist&show_page=15&cur_page=1&uid=" + commonGridObj_payaudit.newGuid() + "&search=" + escape($("h_searchJson").value.trim())); //&uid=" + uid
commonGridObj_payaudit.setSourceType("json");
commonGridObj_payaudit.setSkin("xp");
commonGridObj_payaudit.setImageUrl("../images/");
commonGridObj_payaudit.initGrid();
setTimeout(function() {
commonGridObj_payaudit.bind();
}, 500);
commonGridObj_payaudit.isSort = true;
commonGridObj_payaudit.initPageByHandle("payappauditlist");
commonGridObj_payaudit.isDBClickEvent = true;
commonGridObj_payaudit.getGridObj().attachEvent("onRowDblClicked", function (rId, cInd) {
var rId = commonGridObj_payaudit.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_payaudit.getGridObj().getRowIndex(rId);
var billNO = commonGridObj_payaudit.getGridObj().cellByIndex(rowIndex, 1).getValue();
var oplb = commonGridObj_payaudit.getGridObj().cellByIndex(rowIndex, 9).getValue();
var openSet = "height=700, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=0,location=no, status=no,Top=30,Left=30";
var openType = "_blank";
var moduleName = commonGridObj_payaudit.$("h_mod").value;
var openUrl = "CommonPayApplicationAudit.aspx?id=" + rId + "&billno=" + billNO + "&mod=" + moduleName + "&oplb=" + oplb;
window.open(openUrl, openType, openSet);
});
commonGridObj_payaudit.clickEvent = function() {
commonGridObj_payaudit.getGridObj().attachEvent("onRowDblClicked", function(rId, cInd) {
var rId = commonGridObj_payaudit.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_payaudit.getGridObj().getRowIndex(rId);
var billNO = commonGridObj_payaudit.getGridObj().cellByIndex(rowIndex, 1).getValue();
var oplb = commonGridObj_payaudit.getGridObj().cellByIndex(rowIndex, 9).getValue();
var openSet = "height=700, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=0,location=no, status=no,Top=30,Left=30";
var openType = "_blank";
var moduleName = commonGridObj_payaudit.$("h_mod").value;
var openUrl = "CommonPayApplicationAudit.aspx?id=" + rId + "&billno=" + billNO + "&mod=" + moduleName + "&oplb=" + oplb;
window.open(openUrl, openType, openSet);
});
}
}
function auditAction(){
var openSet = "height=680, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-650)/2 + ",Left= "+(screen.width-1200)/2
var openType = "_blank";
var openUrl = "commonsettlement.aspx";
window.open (openUrl,openType,openSet);
}
function initCombo(){
createComboCustomer();//结算单位
}
function refreshList(){
createGrid();
}
function auditPass(){
var iCount = 0;
if (commonGridObj_payaudit != null) {
var selGroup = new Array();
var selRowID = commonGridObj_payaudit.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
if(selRowID.trim()=="")
{
alert("您没有选择要审核的付费申请");
return;
}
if(selRowID.indexOf(",") > 0){
selGroup = selRowID.split(",");
}else{
if(selRowID != null){
selGroup.push(selRowID);
}
}
//查看是否有被选中的费用项
if (selGroup.length > 0) {
for (var i = 0; i < selGroup.length; i++) {
var rowId = selGroup[i].toString();//获取RowID
//获取当前RowIndex
var RowIndex = commonGridObj_payaudit.getGridObj().getRowIndex(rowId);
var billno = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 1).getValue();
var clientName = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 3).getValue().trim();
var oplb = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 9).getValue();
//如果选中,则进入审核流程
var isOrderPay = false;
var isRun = true;
var stlName = "";
//验证结算单位是否是月结或者是半月结
var url = "../FeeCodes/CRMClientInfo.aspx?handle=clientstl&name=" + escape(clientName) + "&uid=" + commonGridObj_payaudit.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stlVal = loader.xmlDoc.responseText;
var stlObj = null;
stlObj = eval('(' + stlVal + ')');
if (stlObj.customer.length > 0) {
var stlType = parseInt(stlObj.customer[0].stl);
switch (stlType) {
case 0:
case 1:
isOrderPay = true;
stlName = "票结";
break;
case 2:
stlName = "半月结";
isOrderPay = false;
break;
case 3:
stlName = "月结";
isOrderPay = false;
break;
}
} else {
isOrderPay = true;
}
if (!isOrderPay) {
if (stlName.trim() == "") {
isRun = true;
}
else {
if (window.confirm("当前结算单位为 " + stlName + " 您确定要提交付费申请")) {
isRun = true;
} else {
isRun = false;
}
}
}
if (isRun) {
//异步执行操作
var url = "FeePayAuditService.aspx?billno=" + billno + "&handle=auditpass&oplb=" + oplb + "&uid=" + commonGridObj_payaudit.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch (status) {
case 1:
iCount=1;
break;
case -1:
case -2:
alert("审核操作异常");
break;
case -3:
alert("您没有权限审核付费申请");
break;
case -4:
alert("付费审核步骤已经完成,不能重复审核");
break;
}
}
}
//
if(iCount==1)
{
$("ddlBILLSTATUS").value = "3"; //审批中// "0";//已审批
search();
alert("批准支付操作完成");
}
}
else {
alert("您没有选择要审核的付费申请");
return;
}
}
}
function auditReject(){
var iCount = 0;
if(commonGridObj_payaudit != null){
var selGroup = new Array();
var selRowID = commonGridObj_payaudit.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
if(selRowID.trim()=="")
{
alert("您没有选择要操作的付费申请");
return;
}
if(selRowID.indexOf(",") > 0){
selGroup = selRowID.split(",");
}else{
if(selRowID != null){
selGroup.push(selRowID);
}
}
//查看是否有被选中的费用项
if (selGroup.length > 0) {
for (var i = 0; i < selGroup.length; i++) {
var rowId = selGroup[i].toString(); //获取RowID
//获取当前RowIndex
var RowIndex = commonGridObj_payaudit.getGridObj().getRowIndex(rowId);
var chBox = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 0).getValue();
var billno = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 1).getValue();
var oplb = commonGridObj_payaudit.getGridObj().cellByIndex(RowIndex, 9).getValue();
//异步执行操作
var url = "FeePayAuditService.aspx?billno=" + billno + "&handle=auditreject&oplb=" + oplb + "&uid=" + commonGridObj_payaudit.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch (status) {
case 1:
iCount = 1;
break;
case -1:
alert("驳回操作失败");
break;
case -2:
alert("您没有权限审核付费申请");
break;
case -3:
alert("审核已经进入下一步,不能执行驳回操作");
break;
}
}
}
//
if(iCount==1)
{
$("ddlBILLSTATUS").value = "6";
search();
alert("驳回申请操作完成");
}
}
}
//校验时间格式
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.setOptionWidth(190);
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 = "";
search();
}
//根据条件查询付费申请信息
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 += "\"billstatus\":\"" + $("ddlBILLSTATUS").value.trim() + "\",";
searchJson += "\"no\":\""+_checkno+"\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
$("h_searchJson").value = searchJson;
//
createGrid();
}
function checkAll(id){
var checkAllState = $(id).checked;
if(checkAllState == 1){
for(var i = 0;i<commonGridObj_payaudit.getGridObj().getRowsNum();i++){
commonGridObj_payaudit.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i = 0;i<commonGridObj_payaudit.getGridObj().getRowsNum();i++){
commonGridObj_payaudit.getGridObj().cellByIndex(i,0).setValue(0);
}
}
}
function Getsearch(){
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 += "]";
searchJson +="}";//alert(searchJson);
$("h_searchJson").value=searchJson;
}
function printInvoice(){
var strBSNO = "";
var checked = commonGridObj_payaudit.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
var printUrl = "";
var companyID = "";
var typeName = "PayFeeAuditList";
var dbSourceID = "";
var userID = "";
var url="";
if($("h_searchJson").value!=null){
url = "../Reports/ReportService.aspx?handle=printpayfeeauditlist&gids=" + checked + "&search=" + escape($("h_searchJson").value) + "&val=" + commonGridObj_payaudit.newGuid();
}
else{
url = "../Reports/ReportService.aspx?handle=printpayfeeauditlist&gids=" + checked + "&val=" + commonGridObj_payaudit.newGuid();
}
typeName = "PayFeeAuditList";
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;
}
}
function printInvoice2() {
var checked = commonGridObj_payaudit.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
var printUrl = "";
var companyID = "";
var typeName = "PayFeeAuditReport2";
var dbSourceID = "";
var userID = "";
if (checked.trim() == "") {
alert("请先选择要操作的数据!");
return;
}
var url = "../Reports/ReportService.aspx?handle=printpayfeeauditreport2&gids=" + checked + "&val=" + commonGridObj_payaudit.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;
}
}