wdyy.js
6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
layui.use('element', function () {
let element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
});
$(function () {
compileData();
_initData();
$('#zjhm').text(getItem('myCookie').zjhm);
$('#username').text(getItem('myCookie').username);
$(document).on("click", ".business", function (e) {
window.open("./businessGuideDeatil.html?ywid=" + $(this).attr('ywid') + "")
})
})
function compileData() {
$('.layui-breadcrumb a').eq(1).attr('href',GetQueryString('href'));
$('.layui-breadcrumb a').eq(1).attr('title', decodeURI(GetQueryString('title')));
$('.layui-breadcrumb a').eq(1).text(decodeURI(GetQueryString('title')));
$('.online-booking').click(function(){
window.open("./yyxz.html?title="+decodeURI(GetQueryString('title')) + "&href="+GetQueryString('href'), "_self")
})
}
// 获取列表信息
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'), getItem('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": getItem('myCookie').userid
};