Browse Source

优化表格请求接口的配置,将url等信息配置到api文件中

raolu 7 years ago
parent
commit
b411133e85
3 changed files with 48 additions and 167 deletions
  1. 4 142
      js/buz/order-list-jg.js
  2. 5 25
      js/buz/order-list.js
  3. 39 0
      js/order-api.js

+ 4 - 142
js/buz/order-list-jg.js

@ -32,7 +32,7 @@ function getPrescriptionList( refresh){
        startDate: startDate,
        endDate: endDate,
        state: state,
        // dispensaryType: 3,
        dispensaryType: 3,
        hospital: hospital,
        nameKey: nameKey
    };
@ -43,25 +43,14 @@ function getPrescriptionList( refresh){
            if(refresh){
                $("#prescriptTable").bootstrapTable('refresh');
            }
            $("#prescriptTable").bootstrapTable({
                method: 'get',
                url: APIService.server + 'doctor/prescriptionInfo/getHDoctorPrescriptionExpressage', 
            var options = $.extend(orderAPI.getHOrderListTableAjaxObj, {
                queryParams: queryParams,
                contentType: "application/json",
                queryParamsType: "limit",
                dataType: "json",
                pagination: true,
                paginationLoop: true,
                sidePagination: 'server',
                pageNumber: 1,
                pageSize: 10,
                ajaxOptions: {
                    beforeSend: function(request) {
                        var userAgent = {"id":4821,"uid":"zbqD201703150228","imei":"864394010176834","token":"ee3fcb6091b46aa0a119c1504b8306d8","platform":2,"hospital":"3502050100"};
                        userAgent = JSON.stringify(userAgent);
                        request.setRequestHeader("userAgent", userAgent);
                    }
                },
                responseHandler: function (res) {
                    var data = _.map(res.data, function(o){
                        var result = "";
@ -85,7 +74,8 @@ function getPrescriptionList( refresh){
                        total: totalOrderCount
                    }
                }
            });
            })
            $("#prescriptTable").bootstrapTable(options);
        }
    });
    
@ -136,34 +126,12 @@ function bindEvents(){
        state = $this.val();
        getPrescriptionList(true);
    });
    $("#express").on('change', function(){
        dispensaryType = $(this).val();
        if(dispensaryType == 3){ //健管师配送时,显示复选框
            $("#checkboxBox").removeClass("hidden");
        }else{
            $("#checkboxBox").addClass("hidden");
            $("#allocationType").prop("checked", false);
            allocationType = 0;
        }
        getPrescriptionList(true);
    });
    
    $("#address").on('change', function(){
        hospital = $(this).val();
        getPrescriptionList(true);
    });
    $("#allocationType").on('change', function(){
        var $this = $(this);
        if($this.prop('checked')){
            allocationType = 1;
        }else{
            allocationType = 0;
        }
        getPrescriptionList(true);
    });
    $("#searchBtn").on('click', function(){
        var $input = $("#searchName"),
            text = $.trim($input.val());
@ -171,112 +139,6 @@ function bindEvents(){
        getPrescriptionList(true);
    });
    $("#selectAll").on('click', function(){
        var $this = $(this),
            $checkbox = $("input[name=orderItem]"),
            length = $checkbox.length;
        if($this.prop("checked")){
            $checkbox.prop("checked", true);
            selectItemNum = length;
            $("#selectedCount").text(selectItemNum);
        }else{
            $checkbox.prop("checked", false);
            selectItemNum = 0;
            $("#selectedCount").text(0);
        }
        checkArrangeDisable('all');
    });
    $("body").on('click', "input[name=orderItem]", function(){
        var $this = $(this),
            status = $this.data('status'),
            type = $this.data('type'),
            expressage = $this.data('expressage'),
            code = $this.data('code');
        if($this.prop("checked")){
            selectItemNum ++;
            if((type == 3) && (status >= 50) && (expressage=='' || !expressage)){
                selectItem.push(code);
            }
        }else{
            selectItemNum --;
            if(selectItem.indexOf(code) > -1){
                var index = selectItem.indexOf(code);
                selectItem.splice(index,1);
            }
        }
        $("#selectedCount").text(selectItemNum);
        checkArrangeDisable();
    });
    $("#arrange").on('click', function(){
        if($(this).hasClass("disabled")){
            return false;
        }
        $('#myModal').modal('toggle');
        getHealthDoctorList();
    });
    $("#doctorName").on('keyup', function(e){
        if (e.which === 13) {
            getHealthDoctorList(true);
        }
    });
    $("#confirmBtn").on('click', function(){
        //发送请求确认的请求
        var params = {
            codes: selectItem.join(","),
            healthDoctor: selectDoctor
        }
        orderAPI.distributeHealthDoctor({data: params}).then(function(res){
            if(res.status == 200){
                $('#myModal').modal('toggle');
                $('#confirmModal').modal('toggle');
                $("#prescriptTable").bootstrapTable('refresh');
            }else{
            }
        })
    });
}
//判断选中的订单是否是可分配的的订单
function checkArrangeDisable(clickType){ //type=all 为点击全选时处理
    //可以分配的条件,1是健管师配送订单,2状态为待分配
    var $checkbox = $("input[name=orderItem]:checked"),
        len = $checkbox.length;
    isArrange = false;
    if(clickType == 'all'){
        selectItem = [];
    }
    for(var i=0; i<len; i++){
        var $item = $($checkbox[i]),
            status = $item.data('status'),
            type = $item.data('type'),
            expressage = $item.data('expressage'),
            code = $item.data('code');
        if(type != 3){
            isArrange = false;
            break;
        }else{
            if((status >= 50) && (expressage=='' || !expressage)){ //支付成功后状态+配送员的名字为空为待分配状态
                isArrange = true;
                if(clickType == 'all'){
                    selectItem.push(code);
                }
            }else{
                isArrange = false;
                break;
            }
        }
    }
    if(!isArrange){
        $("#arrange").addClass("disabled");
    }else{
        $("#arrange").removeClass("disabled");
    }
}
//根据选择的tab获得开始和结束时间

