函数封装多个不同按钮的点击事件

 1     function btnGroup_fn1(taskId, proInstanceId, textContent, requestUrl) {
 2         layer.confirm('确定' + textContent + '任务吗?', function (index) {
 3             $.ajax({
 4                 url: requestUrl,
 5                 data: {
 6                     taskId: taskId,
 7                     processId: proInstanceId
 8                 },
 9                 type: 'POST',
10                 dataType: 'json',
11                 success: function (data) {
12                     if (data != null) {
13                         var divHtml = "<div><p>" + textContent + "</p>" +
14                             "<p>" + data.msg + '心跳异常' + "</p>" +
15                             "</div>"
16                         layer.msg(divHtml, {time: 3000})
17                         freshCurrentTable(freshCurrentTableUrl)
18                     }
19                 },
20                 error: function () {
21                 }
22             });
23             layer.closeAll();
24         });
25     }

使用:

1   // 开始
2                     $('#start_btn').off().on('click', function (e) {
3                         layui.stope(e)
4                         var taskId = this.getAttribute('data-taskid');
5                         var proInstanceId = this.getAttribute('data-proId');
6                         var textContent = '开始';
7                         var requestUrl = '/proMg/continue.afca';
8                         btnGroup_fn(taskId, proInstanceId, textContent, requestUrl);
9                     });

猜你喜欢

转载自www.cnblogs.com/yangguoe/p/9267490.html