159 lines
5.8 KiB
Plaintext
159 lines
5.8 KiB
Plaintext
<%@ page contentType="text/html; charset=GBK"%>
|
|
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
|
|
String customer_id = CurPage.getParameter("customerId");
|
|
if(customer_id == null) customer_id ="";
|
|
String id = CurPage.getParameter("id");
|
|
if(id == null) id ="";
|
|
String tax_isdefault = CurPage.getParameter("tax_isdefault");
|
|
if(tax_isdefault == null)tax_isdefault ="";
|
|
String flag = CurPage.getParameter("flag");
|
|
if(flag == null)flag = "";
|
|
String rightType = CurPage.getParameter("rightType");
|
|
if(rightType ==null)rightType="";
|
|
String sTempletNo = "CustomerInvoice";//--模板号--
|
|
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
|
|
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
|
|
dwTemp.Style = "2";//freeform
|
|
if(rightType.equals("ReadOnly")){
|
|
dwTemp.ReadOnly = "1";//只读模式
|
|
}
|
|
dwTemp.genHTMLObjectWindow(CurPage.getParameter("id"));
|
|
CurPage.getCurComp().setAttribute("RightType", rightType);
|
|
|
|
String sButtons[][] = {
|
|
{"true","All","Button","保存","保存所有修改","saveRecord()","","","","btn_icon_save"},
|
|
{"true","","Button","返回","返回列表页面","parent.AsDialog.ClosePage()","","","","btn_icon_return"}
|
|
};
|
|
sButtonPosition = "south";
|
|
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
|
|
<script type="text/javascript">
|
|
window.onload=function(){
|
|
if("<%=flag%>" == "edit"){
|
|
var tax_payercategory = getItemValue(0,getRow(),"tax_payercategory");
|
|
if(tax_payercategory == "tax_payercategory2"){
|
|
setItemRequired(0,"tax_no",false);
|
|
setItemRequired(0,"tax_bank",false);
|
|
setItemRequired(0,"tax_account",false);
|
|
setItemRequired(0,"tax_address",false);
|
|
setItemRequired(0,"tax_phone",false);
|
|
}
|
|
}
|
|
}
|
|
function onChange(){
|
|
if(getItemValue(0,getRow(),"tax_payercategory") == "tax_payercategory1"){
|
|
setItemRequired(0,"tax_no",true);
|
|
setItemRequired(0,"tax_bank",true);
|
|
setItemRequired(0,"tax_account",true);
|
|
setItemRequired(0,"tax_address",true);
|
|
setItemRequired(0,"tax_phone",true);
|
|
}else{
|
|
setItemRequired(0,"tax_no",false);
|
|
setItemRequired(0,"tax_bank",false);
|
|
setItemRequired(0,"tax_account",false);
|
|
setItemRequired(0,"tax_address",false);
|
|
setItemRequired(0,"tax_phone",false);
|
|
}
|
|
}
|
|
function saveRecord(){
|
|
if(!iV_all("0")) return;//先检查填写完整性
|
|
var tax_isdefault = getItemValue(0,getRow(),"tax_isdefault");
|
|
var tax_isdefault = getItemValue(0,getRow(),"tax_isdefault");
|
|
var id = getItemValue(0,getRow(),"id");
|
|
if(id == ''){//新增时
|
|
var result = RunJavaMethodTrans("com.tenwa.customer.controller.invoice.CustomerInvoiceController","selectInvoice","customer_id="+"<%=customer_id%>");
|
|
if(result == "false"){
|
|
if(tax_isdefault == "no"){
|
|
alert("第一条开票信息必须设置为默认开票信息");
|
|
return;
|
|
}
|
|
}else{
|
|
if(tax_isdefault == "yes"){
|
|
if(!confirm("已有一条默认开票信息,是否确认设为默认?")){
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
if('<%=tax_isdefault%>' == 'yes'){
|
|
if(tax_isdefault == "no"){
|
|
alert("默认开票信息不许修改为非默认开票信息");
|
|
return;
|
|
}
|
|
}
|
|
var result = RunJavaMethodTrans("com.tenwa.customer.controller.invoice.CustomerInvoiceController","selectEditInvoice","customer_id="+"<%=customer_id%>"+",id="+'<%=id%>');
|
|
if(result == 'true'){
|
|
if(tax_isdefault == "yes"){
|
|
if(!confirm("已有一条默认开票信息,是否确认设为默认?")){
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!validityCheck())return;
|
|
as_save("myiframe0","parent.AsDialog.ClosePage()");
|
|
}
|
|
function validityCheck(){
|
|
//验证纳税人识别号
|
|
var tax_no = getItemValue(0,getRow(),"tax_no");//纳税人识别号
|
|
var id = getItemValue(0,getRow(),"id");
|
|
var tax_account = getItemValue(0,getRow(),"tax_account");//开户账号
|
|
var tax_status = getItemValue(0,getRow(),"tax_status");//开票状态
|
|
var tax_isdefault = getItemValue(0,getRow(),"tax_isdefault");//是否默认
|
|
var tax_phone = getItemValue(0,getRow(),"tax_phone");//开票电话
|
|
//无效不需要验证
|
|
if(tax_status != "invalid"){
|
|
//新增时验证
|
|
if('<%=flag%>' != "edit"){
|
|
if(typeof(tax_no) != undefined && tax_no != ""){
|
|
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.invoice.CustomerInvoiceController","checkTax_no","tax_no="+tax_no+",customer_id="+"<%=customer_id%>");
|
|
if(sReturnInfo != "true"){
|
|
alert("纳税人识别号已存在");
|
|
return false;
|
|
}
|
|
}
|
|
}else{//修改时验证
|
|
if(typeof(tax_no) != undefined && tax_no != "" ){
|
|
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.invoice.CustomerInvoiceController","editCheckTax_no","tax_no="+tax_no+",id="+id+",customer_id="+"<%=customer_id%>");
|
|
if(sReturnInfo != "true"){
|
|
alert("纳税人识别号已存在");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//验证手机号
|
|
if(typeof(tax_phone) != undefined && tax_phone != "" ){
|
|
if(!CheckPhoneCode(tax_phone)){
|
|
alert("开票电话格式错误");
|
|
return false;
|
|
}
|
|
}
|
|
//验证开户账号
|
|
if(typeof(tax_account) != undefined && tax_account != "" ){
|
|
var account = "";
|
|
for(var i = 0;i < tax_account.length;i++){
|
|
if(tax_account[i] != " "){
|
|
account += tax_account[i];
|
|
}
|
|
}
|
|
var reg = /^[0-9]+$/;
|
|
if (!(reg.test(account))) {
|
|
alert("开户账号格式错误");
|
|
return false;
|
|
}
|
|
}
|
|
//无效不许设置为默认
|
|
if(typeof(tax_status) != undefined && tax_status != "" && tax_status == "invalid"){
|
|
if(typeof(tax_isdefault) != undefined && tax_isdefault != "" && tax_isdefault == "yes"){
|
|
alert("无效开票信息不允许设置为默认开票");
|
|
return false;
|
|
}
|
|
}
|
|
//默认开票为是时保存要更新其它开票为非默认
|
|
if(typeof(tax_isdefault) != undefined && tax_isdefault != "" && tax_isdefault == "yes"){
|
|
var sReturnInfo = RunJavaMethodTrans("com.tenwa.customer.controller.invoice.CustomerInvoiceController","updateIsDefault","customer_id="+"<%=customer_id%>"+",id="+'<%=id%>');
|
|
}
|
|
return true;
|
|
}
|
|
</script>
|
|
<%@ include file="/Frame/resources/include/include_end.jspf"%> |