+ 5 - 25
js/buz/order-list.js

@ -56,25 +56,14 @@ function getPrescriptionList( refresh){
            if(refresh){
                $("#prescriptTable").bootstrapTable('refresh');
            }
            $("#prescriptTable").bootstrapTable({
                method: 'get',
                url: APIService.server + 'doctor/prescriptionInfo/getDoctorPrescriptionExpressage', 
            var options = $.extend(orderAPI.getOrderListTableAjaxObj, {
                queryParams: queryParams,
                contentType: "application/json",
                queryParamsType: "limit",
                dataType: "json",
                pagination: true,
                paginationLoop: true,
                sidePagination: 'server',
                pageNumber: 1,
                pageSize: 10,
                ajaxOptions: {
                    beforeSend: function(request) {
                        var userAgent = {"id":4800,"uid":"zbqD201703150222","imei":"864394010176834","token":"71738e0adf3fa6dfe72eb71dc9c07ce2","platform":2,"hospital":"3502050100"};
                        userAgent = JSON.stringify(userAgent);
                        request.setRequestHeader("userAgent", userAgent);
                    }
                },
                responseHandler: function (res) {
                    var data = _.map(res.data, function(o){
                        var result = "";
@ -106,7 +95,8 @@ function getPrescriptionList( refresh){
                        total: totalOrderCount
                    }
                }
            });
            })
            $("#prescriptTable").bootstrapTable(options);
        }
    });
    
@ -140,26 +130,15 @@ function getHealthDoctorList(isRefresh){
    if(isRefresh){
        $("#hDoctor").bootstrapTable('refresh');
    }
    $("#hDoctor").bootstrapTable({
        method: 'get',
        url: APIService.server + 'doctor/prescriptionInfo/getHDoctorInDoctorHosiptal', 
    var options = $.extend(orderAPI.getHealthDoctorTableAjaxObj, {
        queryParams: queryParams2,
        contentType: "application/json",
        queryParamsType: "limit",
        dataType: "json",
        pagination: true,
        paginationLoop: true,
        sidePagination: 'server',
        pageNumber: 1,
        pageSize: 8,
        pageList: [5,8,10],
        ajaxOptions: {
            beforeSend: function(request) {
                var userAgent = {"id":4800,"uid":"zbqD201703150222","imei":"864394010176834","token":"71738e0adf3fa6dfe72eb71dc9c07ce2","platform":2,"hospital":"3502050100"};
                userAgent = JSON.stringify(userAgent);
                request.setRequestHeader("userAgent", userAgent);
            }
        },
        responseHandler: function (res) {
            return {
                rows: res.data.doctors,
@ -193,6 +172,7 @@ function getHealthDoctorList(isRefresh){
            selectDoctor = row.code;
        }
    });
    $("#hDoctor").bootstrapTable(options);
}
function queryParams2(params) {

+ 39 - 0
js/order-api.js

@ -3,6 +3,19 @@
        getOrderList: function(data){
            return APIService.httpGet('doctor/prescriptionInfo/getDoctorPrescriptionExpressage', data);
        },
        getOrderListTableAjaxObj: { //表格数据获取时,使用的ajax请求配置
            method: 'get',
            url: APIService.server + 'doctor/prescriptionInfo/getDoctorPrescriptionExpressage', 
            contentType: "application/json",
            dataType: "json",
            ajaxOptions: {
                beforeSend: function(request) {
                    var userAgent = APIService.userAgent;
                    userAgent = JSON.stringify(userAgent);
                    request.setRequestHeader("userAgent", userAgent);
                }
            }
        },
        getFilterInfo: function(){
            return APIService.httpGet('doctor/prescriptionInfo/getPrescriptionExpressageAsdoctorFilter');
        },
@ -15,6 +28,19 @@
        getHealthDoctor: function(data){
            return APIService.httpGet('doctor/prescriptionInfo/getHDoctorInDoctorHosiptal', data);
        },
        getHealthDoctorTableAjaxObj: { //表格数据获取时,使用的ajax请求配置
            method: 'get',
            url: APIService.server + 'doctor/prescriptionInfo/getHDoctorInDoctorHosiptal', 
            contentType: "application/json",
            dataType: "json",
            ajaxOptions: {
                beforeSend: function(request) {
                    var userAgent = APIService.userAgent;
                    userAgent = JSON.stringify(userAgent);
                    request.setRequestHeader("userAgent", userAgent);
                }
            }
        },
        distributeHealthDoctor: function(data){
            return APIService.httpPost('doctor/prescriptionInfo/distributionHealthDoctor', data);
        },
@ -22,6 +48,19 @@
        getHOrderList: function(data){
            return APIService.httpGet('doctor/prescriptionInfo/getHDoctorPrescriptionExpressage', data);
        },
        getHOrderListTableAjaxObj: { //表格数据获取时,使用的ajax请求配置
            method: 'get',
            url: APIService.server + 'doctor/prescriptionInfo/getHDoctorPrescriptionExpressage', 
            contentType: "application/json",
            dataType: "json",
            ajaxOptions: {
                beforeSend: function(request) {
                    var userAgent = APIService.userAgent;
                    userAgent = JSON.stringify(userAgent);
                    request.setRequestHeader("userAgent", userAgent);
                }
            }
        },
        getHFilterInfo: function(){
            return APIService.httpGet('doctor/prescriptionInfo/getPrescriptionExpressageFilter');
        },