/**
 * 对账模块-开票申请单财务确认页面JS
 *
 * Created by li.kui on 2020/8/20.
 */
'use strict';
var el = {
    dataPanel: '#dataPanel',
    dataDiv: '#dataDiv',
    deductionAmountTotal: '#deductionAmountTotal',
    strikePriceAmount: '#strikePriceAmount',
    actualUnpaidAmount: '#actualUnpaidAmount',
    invoiceTaxAmount: '#invoiceTaxAmount',
    id: '#id',
    tbFile: '#tbFile',
    iaNo: '#invoiceApplyNo',
    orderType: '#orderType',
    supplierCode: '#supplierCode',
    companyCode: '#companyCode',
    factoryCode: '#factoryCode',
    currencyCode: '#currencyCode',
    approveRemark: '#approveRemark',
    invoiceNum: '#invoiceNum',
    invoiceNo: '#invoiceNo',
    remark: '#remark',
    dataTabs: '#dataTabs',
    tbDetails: '#tbDetails',
    tbDeduction: '#tbDeduction',
    tbRebate: '#tbRebate',
    tbIaApprove: '#tbIaApprove',
    userTableColumn: [],
    bodyHeight: document.documentElement.clientHeight,

    taxDict: [],
    tbInvoice: '#tbInvoice',
    diffAmount: '#diffAmount',
    diffAmount1: '#diffAmount1',
    editIndex: undefined,
    tbAdvance: '#tbAdvance',
    rntAmount: '#rntAmount',
    dntAmount: '#dntAmount',
    typeName : 'finance_confirm'
};

$(function () {
    $(el.dataPanel).panel({
        collapsible: true,
        onCollapse: function () {
            $(el.dataTabs).tabs('select', 0);

            $(el.tbDetails).datagrid('resize', {height: el.bodyHeight - 80});
            // $(el.tbRebate).datagrid('resize', {height: el.bodyHeight - 80});
            // $(el.tbDeduction).datagrid('resize', {height: el.bodyHeight - 80});
            $(el.tbApproveLog).datagrid('resize', {height: el.bodyHeight - 80});
        },
        onExpand: function () {
            $(el.dataTabs).tabs('select', 0);

            var dataDiv = $(el.dataDiv).outerHeight() + 90;
            $(el.tbDetails).datagrid('resize', {height: el.bodyHeight - dataDiv});
            // $(el.tbRebate).datagrid('resize', {height: el.bodyHeight - dataDiv});
            // $(el.tbDeduction).datagrid('resize', {height: el.bodyHeight - dataDiv});
            $(el.tbApproveLog).datagrid('resize', {height: el.bodyHeight - dataDiv});
        }
    });
    initPageInput();
    // findUserTableColumn();

    initTbDetails();

    // initTbDeduction();

    // initTbRebate();

    initTbIaApprove()

    // 初始化预付款
    initTbAdvance();

    findTaxDictData();
});

/**
 * 初始化页面输入框
 */
function initPageInput() {
    // 初始化税率代码下拉框
    $('#taxCode').combobox({
        required: true,
        panelHeight: 300,
        panelWidth: 340,
        limitToList: 'true',
        valueField: 'taxCode',
        method: 'GET',
        textField: 'codeWithDesc',
        url: g.ctx + 'pc/sys/tax/rest/listAll',
        prompt: '--- 请选择 ---'
    });
    // 付款条件
    $('#paymentTermCode').combobox({
        required: true,
        limitToList: 'true',
        panelHeight: 'auto',
        panelWidth: 200,
        method: 'GET',
        valueField: 'code',
        textField: 'codeWithDesc',
        prompt: '--- 请选择 ---',
        url: g.ctx + 'pc/sys/dict/getDicByType?type=payment_method',
    });
    getExchangeRate($(el.currencyCode).textbox('getValue'));
}

/**
 * 初始化预付款明细表格
 */
function initTbAdvance() {
    var dataDiv = $(el.dataDiv).outerHeight() + 90, orderType = $(el.orderType).val();
    $(el.tbAdvance).datagrid({
        loadMsg: '数据加载中, 请耐心等待......',
        height: el.bodyHeight - dataDiv,
        singleSelect: false,
        rownumbers: true,
        showFooter: true,
        pagination: true,
        queryParams: {invoiceApplyId:$(el.id).val()},
        url: g.ctx + 'fin/payment/advance/apply/rest/find/paa/findPaaDetailByInvoiceApplyId',
        frozenColumns: [
            [
                // {
                //     field: 'ck',
                //     checkbox: true
                // },
                {
                    field: 'zlsdh',
                    title: 'SC订单号',
                    width:140
                },
                {
                    field: 'oldPoCode',
                    title: '旧订单号',
                    width:120
                },
                {
                    field: 'poCode',
                    title: '采购订单',
                    width: 200,
                    sortable: true
                },
                {
                    field: 'poItemNo',
                    title: '订单行号',
                    width: 200,
                    sortable: true
                }
            ]
        ],
        toolbar: [
            {
                text: '导出',
                iconCls: 'icon-download',
                handler: function () {
                    advanceExport();
                }
            },
        ],
        columns: [
            [
                {
                    field: 'applyPrice',
                    title: '预付款金额',
                    width: 200,
                    sortable: true,
                    formatter:function (value) {
                        if (!value) {
                            return '';
                        }
                        return  formatNumber(value, 4, 1).toString().replace(/(?:\.0*|(\.\d+?)0+)$/,'$1');
                    }
                },
                {
                    field: 'strikePrice',
                    title: '本次冲账金额',
                    width: 200,
                    sortable: true,
                    formatter:function (value) {
                        if (!value) {
                            return '';
                        }
                        return  formatNumber(value, 4, 1).toString().replace(/(?:\.0*|(\.\d+?)0+)$/,'$1');
                    }
                },
                {
                    field: 'yearNum',
                    title: '年度',
                    width:100
                },
                {
                    field: 'currencyCode',
                    title: '币种',
                    width:100
                },
                {
                    field: 'applyNo',
                    title: '预付款凭证号',
                    width:140
                },
                {
                    field: 'applyItemNo',
                    title: '预付款凭证行号',
                    width:120
                },
                {
                    field: 'remark',
                    title: '摘要',
                    width:200
                },
            ]
        ],
    });
}

/**
 * 初始化开票申请明细表格
 */
