/**
 * 对账模块-采购到票确认首页JS
 *
 * Created by li.kui on 2020/8/28.
 */
'use strict';
var el = {
    searchForm: '#searchForm',
    companyCode: '#companyCode',
    supCodeOrName: '#supCodeOrName',
    invoiceApplyNo: '#invoiceApplyNo',
    createTimeStart: '#createTimeStart',
    purchaseGroup: '#purchaseGroup',
    paperlessFlag: '#paperlessFlag',
    currencyCode: '#currencyCode',
    createTimeEnd: '#createTimeEnd',
    oaProcessNo: '#oaProcessNo',
    status: '#status',
    orderType: '#orderType',
    accountStatementYear: '#accountStatementYear',
    accountStatementMonth: '#accountStatementMonth',
    tb: '#tb',
    optConfirmDialog: null,
    lookDialog: null,
    bodyHeight: document.documentElement.clientHeight
};
$(function () {
    initNecessaryDatas('pc/sys/purchaseGroup/rest/listAll,pc/sys/company/rest/listAll')
    initComBoBoxData();

    loadGrid();
});

var editor = undefined;


/**
 * 初始化页面下拉框数据
 */
function initComBoBoxData() {
    // 初始化数据状态下拉框
    // 开票申请单状态 1:暂存发票 2:待采购确认发票 3:采购拒绝发票 4:待推送OA审批 5:OA审批中 6:OA审批不通过 7:待财务确认发票 8:财务驳回发票 9:发票已确认
    $(el.status).combobox({
        valueField: 'value',
        textField: 'label',
        value: -1,
        data: [
            {label: '全部', value: -1},
            {label: '待采购确认发票', value: 2},
            // {label: '待推送OA审批', value: 4},
            // {label: 'OA审批中', value: 5},
            // {label: 'OA审批不通过', value: 6},
            {label: '待财务确认发票', value: 7},
            {label: '财务驳回发票', value: 8},
            {label: '发票已确认', value: 9}
        ],
        editable: false,
        panelHeight: 'auto'
    });

    // 初始化公司名称下拉框
    $(el.companyCode).combobox({
        url: g.ctx + 'pc/sys/company/rest/listAll?isAuthority=0',
        panelHeight: 300,
        panelWidth: 340,
        valueField: 'code',
        textField: 'codeWithDesc',
        prompt: '--- 请选择 ---',
        onLoadSuccess: function () { //加载完成后,设置选中第一项
            $(this).combobox("select", $('#deptCode').val());
        }
    });

    // 初始化单据类型下拉框
    // 单据类型 -1:全部 1:材料类 2:运费类
    $(el.orderType).combobox({
        valueField: 'value',
        textField: 'label',
        value: -1,
        data: [
            {label: '全部', value: -1},
            {label: '材料类', value: 1},
            {label: '运费类', value: 2}
        ],
        editable: false,
        panelHeight: 'auto'
    });
    //初始化日期
    var months = [];

    for (let i = 1; i <= 12; i++) {
        let paddedNumber = i.toString().padStart(2, '0');
        months.push({
            label: paddedNumber,
            value: paddedNumber
        });
    }

    $('#accountStatementMonth').combobox({
        data: months,
        valueField: 'value',
        textField: 'label'
    });

    $(el.accountStatementYear).val('');
    $(el.accountStatementMonth).combobox('setValue', "");
}


/**
 * 初始化页面表格
 */
