let bankDate;
$(function () {
    initDict('pay_mode,pay_type,contractCategory,payment_stage,pay_contract_type,contractPayCategory,contract_pay_boot_item');

    initColumns();

    loadGrid();

});


function initColumns() {

    $('#payOrgName').textbox({
        buttonText: '选择',
        iconCls: 'icon-man',
        iconAlign: 'left',
        onClickButton: function () {
            layer.open({
                title: "付款单位选择",
                type: 2,
                area: ['600px', '550px'],
                content: '/pc/contract/manage/page/choseSupplier?type=1',
                btn: ['选择', '关闭'],
                yes: function (index, layero) {
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    var name = $(layero).find("iframe")[0].contentWindow.document.getElementById("name").value;
                    var code = $(layero).find("iframe")[0].contentWindow.document.getElementById("code").value;
                    if (name != undefined && code != '') {
                        $('#payOrgName').textbox('setValue', name);
                        $('#payOrgCode').val(code);
                        layer.close(index);
                    } else {
                        layer.alert("未选择", {icon: 2})
                    }
                },
            });
        }
    });


    $('#contractCode').textbox({
        buttonText: '选择合同',
        // iconCls:'icon-man',
        iconAlign: 'left',
        onClickButton: function () {
            var url = '/pc/contract/pay/page/choseContractHistory';
            let contractDialog = openDialog("contractSelectDialog", url, {
                title: "合同选择",
                width: '80%',
                height: '90%',
                cache: false,
                modal: true,
                border: 'thin',
                onClose: function () {
                    contractDialog.dialog('destroy');
                },
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        topWin.frames['contractSelectDialog'].submitContractForm(function (data) {

                            $("#payOrgCode").val(data.contractCompanyCode);
                            $("#payOrgName").textbox('setValue', data.contractCompanyName);
                            $("#payeeCode").val(data.contractSupplierCode);
                            $("#payeeName").textbox('setValue', data.contractSupplierName);
                            $("#payCurrency").textbox('setValue', data.contractCurrency);

                            let srt = "";
                            getDictList("contractCategory").forEach(function (v, n) {
                                if (data.contractType == v.code) {
                                    srt = v.codeWithDesc;
                                }
                            })

                            $("#contractCode").textbox('setValue', data.contractCode);
                            $("#contractName").textbox('setValue', data.contractTitle);
                            $("#contractAmount").textbox('setValue', data.contractAmount);
                            $("#orderCode").textbox('setValue', data.orderCode);

                            //查询供应商银行信息
                            $.ajax({
                                type: 'POST',
                                url: g.ctx + 'pc/contract/pay/rest/supplierBankDate',
                                async: false,
                                data: {"contractSupplierCode": data.contractSupplierCode},
                                success: function (res) {
                                    bankDate = res;
                                    if (res.length > 0) {
                                        if (res.length == 1) {
                                            $("#bankName").textbox('setValue', res[0].openingBankName);
                                            $("#bankAccount").textbox('setValue', res[0].bankAccount);
                                            $("#bankCode").textbox('setValue', res[0].bankCode);
                                            $("#bankSwiftCode").textbox('setValue', res[0].bankInterCode);
                                        } else {
                                            $("#bankAccount").combobox({
                                                valueField: 'bankAccount',
                                                textField: 'bankAccount',
                                                data: bankDate,
                                                editable: false,
                                                panelHeight: 'auto',
                                                onLoadSuccess: function () {
                                                    $("#bankAccount").combobox('select', bankDate[0].bankAccount);
                                                    $("#bankName").textbox('setValue', bankDate[0].openingBankName);
                                                    $("#bankCode").textbox('setValue', bankDate[0].bankCode);
                                                    $("#bankSwiftCode").textbox('setValue', bankDate[0].bankInterCode);
                                                }
                                            });
                                        }
                                    } else {
                                        $("#bankName").textbox('setValue','');
                                        $("#bankAccount").textbox('setValue', '');
                                        $("#bankCode").textbox('setValue', '');
                                        $("#bankSwiftCode").textbox('setValue', '');
                                    }
                                }
                            });

                            //查合同累计付款金额
                            $.ajax({
                                type: 'POST',
                                url: g.ctx + 'pc/contract/pay/rest/totalPayAmount',
                                async: false,
                                data: {"contractCode": data.contractCode},
                                success: function (res) {
                                    var unpaidAmount = parseFloat(data.contractAmount) - parseFloat(res);
                                    $("#unpaidAmount").textbox('setValue', unpaidAmount.toFixed(2));
                                }
                            });

                            let je = 0;
                            let details = data.payStages;
                            let payStageIds = [];
                            let contractIds = [];
                            details.forEach(function (v, n) {
                                v.contractId = data.id;
                                v.payStageId = v.id
                                je = (je + v.paymentAmount);
                                v.id = "";
                                v.amount = v.paymentAmount - v.paymentAlreadyAmount;
                                v.amountPaid = v.paymentAlreadyAmount;
                                payStageIds.push(v.payStageId);
                            });
                            contractIds.push(data.id);
                            /*//查询已付款金额
                            $.ajax({
                                type: 'POST',
                                url: g.ctx + 'pc/contract/pay/rest/amountSum',
                                async: false,
                                data: {
                                    "payStageIds": payStageIds.join(","),
                                    "contractIds": contractIds.join(","),
                                    "payId": $("#id").val()
                                },
                                success: function (res) {
                                    details.forEach(function (v, n) {
                                        let am = res.hasOwnProperty(v.payStageId) ? res[v.payStageId] : 0
                                        v.amountPaid = am;
                                    });
                                }
                            });*/

                            $("#table_pay").datagrid('loadData', details);
                            $("#payeeAmount").textbox('setValue', je.toFixed(4));
                            $("#paymentProgress").textbox('setValue', data.contractAmount);
                            //$("#paymentProgress").textbox('setValue', (je / data.contractAmount).toFixed(4));
                            console.log($("#table_pay").datagrid('getRows'))
                            contractDialog.dialog('close');
                        });
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        contractDialog.dialog('close');
                    }
                }]
            });
        }
    });
    $("#bankAccount").combobox({
        valueField: 'bankAccount',
        textField: 'bankAccount',
        data: bankDate,
        editable: false,
        panelHeight: 'auto',
        onChange: function (d) {
            bankDate.forEach(function (v, n) {
                if (v.bankAccount == d) {
                    $("#bankName").textbox('setValue', v.openingBankName);
                    $("#bankCode").textbox('setValue', v.bankCode);
                    $("#bankSwiftCode").textbox('setValue', v.bankInterCode);
                }
            });
        }
    });

    $('#payeeName').textbox({
        buttonText: '选择',
        iconCls: 'icon-man',
        iconAlign: 'left',
        onClickButton: function () {
            layer.open({
                title: "收款单位选择",
                type: 2,
                area: ['650px', '550px'],
                content: '/pc/contract/manage/page/choseSupplier?type=2',
                btn: ['选择', '关闭'],
                yes: function (index, layero) {
                    var body = layer.getChildFrame('body', index);
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    var name = $(layero).find("iframe")[0].contentWindow.document.getElementById("name").value;
                    var code = $(layero).find("iframe")[0].contentWindow.document.getElementById("code").value;
                    if (name != undefined && code != '') {
                        $('#payeeName').textbox('setValue', name);
                        $('#payeeCode').val(code);
                        layer.close(index);
                    } else {
                        layer.alert("未选择", {icon: 2})
                    }
                },
            });
        }
    });


    $('#createTime').datebox({
        value: moment().format('YYYY-MM-DD'),
    });

    $('#payeeAmount').textbox({
        min: 0,
        precision: 4
    });

    $('#paymentProgress').textbox({
        min: 0,
        precision: 2
    });


    $("#settlementMethod").combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: getDictList('pay_mode')
    });

    $("#payType").combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: getDictList('pay_type')
    });

    $("#sapPayType").combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: [
            {"code": "是", "name": "是"},
            {"code": "否", "name": "否"}
        ],
        onLoadSuccess: function () {
            var id = $("#id").val();
            if (id == '') {
                $("#sapPayType").combobox('select', '是');
            }
        },
        onSelect: function (d) {
            if (d.code == '是') {
                // $("#tableLb").hide();
                $("#tableOrder").show();
            } else {
                $("#tableLb").show();
                var id = $("#id").val();
                if (id == '') {
                    $("#table_lb").datagrid('reload');
                }else{
                   loadGrid();
                }
                //$("#table_lb").datagrid('reload');
                //$("#tableOrder").hide();
            }
        }
    });

    $("#isBalanceDue").combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: [
            {"code": "是", "name": "是"},
            {"code": "否", "name": "否"}
        ]
    });


    $("#applicationType").combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: getDictList('pay_contract_type')
    });

    $("#totalAmount").textbox({
        onChange: function (newValue, oldValue) {
            $('#amountCapital').textbox('setValue', number_chinese(newValue));
        }
    });


    $('#belongDeptName').combobox({
        valueField: 'code',
        textField: 'name',
        panelHeight: 'auto',
        editable: false,
        data: [
            {"code": "申请部门", "name": "申请部门"},
            {"code": "需要分摊", "name": "需要分摊"}
        ]
    });


    $("#accepProcess").textbox({
        buttonText: '选择',
        iconCls: 'icon-search',
        iconAlign: 'left',
        onClickButton: function () {
            var ProcessType = "3";
            topWin.layer.open({
                title: "验收流程选择",
                type: 2,
                area: ['70%', '70%'],
                content: '/pc/contract/pay/page/choseOaProcess?flag=0' + '&ProcessType=' + ProcessType,
                btn: ['选择', '关闭'],
                yes: function (index, layero) {
                    var iframeWin = topWin.window[layero.find('iframe')[0]['name']];
                    iframeWin.selectRow(function (code) {
                        if (code != '') {
                            $('#accepProcess').textbox('setValue', code);
                            topWin.layer.close(index);
                        } else {
                            topWin.layer.alert("未选择", {icon: 2})
                        }
                    });
                },
            });
        }
    });


    $("#process").textbox({
        buttonText: '选择',
        iconCls: 'icon-search',
        iconAlign: 'left',
        onClickButton: function () {
            var ProcessType = "3";
            topWin.layer.open({
                title: "OA流程选择",
                type: 2,
                area: ['70%', '70%'],
                content: '/pc/contract/pay/page/choseOaProcess?flag=1' + '&ProcessType=' + ProcessType,
                btn: ['选择', '关闭'],
                yes: function (index, layero) {
                    var iframeWin = topWin.window[layero.find('iframe')[0]['name']];
                    iframeWin.selectRow(function (code) {
                        console.log(1, code)
                        if (code != '') {
                            $('#process').textbox('setValue', code);
                            topWin.layer.close(index);
                        } else {
                            topWin.layer.alert("未选择", {icon: 2})
                        }
                    });
                },
            });
        }
    });

}