function initTbDetails() {
    var dataDiv = $(el.dataDiv).outerHeight() + 90, orderType = $(el.orderType).val();
    // var columns = dynamicColumns(orderType);

    $(el.tbDetails).datagrid({
        loadMsg: '数据加载中, 请耐心等待......',
        height: el.bodyHeight - dataDiv,
        url: g.ctx + 'pc/finance/invoiced/apply/detail/rest/find/by/apply/id',
        singleSelect: true,
        showFooter: true,
        rownumbers: true,
        // 定义从服务器对数据进行排序
        remoteSort: false,
        // 定义是否允许多列排序
        // multiSort: true,
        pagination: false,
        queryParams: {
            iaId: $(el.id).val(),
            becShare: 0
        },
        columns: [
            tableColumns
        ],
        toolbar: [
            {
                text: '导出',
                iconCls: 'icon-download',
                handler: function () {
                    detailDataExport();
                }
            },
            // '-',
            // {
            //     text: '调整布局',
            //     iconCls: 'icon-man',
            //     handler: function () {
            //         adjustTableColumn();
            //     }
            // }
        ],
        onClickRow: function (index, row) {
            if (el.editIndex !== undefined) {
                if(endEditor()){
                    beginEditor(index, row);
                }
            }else {
                beginEditor(index, row);
            }
        },
        onLoadSuccess: function () {
            // handleVoucherTail();
            calculationPageAmount();
        }
    });
}

/**
 * 计算表头金额
 */
function  calculationPageAmount() {
    // 需要处理统计行中 未税金额 != 含税金额 / (1 + 税率)
    var taxValue = new BigNumber(1), itSumAmount = new BigNumber(0), ntSumAmount = new BigNumber(0);
    var maxAmount = new BigNumber(0), maxAmountRowIndex = -1, maxAdtAmount = new BigNumber(0), maxAntAmount = new BigNumber(0);
    var rows = $(el.tbDetails).datagrid('getRows');
    for (var n = 0; n < rows.length; n++) {
        var item = rows[n];
        ntSumAmount = ntSumAmount.plus(item.asNotTaxAmount);
        itSumAmount = itSumAmount.plus(item.asTaxAmount);
        taxValue = new BigNumber(item.asTaxValue);

        if(maxAmount.eq(0)){
            maxAmount = new BigNumber(item.asTaxAmount);
            maxAdtAmount = new BigNumber(item.asDiffTaxAmount);
            maxAntAmount = new BigNumber(item.asNotTaxAmount);
            maxAmountRowIndex = $(el.tbDetails).datagrid('getRowIndex', item);
        }
        if(!maxAmount.eq(0) && maxAmount.lt(item.asTaxAmount)){
            maxAmount = new BigNumber(item.asTaxAmount);
            maxAdtAmount = new BigNumber(item.asDiffTaxAmount);
            maxAntAmount = new BigNumber(item.asNotTaxAmount);
            maxAmountRowIndex = $(el.tbDetails).datagrid('getRowIndex', item);
        }
    }

    // 创建的时候不需要一下逻辑(下面的逻辑:保证表体合计含税金额=表体合计未税金额*(1+税率))
    // var tax = taxValue.div(100).plus(1);
    // // 表体明细相加的含税金额除以税率减去表体明细相加的未税金额, 如果差异超过±0.01(包含±0.01), 需要将差异加到表体含税金额最大一行中
    // var diff = itSumAmount.div(tax).sub(ntSumAmount);
    // var diffNum = Number(diff.abs().toFixed(2));
    // if(diffNum >= 0.01){
    //     var adtAmount = maxAdtAmount.sub(diff).toFixed(2);
    //     var antAmount = maxAntAmount.plus(diff).toFixed(2);
    //
    //     $(el.tbDetails).datagrid('updateRow', {
    //         index: maxAmountRowIndex,
    //         row: {
    //             asDiffTaxAmount: adtAmount,
    //             asNotTaxAmount: antAmount
    //         }
    //     });
    // }

    var detail = $(el.tbDetails).datagrid('getRows'), rebate = "", deduction = "";
    var itAmount = new BigNumber(0), ntAmount = new BigNumber(0), statementNum = new BigNumber(0);
    for (var i = 0; i < detail.length; i++) {
        var item1 = detail[i];
        ntAmount = ntAmount.plus(item1.asNotTaxAmount);
        itAmount = itAmount.plus(item1.asTaxAmount);
        statementNum = statementNum.plus(item1.statementNum);
    }

    var advanceDetail = $(el.tbAdvance).datagrid('getRows');
    var allBudInnerMoney = new BigNumber(0);
    for (var i = 0; i < advanceDetail.length; i++) {
        var item2 = advanceDetail[i];
        allBudInnerMoney = allBudInnerMoney.plus(item2.alreadyAdvanceAmount);
    }

    // var rtAmount = new BigNumber(0), rntAmount = new BigNumber(0);
    // for(var j = 0; j < rebate.length; j++){
    //     var item2 = rebate[j];
    //     // 1:购方对供方返利 2:供方对购方返利
    //     if(Number(item2.rebateType) === 1){
    //         rtAmount = rtAmount.plus(item2.rebateAmount);
    //         rntAmount = rntAmount.plus(item2.rntAmount);
    //     }else {
    //         rtAmount = rtAmount.minus(item2.rebateAmount);
    //         rntAmount = rntAmount.minus(item2.rntAmount);
    //     }
    // }

    // var dtAmount = new BigNumber(0), dntAmount = new BigNumber(0);
    // for(var k = 0; k < deduction.length; k++){
    //     var item3 = deduction[k];
    //     dtAmount = dtAmount.plus(item3.deductionAmount);
    //     dntAmount = dntAmount.plus(item3.dntAmount);
    // }

    if(0 !== rows.length){
        // 更新页脚行的值并刷新
        var footers = $(el.tbDetails).datagrid('getFooterRows');
        footers[0]['asNotTaxAmount'] = ntAmount.toFormat(2);
        footers[0]['asTaxAmount'] = itAmount.toFormat(2);
        footers[0]['asDiffTaxAmount'] = itAmount.minus(ntAmount).toFormat(2);
        footers[0]['statementNum'] = statementNum.toNumber();
        $(el.tbDetails).datagrid('reloadFooter');
    }else {
        // 更新页脚行并载入新数据
        $(el.tbDetails).datagrid('reloadFooter', [
            {
                asNotTaxAmount: 0,
                asTaxAmount: 0,
                asDiffTaxAmount: 0,
                statementNum: 0
            }
        ]);
    }

    // ntAmount = ntAmount.plus(rntAmount).plus(dntAmount);
    // itAmount = itAmount.plus(rtAmount).plus(dtAmount);
    $(el.invoiceNetAmount).textbox('setValue', ntAmount.toFormat(2));
    $(el.invoiceTaxAmount).textbox('setValue', itAmount.toFormat(2));
    // $(el.diffAmount).textbox('setValue', itAmount.minus(ntAmount).toFormat(2));
    // $(el.allBudInnerMoney).textbox('setValue', allBudInnerMoney.toFormat(2));
    // $(el.rebateAmount).numberbox('setValue', Number(rtAmount.toFixed(2)));
    // $(el.rntAmount).val(Number(rntAmount.toFixed(2)));
    // $(el.deductionAmount).numberbox('setValue', Number(dtAmount.toFixed(2)));
    // $(el.dntAmount).val(Number(dntAmount.toFixed(2)));
}

