/**
 *
 * @author BOGON
 * @version 1.0
 */

var page = {
    initTb: function () {
        var options = {
            url: g.ctx + 'pc/supplier/supplierQualification/rest/list?supplierId=' + supplierId,
            method: "GET",
            height: document.documentElement.clientHeight - $("#searchForm").outerHeight() - 10,
            singleSelect: false,
            columns: [[{field: 'ck', checkbox: true}, {
                field: 'state', title: '状态', width: '120', align: 'left', formatter: function (value) {
                    if (value === 1) {
                        return '有效'
                    }
                    if (value === 8) {
                        return '待上传'
                    }
                    if (value === 9) {
                        return '失效'
                    }
                }
            }, {
                field: 'supplierName', title: '供应商名称', width: '160', align: 'left'
            }, {
                field: 'qualificationCode', title: '资质编码', width: '160', align: 'left'
            }, {
                field: 'qualificationName', title: '资质名称', width: '150', align: 'left'
            }, {
                field: 'fileName', title: '证书文件', width: '160', align: 'left', formatter: function (value, row) {
                    if (value) {
                        return "<a href='" + g.ctx + "pc/sys/file/rest/download/" + row.fileId + "'>" + value + "</a>"
                    }
                    return ''
                }
            }, {
                field: 'availableStartDate', title: '生效日期', width: '160', align: 'left'
            }, {
                field: 'availableStartDate', title: '失效日期', width: '160', align: 'left'
            }, {
                field: 'createTime', title: '创建时间', width: '160', align: 'left'
            }]],
            pagination: true,
            autoHeight: true,
            loadMsg: "数据加载中......",
            rownumbers: true,
            fitColumns: false,
            nowrap: true,
            remoteSort: true,
            striped: true
        };
        $("#tb").datagrid(options)
    }, getChecked: function (call) {
        var rows = $("#tb").datagrid("getChecked")
        if (rows.length <= 0) {
            topWin.layer.msg("至少选中一条数据")
            return
        }
        call(rows)
    }
}
$(function () {
    page.initTb()
})