InvoicesIndex.js 1.89 KB
'use strict';
var $ = require('jquery'),
    common = require('../../common/common');

var ENUM = {
    isSupport: {'Y': '支持', 'N': '不支持'},
    defaultInvoice: {'0': '-', '1': '纸质发票', '2': '电子发票'}
};

new common.dropDown({el: '#supplier-name', ajax: 'supplier'});
new common.dropDown({el: "#isElecInvoice"});
new common.dropDown({el: "#isPaperInvoice"});
new common.dropDown({el: "#defaultInvoice"});

var g = new common.grid({
    el: "#basicTable",
    parms: function () {
        return {
            id: common.util.__input("supplier-name"),
            isElecInvoice: common.util.__input("isElecInvoice"),
            isPaperInvoice: common.util.__input("isPaperInvoice"),
            defaultInvoice: common.util.__input("defaultInvoice")
        };
    },
    columns: [
        {display: "供应商ID", name: "supplierId"},
        {display: "供应商", name: "supplierName"},
        {
            display: "电子发票", name: "isElecInvoice", render: function (item) {
                return ENUM.isSupport[item.isElecInvoice];
            }
        },
        {
            display: "纸质发票", name: "isPaperInvoice", render: function (item) {
                return ENUM.isSupport[item.isPaperInvoice];
            }
        },
        {
            display: "默认发票", name: "defaultInvoice", render: function (item) {
                return ENUM.defaultInvoice[item.defaultInvoice];
            }
        },
        {display: "更新时间", name: "updateTime"},
        {
            display: "操作", name: "id", render: function (item) {
                var HtmArr = [];
                HtmArr.push('<a href="/supplier/invoices/update/' + item.supplierId + '" class="btn btn-success btn-xs btn-edit">编辑</a>');
                return HtmArr.join('');
            }
        }
    ]
})

g.init($("#gridurl").val());

$("#filter-btn").click(function () {
    g.reload(1);
});