/**
* Created by chenbiao on 2017/8/23.
*/
function formatSeconds(value) {
var theTime = parseInt(value); // 秒
var theTime1 = 0; // 分
var theTime2 = 0; // 小时
// alert(theTime);
if (theTime < 60) {
return theTime + '秒';
}
if (theTime > 60) {
theTime1 = parseInt(theTime / 60);
theTime = parseInt(theTime % 60);
// alert(theTime1+"-"+theTime);
if (theTime1 > 60) {
theTime2 = parseInt(theTime1 / 60);
theTime1 = parseInt(theTime1 % 60);
}
}
var result = '';
if (theTime1 > 0) {
result = "" + parseInt(theTime1) + "分钟" + result;
}
if (theTime2 > 0) {
result = "" + parseInt(theTime2) + "小时" + result;
}
return result;
};
window.downloadFile = function (sUrl) {
//iOS devices do not support downloading. We have to inform user about this.
if (/(iP)/g.test(navigator.userAgent)) {
alert('Your device does not support files downloading. Please try again in desktop browser.');
return false;
}
//If in Chrome or Safari - download via virtual link click
if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
//Creating new link node.
var link = document.createElement('a');
link.href = sUrl;
if (link.download !== undefined) {
//Set HTML5 download attribute. This will prevent file from opening if supported.
var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
link.download = fileName;
}
//Dispatching click event.
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
link.dispatchEvent(e);
return true;
}
}
// Force file download (whether supported by server).
if (sUrl.indexOf('?') === -1) {
sUrl += '?download';
}
window.open(sUrl, '_self');
return true;
}
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
/*时间筛选框*/
$("#timeoutEndDate").val(moment().subtract('days', 0).format('YYYY-MM-DD'));
$("#timeoutEndDate").datetimepicker({
endDate: moment().subtract('days', 0).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
// startView: 3,
// //maxDate:moment().subtract('months', 3),
minView: 2,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-left"
});
$("#timeoutoperEndDate").val(moment().subtract('days', 0).format('YYYY-MM-DD'));
$("#timeoutoperEndDate").datetimepicker({
endDate: moment().subtract('days', 0).format('YYYY-MM-DD'),
format: 'yyyy-mm-dd',
autoclose: true,
// startView: 3,
// //maxDate:moment().subtract('months', 3),
minView: 2,
forceParse: false,
locale: "zh-CN",
language: 'zh-CN',
pickerPosition: "bottom-left"
});
/*搜索条件toggle*/
$('#transQuery_toggle').on('click', function () {
$('.showtoggle').toggleClass('display-none');
$(this).find('.transQuery_toggle_arrow').toggleClass('transQuery_toggle_arrow_active');
});
(function () {
var invoicefun = {
init: function () {
//初始化table
$('#onduty').selectpicker('refresh');
//初始化停车场下拉框
commSelect.plName_select("#parkIds",true);
$('#parkIds').selectpicker('render');
invoicefun.createTableData();
},
//生成表格数据
createTableData: function () {
$('#recordtable').bootstrapTable('destroy').bootstrapTable({
striped: true, //表格显示条纹
pagination: true, //启动分页
pageNumber: 1, //当前第几页
pageSize: 10, //每页显示的记录数
pageList: [10, 15, 20], //记录数可选列表
sidePagination: 'server', //表示服务端分页
queryParamsType: 'limit',
method: 'POST', //请求方法
paginationPreText: '<',
paginationNextText: '>',
ajax: tableLoadRequest, //自定义ajax加载数据
// uniqueId:'id',
columns: [
{
field: 'invoiceType',
title: '开票单位',
width: '20%',
align: 'left',
formatter: function (value, row, index) {
return '
' +
'
' + (null == row.custName ? "-" : row.custName) + '
' +
'
纳税人识别号 : ' + (null == row.custTaxid ? "-" : row.custTaxid) + '
' +
'
'
}
},
{
field: 'invoiceKind',
title: '发票信息',
width: '15%',
align: 'left',
formatter: function (value, row, index) {
return '' + commonObj.moneyFormatter(row.invoiceTotalFee) + '元
' +
'' + (null == row.invoiceKind ? "-" : (0 == row.invoiceKind ? "普通发票" : "增值税发票")) + '
'
}
},
{
field: 'applyDate',
title: '申请人',
width: '15%',
align: 'left',
formatter: function (value, row, index) {
return '' + (null == row.recipients ? "-" : row.recipients) + '
' +
'电话 : ' + (null == row.recipientsPhone ? "-" : row.recipientsPhone) + '
'
}
},
{
field: 'fetchTicketWay',
title: '邮寄信息',
width: '15%',
align: 'left',
formatter: function (value, row, index) {
return '' + invoicefun.mailInfoFormater(value, row, index) + '
' +
'' + (null == row.fetchTicketWay ? "-" : 1 == row.fetchTicketWay ? "上门自取" : "邮寄") + ' '+invoicefun.mailInfoDetail(value,row,index)+'
'
}
},
{
field: 'invoiceState',
title: '开票时间',
width: '20%',
align: 'left',
formatter: function (value, row, index) {
return '' + (1 == row.invoiceState ? "待开票" : (null == row.invoiceDate ? "-" : DateUtils.long2String(row.invoiceDate, 10))) + '
' +
'申请时间 : ' + (null == row.applyDate ? "-" : DateUtils.long2String(row.applyDate, 10)) + '
'
}
},
// {
// field: 'invoiceTotalFee',
// title: '发票金额',
// width: '10%',
// align: 'left',
// formatter: invoicefun.moneyFormatter
// },
// {
// field: 'postDate',
// title: '开票时间',
// width: '15%',
// align: 'left',
// formatter: invoicefun.inDatatimeFormatter
// },
{
field: '',
title: '操作',
width: '15%',
align: 'left',
//visible: false,
formatter: invoicefun.freeReasonFormater
}
]
});
},
/*获取查询参数*/
getQueryParam: function () {
var searchLike = $('#searchLike').val();
var plNos = JSON.parse($("#parkIds").val());
var onduty;
var ondutyStr = $('#invoice-toptab div.ITD-graynav-topbaractive').data('type');
//全部
if(ondutyStr == 'all'){
onduty = null;
}
//未开票
if(ondutyStr == 'no'){
onduty = [1];
}
//已开票
if(ondutyStr == 'yes'){
onduty = [2,3];
}
var _carNumber = $("#_carNumber").val();
var custPhone = $("#_phone").val();
var req = {
custPhone: custPhone,
carNumber: _carNumber,
custName : searchLike,
custTaxid :searchLike,
// plNos:plNos,
invoiceStates: onduty
};
return req;
},
//邮寄信息格式化
mailInfoFormater: function (value, row, index) {
/**发票状态,1 待开票,3 已开票,2 已邮寄*/
//private String invoiceState;
/**取票方式:1 自取,2 邮寄*/
//private Integer fetchTicketWay;
//
if (null == row.invoiceState ||row.invoiceState==''||row.invoiceState==undefined) {
return "-";
}
if (1 == row.invoiceState) {
return "待开票"
}
if (3 == row.invoiceState) {
if (1 == row.fetchTicketWay) {
return "待自取"
}
if (2 == row.fetchTicketWay) {
return "待邮寄"
}
return "已开票"
}
if (2 == row.invoiceState) {
if (1 == row.fetchTicketWay) {
return "已自取"
}
if (2 == row.fetchTicketWay) {
return "已邮寄"
}
return "已开票"
}
},
//邮寄详情 展示邮寄信息,只有邮寄的展示
mailInfoDetail: function (value, row, index) {
/**取票方式:1 自取,2 邮寄*/
//private Integer fetchTicketWay;
var rowStr = JSON.stringify(row).replace(/\"/g, "'");
if (2 == row.fetchTicketWay) {
return '详情'
}
return '';
},
//操作
freeReasonFormater: function (value, row, index) {
/**发票状态,1 开票中,3 已开票 2 已邮寄 */
var invoiceaddState = row.invoiceState;
var invoiceaddType = row.invoiceType;
var invoiceid = row.id;
var row = JSON.stringify(row).replace(/\"/g, "'");
var operStr = '';
//
if (1 == parseInt(invoiceaddState)) {
operStr = ' 查看开票';
return operStr;
} else if(3 == parseInt(invoiceaddState)){
operStr = '查看邮寄';
return operStr;
}else {
operStr = '查看';
return operStr;
}
},
};
//初始执行
invoicefun.init();
//查询
$(document).on('click', '#invoice-queryBtn', function () {
invoicefun.createTableData();
});
//详情公司 弹窗
documentBindFunc.on('click', '.lookMsg', function () {
var type = $(this).attr('data-type')
var row = eval('(' + $(this).attr("data-index") + ')');
console.log(type)
if (type == 0) {
$('#print_perfoot').css('display', 'block');
$('#detail_perAddressee').html(row.recipients);//收件人
$('#detail_peroperAddr').html(row.recipientsAddress);//地址
$('#detail_peroperAddr').attr('title',row.recipientsAddress);//地址
$('#detail_perpersonphone').html(row.recipientsPhone);//收件人电话
// invoicefun.getinvoiceDetailInfo(id);
$('#invoice_perdetailmodel').modal('show');
} else if (type == 1) {
$('#print_foot').css('display', 'block');
$('#detail_invoicetopCode').html(row.custName);//抬头
$('#detail_dutynum').html(row.custTaxid);//税号
$('#detail_bankNum').html(row.custBankName);//银行
$('#detail_groupphone').html(row.custPhone);//电话
$('#detail_groupName').html(row.custCardNo);//账户
$('#detail_Addressee').html(row.recipients);//收件人
$('#detail_operAddr').html(row.recipientsAddress);//地址
$('#detail_operAddr').attr('title',row.recipientsAddress);//地址
$('#detail_personphone').html(row.recipientsPhone);//收件人电话
// invoicefun.getinvoiceDetailInfo(id);
$('#invoice_detailmodel').modal('show');
}
});
//公司 打印功能
documentBindFunc.on('click', '#detail-print', function () {
var oldstr = document.body.innerHTML;//保存当前页面的HTML
$('#print_foot').css('display', 'none');
var newstr = document.getElementById("print_Msg").innerHTML;//得到需要打印的元素HTML
document.body.innerHTML = newstr;
window.print();
$('#print_foot').css('display', 'block');
document.body.innerHTML = oldstr;
});
//公司 close 发票弹窗
documentBindFunc.on('click', '#print_close', function () {
$('#invoice_detailmodel').css('display', 'none');
$('.modal-backdrop').css('display', 'none');
});
//个人 打印功能
documentBindFunc.on('click', '#detail-perprint', function () {
var oldstr = document.body.innerHTML;//保存当前页面的HTML
$('#print_perfoot').css('display', 'none');
var newstr = document.getElementById("print_perMsg").innerHTML;//得到需要打印的元素HTML
document.body.innerHTML = newstr;
window.print();
$('#print_perfoot').css('display', 'block');
document.body.innerHTML = oldstr;
});
//个人 close 发票弹窗
documentBindFunc.on('click', '#print_perclose', function () {
$('#invoice_perdetailmodel').css('display', 'none');
$('.modal-backdrop').css('display', 'none');
});
//开票弹窗
$(document).on('click', '.reMsg', function (element) {
var id = $(this).attr('data-index');
var status = $(this).attr('data-status');
if(2==status){
$('#resTitle').html('确认邮寄');
$('#resCont').html('确定已邮寄或已自取吗');
}
if(3 ==status){
$('#resTitle').html('确认开票');
$('#resCont').html('确定修改开票状态为已开票吗?');
}
$("#updateId").val(id);
$('#updateStatus').val(status);
$('#resetmodel').modal('show')
});
//详情弹窗 邮寄方式
documentBindFunc.on('click', '.pop_detail', function (element) {
//收件人
$('#mail_perAddressee').html('-')
//地址
$('#mail_peroperAddr').html('-')
//电话
$('#mail_perpersonphone').html('-')
var rowStr = $(this).data('row').replace(/\'/g, '"');
var row = JSON.parse(rowStr);
//收件人
$('#mail_perAddressee').html(row.recipients)
//地址
$('#mail_peroperAddr').html(row.recipientsAddress)
//电话
$('#mail_perpersonphone').html(row.recipientsPhone)
$('#invoice_mailmodel').modal('show')
});
//详情弹窗 邮寄方式 确认按钮
documentBindFunc.on('click', '#mail-sure', function (element) {
$('#invoice_mailmodel').modal('hide')
});
/**
* 自定义table AJAX请求
* @param {Object} params
*/
function tableLoadRequest(params) {
var req = invoicefun.getQueryParam();
//设置请求参数
var pageNum = (params.data.offset / params.data.limit) + 1;
//条件查询
req.baseRequest = {
pageNum: pageNum,
pageSize: params.data.limit
};
req.sysCode = sysComm.sysCode;
var opt = {
method: 'post',
url: dataUrl.util.queryInvoiceListInfo(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
console.log(res.data);
params.success(res.data);
}
}
};
sysAjax(opt);
}
//切换 搜索部分 发票
documentBindFunc.on('click', "#invoice-toptab div.invoice-topbar", function () {
var index = $(this).index();
$(this).addClass('ITD-graynav-topbaractive').siblings('div').removeClass('ITD-graynav-topbaractive');
invoicefun.createTableData();
//console.log(index);
})
})();
//发票状态
$("#reset-submit").on('click', function () {
var id = $("#updateId").val();
var updateStatus = $('#updateStatus').val();
console.log(id);
var req = {
id: id,
invoiceState:updateStatus,
sysCode: sysComm.sysCode
};
var opt = {
method: 'post',
url: dataUrl.util.updateInvoiceStateById(),
data: JSON.stringify(req),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (res) {
if (res.code == '8888') {
swal({
title: "提示",
text: "保存成功",
type: "success",
timer: 3000,
allowOutsideClick: true
});
//关闭添加页面
$('#resetmodel').modal('hide');
//初始化table
$('#recordtable').bootstrapTable('refresh', {
silent: true
});
} else {
swal({
title: "提示",
text: res.msg,
type: "warning",
timer: 3000,
allowOutsideClick: true
});
}
}
};
sysAjax(opt);
});