function loadGrid() {
    var searchHeight = $(el.searchForm).outerHeight();
    var pager = initGridPagerNew(el.bodyHeight - searchHeight, 37, 40);

    $(el.tb).edatagrid({
        loadMsg: '数据加载中......',
        emptyMsg: '暂无数据',
        url: g.ctx + 'pc/finance/cost/invoiced/apply/rest/list',
        height: el.bodyHeight - searchHeight,
        singleSelect: true,
        rownumbers: true,
        // 定义从服务器对数据进行排序
        remoteSort: true,
        // 定义是否允许多列排序
        // multiSort: true,
        pagination: true,
        pageSize: pager.pageSize,
        pageList: pager.pageList,
        queryParams: {
            roleType: 1,
            status: -1,
            companyCode: $('#deptCode').val()
        },
        frozenColumns: [
            [
                {
                    field: 'ck',
                    checkbox: true
                },
                {
                    field: 'status',
                    title: '数据状态',
                    width: 115,
                    sortable: true,
                    formatter: function (value) {
                        // 开票申请单状态 1:暂存发票 2:待采购确认发票 3:采购拒绝发票 4:待推送OA审批 5:OA审批中 6:OA审批不通过 7:待财务确认发票 8:财务驳回发票 9:发票已确认
                        switch (Number(value)) {
                            case 1:
                                return '暂存发票';
                            case 2:
                                return '<span style="color: rebeccapurple;">待采购确认发票</span>';
                            case 3:
                                return '<span style="color: red;">采购拒绝发票</span>';
                            case 4:
                                return '<span style="color: yellow;">待推送OA审批</span>';
                            case 5:
                                return '<span style="color: blue;">OA审批中</span>';
                            case 6:
                                return '<span style="color: red;">OA审批不通过</span>';
                            case 7:
                                return '<span style="color: orange;">待财务确认发票</span>';
                            case 8:
                                return '<span style="color: red;">财务驳回发票</span>';
                            case 9:
                                return '<span style="color: green;">发票已确认</span>';
                            default:
                                return '';
                        }
                    }
                },
                // {
                //     field: 'contractSupplementStatus',
                //     title: '合同补录状态',
                //     width: 110,
                //     sortable: true,
                //     formatter: function (value) {
                //         switch (value) {
                //             case 0:
                //                 return '无';
                //             case 1:
                //                 return '<span style="color: blue;">待复核</span>';
                //             case 2:
                //                 return '<span style="color: red;">复核未通过</span>';
                //             case 3:
                //                 return '<span style="color: green;">复核通过</span>';
                //             default:
                //                 return '';
                //         }
                //     }
                // },
                // {
                //     field: 'foreignCurrencyAddFlag',
                //     title: '外币资料交接',
                //     width: 100,
                //     sortable: true,
                //     exportEnum:[
                //         {code:0,codeWithDesc:'否'},
                //         {code:1,codeWithDesc:'是'}
                //     ],
                //     formatter:function (value) {
                //         if(value === 0){
                //             return "否"
                //         }else{
                //             return "<span style='color: green;'>是</span>"
                //         }
                //     }
                // },
                {
                    field: 'paperlessFlag',
                    title: '是否无纸化',
                    width: 100,
                    exportEnum:[
                        {code:0,codeWithDesc:'否'},
                        {code:1,codeWithDesc:'是'}
                    ],
                    formatter:function (value) {
                        if(value === 0){
                            return "否"
                        }else{
                            return "<span style='color: green;'>是</span>"
                        }
                    }
                },
                {
                    field: 'postStatus',
                    title: '过账状态',
                    width: 80,
                    sortable: true,
                    formatter: function (value, row) {
                        // 过账状态 1:暂存 2:待过账 3:过账失败 4:过账成功
                        switch (Number(value)) {
                            case 1:
                                return '暂存';
                            case 2:
                                return '<span style="color: orange;">待预制</span>';
                            case 3:
                                return '<span  style="color: red;">预制失败</span>';
                            case 4:
                                return '<span style="color: green;">预制成功</span>';
                            case 5:
                                return '<span style="color: blue;" >过账成功</span>';
                            case 6:
                                return '<span style="color: grey;">无需过账</span>';
                            case 7:
                                return '<span  style="color: red;">已冲销</span>';
                            default:
                                return '';
                        }
                    }
                },

            ]
        ],
        columns: [
            [
                {
                    field: 'invoiceApplyNo',
                    title: '开票申请单号',
                    width: 140,
                    sortable: true
                },
                {
                    field: 'accountStatementNo',
                    title: '对账单号',
                    width: 140,
                    sortable: true
                },{
                field: 'accountStatementYear',
                title: '对账单年份',
                width: 100,
                sortable: true
            },
                {
                    field: 'accountStatementMonth',
                    title: '对账单月份',
                    width: 100,
                    sortable: true
                },
                {
                    field: 'paymentExpireDate',
                    title: '付款到期日',
                    width: 120,
                    sortable: true,
                    exportDateFormatter:'date',
                    formatter: function (value, row) {
                        if (!value) {
                            return '';
                        }
                        return '<span style="color: red;">' + moment(value).format('YYYY-MM-DD') + '</span>';
                    }
                },
                // {
                //     field: 'newPaymentExpireDate',
                //     title: '新付款到期日',
                //     width: 120,
                //     sortable: true,
                //     exportDateFormatter:'date',
                //     formatter: function (value, row) {
                //         if (!value) {
                //             return '';
                //         }
                //         return '<span style="color: red;">' + moment(value).format('YYYY-MM-DD') + '</span>';
                //     },
                //     editor: {
                //         type: 'datebox',
                //         options: {
                //             editable: false,
                //             parser: function (value) {
                //                 if (value) {
                //                     return new Date(value);
                //                 } else {
                //                     return new Date();
                //                 }
                //             }
                //         }
                //     }
                // },

                {
                    field: 'purchaseGroup',
                    title: '采购组',
                    width: 100,
                    formatter: function (value) {
                        return getNecessaryDataName('pc/sys/purchaseGroup/rest/listAll',value);
                    }
                },
                {
                    field: 'supplierCode',
                    title: '供应商编码',
                    width: 90,
                    sortable: true
                },
                {
                    field: 'supplierName',
                    title: '供应商名称',
                    width: 270,
                    sortable: true
                },
                {
                    field: 'invoiceNo',
                    title: '到票发票号',
                    width: 110,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return '';
                        }
                        return '<span style="width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: keep-all;" title="'+ value +'">' + value + '</span>';
                    }
                },
                {
                    field: 'invoiceNetAmount',
                    title: '到票净价总金额',
                    width: 110,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return 0;
                        }
                        return formatNumber(value, 2, 1);
                    }
                },
                {
                    field: 'invoiceTaxAmount',
                    title: '到票含税总金额',
                    width: 110,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return 0;
                        }
                        return formatNumber(value, 2, 1);
                    }
                },
                {
                    field: 'invoiceDiffAmount',
                    title: '到票税额',
                    width: 90,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return 0;
                        }
                        return formatNumber(value, 2, 1);
                    }
                },
                {
                    field: 'currencyCode',
                    title: '货币代码',
                    width: 70,
                    sortable: true
                },
                {
                    field: 'companyCode',
                    title: '采购公司',
                    width: 240,
                    sortable: true,
                    formatter: function (value) {
                        return getNecessaryDataName('pc/sys/company/rest/listAll',value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    width: 130,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return '';
                        }
                        return moment(value).format('YYYY-MM-DD HH:mm');
                    }
                },
                {
                    field: 'updateTime',
                    title: '最后更新时间',
                    width: 140,
                    sortable: true,
                    formatter: function (value) {
                        if (!value) {
                            return '';
                        }
                        return moment(value).format('YYYY-MM-DD HH:mm');
                    }
                },
                // {
                //     field: 'purchaseUser',
                //     title: '采购员',
                //     width: 140,
                // }

                {
                    field: 'createUserName',
                    title: '创建人',
                    width: 140,
                }
            ]
        ],
        toolbar: [
            {
                text: '查看',
                iconCls: 'icon-find',
                id: 'btn_look',
                handler: function () {
                    detail(2);
                }
            },
            '-',
            {
                text: '采购确认',
                iconCls: 'icon-ok',
                id: 'btn_purchase_confirm',
                handler: function () {
                    // optConfirm();
                    detail(3);
                }
            },
            // '-',
            // {
            //     text: '推送OA审批',
            //     iconCls: 'icon-ok',
            //     id: 'btn_push_oa',
            //     handler: function () {
            //         pushOa();
            //     }
            // },
            '-',
            {
                text: '撤销财务确认',
                iconCls: 'icon-redo',
                id: 'btn_revoke_fc',
                handler: function () {
                    revokeFinConfirm();
                }
            }
        ],
        onCheck: function (rowIndex) {
            var rows = $(el.tb).datagrid('getRows');
            var contractSupplementStatus = rows[rowIndex].contractSupplementStatus;
            //1-新增；2-发布；3-截止；4-取消；5-完成
            switch (Number(contractSupplementStatus)) {
                case 1:
                    $('#btn_sale_contract_confirm').linkbutton('enable');
                    break;
                case 2:
                    $('#btn_sale_contract_confirm').linkbutton('enable');
                    break;
                default:
                    $('#btn_sale_contract_confirm').linkbutton('disable');
                    break;
            }
        },
        onLoadSuccess: function () {
            displayButtonByUserRole('cost_invoiced_apply_purchase_list');
            $(el.tb).edatagrid('clearSelections');
        },
        onClickRow: function (inx,row) {
            endInvoiceEditor();
            $(el.tb).edatagrid('editRow', inx);
            editor = inx;
            debugger
        },
    });
}

