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.
HENGCHENG/DSWeb/js/PayApplicationSettlement.js

318 lines
12 KiB
JavaScript

12 months ago
//Grid 对象
var commonGridObj_payappsettlement;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
//创建Grid
function createGrid(){
//header
var headerArgs_paysettlement = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />","申请单号","申请单状态","结算单位","结算方式","USD","RMB","申请人","申请日期","备注");
//width
var widthArgs_paysettlement = new Array("40","120","70","100","70","80","80","80","150","200");
//column align
var colAlignArgs_paysettlement = new Array("center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_paysettlement = new Array("na","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_paysettlement = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_payappsettlement = new TGridCommon("mygrid_container_paysettlement","form1",headerArgs_paysettlement,widthArgs_paysettlement,colAlignArgs_paysettlement,colSortArgs_paysettlement,colTypeArgs_paysettlement);
commonGridObj_payappsettlement.setResponseUrl("PaySettlementGridSource.aspx");
commonGridObj_payappsettlement.setRequest("PaySettlementGridSource.aspx?handle=payappsettlelist&search=" + escape($("hdSearch").value.trim()));
commonGridObj_payappsettlement.setSourceType("json");
commonGridObj_payappsettlement.setSkin("xp");
commonGridObj_payappsettlement.setImageUrl("../images/");
commonGridObj_payappsettlement.initGrid();
commonGridObj_payappsettlement.bind();
commonGridObj_payappsettlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var rId = commonGridObj_payappsettlement.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_payappsettlement.getGridObj().getRowIndex(rId);
var billNO = commonGridObj_payappsettlement.getGridObj().cellByIndex(rowIndex,1).getValue();
var openSet = "height=500, width=1050, 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 moduleName = commonGridObj_payappsettlement.$("h_mod").value;
var openUrl = "CommonPayApplicationSettlement.aspx?id="+rId+"&billno=" + billNO + "&mod=" + moduleName;
window.open (openUrl,openType,openSet);
});
}
function initCombo(){
createComboCustomer();//结算单位
}
//结算按钮事件
function settleAction(){
var iCount = 0;
if(commonGridObj_payappsettlement != null){
var rowId = "";
var billno = "";
for(var i = 0;i<commonGridObj_payappsettlement.getGridObj().getRowsNum();i++){
rowId = commonGridObj_payappsettlement.getGridObj().getRowId(i);
var chBox = commonGridObj_payappsettlement.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则进入付费申请结算
if(chBox == 1){
iCount++;
if(iCount == 1){
billno = commonGridObj_payappsettlement.getGridObj().cellByIndex(i,1).getValue();
}else{
break;
}
}
}
if(iCount == 0){
alert("请选择您要结算的申请");
}else if(iCount == 1){
//异步执行操作
var url = "FeePayAuditService.aspx?billno="+billno+"&handle=issettled&uid="+commonGridObj_payappsettlement.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 0:
break;
case 1:
//createGrid();
alert("付费申请已经结算完毕,不能重复结算");
break;
case -1:
alert("没有相关申请信息");
break;
case -2:
alert("付费申请正在审批中");
break;
}
if(status == 0){
var openSet = "height=600, width=950, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-460)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var openUrl = "DoPayApplicationSettlement.aspx?billno=" + billno;
window.open (openUrl,openType,openSet);
}
}else{
rowId = "";
billno = "";
alert("每次只能选择一条付费申请进行结算,请重新选择");
}
}
}
//刷新列表
function refreshList(){
createGrid();
}
function mergerSettle(){
var iCount = 0;
var payArg = new Array();
for(var i = 0;i<commonGridObj_payappsettlement.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_payappsettlement.getGridObj().cellByIndex(i,0).getValue();
if(checkState == 1){
payArg.push(commonGridObj_payappsettlement.getGridObj().cellByIndex(i,1).getValue())
iCount++;
}
}
if(iCount == 0){
alert("没有选择要合并结算的付费申请");
return;
}
var strBillGroup = "";
if(payArg.length > 0){
for(var j=0;j<payArg.length;j++){
}
}
if(strBillGroup.trim() != ""){
var url = "FeePayAuditService.aspx?billgroup="+strBillGroup+"&handle=issettled&uid="+commonGridObj_payappsettlement.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
}
}
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 checkAll(id){
if($(id).checked){
for(var i=0;i<commonGridObj_payappsettlement.getGridObj().getRowsNum();i++){
commonGridObj_payappsettlement.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i=0;i<commonGridObj_payappsettlement.getGridObj().getRowsNum();i++){
commonGridObj_payappsettlement.getGridObj().cellByIndex(i,0).setValue(0);
}
}
}
function mergePayApp(){
var payAppArg = new Array();
var firstCust = "";
for(var i=0;i<commonGridObj_payappsettlement.getGridObj().getRowsNum();i++){
if(commonGridObj_payappsettlement.getGridObj().cellByIndex(i,0).getValue() == 1){
if(payAppArg.length > 0){
}else{
firstCust
}
payAppArg.push(commonGridObj_payappsettlement.getGridObj().getRowId(i));
}
}
if(payAppArg.length > 1){
$("h_merge").value = payAppArg;
$("h_enter").value = "1";
postEnterFee();
}else{
alert("合并结算操作错误,合并操作至少不能小于2条付费申请");
}
}
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function redirectSettle(type,val){
var openSet = "height=600, width=950, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " + (screen.height - 460) / 2 + ",Left= " + (screen.width - 800) / 2
var openType = "_blank";
var openUrl = "";
if(type == 1){
//单个付费申请结算
openUrl = "DoPayApplicationSettlement.aspx?type="+type+"&billno="+val;
}else if(type == 2){
//合并付费申请结算
openUrl = "DoPayApplicationSettlement.aspx?type="+type+"&mergecachename="+val;
}
window.open (openUrl,openType,openSet);
}
//根据条件查询付费申请信息
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 += "]";
searchJson += "}"; //alert(searchJson);
$("hdSearch").value = searchJson;
createGrid();
}