/**
 * 结束编辑
 *
 * @return {boolean}
 */
function endEditor() {
    // 结束行编辑
    $(el.tbDetails).datagrid('endEdit', el.editIndex);
    $(el.tbDetails).datagrid('unselectRow', el.editIndex);
    el.editIndex = undefined;
    return true;
}

/**
 * 启动行编辑
 */
function beginEditor(rowIndex, row) {
    var dntAmount = $(el.dntAmount).val(), rntAmount = $(el.rntAmount).val();
    // if(Number(row.shareFlag) === 0){
    //     topWin.layer.msg('该行不可以编辑');
    //     return false;
    // }
    $(el.tbDetails).datagrid('beginEdit', rowIndex);
    el.editIndex = rowIndex;

    var editors = $(el.tbDetails).datagrid('getEditors', rowIndex);
    if(Number(rntAmount) === 0){
        editors[4].target.numberbox('disable');
        editors[5].target.numberbox('disable');
    }
    if(Number(dntAmount) === 0){
        editors[6].target.numberbox('disable');
        editors[7].target.numberbox('disable');
    }
}

/**
 * 初始化返利信息表格
 */
// function initTbRebate() {
//     var dataDiv = $(el.dataDiv).outerHeight() + 90;
//
//     $(el.tbRebate).datagrid({
//         loadMsg: '数据加载中, 请耐心等待......',
//         height: el.bodyHeight - dataDiv,
//         url: g.ctx + 'fin/invoiced/apply/detail/rest/find/rebate/by/apply/id',
//         singleSelect: false,
//         showFooter: true,
//         rownumbers: true,
//         // 定义从服务器对数据进行排序
//         remoteSort: false,
//         // 定义是否允许多列排序
//         // multiSort: true,
//         pagination: false,
//         queryParams: {iaId: $(el.id).val()},
//         frozenColumns: [
//             [
//                 {
//                     field: 'rebateId',
//                     title: '附件查看',
//                     width: 80,
//                     formatter: function (value) {
//                         if(value){
//                             return '<a href="javascript:void(0)" onclick="lookDrAttachment(this)" data-type="2" data-id="' + value + '">查看</a>';
//                         }
//                         return '';
//                     }
//                 },
//                 {
//                     field: 'asNo',
//                     title: '对账单号',
//                     width: 130,
//                     sortable: true
//                 },
//                 {
//                     field: 'rebateNo',
//                     title: '返利单号',
//                     width: 140,
//                     sortable: true
//                 },
//                 {
//                     field: 'rebateType',
//                     title: '返利类型',
//                     width: 120,
//                     sortable: true,
//                     formatter: function (value) {
//                         if(Number(value) === 1){
//                             return '购方对供方返利';
//                         }
//                         if(Number(value) === 2) {
//                             return '供方对购方返利';
//                         }
//                         return '';
//                     }
//                 },
//                 {
//                     field: 'rebateAmount',
//                     title: '含税返利金额(元)',
//                     width: 110,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (!value) {
//                             return '';
//                         }
//                         return formatNumber(value, 2, 1);
//                     }
//                 },
//                 {
//                     field: 'taxCodeDesc',
//                     title: '税率',
//                     width: 160,
//                     sortable: true
//                 }
//             ]
//         ],
//         columns: [
//             [
//                 {
//                     field: 'rebateReason',
//                     title: '返利原因',
//                     width: 300
//                 },
//                 {
//                     field: 'rebateTime',
//                     title: '返利时间',
//                     width: 110,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (value) {
//                             return moment(value).format("YYYY-MM-DD");
//                         }
//                         return '';
//                     }
//                 },
//                 {
//                     field: 'companyCode',
//                     title: '公司代码',
//                     width: 80
//                 },
//                 {
//                     field: 'companyName',
//                     title: '公司名称',
//                     width: 180
//                 },
//                 {
//                     field: 'supplierCode',
//                     title: '供应商编码',
//                     width: 90
//                 },
//                 {
//                     field: 'supplierName',
//                     title: '供应商名称',
//                     width: 270
//                 },
//                 {
//                     field: 'createTime',
//                     title: '创建时间',
//                     width: 140,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (value) {
//                             return moment(value).format("YYYY-MM-DD HH:mm:ss");
//                         }
//                         return '';
//                     }
//                 }
//             ]
//         ]
//     });
// }


/**
 * 初始化扣款信息表格
 */