function loadGrid() {

    //加载列表数据
    $("#table_pay").datagrid({
        iconCls: 'icon-list',
        url: '/pc/contract/pay/rest/detailLists?id=&payId=' + $("#id").val() + '&contractId=',
        height: 250,
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        loadMsg: "数据加载中......",
        rownumbers: true,
        nowrap: true,
        striped: true,
        page: 1,
        pageSize: 10,
        columns: [[
            {
                field: 'paymentStage', title: '付款阶段', width: '120',
                exportEnum: getDictList('payment_stage'),
                formatter: function (value) {
                    return getDicName('payment_stage', value);
                }
            },
            {field: 'paymentTime', title: '付款日期', width: '120'},
            {field: 'paymentRatio', title: '付款比例', width: '120'},
            {field: 'paymentAmount', title: '付款金额', width: '120'},
            {field: 'amount', title: '剩余未付款金额', width: '120', editor: {type: 'numberbox', options: {validType: ['num']}}},
            {field: 'amountPaid', title: '本次付款金额', width: '120'},
        ]],
        //监听编辑事件 查看合同创建时是怎么通过编辑汇总金额的
        // 编辑后触发汇总
        //开启编辑
        // onClickCell: onClickCell,
    });


    /*$("#table_order").datagrid({
        iconCls: 'icon-list',
        url: '/pc/contract/pay/rest/detailOrderLists?id=&payId=' + $("#id").val() + '&contractId=',
        height: 400,
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        loadMsg: "数据加载中......",
        rownumbers: true,
        nowrap: true,
        striped: true,
        page: 1,
        pageSize: 10,
        columns: [[
            {field: 'orderCode', title: '订单编码', width: '120'},
            {field: 'bz', title: '摘要', width: '120'},
            {field: 'enAmount', title: '应付金额', width: '120'},
            {field: 'unAmount', title: '未付金额', width: '120'},
            {field: 'amount', title: '本次付款金额', width: '120'},
            {field: 'user', title: '使用人', width: '120'},
            {field: 'costCenter', title: '成本中心', width: '120'},
        ]],
        toolbar: [
            {
                text: '新增',
                id: 'btn_add',
                iconCls: 'icon-add',
                handler: function () {
                    addOrderDetail();
                }
            },
            {
                text: '编辑',
                id: 'btn_edit',
                iconCls: 'icon-edit',
                handler: function () {
                    editOrderDetail();
                }
            },
            {
                text: '删除',
                id: 'btn_del',
                iconCls: 'icon-remove',
                handler: function (d) {
                    delOrderDetail();
                }
            },
        ],
    });*/


    $("#table_lb").datagrid({
        iconCls: 'icon-list',
        url: '/pc/contract/pay/rest/detailTypeLists?id=&payId=' + $("#id").val() + '&contractId=',
        height: 400,
        fitColumns: true,
        singleSelect: true,
        pagination: true,
        loadMsg: "数据加载中......",
        rownumbers: true,
        nowrap: true,
        striped: true,
        page: 1,
        pageSize: 10,
        columns: [[
            {
                field: 'type', title: '报销类别', width: '120',
                formatter: function (value) {
                    return getDicName('contractPayCategory', value);
                }
            },
            {field: 'bz', title: '业务描述', width: '120'},
            {field: 'amount', title: '金额', width: '120'},
            {field: 'user', title: '使用人', width: '120'},
            {field: 'code', title: '项目编码', width: '120'},
            {field: 'serviceUser', title: '服务客户', width: '120'},
            {field: 'serviceUserCode', title: '客户编码', width: '80'},
            {field: 'costCenterName', title: '成本中心', width: '120'},
            {field: 'driveBz', title: '驱动因素', width: '120',formatter: function (value) {
                    return getDicName('contract_pay_boot_item', value);
                }},
            {field: 'assetCode', title: '固定资产编码', width: '120'}

        ]],

        toolbar: [
            {
                text: '新增',
                id: 'btn_add',
                iconCls: 'icon-add',
                handler: function () {
                    addLbDetail();
                }
            },
            {
                text: '编辑',
                id: 'btn_edit',
                iconCls: 'icon-edit',
                handler: function () {
                    editLbDetail();
                }
            },
            {
                text: '删除',
                id: 'btn_del',
                iconCls: 'icon-remove',
                handler: function (d) {
                    delLbDetail();
                }
            },
        ],
    });

}