function saveInvoice() {
    // 结束行编辑
    endInvoiceEditor();

    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }
    if(row.paymentExpireDate){
        topWin.layer.alert('只有付款到期日不为空才能修改新付款到期日', {icon: 0});
        return false;
    }
    if(Number(row.status) !== 9){
        topWin.layer.alert('只有发票已确认状态才能修改新付款到期日', {icon: 0});
        return false;
    }
    if(!row.newPaymentExpireDate){
        topWin.layer.alert('请选择新付款到期日', {icon: 0});
        return false;
    }

    var loading = topWin.layer.msg('数据保存中, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
    $.ajax({
        url: g.ctx + 'pc/finance/invoiced/apply/rest/revoke/fin/updateNewDate',
        type: 'POST',
        data: {
            iaId: row.id,
            newPaymentExpireDate: row.newPaymentExpireDate
        },
        success: function () {
            topWin.layer.close(loading);
            topWin.layer.alert('保存成功', {icon: 1});
            $(el.tb).edatagrid('reload');
        },
        error: function (data) {
            topWin.layer.close(loading);
            topWin.layer.alert(JSON.parse(data.responseText).message,{icon: 2, shadeClose: true, title: '温馨提示'});
        }
    });
}

function endInvoiceEditor() {
    $(el.tb).edatagrid('saveRow')
    editor = undefined;
}