// function initTbDeduction() {
//     var dataDiv = $(el.dataDiv).outerHeight() + 90;
//
//     $(el.tbDeduction).datagrid({
//         loadMsg: '数据加载中, 请耐心等待......',
//         height: el.bodyHeight - dataDiv,
//         url: g.ctx + 'fin/invoiced/apply/detail/rest/find/deduction/by/apply/id',
//         singleSelect: false,
//         showFooter: true,
//         rownumbers: true,
//         // 定义从服务器对数据进行排序
//         remoteSort: false,
//         // 定义是否允许多列排序
//         // multiSort: true,
//         pagination: false,
//         queryParams: {iaId: $(el.id).val()},
//         frozenColumns: [
//             [
//                 {
//                     field: 'deductionId',
//                     title: '附件查看',
//                     width: 80,
//                     formatter: function (value) {
//                         if(value){
//                             return '<a href="javascript:void(0)" onclick="lookDrAttachment(this)" data-type="1" data-id="' + value + '">查看</a>';
//                         }
//                         return '';
//                     }
//                 },
//                 {
//                     field: 'asNo',
//                     title: '对账单号',
//                     width: 140,
//                     sortable: true
//                 },
//                 {
//                     field: 'deductionNo',
//                     title: '扣款编号',
//                     width: 140,
//                     sortable: true
//                 },
//                 {
//                     field: 'deductionTypeDesc',
//                     title: '扣款类型',
//                     width: 90,
//                     sortable: true
//                 },
//                 {
//                     field: 'deductionAmount',
//                     title: '含税扣款金额(元)',
//                     width: 110,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (!value) {
//                             return '';
//                         }
//                         return formatNumber(value, 2, 1);
//                     }
//                 },
//                 {
//                     field: 'taxCodeDesc',
//                     title: '税率',
//                     width: 160,
//                     sortable: true
//                 }
//             ]
//         ],
//         columns: [
//             [
//                 {
//                     field: 'deductionReason',
//                     title: '扣款原因',
//                     width: 300
//                 },
//                 {
//                     field: 'deductionTime',
//                     title: '扣款时间',
//                     width: 90,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (value) {
//                             return moment(value).format("YYYY-MM-DD");
//                         }
//                         return '';
//                     }
//                 },
//                 {
//                     field: 'associatedOaNo',
//                     title: 'OA流程单号',
//                     width: 120,
//                     sortable: true
//                 },
//                 {
//                     field: 'associatedNo',
//                     title: 'SRM业务单据',
//                     width: 140,
//                     formatter: function (value, row) {
//                         if(!row.associatedRowNo){
//                             return value;
//                         }else {
//                             return value + '|' + row.associatedRowNo;
//                         }
//                     }
//                 },
//                 {
//                     field: 'companyCode',
//                     title: '公司代码',
//                     width: 80
//                 },
//                 {
//                     field: 'companyName',
//                     title: '公司名称',
//                     width: 180
//                 },
//                 {
//                     field: 'supplierCode',
//                     title: '供应商编码',
//                     width: 90
//                 },
//                 {
//                     field: 'supplierName',
//                     title: '供应商名称',
//                     width: 270
//                 },
//                 {
//                     field: 'createTime',
//                     title: '创建时间',
//                     width: 140,
//                     sortable: true,
//                     formatter: function (value) {
//                         if (value) {
//                             return moment(value).format("YYYY-MM-DD HH:mm:ss");
//                         }
//                         return '';
//                     }
//                 }
//             ]
//         ]
//     });
// }


/**
 * 初始化审批信息表格
 */
function initTbIaApprove() {
    var dataDiv = $(el.dataDiv).outerHeight() + 90;

    $(el.tbIaApprove).datagrid({
        loadMsg: '数据加载中, 请耐心等待......',
        height: el.bodyHeight - dataDiv,
        url: g.ctx + 'pc/finance/invoiced/apply/detail/rest/find/ia/approve/log',
        singleSelect: false,
        rownumbers: true,
        // 定义从服务器对数据进行排序
        remoteSort: false,
        // 定义是否允许多列排序
        // multiSort: true,
        pagination: true,
        queryParams: {
            iaId: $(el.id).val()
        },
        columns: [
            [
                {
                    field: 'approveNode',
                    title: '审批节点描述',
                    width: 120,
                    formatter: function (value) {
                        if(Number(value) === 1){
                            return '对账确认';
                        }else {
                            return '财务节点';
                        }
                    }
                },
                {
                    field: 'approveResult',
                    title: '审批结果',
                    width: 120,
                    formatter: function (value) {
                        switch (Number(value)){
                            case 0:
                                return '<span style="color: red;">拒绝</span>';
                            case 1:
                                return '<span style="color: green;">同意</span>';
                            case 2:
                                return '<span style="color: orange;">采购撤销</span>';
                            default:
                                return '';
                        }
                    }
                },
                {
                    field: 'approveOpinion',
                    title: '审批意见',
                    width: 300
                },
                {
                    field: 'approveUserName',
                    title: '审批用户姓名',
                    width: 130
                },
                {
                    field: 'approveTime',
                    title: '审批时间',
                    width: 140,
                    sortable: true,
                    formatter: function (value) {
                        if (value) {
                            return moment(value).format("YYYY-MM-DD HH:mm:ss");
                        }
                        return '';
                    }
                }
            ]
        ]
    });
}


/**
 * 数据保存
 */
function dataSave(callback) {
    endInvoiceOtherEditor();
    var id = $(el.id).val(),  remark = $(el.remark).val(),invoiceNum = $(el.invoiceNum).numberbox('getValue'),invoiceNo = $(el.invoiceNo).textbox('getValue'),
        approveRemark = $(el.approveRemark).val(),
        strikePriceAmount = $(el.strikePriceAmount).textbox('getValue'),
        actualUnpaidAmount = $(el.actualUnpaidAmount).textbox('getValue'),
        deductionAmountTotal = $(el.deductionAmountTotal).textbox('getValue');
    if(!approveRemark){
        topWin.layer.alert('请输入审批意见', {icon: 0});
        return false;
    }
    var invoicedReceipt = $(el.tbInvoice).datagrid('getRows');
    if (invoicedReceipt.length === 0) {
        topWin.layer.alert('请添加关联发票信息', {icon: 0});
        return false;
    }

    for (let i = 0 ; i < invoicedReceipt.length ; i ++){
        // if(!invoicedReceipt[i].deductionCodeType){
        //     layer.msg("关联发票信息：第"+ ++i+"行可抵扣编号不能为空");
        //     return false;
        // }
        if(!invoicedReceipt[i].invoiceDate){
            layer.msg("关联发票信息：第"+ ++i+"行发票日期不能为空");
            return false;
        }
        // if(!invoicedReceipt[i].invoiceCode){
        //     layer.msg("关联发票信息：第"+ ++i+"行发票代码不能为空");
        //     return false;
        // }
        if(!invoicedReceipt[i].invoiceNumber){
            layer.msg("关联发票信息：第"+ ++i+"行发票号码不能为空");
            return false;
        }
        if(!invoicedReceipt[i].dutyParagraph){
            layer.msg("关联发票信息：第"+ ++i+"行税号不能为空");
            return false;
        }
        if(!invoicedReceipt[i].taxRate){
            layer.msg("关联发票信息：第"+ ++i+"行税率不能为空");
            return false;
        }
        if(!invoicedReceipt[i].currencyCode){
            layer.msg("关联发票信息：第"+ ++i+"行币种不能为空");
            return false;
        }
        if(!invoicedReceipt[i].taxAmount){
            layer.msg("关联发票信息：第"+ ++i+"行含税金额不能为空");
            return false;
        }
        if(!invoicedReceipt[i].noTaxAmount&&invoicedReceipt[i].noTaxAmount!==0){
            layer.msg("关联发票信息：第"+ ++i+"行未税金额不能为空");
            return false;
        }
        // if(!invoicedReceipt[i].fileId){
        //     layer.msg("关联发票信息：第"+ ++i+"行发票附件不能为空");
        //     return false;
        // }
    }
    var headData = {};
    headData.id = id;
    headData.remark = remark;
    headData.invoiceNum = invoiceNum;
    headData.invoiceNo = invoiceNo;
    headData.strikePriceAmount = Number(strikePriceAmount.replace(/,/g,''));
    headData.actualUnpaidAmount = Number(actualUnpaidAmount.replace(/,/g,''));
    headData.deductionAmountTotal = Number(deductionAmountTotal.replace(/,/g,''));

    // 对账单明细
    var detail = $(el.tbDetails).datagrid('getRows'), detailDate = [];
    for(var i = 0; i < detail.length; i++){
        detailDate.push(detail[i]);
    }

    var dataParams = {};
    dataParams.headData = headData;
    dataParams.detailDate = detailDate;
    dataParams.delDetailIds = [];
    dataParams.invoicedReceiptData = invoicedReceipt;
    // dataParams.deductionDetailData = getDeductionDetail();
    dataParams.addSdIds = [];
    dataParams.delSdIds = [];
    dataParams.addSrIds = [];
    dataParams.delSrIds = [];
    dataParams.approveRemark = approveRemark;

    callback(dataParams);
}