/*function addOrderDetail() {
    var addOrderDetailDialog = openDialog('addOrderDetail',
        g.ctx + 'pc/contract/pay/page/formOrderDetail', {
            title: '新增',
            width: '70%',
            height: '80%',
            cache: false,
            modal: true,
            border: 'thin',
            onClose: function () {
                addOrderDetailDialog.dialog('destroy');
            },
            buttons: [
                {
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        topWin.frames['addOrderDetail'].savePayOrderDetail(function (data) {
                            $("#table_order").datagrid('appendRow', data);
                            addOrderDetailDialog.dialog('close');
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        addOrderDetailDialog.dialog('close');
                    }
                }
            ]
        });
}*/


/*function editOrderDetail() {
    let row = $("#table_order").datagrid('getSelected');
    if (!row) {
        layer.msg("请选中一条记录");
        return;
    }

    let indexRow = $("#table_order").datagrid('getRowIndex', row);

    let p = "?id=" + row.id + "&orderCode=" + row.orderCode + "&bz=" + row.bz + "&enAmount=" + row.enAmount + "&unAmount=" + row.enAmount + "&amount=" + row.amount + "&user=" + row.user + "&costCenter=" + row.costCenter + "&payId=" + $("#id").val();
    var editOrderDetailDialog = openDialog('editOrderDetail',
        g.ctx + 'pc/contract/pay/page/formOrderDetail' + p, {
            title: '编辑',
            width: '70%',
            height: '80%',
            cache: false,
            modal: true,
            border: 'thin',
            onClose: function () {
                editOrderDetailDialog.dialog('destroy');
            },
            buttons: [
                {
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        topWin.frames['editOrderDetail'].savePayOrderDetail(function (data) {
                            $("#table_order").datagrid('updateRow', {index: indexRow, row: data});
                            editOrderDetailDialog.dialog('close');
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        editOrderDetailDialog.dialog('close');
                    }
                }
            ]
        });
}*/

