$('#save').click(function() {
    var fields = [];
    var fieldArray = $('.fieldTable tbody tr');
    $.each(fieldArray, function (index, target) {
        var field = {};
        field.code = $(this).find('.code').val().replace(/,/g,'');
        if ($(this).find('.contractPaymentApplyFlag').is(':checked')) {
            field.contractPaymentApplyFlag = 1;
        } else {
            field.contractPaymentApplyFlag = 0;
        }
        if ($(this).find('.deliveryOrderFlag').is(':checked')) {
            field.deliveryOrderFlag = 1;
        } else {
            field.deliveryOrderFlag = 0;
        }
        if ($(this).find('.overseasDeliveryOrderFlag').is(':checked')) {
            field.overseasDeliveryOrderFlag = 1;
        } else {
            field.overseasDeliveryOrderFlag = 0;
        }
        if ($(this).find('.purchaseOrderFlag').is(':checked')) {
            field.purchaseOrderFlag = 1;
        } else {
            field.purchaseOrderFlag = 0;
        }
        if ($(this).find('.customsDeclarationFlag').is(':checked')) {
            field.customsDeclarationFlag = 1;
        } else {
            field.customsDeclarationFlag = 0;
        }
        if ($(this).find('.contractDeliveryFlag').is(':checked')) {
            field.contractDeliveryFlag = 1;
        } else {
            field.contractDeliveryFlag = 0;
        }
        if ($(this).find('.contractOrderReturnFlag').is(':checked')) {
            field.contractOrderReturnFlag = 1;
        } else {
            field.contractOrderReturnFlag = 0;
        }
        if ($(this).find('.paymentMatchingFlag').is(':checked')) {
            field.paymentMatchingFlag = 1;
        } else {
            field.paymentMatchingFlag = 0;
        }
        if ($(this).find('.paymentMatchingCreateFlag').is(':checked')) {
            field.paymentMatchingCreateFlag = 1;
        } else {
            field.paymentMatchingCreateFlag = 0;
        }
        if ($(this).find('.paymentMatchingCheckFlag').is(':checked')) {
            field.paymentMatchingCheckFlag = 1;
        } else {
            field.paymentMatchingCheckFlag = 0;
        }
        if ($(this).find('.paymentNoticeFlag').is(':checked')) {
            field.paymentNoticeFlag = 1;
        } else {
            field.paymentNoticeFlag = 0;
        }
        if ($(this).find('.costMatchingFlag').is(':checked')) {
            field.costMatchingFlag = 1;
        } else {
            field.costMatchingFlag = 0;
        }
        if ($(this).find('.costMatchingCreateFlag').is(':checked')) {
            field.costMatchingCreateFlag = 1;
        } else {
            field.costMatchingCreateFlag = 0;
        }
        if ($(this).find('.costMatchingCheckFlag').is(':checked')) {
            field.costMatchingCheckFlag = 1;
        } else {
            field.costMatchingCheckFlag = 0;
        }
        if ($(this).find('.accountStatementCreateFlag').is(':checked')) {
            field.accountStatementCreateFlag = 1;
        } else {
            field.accountStatementCreateFlag = 0;
        }
        if ($(this).find('.accountStatementCheckFlag').is(':checked')) {
            field.accountStatementCheckFlag = 1;
        } else {
            field.accountStatementCheckFlag = 0;
        }
        if ($(this).find('.transferAccountStatementCheckFlag').is(':checked')) {
            field.transferAccountStatementCheckFlag = 1;
        } else {
            field.transferAccountStatementCheckFlag = 0;
        }
        if ($(this).find('.acceptanceAccountStatementCheckFlag').is(':checked')) {
            field.acceptanceAccountStatementCheckFlag = 1;
        } else {
            field.acceptanceAccountStatementCheckFlag = 0;
        }
        if ($(this).find('.overseasAccountStatementCreateFlag').is(':checked')) {
            field.overseasAccountStatementCreateFlag = 1;
        } else {
            field.overseasAccountStatementCreateFlag = 0;
        }
        if ($(this).find('.overseasAccountStatementCheckFlag').is(':checked')) {
            field.overseasAccountStatementCheckFlag = 1;
        } else {
            field.overseasAccountStatementCheckFlag = 0;
        }
        if ($(this).find('.overseasTransferAccountStatementCheckFlag').is(':checked')) {
            field.overseasTransferAccountStatementCheckFlag = 1;
        } else {
            field.overseasTransferAccountStatementCheckFlag = 0;
        }
        if ($(this).find('.correlationAccountStatementCreateFlag').is(':checked')) {
            field.correlationAccountStatementCreateFlag = 1;
        } else {
            field.correlationAccountStatementCreateFlag = 0;
        }
        if ($(this).find('.correlationAccountStatementCheckFlag').is(':checked')) {
            field.correlationAccountStatementCheckFlag = 1;
        } else {
            field.correlationAccountStatementCheckFlag = 0;
        }
        if ($(this).find('.correlationAccountStatementManualCheckFlag').is(':checked')) {
            field.correlationAccountStatementManualCheckFlag = 1;
        } else {
            field.correlationAccountStatementManualCheckFlag = 0;
        }

        // if ($(this).find('.stoAccountStatementCreateFlag').is(':checked')) {
        //     field.stoAccountStatementCreateFlag = 1;
        // } else {
        //     field.stoAccountStatementCreateFlag = 0;
        // }
        // if ($(this).find('.stoAccountStatementCheckFlag').is(':checked')) {
        //     field.stoAccountStatementCheckFlag = 1;
        // } else {
        //     field.stoAccountStatementCheckFlag = 0;
        // }
        // if ($(this).find('.stoAccountStatementManualCheckFlag').is(':checked')) {
        //     field.stoAccountStatementManualCheckFlag = 1;
        // } else {
        //     field.stoAccountStatementManualCheckFlag = 0;
        // }
        if ($(this).find('.invoicedApplyCreateFlag').is(':checked')) {
            field.invoicedApplyCreateFlag = 1;
        } else {
            field.invoicedApplyCreateFlag = 0;
        }
        if ($(this).find('.invoicedApplyCheckFlag').is(':checked')) {
            field.invoicedApplyCheckFlag = 1;
        } else {
            field.invoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.transferInvoicedApplyCheckFlag').is(':checked')) {
            field.transferInvoicedApplyCheckFlag = 1;
        } else {
            field.transferInvoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.acceptanceInvoicedApplyCheckFlag').is(':checked')) {
            field.acceptanceInvoicedApplyCheckFlag = 1;
        } else {
            field.acceptanceInvoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.overseasInvoicedApplyCreateFlag').is(':checked')) {
            field.overseasInvoicedApplyCreateFlag = 1;
        } else {
            field.overseasInvoicedApplyCreateFlag = 0;
        }
        if ($(this).find('.overseasInvoicedApplyCheckFlag').is(':checked')) {
            field.overseasInvoicedApplyCheckFlag = 1;
        } else {
            field.overseasInvoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.overseasTransferInvoicedApplyCheckFlag').is(':checked')) {
            field.overseasTransferInvoicedApplyCheckFlag = 1;
        } else {
            field.overseasTransferInvoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.paymentAdvanceApplyCreateFlag').is(':checked')) {
            field.paymentAdvanceApplyCreateFlag = 1;
        } else {
            field.paymentAdvanceApplyCreateFlag = 0;
        }
        if ($(this).find('.paymentAdvanceApplyCheckFlag').is(':checked')) {
            field.paymentAdvanceApplyCheckFlag = 1;
        } else {
            field.paymentAdvanceApplyCheckFlag = 0;
        }
        if ($(this).find('.paymentDeliveryAdvanceApplyCreateFlag').is(':checked')) {
            field.paymentDeliveryAdvanceApplyCreateFlag = 1;
        } else {
            field.paymentDeliveryAdvanceApplyCreateFlag = 0;
        }
        if ($(this).find('.paymentDeliveryAdvanceApplyCheckFlag').is(':checked')) {
            field.paymentDeliveryAdvanceApplyCheckFlag = 1;
        } else {
            field.paymentDeliveryAdvanceApplyCheckFlag = 0;
        }
        if ($(this).find('.overseasPaymentAdvanceApplyCreateFlag').is(':checked')) {
            field.overseasPaymentAdvanceApplyCreateFlag = 1;
        } else {
            field.overseasPaymentAdvanceApplyCreateFlag = 0;
        }
        if ($(this).find('.overseasPaymentAdvanceApplyCheckFlag').is(':checked')) {
            field.overseasPaymentAdvanceApplyCheckFlag = 1;
        } else {
            field.overseasPaymentAdvanceApplyCheckFlag = 0;
        }
        if ($(this).find('.costInvoicedApplyCheckFlag').is(':checked')) {
            field.costInvoicedApplyCheckFlag = 1;
        } else {
            field.costInvoicedApplyCheckFlag = 0;
        }
        if ($(this).find('.companyInvoicedApplyCheckFlag').is(':checked')) {
            field.companyInvoicedApplyCheckFlag = 1;
        } else {
            field.companyInvoicedApplyCheckFlag = 0;
        }
        //资产合同请款附件配置
        if ($(this).find('.contractPaymentNoModelOneFlag').is(':checked')) {
            field.contractPaymentNoModelOneFlag = 1;
        } else {
            field.contractPaymentNoModelOneFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelOneCheckFlag').is(':checked')) {
            field.contractPaymentNoModelOneCheckFlag = 1;
        } else {
            field.contractPaymentNoModelOneCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelTwoFlag').is(':checked')) {
            field.contractPaymentNoModelTwoFlag = 1;
        } else {
            field.contractPaymentNoModelTwoFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelTwoCheckFlag').is(':checked')) {
            field.contractPaymentNoModelTwoCheckFlag = 1;
        } else {
            field.contractPaymentNoModelTwoCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelThreeFlag').is(':checked')) {
            field.contractPaymentNoModelThreeFlag = 1;
        } else {
            field.contractPaymentNoModelThreeFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelThreeCheckFlag').is(':checked')) {
            field.contractPaymentNoModelThreeCheckFlag = 1;
        } else {
            field.contractPaymentNoModelThreeCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelFourFlag').is(':checked')) {
            field.contractPaymentNoModelFourFlag = 1;
        } else {
            field.contractPaymentNoModelFourFlag = 0;
        }
        if ($(this).find('.contractPaymentNoModelFourCheckFlag').is(':checked')) {
            field.contractPaymentNoModelFourCheckFlag = 1;
        } else {
            field.contractPaymentNoModelFourCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentModelOneFlag').is(':checked')) {
            field.contractPaymentModelOneFlag = 1;
        } else {
            field.contractPaymentModelOneFlag = 0;
        }
        if ($(this).find('.contractPaymentModelOneCheckFlag').is(':checked')) {
            field.contractPaymentModelOneCheckFlag = 1;
        } else {
            field.contractPaymentModelOneCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentModelTowFlag').is(':checked')) {
            field.contractPaymentModelTowFlag = 1;
        } else {
            field.contractPaymentModelTowFlag = 0;
        }
        if ($(this).find('.contractPaymentModelTwoCheckFlag').is(':checked')) {
            field.contractPaymentModelTwoCheckFlag = 1;
        } else {
            field.contractPaymentModelTwoCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentModelThreeFlag').is(':checked')) {
            field.contractPaymentModelThreeFlag = 1;
        } else {
            field.contractPaymentModelThreeFlag = 0;
        }
        if ($(this).find('.contractPaymentModelThreeCheckFlag').is(':checked')) {
            field.contractPaymentModelThreeCheckFlag = 1;
        } else {
            field.contractPaymentModelThreeCheckFlag = 0;
        }
        if ($(this).find('.contractPaymentModelFourFlag').is(':checked')) {
            field.contractPaymentModelFourFlag = 1;
        } else {
            field.contractPaymentModelFourFlag = 0;
        }
        if ($(this).find('.contractPaymentModelFourCheckFlag').is(':checked')) {
            field.contractPaymentModelFourCheckFlag = 1;
        } else {
            field.contractPaymentModelFourCheckFlag = 0;
        }

        fields.push(field);
    });

    var loading = top.layer.msg('处理中', {icon: 16, shade: [0.1, '#000'], time: false});
    $.ajax({
        url: g.ctx + 'pc/sys/attachmentTypeConfig/rest/saveOrUpdate',
        method: 'post',
        data: JSON.stringify(fields),
        contentType: 'application/json',
        success: function (data) {
            topWin.layer.msg('数据保存成功', {icon: 1});
        },
        complete: function(data) {
            top.layer.close(loading);
        },
        error: function (data) {
            layer.alert(JSON.parse(data.responseText).message);
        }
    });
});