/**
 * 明细导出
 */
function detailDataExport() {
    var rows = $(el.tbDetails).datagrid('getRows');
    $(el.tbDetails).datagrid('toExcel', {
        filename: '开票申请数据.xls',
        rows: rows,
        worksheet: '开票申请明细'
    });
}

function advanceExport() {
    var rows = $(el.tbAdvance).datagrid('getRows');
    $(el.tbAdvance).datagrid('toExcel', {
        filename: '开票申请数据-预付款.xls',
        rows: rows,
        worksheet: '开票申请明细-预付款'
    });
}

function invoiceExport() {
    var rows = $(el.tbInvoice).datagrid('getRows');

    for(var i = 0; i < rows.length; i++){
        var row =rows[i];
        row['invoiceDate']=timestampToTime(row['invoiceDate']);
    }

    $(el.tbInvoice).datagrid('toExcel', {
        filename: '开票申请数据-关联发票.xls',
        rows: rows,
        worksheet: '开票申请明细-关联发票'
    });
}

// 时间戳：1637244864707
/* 时间戳转换为时间 */
function timestampToTime(timestamp) {
    timestamp = timestamp ? timestamp : null;
    let date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    return Y + M + D  ;
}

/**
 * 查看扣款或返利附件
 *
 * @param ele 当前操作DOM节点
 */
function lookDrAttachment(ele) {
    var drId = $(ele).data('id'), attType = $(ele).data('type');
    var url = g.ctx + 'fin/common/look/dr/attachment?drId=' + drId + '&attType=' + attType;
    var lookDrAttDialog = openDialog('lookDrAtt', url, {
        title: '附件查看',
        width: '35%',
        height: '45%',
        cache: false,
        modal: true,
        border: 'thin',
        onClose: function () {
            lookDrAttDialog.dialog('destroy');
        },
        buttons: [
            {
                text: '关闭',
                iconCls: 'icon-cancel',
                handler: function () {
                    lookDrAttDialog.dialog('close');
                }
            }
        ]
    });
}


/**
 * 调整表格列布局
 */
function adjustTableColumn() {
    var url = g.ctx + 'fin/common/adjust/table/column?pageTable=3';
    el.adjustTableColumnDialog = openDialog('adjustTableColumn', url, {
        title: '调整表格列布局',
        width: '970px',
        height: '80%',
        cache: false,
        modal: true,
        border: 'thin',
        onClose: function () {
            el.adjustTableColumnDialog.dialog('destroy');
        },
        buttons: [
            {
                text: '确定并保存设置',
                iconCls: 'icon-ok',
                handler: function () {
                    topWin.frames['adjustTableColumn'].confirmAndSaveSetUp(function (data) {
                        el.userTableColumn = [];
                        for(var i = 0; i < data.length; i++){
                            el.userTableColumn.push(data[i].columnField);
                        }

                        initTbDetails();
                        el.adjustTableColumnDialog.dialog('close');
                    });
                }
            },
            {
                text: '确定',
                iconCls: 'icon-ok',
                handler: function () {
                    topWin.frames['adjustTableColumn'].confirmSetUp(function (data) {
                        el.userTableColumn = [];
                        for(var i = 0; i < data.length; i++){
                            el.userTableColumn.push(data[i].columnField);
                        }

                        initTbDetails();
                        el.adjustTableColumnDialog.dialog('close');
                    });
                }
            },
            {
                text: '关闭',
                iconCls: 'icon-cancel',
                handler: function () {
                    el.adjustTableColumnDialog.dialog('close');
                }
            }
        ]
    });
}

/**
 * 获取税率字典数据
 */
function findTaxDictData() {
    $.ajax({
        type: 'POST',
        url: g.ctx + 'pc/sys/tax/rest/listAll',
        async: false,
        success: function (data) {
            for(var i = 0; i < data.length; i++){
                var obj = {};
                obj.itemCode = data[i].taxCode;
                obj.itemName = data[i].taxName;
                obj.itemValue = data[i].taxValue;
                obj.itemRemark = data[i].taxName;
                el.taxDict.push(obj);
            }
        }
    });
}
/**
 * 更新行数数据
 *
 * @param data 修改后的数据
 * @param editColumn 编辑的列名
 */