/*
function delOrderDetail() {

    let row = $("#table_order").datagrid('getSelected');
    if (!row) {
        layer.msg("请选中一条记录");
        return;
    }
    topWin.layer.confirm("是否删除", function (index) {
        var rowIndex = $("#table_order").datagrid('getRowIndex', row);
        $("#table_order").datagrid('deleteRow', rowIndex);
        topWin.layer.close(index);
    })
}
*/


function addLbDetail() {
    var addLbDetailDialog = openDialog('addLbDetail',
        g.ctx + 'pc/contract/pay/page/formLbDetail', {
            title: '新增',
            width: '70%',
            height: '80%',
            cache: false,
            modal: true,
            border: 'thin',
            onClose: function () {
                addLbDetailDialog.dialog('destroy');
            },
            buttons: [
                {
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        topWin.frames['addLbDetail'].savePayTypeDetail(function (data) {
                            $("#table_lb").datagrid('appendRow', data);
                            addLbDetailDialog.dialog('close');
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        addLbDetailDialog.dialog('close');
                    }
                }
            ]
        });
}


function editLbDetail() {
    let row = $("#table_lb").datagrid('getSelected');
    if (!row) {
        layer.msg("请选中一条记录");
        return;
    }

    let indexRow = $("#table_lb").datagrid('getRowIndex', row);

    let p = "?id=" + row.id + "&type=" + row.type + "&bz=" + row.bz + "&code=" + row.code + "&serviceUser=" + row.serviceUser + "&amount=" + row.amount + "&user=" + row.user + "&driveBz=" + row.driveBz + "&assetCode=" + row.assetCode + "&payId=" + $("#id").val();
    var editLbDetailDialog = openDialog('editLbDetail',
        g.ctx + 'pc/contract/pay/page/formLbDetail' + p, {
            title: '编辑',
            width: '70%',
            height: '80%',
            cache: false,
            modal: true,
            border: 'thin',
            onClose: function () {
                editLbDetailDialog.dialog('destroy');
            },
            buttons: [
                {
                    text: '保存',
                    iconCls: 'icon-save',
                    handler: function () {
                        topWin.frames['editLbDetail'].savePayTypeDetail(function (data) {
                            $("#table_lb").datagrid('updateRow', {index: indexRow, row: data});
                            editLbDetailDialog.dialog('close');
                        });
                    }
                },
                {
                    text: '关闭',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        editLbDetailDialog.dialog('close');
                    }
                }
            ]
        });
}

