/**
 * 对账模块-对账单新增页面JS
 *
 * Created by li.kui on 2020/8/1.
 */
'use strict';
var el = {
    paymentPlanYear: '#paymentPlanYear',
    paymentPlanMonth: '#paymentPlanMonth'
};


/**
 * 文档就绪
 */
$(function () {
    //初始化日期
    var months = [];

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

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

/**
 * 手工新增付款计划单
 */
function submitPaymentPlanSave(optType,callback) {
    var paymentPlanYear = $.trim($(el.paymentPlanYear).val());
    var paymentPlanMonth = $.trim($(el.paymentPlanMonth).val());
    var reg = "[0-9]";

    // if(rows.length === 0) {
    //     topWin.layer.alert('请选择您要删除的入库明细', {icon: 0});
    //     return false;
    // }
    //
    //
    //
    // if(surplusReceiveId.length === 0){
    //     topWin.layer.alert('明细不能全部删除', {icon: 0});
    //     return false;
    // }

    var loading = topWin.layer.msg('正在生成付款计划单, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
    $.ajax({
        type: 'POST',
        url: g.ctx + 'pc/finance/payment/plan/rest/addNewPaymentPlan',
        data: {
            paymentPlanYear: paymentPlanYear,
            paymentPlanMonth: paymentPlanMonth
        },
        success: function () {
            topWin.layer.close(loading);
            callback();
        },
        error: function (data) {
            topWin.layer.close(loading);
            topWin.layer.alert(data.responseJSON.message, {icon: 2});
        }
    });
}
