代碼如下:
//企業開票信息
vm.invoiceInfo = {
companyId : "", //企業Id
companyName : "", //企業名稱
companyAddress : "",
//公司地址
companyTelphone : "",
//公司電話
fax : "",
//公司傳真
contactName : "",
//聯系人
usdBank : "",
//美金開戶銀行
usdBankNumber : "",
//美金開戶銀行賬號usdBankNumber
cnyBank : "",
//人民幣開戶銀行
cnyBankNumber : "",
//人民幣開戶銀行賬號
taxCode : "", //納稅人識別號
taxTypes : "",
//納稅類型
receiver : "",
//收件人
receiverContactType : "", //聯系方式
receiverCompanyName : "", //公司名稱
sendAddressCode : "",
//省市區地址的code值
sendAddress :"",
//省市區
regionAddress : "",
//收件詳細地址
requirement : ""
//開票要求
}
var data =
voiceVm.invoiceInfo.
$mode
l;
avalon.ajax({
url : "/dzg-system-rest/rest/invoice/save",
type : "post",
dataType : "json",
data : data,
success : function(data){
if (data == 1){
vm.message = "保存成功!";
dialogVm.toggle = true;
voiceVm.taxTpyesFlag = true;
voiceVm.getVoiceInfo();
}else{
vm.message = "保存失敗!";
dialogVm.toggle = true;
}
}
});
后台用一個對象去接收:
@ResponseBody
@RequestMapping(value = "/save",method={RequestMethod.GET,RequestMethod.POST})
public int savaInvoice(
InvoiceAddressInfo info) {
IInvoiceAddressInfoService invoiceAddressInfoService;
int flag=0;
try {
Long companyId = IdentityHelper.getOrgId();
PHPRPCClientService invoiceService = SpringContextHolder.getBean("invoiceService");
invoiceAddressInfoService = invoiceService.getPHPRPCService(IInvoiceAddressInfoService.class);
if (null==invoiceAddressInfoService.selectInvoiceInfoByCompanyId(companyId)) {
flag = invoiceAddressInfoService.insertInvoiceInfo(info);
}else{
flag = invoiceAddressInfoService.updateInvocieInfo(info);
}
} catch (Exception e) {
logger.error("", e);
}
return flag;
}