function updateRowData(data, editColumn) {
    var row = {}, rows = $(el.tbDetails).datagrid('getRows');
    for (var i = 0; i < rows.length; i++) {
        var rowIndex = $(el.tbDetails).datagrid('getRowIndex', rows[i]);
        if (rowIndex === el.editIndex) {
            row = rows[i];
            break;
        }
    }

    // 税率转换: 1 + 税率
    var taxConvert = new BigNumber(1).plus(row.taxValue / 100);

    // 修改的字段 到票含税单价、到票未税金额、到票税额、到票税率

    // 到票含税单价 -> 联动变更的行数据: 到票不含税单价、到票差异含税单价、到票不含税金额、到票含税金额、到票差异含税金额、到票税额
    if ('taxPrice' === editColumn) {
        // 修改后的数据
        var ud1 = new BigNumber(data);

        // 到票含税金额 = 对账数量 * 到票含税单价
        var taxAmount1 = ud1.multipliedBy(row.statementNum);
        // 到票不含税单价 = 到票含税单价 / (1 + 税率)
        var notTaxPrice1 = ud1.div(taxConvert);
        // 到票差异含税单价 = 到票含税单价 - 对账含税单价
        var iaDiffPrice1 = ud1.minus(row.asTaxPrice);
        // 到票未税金额 = 含税金额 / (1 + 税率)
        var notTaxAmount1 = taxAmount1.div(taxConvert);
        // 到票差异含税金额 = 对账数量 * 到票差异含税单价
        var iaDiffAmount1 = iaDiffPrice1.multipliedBy(row.statementNum);
        // // 到票税额 = 到票含税金额 - 到票未税金额
        // var diffTaxAmount1 = taxAmount1.sub(notTaxAmount1);
        // 到票税额 = 到票含税金额(四舍五入保留2位) - 到票未税金额(四舍五入保留2位)
        var diffTaxAmount1 = Number(taxAmount1.toFixed(2)) - Number(notTaxAmount1.toFixed(2));

        // 更新Editor列数据(initValue 不触发numberBox的onChange事件)
        var notTaxAmountTarget1 = $(el.tbDetails).datagrid('getEditor', {
            index: el.editIndex,
            field: 'notTaxAmount'
        }).target;
        notTaxAmountTarget1.numberbox('initValue', Number(notTaxAmount1.toFixed(2)));

        // 更新Editor列数据(initValue 不触发numberBox的onChange事件)
        var diffTaxAmountTarget1 = $(el.tbDetails).datagrid('getEditor', {
            index: el.editIndex,
            field: 'diffTaxAmount'
        }).target;
        diffTaxAmountTarget1.numberbox('initValue', Number(diffTaxAmount1.toFixed(2)));

        // 更新非Editor列数据
        var columns1 = ['notTaxPrice', 'iaDiffPrice', 'taxAmount', 'iaDiffAmount'];
        var columnsData1 = [
            Number(notTaxPrice1.toFixed(6)), Number(iaDiffPrice1.toFixed(6)), Number(taxAmount1.toFixed(2)),
            Number(iaDiffAmount1.toFixed(2))
        ];
        var ed1 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'taxPrice'});
        updatePageShowValue($(ed1.target).parents('td[field="taxPrice"]'), row, columns1, columnsData1);

        row.taxPrice = Number(ud1.toFixed(6));

        editDataAgainCountAmount();
    }

    // 到票未税金额 -> 联动变更的行数据 到票含税金额、到票差异含税金额、到票含税单价、到票不含税单价、到票差异含税单价
    if ('notTaxAmount' === editColumn) {
        // 修改后的数据
        var ud2 = new BigNumber(data);

        // 到票含税金额 = 到票未税金额 + 税额
        var taxAmount2 = ud2.plus(row.diffTaxAmount);
        // 到票含税单价 = 到票含税金额 / 对账数量
        var taxPrice2 = taxAmount2.div(row.statementNum);
        // 到票未税单价 = 到票未税金额 / 对账数量
        var notTaxPrice2 = ud2.div(row.statementNum);
        // 到票差异含税单价 = 到票含税单价 - 对账含税单价
        var iaDiffPrice2 = taxPrice2.minus(row.asTaxPrice);
        // 到票差异含税金额 = 对账数量 * 到票差异含税单价
        var iaDiffAmount2 = iaDiffPrice2.multipliedBy(row.statementNum);

        // 更新Editor列数据(initValue 不触发numberBox的onChange事件)
        var taxPriceTarget1 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'taxPrice'}).target;
        taxPriceTarget1.numberbox('initValue', Number(taxPrice2.toFixed(6)));

        // 更新非Editor列数据
        var columns2 = ['taxAmount', 'iaDiffAmount', 'notTaxPrice', 'iaDiffPrice'];
        var columnsData2 = [
            Number(taxAmount2.toFixed(2)), Number(iaDiffAmount2.toFixed(2)), Number(notTaxPrice2.toFixed(6)),
            Number(iaDiffPrice2.toFixed(6))
        ];
        var ed2 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'notTaxAmount'});
        updatePageShowValue($(ed2.target).parents('td[field="notTaxAmount"]'), row, columns2, columnsData2);

        row.notTaxAmount = Number(ud2.toFixed(2));

        // var loading = topWin.layer.msg('正在计算表体分摊金额, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
        editDataAgainCountAmount();
    }

    // 到票税额 -> 联动变更的行数据 到票含税金额、到票差异含税金额、到票含税单价、到票差异含税单价
    if ('diffTaxAmount' === editColumn) {
        // 修改后的数据
        var ud3 = new BigNumber(data);

        // 到票含税金额 = 税额 + 到票未税金额
        var taxAmount3 = ud3.plus(row.notTaxAmount);
        // 到票含税单价 = 到票含税金额 / 对账数量
        var taxPrice3 = taxAmount3.div(row.statementNum);
        // 到票差异含税单价 = 到票含税单价 - 对账含税单价
        var iaDiffPrice3 = taxPrice3.minus(row.asTaxPrice);
        // 到票差异含税金额 = 对账数量 * 到票差异含税单价
        var iaDiffAmount3 = iaDiffPrice3.multipliedBy(row.statementNum);

        // 更新Editor列数据(initValue 不触发numberBox的onChange事件)
        var taxPriceTarget3 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'taxPrice'}).target;
        taxPriceTarget3.numberbox('initValue', Number(taxPrice3.toFixed(6)));

        // 更新非Editor列数据
        var columns3 = ['taxAmount', 'iaDiffAmount', 'iaDiffPrice'];
        var columnsData3 = [
            Number(taxAmount3.toFixed(2)), Number(iaDiffAmount3.toFixed(2)), Number(iaDiffPrice3.toFixed(6))
        ];
        var ed3 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'diffTaxAmount'});
        updatePageShowValue($(ed3.target).parents('td[field="diffTaxAmount"]'), row, columns3, columnsData3);

        row.diffTaxAmount = Number(ud3.toFixed(2));

        editDataAgainCountAmount();
    }

    // 到票税率 -> 联动变更的行数据 到票未税单价、到票未税金额、到票税额
    // if ('taxCodeDesc' === editColumn) {
    //     var taxData = {};
    //     for (var j = 0; j < el.taxDict.length; j++) {
    //         if (el.taxDict[j].itemName === data) {
    //             taxData = el.taxDict[j];
    //             break;
    //         }
    //     }
    //     // 税率转换 = 1 + 税率值
    //     var tax = taxData.itemValue.replace('%', '');
    //     taxConvert = new BigNumber(1).plus(tax / 100);
    //
    //     var taxAmount = new BigNumber(row.taxAmount);
    //     // 到票未税单价 = 到票含税单价 / (1 + 税率)
    //     var notTaxPrice4 = new BigNumber(row.taxPrice).div(taxConvert);
    //     // 到票未税金额 = 含税金额 / (1 + 税率)
    //     var notTaxAmount4 = taxAmount.div(taxConvert);
    //     // // 到票税额 = 到票含税金额 - 到票未税金额
    //     // var diffTaxAmount4 = taxAmount.sub(notTaxAmount4);
    //     // 到票税额 = 到票含税金额(四舍五入保留2位) - 到票未税金额(四舍五入保留2位)
    //     var diffTaxAmount4 = Number(taxAmount.toFixed(2)) - Number(notTaxAmount4.toFixed(2));
    //
    //     // 更新非Editor列数据
    //     var columns4 = ['notTaxPrice'];
    //     var columnsData4 = [Number(notTaxPrice4.toFixed(6))];
    //     var ed4 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'taxCodeDesc'});
    //     updatePageShowValue($(ed4.target).parents('td[field="taxCodeDesc"]'), row, columns4, columnsData4);
    //
    //     var notTaxAmountTarget4 = $(el.tbDetails).datagrid('getEditor', {
    //         index: el.editIndex,
    //         field: 'notTaxAmount'
    //     }).target;
    //     notTaxAmountTarget4.numberbox('initValue', Number(notTaxAmount4.toFixed(2)));
    //
    //     var diffTaxAmountTarget4 = $(el.tbDetails).datagrid('getEditor', {
    //         index: el.editIndex,
    //         field: 'diffTaxAmount'
    //     }).target;
    //     diffTaxAmountTarget4.numberbox('initValue', Number(diffTaxAmount4.toFixed(2)));
    //
    //     // 更新非页面显示列数据
    //     row.taxCode = taxData.itemCode;
    //     row.taxValue = Number(tax);
    //
    //     editDataAgainCountAmount();
    // }

    if ('taxCodeDesc' === editColumn) {
        var taxData = {};
        for (var j = 0; j < el.taxDict.length; j++) {
            if (el.taxDict[j].itemName === data) {
                taxData = el.taxDict[j];
                break;
            }
        }
        // 税率转换 = 1 + 税率值
        var tax = taxData.itemValue.replace('%', '');
        taxConvert = new BigNumber(1).plus(tax / 100);

        var taxAmount = new BigNumber(row.taxAmount);
        // 到票含税单价 = 到票未税单价 * (1 + 税率)
        var taxPrice4 = new BigNumber(row.notTaxPrice).multipliedBy(taxConvert);
        // 到票含税金额 = 含税金额 / (1 + 税率)
        var taxAmount4 = taxPrice4.multipliedBy(row.statementNum);
        // // 到票税额 = 到票含税金额 - 到票未税金额
        // var diffTaxAmount4 = taxAmount.sub(notTaxAmount4);
        // 到票税额 = 到票含税金额(四舍五入保留2位) - 到票未税金额(四舍五入保留2位)
        var diffTaxAmount4 = Number(taxAmount4.toFixed(2)) - Number(row.notTaxAmount.toFixed(2));

        // 更新非Editor列数据
        var columns4 = ['taxAmount'];
        var columnsData4 = [Number(taxAmount4.toFixed(6))];
        var ed4 = $(el.tbDetails).datagrid('getEditor', {index: el.editIndex, field: 'taxCodeDesc'});
        updatePageShowValue($(ed4.target).parents('td[field="taxCodeDesc"]'), row, columns4, columnsData4);

        var taxPriceTarget4 = $(el.tbDetails).datagrid('getEditor', {
            index: el.editIndex,
            field: 'taxPrice'
        }).target;
        taxPriceTarget4.numberbox('initValue', Number(taxPrice4.toFixed(2)));

        var diffTaxAmountTarget4 = $(el.tbDetails).datagrid('getEditor', {
            index: el.editIndex,
            field: 'diffTaxAmount'
        }).target;
        diffTaxAmountTarget4.numberbox('initValue', Number(diffTaxAmount4.toFixed(2)));

        // 更新非页面显示列数据
        row.taxCode = taxData.itemCode;
        row.taxValue = Number(tax);

        editDataAgainCountAmount();
    }
}

