selfNotify.js
5.66 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
var prefix = "/oa/notify"
$(function() {
load();
});
function load() {
$('#exampleTable')
.bootstrapTable(
{
method : 'get', // 服务器数据的请求方式 get or post
url : prefix + "/selfList", // 服务器数据的加载地址
// showRefresh : true,
// showToggle : true,
// showColumns : true,
iconSize : 'outline',
toolbar : '#exampleToolbar',
striped : true, // 设置为true会有隔行变色效果
dataType : "json", // 服务器返回的数据类型
pagination : true, // 设置为true会在底部显示分页条
// queryParamsType : "limit",
// //设置为limit则会发送符合RESTFull格式的参数
singleSelect : false, // 设置为true将禁止多选
// contentType : "application/x-www-form-urlencoded",
// //发送到服务器的数据编码类型
pageSize : 10, // 如果设置了分页,每页数据条数
pageNumber : 1, // 如果设置了分布,首页页码
//search : true, // 是否显示搜索框
showColumns : false, // 是否显示内容下拉框(选择显示的列)
sidePagination : "server", // 设置在哪里进行分页,可选值为"client" 或者 "server"
queryParams : function(params) {
return {
//说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对
limit : params.limit,
offset : params.offset
// name:$('#searchName').val(),
// username:$('#searchName').val()
};
},
// //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果
// queryParamsType = 'limit' ,返回参数必须包含
// limit, offset, search, sort, order 否则, 需要包含:
// pageSize, pageNumber, searchText, sortName,
// sortOrder.
// 返回false将会终止请求
columns : [
{
checkbox : true
},
{
visible : false,
field : 'id',
title : '编号'
},
{
visible :false,
field : 'type',
title : '类型'
},
{
field : 'title',
width: '20%',
title : '标题',
formatter:function (value,row,index) {
return '<a href="#" onclick="read(\''+ row.id+ '\')">'+row.title+'</a>';
}
},
{
field : 'content',
width: '30%',
title : '内容'
},
{
visible : false,
field : 'files',
title : '附件'
},
{
field : 'isRead',
title : '状态',
align :'center',
formatter : function(value, row, index){
if(value==0){
return '<span class="label label-warning">未读</span>';
}else if(value==1){
return '<span class="label label-primary">已读</span>';
}
}
},
{
visible : false,
field : 'createBy',
title : '创建者'
},
{
visible : false,
field : 'createDate',
title : '创建时间'
},
{
visible : false,
field : 'updateBy',
title : '更新者'
},
{
visible : false,
field : 'updateDate',
title : '更新时间'
},
{
field : 'remarks',
title : '备注信息'
},
{
visible : false,
field : 'delFlag',
title : '删除标记'
},
{
title : '操作',
field : 'opera',
align : 'center',
formatter : function(value, row, index) {
var e = '<a class="btn btn-primary btn-sm" href="#" mce_href="#" title="打开" onclick="read(\''
+ row.id
+ '\')"><i class="fa fa-book"></i></a> ';
var d = '<a class="btn btn-warning btn-sm ' + s_remove_h + '" href="#" title="删除" mce_href="#" onclick="remove(\''
+ row.id
+ '\')"><i class="fa fa-remove"></i></a> ';
var f = '<a class="btn btn-success btn-sm" href="#" title="备用" mce_href="#" onclick="resetPwd(\''
+ row.id
+ '\')"><i class="fa fa-key"></i></a> ';
return e ;
}
} ]
});
}
function reLoad() {
$('#exampleTable').bootstrapTable('refresh');
}
function add() {
layer.open({
type : 2,
title : '增加',
maxmin : true,
shadeClose : false, // 点击遮罩关闭层
area : [ '800px', '520px' ],
content : prefix + '/add' // iframe的url
});
}
function read(id) {
layer.open({
type : 2,
title : '查看',
maxmin : true,
shadeClose : false, // 点击遮罩关闭层
area : [ '800px', '520px' ],
content : prefix + '/read/' + id // iframe的url
});
}
function remove(id) {
layer.confirm('确定要删除选中的记录?', {
btn : [ '确定', '取消' ]
}, function() {
$.ajax({
url : prefix + "/remove",
type : "post",
data : {
'id' : id
},
success : function(r) {
if (r.code == 0) {
layer.msg(r.msg);
reLoad();
} else {
layer.msg(r.msg);
}
}
});
})
}
function resetPwd(id) {
}
function batchRemove() {
var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行,当没有选择的记录时,返回一个空数组
if (rows.length == 0) {
layer.msg("请选择要删除的数据");
return;
}
layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
btn : [ '确定', '取消' ]
// 按钮
}, function() {
var ids = new Array();
// 遍历所有选择的行数据,取每条数据对应的ID
$.each(rows, function(i, row) {
ids[i] = row['id'];
});
$.ajax({
type : 'POST',
data : {
"ids" : ids
},
url : prefix + '/batchRemove',
success : function(r) {
if (r.code == 0) {
layer.msg(r.msg);
reLoad();
} else {
layer.msg(r.msg);
}
}
});
}, function() {});
}