//打印
function printInvoice() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert("请选择数据", {icon: 0});
        return false;
    }
    if(row.deleteFlag === 1){ layer.msg("删除的单据不可打印"); return; }

    var companyCode = $(el.companyCode).combobox('getValue');
    if (!companyCode) {
        topWin.layer.alert("请选择采购公司", {icon: 0});
        return false;
    }

    $.ajax({
        type: 'GET',
        url: g.ctx + 'pc/finance/invoiced/apply/print2?id=' + row.id + '&companyCode=' + companyCode,
        success: function (data) {
            $('#printOrder').print({
                globalStyles: false,
                mediaPrint: true,
                iframe: true,
                prepend: data,
                deferred: $.Deferred().done(function () {
                    $.ajax({
                        type: 'POST',
                        url: g.ctx + 'pc/finance/invoiced/apply/rest/update/print?id=' + row.id,
                        success: function (data) {
                            $('#tb').edatagrid('reload');
                        }
                    });
                })
            });
        }
    });
}
/**
 * 查看开票申请单
 */
function lookOrder() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }

    var url = g.ctx + 'pc/finance/invoiced/apply/look?id=' + row.id;
    el.lookDialog = openDialog('lookStatementOrder', url, {
        title: '查看开票申请',
        width: '99%',
        height: '100%',
        cache: false,
        modal: true,
        border: 'thin',
        onClose: function () {
            el.lookDialog.dialog('destroy');
        },
        buttons: [
            {
                text: '关闭',
                iconCls: 'icon-cancel',
                handler: function () {
                    el.lookDialog.dialog('close');
                }
            }
        ]
    });
}


/**
 * 采购操作确认
 */