/**
 * 获取当前用户表格列布局
 */
// function findUserTableColumn() {
//     $.ajax({
//         type: 'POST',
//         url: g.ctx + 'fin/table/column/rest/user/setting?pageTable=3&isAuthority=1',
//         async: false,
//         success: function (data) {
//             for(var i = 0; i < data.length; i++){
//                 el.userTableColumn.push(data[i].columnField);
//             }
//         }
//     });
// }


/**
 * 动态表格列
 */
// function dynamicColumns(orderType) {
//     var result = [];
//     for(var i = 0; i < el.userTableColumn.length; i++){
//         var columnField = el.userTableColumn[i];
//
//         for(var j = 0; j < tableColumns.length; j++){
//             var column =  tableColumns[j];
//             if(column.field === columnField){
//
//                 if(column.field === 'materialSupplierCode' || column.field === 'materialSupplierName' || column.field === 'freightType'){
//                     column.hidden = Number(orderType) === 1;
//                 }
//
//                 result.push(column);
//                 break;
//             }
//         }
//     }
//
//     return result;
// }


// 报表所有列
var tableColumns = [
    {
        field: 'itemNo',
        title: '行号',
        width: 70,
        sortable: true
    },
    // 开票申请相关
    {
        field: 'statementNum',
        title: '对账数量',
        width: 70,
        sortable: true,
        formatter: function (value) {
            if(Number(value) < 0){
                return '<span style="color: red;">' + value + '</span>';
            }
            return value;
        }
    },
    {
        field: 'notTaxPrice',
        title: '到票未税单价',
        width: 90,
        sortable: true
    },
    {
        field: 'taxPrice',
        title: '到票含税单价',
        width: 90,
        sortable: true,
        editor: {
            type: 'numberbox',
            options: {
                precision: 6,
                onChange: function (nv, ov) {
                    if(ov){
                        updateRowData(nv, 'taxPrice');
                    }
                }
            }
        }
    },
    {
        field: 'iaDiffPrice',
        title: '到票含税单价差异',
        width: 70,
        sortable: true
    },
    {
        field: 'taxCodeDesc',
        title: '到票税率',
        width: 160,
        sortable: true,
        styler: function (value, row) {
            if(Number(row.shareFlag === 1)){
                return 'background-color:#E1E1E1;';
            }
            return '';
        },
        editor: {
            type: 'combobox',
            options: {
                url: g.ctx + 'dic/getDicByType.do?type=tax',
                valueField: 'dicId',
                textField: 'dicTxt',
                data: el.taxDict,
                panelHeight: 200,
                onChange: function (nv, ov) {
                    if(ov && nv !== ov){
                        updateRowData(nv, 'taxCodeDesc');
                    }
                }
            }
        }
    },
    {
        field: 'notTaxAmount',
        title: '到票未税金额',
        width: 95,
        sortable: true,
        editor: {
            type: 'numberbox',
            options: {
                precision: 2,
                onChange: function (nv, ov) {
                    if(ov){
                        updateRowData(nv, 'notTaxAmount');
                    }
                }
            }
        }
    },
    {
        field: 'taxAmount',
        title: '到票含税金额',
        width: 95,
        sortable: true
    },
    {
        field: 'diffTaxAmount',
        title: '到票税额',
        width: 70,
        sortable: true,
        editor: {
            type: 'numberbox',
            options: {
                precision: 2,
                onChange: function (nv, ov) {
                    if(ov){
                        updateRowData(nv, 'diffTaxAmount');
                    }
                }
            }
        }
    },
    {
        field: 'iaDiffAmount',
        title: '到票含税金额差异',
        width: 70,
        sortable: true
    },
    // 对账相关
    {
        field: 'asNotTaxPrice',
        title: '对账未税单价',
        width: 65,
        sortable: true
    },
    {
        field: 'asNotTaxAmount',
        title: '对账未税金额',
        width: 95,
        sortable: true,
        formatter: function (value) {
            return formatNumber(value, 2, 1);
        }
    },
    {
        field: 'asTaxCodeDesc',
        title: '对账税率',
        width: 160,
        sortable: true
    },
    {
        field: 'asTaxPrice',
        title: '对账含税单价',
        width: 65,
        sortable: true
    },
    {
        field: 'asTaxAmount',
        title: '对账含税金额',
        width: 95,
        sortable: true,
        formatter: function (value) {
            return formatNumber(value, 2, 1);
        }
    },
    {
        field: 'asDiffTaxAmount',
        title: '对账税额',
        width: 70,
        sortable: true,
        formatter: function (value) {
            return formatNumber(value, 2, 1);
        }
    },
    {
        field: 'asDiffPrice',
        title: '对账差异含税单价',
        width: 80,
        sortable: true,
        formatter: function (value) {
            if(value === undefined){
                return '';
            }
            return formatNumber(value, 2, 1);
        }
    },
    {
        field: 'asDiffAmount',
        title: '对账差异含税金额',
        width: 80,
        sortable: true,
        formatter: function (value) {
            return formatNumber(value, 2, 1);
        }
    },
    // 凭证和订单相关
    {
        field: 'receiveCode',
        title: '物料凭证',
        width: 100,
        sortable: true
    },
    {
        field: 'receiveRowNo',
        title: '凭证行号',
        width: 70,
        sortable: true
    },
    {
        field: 'receiveDate',
        title: '入库日期',
        width: 100,
        sortable: true
    },
    {
        field: 'inOutFlag',
        title: '出入库标识',
        width: 85,
        sortable: true
    },
    {
        field: 'materialCode',
        title: '物料编码',
        width: 90,
        sortable: true
    },
    {
        field: 'materialName',
        title: '物料名称',
        width: 320,
        sortable: true
    },
    {
        field: 'materialUnit',
        title: '单位',
        width: 65,
        sortable: true
    },
    {
        field: 'poCode',
        title: 'SAP订单号',
        width: 100,
        sortable: true,
        formatter: function (value, row, index) {
            return "<a href='/purchaseOrder/detailByCode?code=" + window.btoa(value) + "' target='_blank'>" + value + "</a>"
        }
    },
    {
        field: 'poItemNo',
        title: '订单行号',
        width: 70,
        sortable: true
    },
    {
        field: 'subjectTypeName',
        title: '科目分配类别',
        width: 100,
    },
    {
        field: 'poTaxCodeDesc',
        title: '订单税率',
        width: 160,
        sortable: true
    },
    {
        field: 'poNotTaxPrice',
        title: '订单未税单价',
        width: 65,
        sortable: true
    },
    {
        field: 'poTaxPrice',
        title: '订单含税单价',
        width: 65,
        sortable: true
    },
    {
        field: 'asNtAmount',
        title: '订单未税金额',
        width: 90,
        sortable: true
    },
    {
        field: 'asItAmount',
        title: '订单含税金额',
        width: 90,
        sortable: true
    },
    {
        field: 'asDtAmount',
        title: '订单税额',
        width: 90,
        sortable: true
    },
    {
        field: 'pgCodeName',
        title: '执行采购组',
        width: 110,
        sortable: true
    },
    // {
    //     field: 'seekPgCodeName',
    //     title: '询源采购组',
    //     width: 110,
    //     sortable: true
    // },
    {
        field: 'paymentTermCodeName',
        title: '付款条件',
        width: 200,
        sortable: true
    },
    // {
    //     field: 'paymentWayCodeDesc',
    //     title: '付款方式',
    //     width: 200,
    //     sortable: true
    // },
    {
        field: 'asNo',
        title: '对账单号',
        width: 120,
        sortable: true
    },
    {
        field: 'asdItemNo',
        title: '对账单行号',
        width: 80,
        sortable: true
    },
    {
        field: 'contractNo',
        title: '合同号',
        width: 120
    }
];

