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

let el = {
    tb: '#tb',
};
$(function () {
    loadDataGride();
});
var userDialog = undefined;
var submitFlag = 0

function loadDataGride() {
    $('#tb').datagrid(
        {
            height: document.documentElement.clientHeight - $("#searchForm").outerHeight() - 10,
            url: g.ctx + 'pc/supplier/supplierQualification/rest/warn/page',
            method: "GET",
            singleSelect: true,
            pagination: true,
            autoHeight: true,
            loadMsg: "数据加载中......",
            rownumbers: true,
            fitColumns: false,
            nowrap: true,
            remoteSort: true,
            striped: true,
            page: 1,
            pageSize: 20,
            columns: [[
                {field: 'ck', checkbox: true},
                {
                    field: 'state', title: itablei8n.status,
                    width: '75', align: 'left',
                    formatter: function (value) {
                        if (value === 1) {
                            return '<span style="color: blue;">' + statusi18n.yx + '</span>';
                        } else if (value === 2) {
                            return '<span style="color: green;">' + statusi18n.sx + '</span>';
                        } else if (value === 9) {
                            return '历史版本';
                        }
                    }
                }, {
                    field: 'supplierCode',
                    title: '供应商编码',
                    width: 90,
                    sortable: true
                },
                {
                    field: 'supplierName',
                    title: '供应商名称',
                    width: 270,
                    sortable: true
                }, {
                    field: 'qualificationCode', title: '资质编码', width: '15%', align: 'left'
                }, {
                    field: 'qualificationName', title: '资质名称', width: '15%', align: 'left'
                }, {
                    field: 'fileName',
                    title: '资质证书名称',
                    width: '20%',
                    align: 'left',
                    formatter: function (value, row) {
                        return "<a href='" + g.ctx + "pc/sys/file/rest/download/" + row.fileId + "'>" + row.fileName + "</a>"
                    },

                }, {
                    field: 'qualificationNumber', title: '资质证书编码', width: '15%', align: 'left'
                }, {
                    field: 'availableStartDate',
                    title: '证书生效时间',
                    width: '15%',
                    align: 'left',
                    editor: {type: 'datebox'}
                }, {
                    field: 'availableEndDate',
                    title: '证书失效时间',
                    width: '15%',
                    align: 'left',
                    editor: {type: 'datebox'}
                }, {
                    field: 'surplusDay',
                    title: '剩余天数',
                    width: '15%',
                    align: 'left'
                }, {
                    field: 'createTime', title: '创建时间', width: '10%', align: 'left', formatter: function (value) {   //格式化时间
                        if (value) {
                            return new Date(value).format("yyyy-MM-dd")
                        }
                        return value;
                    }
                }
            ]],
            toolbar: [],
            onLoadSuccess: function () {
                displayButtonByUserRole('qualificationsWarnManage');
            }
        }
    )
}

function refreshLoad() {
    $('#tb').datagrid('reload');
}


function resetSearch() {
    $('#qualificationCode').val("");
    $('#supplierCode').val("");
    $('#state').val("");
    var queryParams = $('#searchForm').serializeJson();
    $('#tb').datagrid('load', queryParams);
}