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.

212 lines
6.6 KiB
JavaScript

9 months ago
var comboCustomer;//委托单位
var comboBank;//开户银行
var comboAccount;//银行账户
function $(id){
return document.getElementById(id);
}
function initCombo(){
createComboCustomer();
initComboBank();
initComboAccount();
createComboBank();
createComboAccount();
}
function createComboCustomer(){//委托单位
var isReadOnly = parseInt($("h_onlyread").value);
comboCustomer = dhtmlXComboFromSelect("sel_customer");
comboCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");
if(isReadOnly >0){
comboCustomer.disable(true);
}
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_clientid").value = clientObj.customer[0].id;alert($("h_clientid").value);
$("h_customer").value = comboCustomer.getComboText().trim();
});
}
//trim
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function initComboBank(){
comboBank = dhtmlXComboFromSelect("sel_bank");
}
function initComboAccount(){
comboAccount = dhtmlXComboFromSelect("sel_account");
}
function createComboBank(){
var isReadOnly = parseInt($("h_onlyread").value);
var currency = $("sel_currency").value;
if(comboBank != null){
comboBank.loadXML("../FeeCodes/CompanyInfo.aspx?mask=0&pos=0&currency="+escape(currency)+"&type=1");
}else{
initComboBank();
comboBank.loadXML("../FeeCodes/CompanyInfo.aspx?mask=0&pos=0&currency="+escape(currency)+"&type=1");
}
if($("h_bank").value != ""){
comboBank.setComboText($("h_bank").value);
}
if(isReadOnly >0){
comboBank.disable(true);
}
//获取银行值
comboBank.attachEvent("onSelectionChange", function(){
$("h_bank").value = comboBank.getComboText().trim();//alert($("h_bank").value);
});
// comboBank.attachEvent("onBlur", function(){
// $("h_bank").value = comboBank.getComboText().trim();//alert($("h_bank").value);
// });
}
function createComboAccount(){
var isReadOnly = parseInt($("h_onlyread").value);
var currency = $("sel_currency").value;
if(comboAccount != null){
comboAccount.loadXML("../FeeCodes/CompanyInfo.aspx?mask=0&pos=0&currency="+escape(currency)+"&type=2");
}
else{
initComboAccount();
comboAccount.loadXML("../FeeCodes/CompanyInfo.aspx?mask=0&pos=0&currency="+escape(currency)+"&type=2");
}
if($("h_account").value != ""){
comboAccount.setComboText($("h_account").value);
}
if(isReadOnly >0){
comboAccount.disable(true);
}
//获取账户值
comboAccount.attachEvent("onSelectionChange", function(){
$("h_account").value = comboAccount.getComboText().trim();//alert($("h_account").value);
});
// comboAccount.attachEvent("onBlur", function(){
// $("h_account").value = comboAccount.getComboText().trim();//alert($("h_account").value);
// });
}
function saveAction(){
if($("h_customer").value.trim() == ""){
alert("付款单位不能为空");
return;
}
var a=/^[0-9]*(\.[0-9]{1,2})?$/;
var tempRecvAmount = $("txt_recvamount").value.trim();
if(!a.test(tempRecvAmount)){
alert("实收金额格式不正确");
return;
}
var recvAmount = parseFloat($("txt_recvamount").value.trim() == ""?0:$("txt_recvamount").value.trim());
if(recvAmount <= 0){
alert("实收金额不能小于0");
return;
}
$("h_post").value = "1";
var clientName = comboCustomer.getComboText().trim();
var url = "../FeeCodes/CRMClientInfo.aspx?handle=clientstl&name="+escape(clientName)+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var clientVal = loader.xmlDoc.responseText;
var clientObj = null;
clientObj = eval('(' + clientVal + ')');
$("h_clientid").value = clientObj.customer[0].id;
if($("h_clientid").value != ""){
postEnterFee();
window.parent.opener.location.href = window.parent.opener.location.href;
}
}
function cancelAction(){
window.close();
}
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
//获取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 currencyChange(id,targetId){
var selectObj = $(id);
var targetSelObj = $(targetId);
targetSelObj.value = selectObj.options[selectObj.selectedIndex].value;
}