function delLbDetail() {

    let row = $("#table_lb").datagrid('getSelected');
    if (!row) {
        layer.msg("请选中一条记录");
        return;
    }
    topWin.layer.confirm("是否删除", function (index) {
        var rowIndex = $("#table_lb").datagrid('getRowIndex', row);
        $("#table_lb").datagrid('deleteRow', rowIndex);
        topWin.layer.close(index);
    })
}


function submitContractPayDetalsForm(call) {
    debugger;
    let b;

    let applicationType = $("#applicationType").textbox('getValue');
    let contractCode = $("#contractCode").textbox('getValue');
    let isBalanceDue = $("#isBalanceDue").textbox('getValue');
    let process = $("#process").textbox('getValue');
    if (applicationType == 1 && contractCode == '') {
        topWin.layer.alert("请选择合同!")
        return;
    }
    if (isBalanceDue != '' && isBalanceDue == '是' && process == '') {
        topWin.layer.alert("请选择验收流程!")
        return;
    }


    let formPayData = $("#formPayData").serializeJson();
    endEditing();
    let rows = $('#table_pay').datagrid('getRows');
    for (let i = 0; i < rows.length; i++) {
        let pre = "第" + (i + 1) + "行明细，";
        let amount = rows[i].paymentAmount - rows[i].amountPaid;
        if (rows[i].amount > amount) {
            topWin.layer.alert(pre + "中本次剩余未付款金额:" + rows[i].amount + "不能大于:" + amount);
            return;
        }
    }
    // let orderRows = $('#table_order').datagrid('getRows');
    let typeTows = $('#table_lb').datagrid('getRows');
    let dlist = JSON.stringify(rows);
    //let orderlist = JSON.stringify(orderRows);
    let typelist = JSON.stringify(typeTows);
    var payFiles = $("#payFiles").attr('data-fileIds')
    formPayData.payFiles = payFiles;
    formPayData.dlist = dlist;
    //formPayData.orderlist = orderlist;
    formPayData.typelist = typelist;
    if ($("#formPayData").form('validate')) {
        $.ajax({
            url: '/pc/contract/pay/rest/form/formPayData',
            type: 'POST',
            async: false,
            data: formPayData,
            success: function (res) {
                topWin.layer.alert("保存成功!", {icon: 1}, function (idx) {
                    topWin.layer.close(idx);
                    call()
                });
            },
            error: function (res) {
                topWin.layer.alert(res.responseJSON.message, {icon: 2});
            }
        });
    }
    return b;
}