function optConfirm() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }
    var status = row.status, id = row.id;
    var url = g.ctx + 'pc/finance/invoiced/apply/opt/confirm?id=' + id + '&roleType=1';

    // 数据状态 1:暂存 2:待采购确认 3:采购拒绝 4:待推送OA审批 5:OA审批中 6:OA审批不通过 7:待财务确认 8:财务拒绝 9:确认完成
    if(Number(status) === 2 || Number(status) === 6 || Number(status) === 8){
        el.optConfirmDialog = openDialog('optConfirm', url, {
            title: '采购确认开票申请单',
            width: '99%',
            height: '100%',
            cache: false,
            modal: true,
            border: 'thin',
            onClose: function () {
                el.optConfirmDialog.dialog('destroy');
            },
            buttons: [
                {
                    text: '通过',
                    iconCls: 'icon-ok',
                    handler: function () {
                        topWin.frames['optConfirm'].dataSave(1,function (dataParams) {
                            console.info(dataParams);
                            // 校验金额数据
                            // 校验 校验关联发票页面的“无税金额合计”= 表头的“开票净价总金额”、“含税金额合计”= 表头的“开票含税总金额”
                            if(dataParams.isBindInvoice){
                                if(dataParams.invoiceTotalAmount != dataParams.invoiceNetAmount){
                                    topWin.layer.alert("金额不符，请重新关联发票，修改开票金额!", {icon: 2});
                                    return false;
                                }

                                if(dataParams.invoiceTaxTotalAmount != dataParams.invoiceTaxAmount){
                                    topWin.layer.alert("金额不符，请重新关联发票，修改开票金额!", {icon: 2});
                                    return false;
                                }

                            }

                            approveConfirm(dataParams, 1);
                        });
                    }
                },
                {
                    text: '拒绝',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        topWin.frames['optConfirm'].dataSave(0,function (dataParams) {
                            approveConfirm(dataParams, 0);
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-clear',
                    handler: function () {
                        el.optConfirmDialog.dialog('close');
                    }
                }
            ]
        });
    }else {
        topWin.layer.alert('采购只能操作待采购确认和财务拒绝状态的开票申请单', {icon: 0});
        return false;
    }
}


/**
 * 采购审批
 *
 * @param dataParams 提交数据
 * @param approveStatus 0:拒绝 1:通过
 */
function approveConfirm(dataParams, approveStatus) {
    dataParams.roleType = 1;
    dataParams.approveStatus = approveStatus;

    console.log(JSON.stringify(dataParams))
    var loading = topWin.layer.msg('数据保存中, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
    $.ajax({
        url: g.ctx + 'pc/finance/invoiced/apply/rest/approve/confirm',
        type: 'POST',
        data: JSON.stringify(dataParams),
        contentType: 'application/json',
        success: function (data) {
            topWin.layer.close(loading);
            el.optConfirmDialog.dialog('close');
            $(el.tb).edatagrid('reload');

            if(Number(data.status) === 4){
                topWin.layer.alert('确认数据保存成功, 但推送OA审批失败请尝试手动推送', {icon: 1});
            }else {
                topWin.layer.msg('操作成功', {icon: 1});
            }
        },
        error: function (data) {
            topWin.layer.close(loading);
            topWin.layer.alert(JSON.parse(data.responseText).message,{icon: 2, shadeClose: true, title: '温馨提示'});
        }
    });
}


/**
 * 开票申请单推送OA
 */
function pushOa() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }
    if(Number(row.status) !== 4){
        topWin.layer.alert('只有待推送审批状态的开票申请单才能推送审批', {icon: 0});
        return false;
    }

    var loading = topWin.layer.msg('数据推送中, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
    $.ajax({
        url: g.ctx + 'fin/invoiced/apply/rest/push/oa',
        type: 'POST',
        data: {iaId: row.id},
        success: function () {
            topWin.layer.close(loading);
            topWin.layer.msg('数据推送成功', {icon: 1});
            $(el.tb).edatagrid('reload');
        },
        error: function (data) {
            topWin.layer.close(loading);
            topWin.layer.alert(data.responseJSON.message, {icon: 2});
        }
    });
}


/**
 * 撤销财务确认
 */
function revokeFinConfirm() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }
    if(Number(row.status) !== 7){
        topWin.layer.alert('只有待财务确认发票状态的才能撤销', {icon: 0});
        return false;
    }

    topWin.layer.prompt({title: '请填写撤销原因', formType: 2, maxlength: 255}, function (text, index) {
        var loading = topWin.layer.msg('数据保存中, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
        $.ajax({
            url: g.ctx + 'pc/finance/cost/invoiced/apply/rest/revoke/fin/confirm',
            type: 'POST',
            data: {
                iaId: row.id,
                revokeReason: text
            },
            success: function () {
                topWin.layer.close(index);
                topWin.layer.close(loading);
                topWin.layer.msg('撤销成功', {icon: 1});
                $(el.tb).edatagrid('reload');
            },
            error: function (data) {
                topWin.layer.close(loading);
                topWin.layer.alert(JSON.parse(data.responseText).message,{icon: 2, shadeClose: true, title: '温馨提示'});
            }
        });
    });
}


