wdyy.js 5.64 KB
layui.use('element', function () {
    let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
});
$(function () {
    _initData();
    $('#zjhm').text(getCookie().zjhm);
    $('#username').text(getCookie().username);

    $(document).on("click", ".business", function (e) {
        window.open("./businessGuideDeatil.html?ywid=" + $(this).attr('ywid') + "")
    })
})
// 获取列表信息
function _initData(currentPage = 1) {
    var appointment_list = $(".appointment_list");
    appointment_list.empty();
    var li;
    $.ajax({
        type: "post",  //提交方式  
        url: portal.api_url + "/portal/WorkBoxService/bookingBusinessReord",//路径  
        dataType: "json",
        data: {
            "userId": dataList.userid,
            "currentPage": currentPage,
            "pageSize": 10
        },
        //数据,这里使用的是Json格式进行传输  
        success: function (result) {//返回数据根据结果进行相应的处理           
            if (result.code == 200 && result.data != null) {
                let records = result.data.records
                for (var i = 0; i < records.length; i++) {
                    li = '<li>'
                    li += '<div class="item_content cardItem">'
                    if (records[i].state == '0') {
                        li += '<div class="item_title success">'
                        li += '<h3>预约成功</h3>'
                        li += '<a href="./yyjg.html?appointmentId=' + records[i].appointmentId + '">查看<i class="layui-icon layui-icon-right"></i></a>'
                        li += '</div>'
                    } else if (records[i].state == '1') {
                        li += '<div class="item_title success">'
                        li += '<h3>已赴约</h3>'
                        li += '</div>'
                    } else if (records[i].state == '2') {
                        li += '<div class="item_title overdue">'
                        li += '<h3>已逾期</h3>'
                        li += '</div>'
                    } else if (records[i].state == '3' || records[i].state == '4') {
                        li += '<div class="item_title cancel">'
                        li += '<h3>已取消预约</h3>'
                        li += '</div>'
                    }
                    li += '<ul class="item_info">'
                    li += '<li><span>预约人:</span><p>' + records[i].name + '</p></li>'
                    li += '<li><span>办事大厅:</span><p>' + records[i].organizationName + '</p></li>'
                    li += '<li><span>办理业务类型:</span><p>' + records[i].businessName + '</p><a class="business" ywid="' + records[i].ywid + '">办事指南</a></li>'
                    li += '<li><span>预约日期:</span><p>' + records[i].reserveTime + '</p></li>'
                    li += '<li><span>预约流水号:</span><p>' + records[i].reservationNumber + '</p></li>'
                    li += '</ul>'
                    if (records[i].state == '0') {
                        li += '<a periodRulesId="' + records[i].periodRulesId + '" jgid="' + records[i].jgid + '" appointmentId="' + records[i].appointmentId + '" class="cancel_reservation">取消预约</a>'
                    }
                    li += '</div>'
                    li += '</li>'
                    appointment_list.append(li);
                }
            }

            paged(result.data.total, result.data.current);
        }
    });
}

// 用户取消预约
$(document).on("click", ".cancel_reservation", function (e) {
    let that = this;
    layui.use('layer', function () {
        layer.confirm('此操作将取消预约', {
            btn: ['是', '否'] //按钮
        }, function () {
            _cancleAppointment($(that).attr('appointmentId'), $(that).attr('jgid'), $(that).attr('periodRulesId'), getCookie('myCookie').userid)
        }, function () {
            layer.msg('已取消');
        });
    })
})

function _cancleAppointment(appointmentId, jgid, periodRulesId, userid) {
    $.ajax({
        type: "post",  //提交方式  
        url: portal.api_url + "/portal/appointmentmh/cancleAppointment",//路径  
        dataType: "json",
        headers: {
            'Content-Type': 'application/json;charset=UTF-8',
        },
        data: JSON.stringify({
            'appointmentId': appointmentId,
            'jgid': jgid,
            'periodRulesId': periodRulesId,
            'userid': userid
        }),
        //数据,这里使用的是Json格式进行传输  
        success: function (result) {//返回数据根据结果进行相应的处理           
            if (result.code == 200) {
                layui.use('layer', function () {
                    var layer = layui.layer;
                    layer.msg('取消预约成功');
                })
                _initData();
            }
        }
    });
}

// 分页
function paged(pageCount, curr) {
    layui.use('laypage', function () {
        let laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
            , count: pageCount //数据总数,从服务端得到
            , curr: curr
            , prev: '<'
            , next: '>'
            , theme: '#0091FF'
            , jump: function (obj, first) {
                if (!first) {
                    _initData(obj.curr);
                }
            }
        });
    })
    if (pageCount == 0) {
        $('#page').hide();
        $('.noData').show();
    } else {
        $('#page').show();
        $('.noData').hide();
    }
}

var dataList = {
    "userid": getCookie().userid
};