/*
 * The Hefei Ceshi RDC(Research and Development Centre) Group.
 * __________________
 *
 *    Copyright 2015-2019
 *    All Rights Reserved.
 *
 *    NOTICE:  All information contained herein is, and remains
 *    the property of Ceshi Company and its suppliers,
 *    if any.
 */
var page = {
    submitFlag: 0,
    dataGrid: {},
    initTableDataGrid: function () {

        var columns = [[]];

        page.dataGrid = $('#tb').datagrid({
            iconCls: 'icon-list',
            width: '100%',
            method: 'GET',
            height: $(window).height() - $('#searchForm').outerHeight() - 10,
            singleSelect: true,
            pagination: true,
            loadMsg: "数据加载中......",
            rownumbers: true,
            fitColumns: false,
            nowrap: true,
            remoteSort: true,
            striped: true,
            page: 1,
            pageSize: 20,
            queryParams: {
                page: 1,
                rows: 10
            },
            url: g.ctx + "pc/tender/bidQuote/rest/list",
            columns: [[{
                field: 'code',
                title: '招标编码',
                width: 150
            },
                {
                    field: 'title',
                    title: '招标主题',
                    width: 200
                },
                {
                    field: 'supplierCode',
                    title: '供应商编码',
                    width: 100
                },
                {
                    field: 'supplierName',
                    title: '供应商名称',
                    width: 200
                },
                {
                    field: 'materialCode',
                    title: '物料编码',
                    width: 90
                },
                {
                    field: 'materialName',
                    title: '物料名称',
                    width: 200,
                    formatter: function (value, row) {
                        return '<span title="' + value + '">' + value + '</span>';
                    }
                },
                {
                    field: 'bided',
                    title: '是否中标',
                    width: 60,
                    exportEnum: [
                        {code: 1, codeWithDesc: '是'},
                        {code: 0, codeWithDesc: '否'}
                    ],
                    formatter: function (value) {
                        if (value === 1) {
                            return '<span style="color: red">是</span>'
                        } else {
                            return '否';
                        }
                    }
                },
                {
                    field: 'type',
                    title: '报价类型',
                    width: 80,
                    exportEnum: [
                        {code: 1, codeWithDesc: '报价'},
                        {code: 2, codeWithDesc: '议价'}
                    ],
                    formatter: function (value) {
                        if (value === 1) {
                            return '报价';
                        } else if (value === 2) {
                            return '议价';
                        }
                    }
                },
                {
                    field: 'taxPrice',
                    title: '含税报价',
                    width: 90,
                    formatter: function (value) {
                        return formatNumber(value, 4, 1);
                    }
                },
                {
                    field: 'noTaxPrice',
                    title: '未税报价',
                    width: 90
                },
                {
                    field: 'createTime',
                    title: '报价时间',
                    width: 140,
                    exportDateFormatter: 'dateTime',
                    formatter: function (value) {
                        if (value) {
                            return new Date(value).format('yyyy-MM-dd hh:mm:ss');
                        }
                        return value;
                    }
                }]],
            toolbar: [{
                text: '导出',
                iconCls: 'icon-print',
                id: 'icon_print',
                handler: function () {
                    openExportDialog('pc/tender/bidQuote/rest/export', 'tb', searchParams());
                }
            }]
        });
    },
};


$(function () {
    $("#bidFlag").combobox({
        valueField: 'code',
        textField: 'name',
        limitToList: 'true',
        data: [
            {'name': '否', 'code': '0'},
            {'name': '是', 'code': '1'},
        ],
        editable: false,
        prompt: '--- 请选择 ---',
        panelHeight: 'auto',
    });
    page.initTableDataGrid();
});
