var page = {
    initTable: function () {
        page.datagrid = $("#tb").datagrid();
        var columns = [
            {
                field: 'ck',
                checkbox: true
            },
            {
                field: 'supplierCode',
                title: '供应商编码',
                width: 150,
                align: 'left'
            },
            {
                field: 'supplierName',
                title: '供应商名称',
                width: 400,
                align: 'left'
            }
        ];
        if (type === 0) {
            columns.push({
                field: 'agreeFlag',
                title: '确认状态',
                width: 150,
                align: 'left',
                formatter: function (val, row) {
                    if (val === 1) {
                        return '已同意';
                    } else if (val === 0) {
                        return '<span style="color: red" title="' + row.disagreeRemark + '">不参加</span>';
                    }
                    {
                        return '未确认';
                    }
                }
            });
        } else if (type === 2) {
            columns.push({
                field: 'contractType',
                title: '合同类型',
                width: 80,
                align: 'left'
            });
            // 转合同情况
            columns.push({
                field: 'contractCode',
                title: '转合同情况',
                width: 240,
                align: 'left',
                formatter: function (val, row) {
                    if (val) {
                        if (row.contractType === "费用合同") {
                            // 费用类合同
                            if (row.contractUrl) {
                                return '<a href="' + row.contractUrl + '" target="_blank" style="color: blue;text-decoration: underline;">'
                                    + val +
                                    '</a>';
                            } else {
                                return '<span style="color: #686802;">' + val + '(获取链接失败)<span';
                            }
                        } else {
                            // 资产类合同
                            return val;
                        }
                    } else {
                        return '<span style="color: red">' + "未转合同" + '<span';
                    }

                }
            });
        } else {
            columns.push({
                field: 'ranking',
                title: '排名',
                width: 35,
                align: 'left',
                formatter: function (val) {
                    if (val) {
                        return '<span style="color: red">' + val + '<span';
                    }
                    return '-'

                }
            });
            columns.push({
                field: 'status',
                title: '投标状态',
                width: 120,
                align: 'left',
                formatter: function (val) {
                    return BID_STATUS_CONST[val].color;
                }
            });
        }
        this.datagrid = $('#tb').datagrid({
            iconCls: 'icon-list',
            url: g.ctx + "pc/tender/rest/supplierProcess?id=" + id + "&type=" + type,
            method: 'get',
            width: '100%',
            height: 450,
            idField: 'id',
            rownumbers: true,
            pagination: false,
            nowrap: true,
            remoteSort: true,
            striped: true,
            columns: [columns]
        });

    }
};
$(function () {
    initDict("purchasing_business_type")
    page.initTable();
});