/**
|
* 管理初始化
|
*/
|
var TBill = {
|
id: "TBillTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TBill.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '订单id', field: 'orderId', visible: false, align: 'center', valign: 'middle'},
|
{title: '申请时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '发票类型', field: 'billType', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if(row.billType === 1){
|
return '<span>电子发票</span>'
|
}
|
}
|
},
|
{title: '抬头类型', field: 'billHeaderType', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if(row.billHeaderType === 1){
|
return '<span>公司</span>'
|
}else if(row.billHeaderType === 2){
|
return '<span>个人</span>'
|
}
|
}
|
},
|
{title: '发票抬头', field: 'companyName', visible: true, align: 'center', valign: 'middle'},
|
{title: '公司税号', field: 'companyTaxNumber', visible: true, align: 'center', valign: 'middle'},
|
{title: '发票内容', field: 'billContent', visible: true, align: 'center', valign: 'middle'},
|
{title: '更多内容', field: 'moreContent', visible: false, align: 'center', valign: 'middle'},
|
{title: '发票金额', field: 'billAmount', visible: true, align: 'center', valign: 'middle'},
|
{title: '收件人姓名', field: 'addresseeName', visible: true, align: 'center', valign: 'middle'},
|
{title: '收件人电话', field: 'addresseePhone', visible: true, align: 'center', valign: 'middle'},
|
{title: '收件人邮箱', field: 'addresseeEmail', visible: true, align: 'center', valign: 'middle'},
|
{title: '开票状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if(row.state === 1){
|
return '<span>待开票</span>'
|
}else if(row.state === 2){
|
return '<span>已开票</span>'
|
}else if(row.state === 3){
|
return '<span>开票失败</span>'
|
}
|
}
|
},
|
{title: '操作', visible: true, align: 'center', valign: 'middle',width:150,
|
formatter: function (value, row) {
|
return '<a href="#" onclick="TBill.confirm('+row.id+','+row.state+')" style="color:blue">确定</a>' + ' ' +
|
'<a href="#" onclick="TBill.cancel('+row.id+','+row.state+')" style="color:red">取消</a>'
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TBill.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TBill.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
TBill.openAddTBill = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加',
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tBill/tBill_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看详情
|
*/
|
TBill.openTBillDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tBill/tBill_update/' + TBill.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除
|
*/
|
TBill.delete = function () {
|
if (this.check()) {
|
var ajax = new $ax(Feng.ctxPath + "/tBill/delete", function (data) {
|
Feng.success("删除成功!");
|
TBill.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tBillId",this.seItem.id);
|
ajax.start();
|
}
|
};
|
|
/**
|
* 确认通过发票
|
*/
|
TBill.confirm = function (id,state) {
|
|
if(1 !== state){
|
Feng.error("该条数据已审核");
|
return;
|
}
|
|
var ajax = new $ax(Feng.ctxPath + "/tBill/confirm", function (data) {
|
Feng.success("操作成功!");
|
TBill.table.refresh();
|
}, function (data) {
|
Feng.error("操作失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tBillId",id);
|
ajax.start();
|
};
|
|
/**
|
* 发票失败
|
*/
|
TBill.cancel = function (id,state) {
|
if(1 !== state){
|
Feng.error("该条数据已审核");
|
return;
|
}
|
|
var ajax = new $ax(Feng.ctxPath + "/tBill/cancel", function (data) {
|
Feng.success("操作成功!");
|
TBill.table.refresh();
|
}, function (data) {
|
Feng.error("操作失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("tBillId",id);
|
ajax.start();
|
};
|
|
/**
|
* 发票信息导出
|
*/
|
TBill.export=function(){
|
var createTime=$("#createTime").val()
|
var addresseePhone=$("#addresseePhone").val()
|
var state=$("#state").val()
|
var billType=$("#billType").val()
|
var billHeaderType=$("#billHeaderType").val()
|
window.location.href=Feng.ctxPath + "/tBill/export?createTime="+createTime
|
+"&addresseePhone="+addresseePhone
|
+"&state="+state
|
+"&billType="+billType
|
+"&billHeaderType="+billHeaderType
|
;
|
}
|
|
/**
|
* 查询列表
|
*/
|
TBill.search = function () {
|
var queryData = {};
|
queryData['createTime'] = $("#createTime").val();
|
queryData['addresseePhone'] = $("#addresseePhone").val();
|
queryData['state'] = $("#state").val();
|
queryData['billType'] = $("#billType").val();
|
queryData['billHeaderType'] = $("#billHeaderType").val();
|
TBill.table.refresh({query: queryData});
|
};
|
|
/**
|
* 重置
|
*/
|
TBill.resetSearch = function (){
|
$("#createTime").val('');
|
$("#addresseePhone").val('');
|
$("#state").val('');
|
$("#billType").val('');
|
$("#billHeaderType").val('');
|
TBill.search();
|
}
|
|
$(function () {
|
var defaultColunms = TBill.initColumn();
|
var table = new BSTable(TBill.id, "/tBill/list", defaultColunms);
|
table.setPaginationType("client");
|
TBill.table = table.init();
|
});
|