var request = getRequest(),
    patient = request.patient,
    startDate = '',
    endDate = '';

$(function(){
    getList();
});

function getList(isRefresh){
    var options = $.extend(jwPrescriptionAPI.getListTableAjaxObj, {
        queryParams: queryParams,
        queryParamsType: "limit",
        pagination: true,
        paginationLoop: true,
        sidePagination: 'server',
        pageNumber: 1,
        pageSize: 10,
        responseHandler: function (res) {
            // var data = JSON.parse(res.data);
            return {
                rows: res.data.list,
                total: res.data.total
            }
        },
        columns: [{
            field: '',
            title:'',
            formatter: function(val, row, index){
                var html = template('info_tmp', row);
                return html;
            }
        },{
            field: 'createTime',
            title: '申请时间',
            class: 'c-999 pr20',
            align: 'right',
            formatter: function(val, row, index){
                return '<span class="pr10">'+val+'</span>';
            }
        }],
        onClickRow: function(row, $el){
            document.location.href = "jw-prescription-info.html?code="+row.code+"&patient="+patient;
        }
    })
    $("#prescriptTable").bootstrapTable(options);
}

function queryParams(params) {
    return {
        page: params.offset/params.limit,
        size: params.limit,
        patient: patient,
    };
}

template.helper('getTypeName', function(type){
    if(type == 1){
        return "门诊";
    }else if(type == 2){
        return "住院";
    }else if(type == 3){
        return "体检";
    }
    return '';
});



