
$("input[name='effectTime']").datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    autoclose: true
}).on('changeDate',changeDate);

function changeDate(data){
    var beginDate=data.date;
    var invalidTime=$("input[name='invalidTime").val();
    if(invalidTime !=""){
        var endDate = new Date(invalidTime.replace(/\-/g, "\/"));
        if(beginDate>endDate){
            $("input[name='invalidTime']").val("");
        }
    }

    $("input[name='invalidTime']").datetimepicker('setStartDate',data.date);
}

$("input[name='invalidTime']").datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    // startDate:new Date(),
    autoclose: true
});

$("input[name='signTime']").datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    autoclose: true
});

$(".file-upload").each(function (i) {
    var val = $("input[name='" + this.id + "']").val();
    if(val ==""){
        $(this).fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        });
    }else{
        $(this).fileinput({
            'uploadUrl': ctx + 'common/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    }
});