$.extend($.fn.datagrid.methods, {
    editCell: function (jq, param) {
        return jq.each(function () {
            var opts = $(this).datagrid('options');
            var fields = $(this).datagrid('getColumnFields', true).concat($(this).datagrid('getColumnFields'));
            for (var i = 0; i < fields.length; i++) {
                var col = $(this).datagrid('getColumnOption', fields[i]);
                col.editor1 = col.editor;
                if (fields[i] != param.field) {
                    col.editor = null;
                }
            }
            $(this).datagrid('beginEdit', param.index);
            for (var i = 0; i < fields.length; i++) {
                var col = $(this).datagrid('getColumnOption', fields[i]);
                col.editor = col.editor1;
            }
        });
    }
});

var editIndex = undefined;

function endEditing() {
    if (editIndex == undefined) {
        return true
    }
    if ($('#table_pay').datagrid('validateRow', editIndex)) {
        $('#table_pay').datagrid('endEdit', editIndex);
        editIndex = undefined;
        return true;
    } else {
        return false;
    }
}

function onClickCell(index, field) {
    if (endEditing()) {
        var d = $("#table_pay").datagrid('getRows');
        changeJe(d);
        let dd = $('#table_pay').datagrid('selectRow', index);
        dd.datagrid('editCell', {index: index, field: field});
        editIndex = index;
    }
}

function changeJe(d) {
    debugger;
    var hs = 0.00;
    d.forEach(function (v, n) {
        let amount = v.amount;
        hs = parseFloat(hs) + parseFloat(amount);
    });
    $("#payeeAmount").textbox('setValue', hs.toFixed(4));
}

$.extend($.fn.validatebox.defaults.rules, {
    num: {
        validator: function (value) {
            return true;
        },
        message: '付款金额有误!'
    }
});