...
|
...
|
@@ -23,9 +23,18 @@ function validateInvoice($el, info) { |
|
|
// 发票抬头
|
|
|
if (!info.titleName) {
|
|
|
pass = false;
|
|
|
$('.invoice-title-tip', $el).removeClass('hide');
|
|
|
$('.company-name-tip', $el).removeClass('hide');
|
|
|
} else {
|
|
|
$('.invoice-title-tip', $el).addClass('hide');
|
|
|
$('.company-name-tip', $el).addClass('hide');
|
|
|
}
|
|
|
|
|
|
if (info.titleId === 2) {
|
|
|
if (!info.taxNumber) {
|
|
|
pass = false;
|
|
|
$('.company-tax-tip', $el).removeClass('hide');
|
|
|
} else {
|
|
|
$('.company-tax-tip', $el).addClass('hide');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 收票人手机号
|
...
|
...
|
@@ -38,7 +47,7 @@ function validateInvoice($el, info) { |
|
|
} else if (info.receiver === defaultReceiver.hide) {
|
|
|
$receiverTip.addClass('hide');
|
|
|
} else if (!/^[0-9]{11}$/.test(info.receiver)) {
|
|
|
$receiverTip.removeClass('hide').find('em').html('手机号码不正确');
|
|
|
$receiverTip.removeClass('hide').find('em').html('请输入正确手机号');
|
|
|
pass = false;
|
|
|
} else {
|
|
|
$receiverTip.addClass('hide');
|
...
|
...
|
@@ -49,29 +58,9 @@ function validateInvoice($el, info) { |
|
|
}
|
|
|
|
|
|
function bindInvoiceEvent($el) {
|
|
|
var $invoiceTypeWrap = $('.invoice-type', $el),
|
|
|
$titleWrap = $('.invoice-title', $el),
|
|
|
$goodsTypeWrap = $('.invoice-goods-type', $el),
|
|
|
$receiver = $('.receiver', $el),
|
|
|
var $titleWrap = $('.invoice-title', $el),
|
|
|
$companyRow = $('.company-row', $el);
|
|
|
|
|
|
$invoiceTypeWrap.on('click', 'li', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('focus')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($this.hasClass('el-invoice')) {
|
|
|
$receiver.removeClass('hide');
|
|
|
} else {
|
|
|
$receiver.addClass('hide');
|
|
|
}
|
|
|
|
|
|
$this.siblings('.focus').removeClass('focus');
|
|
|
$this.addClass('focus');
|
|
|
});
|
|
|
|
|
|
$titleWrap.on('click', '.radio-btn', function() {
|
|
|
var $this = $(this),
|
|
|
id = $this.data('id');
|
...
|
...
|
@@ -90,17 +79,6 @@ function bindInvoiceEvent($el) { |
|
|
$this.addClass('on');
|
|
|
});
|
|
|
|
|
|
$goodsTypeWrap.on('click', '.radio-btn', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
if ($this.hasClass('on')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$goodsTypeWrap.find('.on').removeClass('on');
|
|
|
$this.addClass('on');
|
|
|
});
|
|
|
|
|
|
$el.on('click', '.invoice-close', function() {
|
|
|
$('.btn-close', $el).trigger('click');
|
|
|
});
|
...
|
...
|
@@ -109,48 +87,35 @@ function bindInvoiceEvent($el) { |
|
|
function bindInvoiceInfo($el, info) {
|
|
|
info = info || {};
|
|
|
|
|
|
// 发票类型
|
|
|
if (info.invocesType === 1) {
|
|
|
$('.pa-invoice', $el).trigger('click');
|
|
|
}
|
|
|
|
|
|
if (info.titleId) {
|
|
|
$('.rbt-' + info.titleId).trigger('click');
|
|
|
|
|
|
if (info.titleId === 2 && info.titleName) {
|
|
|
$('#company-name', $el).val(info.titleName);
|
|
|
if (info.titleId === 2) {
|
|
|
$('#company-name', $el).val(info.titleName || '');
|
|
|
$('#company-tax-num', $el).val(info.taxNumber || '');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (info.contentId) {
|
|
|
$('.rbc-' + info.contentId, $el).trigger('click');
|
|
|
}
|
|
|
|
|
|
$('#receiver-phone', $el).val(info.receiver || defaultReceiver.hide || '');
|
|
|
}
|
|
|
|
|
|
function packInvoiceInfo($el) {
|
|
|
var $goodsType = $('.invoice-goods-type .on', $el);
|
|
|
var resData = {},
|
|
|
var resData = { // 5.8.1需求,只支持电子发票(type: 2),发票内容只能开明细(id:12)
|
|
|
invocesType: 2,
|
|
|
contentId: 12,
|
|
|
contentName: '明细'
|
|
|
},
|
|
|
receiver = $('#receiver-phone', $el).val();
|
|
|
|
|
|
if ($('.pa-invoice', $el).hasClass('focus')) {
|
|
|
resData.invocesType = 1;
|
|
|
} else {
|
|
|
resData.invocesType = 2;
|
|
|
}
|
|
|
|
|
|
resData.titleId = $('.invoice-title .on', $el).data('id') || 1;
|
|
|
|
|
|
if (resData.titleId * 1 === 1) {
|
|
|
resData.titleName = '个人';
|
|
|
} else {
|
|
|
resData.titleName = $('#company-name', $el).val();
|
|
|
resData.taxNumber = $('#company-tax-num', $el).val();
|
|
|
}
|
|
|
|
|
|
resData.contentId = $goodsType.data('id');
|
|
|
resData.contentName = $goodsType.data('name');
|
|
|
|
|
|
if (receiver) {
|
|
|
resData.receiver = receiver;
|
|
|
}
|
...
|
...
|
@@ -173,8 +138,7 @@ function setShowInvoiceInfo() { |
|
|
_h += '电子发票';
|
|
|
}
|
|
|
|
|
|
_h += ' ' + invoiceInfo.titleName +
|
|
|
' ' + invoiceInfo.contentName;
|
|
|
_h += ' ' + invoiceInfo.titleName;
|
|
|
|
|
|
$dom.removeClass('hide').find('span').html(_h);
|
|
|
}
|
...
|
...
|
@@ -186,7 +150,7 @@ function invoiceEditDialog(baseInfo) { |
|
|
btns: [
|
|
|
{
|
|
|
id: 'save-invoice',
|
|
|
name: '保存发票信息',
|
|
|
name: '提交',
|
|
|
btnClass: ['save-invoice'],
|
|
|
cb: function() {
|
|
|
var info = packInvoiceInfo(invoice.$el);
|
...
|
...
|
@@ -258,6 +222,7 @@ exports.getInvoice = function() { |
|
|
invoicesType: invoiceInfo.invocesType,
|
|
|
invoicesTitle: invoiceInfo.titleName,
|
|
|
invoicesContent: invoiceInfo.contentId,
|
|
|
taxNumber: invoiceInfo.taxNumber || '',
|
|
|
receiver: invoiceInfo.receiver === defaultReceiver.hide ? defaultReceiver.full : invoiceInfo.receiver
|
|
|
};
|
|
|
}; |
...
|
...
|
|