/**
 * 导出开票申请
 */
function exportInvoiceApply() {
    var row = $(el.tb).edatagrid('getSelected');
    if (!row) {
        topWin.layer.alert('请选择一条开票申请单进行操作', {icon: 0});
        return false;
    }

    var url = g.ctx + 'pc/finance/invoiced/apply/rest/data/export?id=' + row.id;
    window.open(url);
}


/**
 * 查询对账单数据
 */
function searchIaData() {
    var queryParams = $(el.tb).edatagrid('options').queryParams;
    queryParams.invoiceApplyNo = $.trim($(el.invoiceApplyNo).val());
    queryParams.supCodeOrName = $.trim($(el.supCodeOrName).val());
    // queryParams.oaProcessNo = $.trim($(el.oaProcessNo).val());
    queryParams.companyCode = $(el.companyCode).combobox('getValue');
    queryParams.status = $(el.status).combobox('getValue');
    queryParams.purchaseGroup = $(el.purchaseGroup).combobox('getValue');
    queryParams.paperlessFlag = $(el.paperlessFlag).combobox('getValue');
    queryParams.currencyCode = $(el.currencyCode).combobox('getValue');
    // queryParams.orderType = $(el.orderType).combobox('getValue');
    queryParams.createTimeStart = $(el.createTimeStart).datebox('getValue');
    queryParams.createTimeEnd = $(el.createTimeEnd).datebox('getValue');
    // queryParams.purchaseUser = $('#purchaseUser').textbox('getValue');
    queryParams.createUserName = $('#createUserName').textbox('getValue');
    queryParams.roleType = 1;
    queryParams.accountStatementMonth = $(el.accountStatementMonth).val();
    queryParams.accountStatementYear = $(el.accountStatementYear).val();
    $(el.tb).edatagrid('load');
}


/**
 * 重置查询
 */
function resetIaSearch() {
    $(el.supCodeOrName).val('');
    // $(el.oaProcessNo).val('');
    $(el.invoiceApplyNo).val('');
    $(el.companyCode).combobox('setValue', '');
    $(el.currencyCode).combobox('setValue', '');
    $(el.status).combobox('setValue', -1);
    $(el.postStatus).combobox('setValue', -1);
    // $(el.orderType).combobox('setValue', -1);
    $(el.createTimeStart).datebox('setValue', '');
    $(el.purchaseGroup).combobox('setValue', '');
    $(el.paperlessFlag).combobox('setValue', '');
    $(el.createTimeEnd).datebox('setValue', '');
    $('#purchaseUser').textbox('setValue', '');
    $('#createUserName').textbox('setValue', '');
    $(el.accountStatementYear).val('');
    $(el.accountStatementMonth).combobox('setValue', "");
    searchIaData();
}


/**
 * 查看OA审批日志
 *
 * @param ele 当前操作DOM节点
 */
function lookOaApproveLog(ele) {
    var url = g.ctx + 'fin/common/look/oa/log/dialog?oaProcessNo=' + $(ele).data('op');
    var lookOaLogDialog = openDialog('lookOaLogDialog', url, {
        title: '查看OA审批日志',
        width: '55%',
        height: '50%',
        cache: false,
        modal: true,
        border: 'thin',
        onClose: function () {
            lookOaLogDialog.dialog('destroy');
        },
        buttons: [
            {
                text: '关闭',
                iconCls: 'icon-clear',
                handler: function () {
                    lookOaLogDialog.dialog('close');
                }
            }
        ]
    });
}


/**
 * 查看开票申请过账结果
 *
 * @param ele 当前操作DOM节点
 */
function lookPostResult(ele) {
    var url = g.ctx + 'fin/common/look/post/result/dialog?iaId=' + $(ele).data('id');
    var lookPostResultDialog = openDialog('lookPostResultDialog', url, {
        title: '查看开票申请过账结果',
        width: '55%',
        height: '400px',
        cache: false,
        modal: true,
        border: 'thin',
        onClose: function () {
            lookPostResultDialog.dialog('destroy');
        },
        buttons: [
            {
                text: '关闭',
                iconCls: 'icon-clear',
                handler: function () {
                    lookPostResultDialog.dialog('close');
                }
            }
        ]
    });
}