/** * 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() { /** * 自定义table AJAX请求 * @param {Object} params */ /*function tableLoadRequest(params) { var req = fun.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.queryParkOrderForFinance(), 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); }*/ var invoicefun = { init: function() { //初始化table $('#onduty').selectpicker('refresh'); 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: '10%', align: 'left', formatter: function(value, row, index) { if(undefined != value && null != value) { if(value == '1') { return '公司' } else if(value == '0') { return '个人'; } else { return '未知' } } else { return '-' } } }, { field: 'invoiceKind', title: '发票种类', width: '10%', align: 'left', formatter: function(value, row, index) { if(undefined != value && null != value) { if(value == '1') { return '增值发票' } else if(value == '0') { return '普通发票'; } else { return '-' } }else { return '-' } } }, { field: 'applyDate', title: '申领时间', width: '15%', align: 'left', formatter: invoicefun.inDatatimeFormatter }, { field: 'fetchTicketWay', title: '取票方式', width: '15%', align: 'left', formatter: function(value, row, index) { if(undefined != value && null != value) { if(value == '1') { return '自取' } else if(value == '2') { return '邮寄' } }else{ return '-'; } } }, { field: 'invoiceState', title: '开票状态', width: '5%', align: 'left', formatter: function(value, row, index) { if(undefined != value && null != value) { if(value == '1') { return '未开票' } else if(value == '2') { return '已开票' }else { return '未知'; } } } }, { field: 'invoiceTotalFee', title: '发票金额', width: '10%', align: 'left', formatter: invoicefun.moneyFormatter }, { field: 'postDate', title: '开票时间', width: '15%', align: 'left', formatter: invoicefun.inDatatimeFormatter }, { field: '', title: '操作', width: '20%', align: 'left', //visible: false, formatter: invoicefun.freeReasonFormater } ] }); }, /*获取查询参数*/ getQueryParam: function() { var _carNumber = $("#_carNumber").val(); var custPhone = $("#_phone").val(); var onduty = $('#onduty').val(); var req = { custPhone: custPhone, carNumber: _carNumber, invoiceState: onduty != '' ? onduty : null }; return req; }, //操作 freeReasonFormater: function(value, row, index) { 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{ operStr ='详情'; return operStr; } }, inDatatimeFormatter: function(value, row, index) { if(value == null) { return ""; } else { return "
" + DateUtils.long2String(value, 7) + "
"; } }, //金额处理 moneyFormatter: function(value) { // console.log(typeof value) if(value == 0 || value == undefined || value == null) { return 0; } else { return(value / 100).toFixed(2); } }, imageformatter: function(value, row, index) { return ""; } }; //初始执行 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_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_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'); $("#updateId").val(id); $('#resetmodel').modal('show') }); /** * 自定义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); } })(); //发票状态 $("#reset-submit").on('click', function() { var id = $("#updateId").val(); console.log(id); var req = { id: id, sysCode: sysComm.sysCode }; var opt = { method: 'post', url: dataUrl.util.updateInvioceById(), 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); });