/**
 * 对账模块-查看开票申请过账结果弹框JS
 *
 * Created by li.kui on 2020/8/23.
 */
'use strict';
var el = {
    iaId: '#iaId',
    tb: '#tb',
    bodyHeight: document.documentElement.clientHeight
};

$(function () {
    var iaId = $(el.iaId).val();

    $(el.tb).datagrid({
        loadMsg: '数据加载中......',
        url: g.ctx + 'fin/common/rest/find/post/result',
        height: el.bodyHeight,
        singleSelect: false,
        rownumbers: true,
        pagination: false,
        queryParams: {
            iaId: iaId
        },
        columns: [
            [
                {
                    field: 'invoiceApplyNo',
                    title: '开票申请单号',
                    width: 140
                },
                {
                    field: 'postInvoiceType',
                    title: '过账发票类型',
                    width: 90,
                    formatter: function (value) {
                        // 1:凭证发票 2:返利发票 3:扣款发票 4:贷方发票
                        switch (Number(value)) {
                            case 1:
                                return '凭证发票';
                            case 2:
                                return '返利发票';
                            case 3:
                                return '扣款发票';
                            case 4:
                                return '贷方发票';
                            default:
                                return '';
                        }
                    }
                },
                {
                    field: 'dataStatus',
                    title: '数据状态',
                    width: 80,
                    formatter: function (value) {
                        // 过账状态 0:未过账 1:过账失败 2:过账成功
                        switch (Number(value)) {
                            case 0:
                                return '未过账';
                            case 1:
                                return '<span style="color: red;">过账失败</span>';
                            case 2:
                                return '<span style="color: green;">过账成功</span>';
                            default:
                                return '';
                        }
                    }
                },
                {
                    field: 'invoiceVoucher',
                    title: '发票凭证号',
                    width: 120
                },
                {
                    field: 'accountantVoucher',
                    title: '会计凭证号',
                    width: 120
                },
                {
                    field: 'voucherYear',
                    title: '凭证年度',
                    width: 100
                },
                {
                    field: 'syncMessage',
                    title: '过账接口描述',
                    width: 300
                },
                {
                    field: 'optPostTime',
                    title: '过账时间',
                    width: 130,
                    formatter: function (value) {
                        if (!value) {
                            return '';
                        }
                        return moment(value).format('YYYY-MM-DD HH:mm');
                    }
                }
            ]
        ]
    });
});