usersNoticeList.html
9.61 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('卖家中心/公告管理', ''));
</script>
<style>
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<a id="addNotice" class="easyui-linkbutton btn-success">添加一条</a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="noticeListTable"></table>
</div>
</div>
<script type="text/javascript">
var userNoticeId;
$(function () {
$('#addNotice').linkbutton({
iconCls: "icon-edit",
onClick: function () {
editRow(0);
}
});
$("#noticeListTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/usersNotice/getNoticeList",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "ID",
field: "id",
width: 20,
align: "center"
}, {
title: "公告名称",
field: "name",
width: 300,
align: "center"
}, {
title: "是否开启滚动通知",
field: "showFront",
width: 40,
align: "center",
formatter: function (value) {
if (value == 1) {
return "开启";
} else if(value == 0){
return "关闭";
}
}
},{
title: "排序",
field: "orderBy",
width: 40,
align: "center"
},{
title: "创建时间",
field: "createTimeStr",
width: 80,
align: "center"
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData) {
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>编辑</a>";
str += "<a role='del' dataId='" + rowData.id + "' style='margin-left:10px;background-color: red'>删除</a>";
return str;
}
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10,30,50],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
// 编辑
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).attr("dataId");
editRow(id);
}
});
// 删除
$(this).myDatagrid("getPanel").find("a[role='del']").linkbutton({
iconCls: "icon-more",
onClick: function () {
del($(this).attr("dataId"));
}
});
}
});
function editRow(id) {
userNoticeId = id;
var div = $("<div>").appendTo($(document.body));
var title = "编辑";
var message = "确认修改吗?";
if (id == 0) {
title = "添加";
message = "确认添加吗?";
}
$(div).myDialog({
width: "680px",
height: "450px",
title: title,
href: contextPath + "/html/usersNotice/editUsersNotice.html?time_version=" + new Date().getTime(),
queryParams: {
id: id
},
modal: true,
collapsible: true,
cache: false,
buttons: [{
id: "saveBtn",
text: "保存",
handler: function () {
$.messager.confirm("确认", message, function (flag) {
if (flag) {
var name = $('#usersNoticeEditForm #name').val();
if (name == '' || name == null || name == undefined) {
$.messager.alert("提示", '公告名称不能为空!', "error");
return false;
}
var url = $('#usersNoticeEditForm #url').val();
if (url == '' || url == null || url == undefined) {
$.messager.alert("提示", '跳转页面不能为空!', "error");
return false;
}
var orderBy = $('#usersNoticeEditForm #orderBy').val();
if (orderBy == '' || orderBy == null || orderBy == undefined) {
$.messager.alert("提示", '排序不能为空!', "error");
return false;
}
var showFront = $('input[name="showFront"]:checked').val();
if (showFront == '' || showFront == null || showFront == undefined) {
$.messager.alert("提示", '请选择是否开启滚动通知!', "error");
return false;
}
var url = contextPath + "/usersNotice/saveOrUpdateNotice";
$("#usersNoticeEditForm").form("submit", {
url: url,
onSubmit: function () {
if (!$("#usersNoticeEditForm").form("validate")) {
return false;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后..."
});
return true;
},
success: function (data) {
$.messager.progress("close");
data = JSON.parse(data);
if (data.code == 200) {
$(div).dialog("close");
$("#noticeListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: title + "成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
});
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}]
});
}
function del(id) {
var message = "确定要删除吗?";
var msg = "删除成功";
$.messager.confirm("确认", message, function (flag) {
if (flag) {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
$.post(contextPath + "/usersNotice/delNoticeById", {
"id": id
}, function (data) {
$.messager.progress("close");
if (data.code == 200) {
$("#noticeListTable").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: msg,
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}, "json");
}
});
}
});
</script>
</body>
</html>