提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['layer', 'form', 'table', 'admin', 'ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var layer = layui.layer; |
|
4 |
var form = layui.form; |
|
5 |
var table = layui.table; |
|
6 |
var $ax = layui.ax; |
|
7 |
var admin = layui.admin; |
|
8 |
var func = layui.func; |
|
9 |
|
|
10 |
/** |
|
11 |
* 系统管理--消息管理 |
|
12 |
*/ |
|
13 |
var Notice = { |
|
14 |
tableId: "noticeTable" //表格id |
|
15 |
}; |
|
16 |
|
|
17 |
/** |
|
18 |
* 初始化表格的列 |
|
19 |
*/ |
|
20 |
Notice.initColumn = function () { |
|
21 |
return [[ |
|
22 |
{type: 'checkbox'}, |
|
23 |
{field: 'noticeId', align: "center", hide: true, sort: true, title: 'id'}, |
|
24 |
{field: 'title', align: "center", sort: true, title: '标题'}, |
|
25 |
{field: 'content', align: "center", sort: true, title: '内容'}, |
|
26 |
{field: 'createrName', align: "center", sort: true, title: '发布者'}, |
|
27 |
{field: 'createTime', align: "center", sort: true, title: '创建时间'}, |
|
28 |
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 200} |
|
29 |
]]; |
|
30 |
}; |
|
31 |
|
|
32 |
/** |
|
33 |
* 点击查询按钮 |
|
34 |
*/ |
|
35 |
Notice.search = function () { |
|
36 |
var queryData = {}; |
|
37 |
queryData['condition'] = $("#condition").val(); |
|
38 |
table.reload(Notice.tableId, { |
|
39 |
where: queryData, page: {curr: 1} |
|
40 |
}); |
|
41 |
}; |
|
42 |
|
|
43 |
/** |
|
44 |
* 弹出添加通知 |
|
45 |
*/ |
|
46 |
Notice.openAddNotice = function () { |
|
47 |
window.location.href = Feng.ctxPath + '/notice/notice_add'; |
|
48 |
}; |
|
49 |
|
|
50 |
/** |
|
51 |
* 点击编辑通知 |
|
52 |
* |
|
53 |
* @param data 点击按钮时候的行数据 |
|
54 |
*/ |
|
55 |
Notice.onEditNotice = function (data) { |
|
56 |
window.location.href = Feng.ctxPath + "/notice/notice_update?noticeId=" + data.noticeId; |
|
57 |
}; |
|
58 |
|
|
59 |
/** |
|
60 |
* 点击删除通知 |
|
61 |
* |
|
62 |
* @param data 点击按钮时候的行数据 |
|
63 |
*/ |
|
64 |
Notice.onDeleteNotice = function (data) { |
|
65 |
var operation = function () { |
|
66 |
var ajax = new $ax(Feng.ctxPath + "/notice/delete", function (data) { |
|
67 |
Feng.success("删除成功!"); |
|
68 |
table.reload(Notice.tableId); |
|
69 |
}, function (data) { |
|
70 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
71 |
}); |
|
72 |
ajax.set("noticeId", data.noticeId); |
|
73 |
ajax.start(); |
|
74 |
}; |
|
75 |
Feng.confirm("是否删除通知 " + data.title + "?", operation); |
|
76 |
}; |
|
77 |
|
|
78 |
// 渲染表格 |
|
79 |
var tableResult = table.render({ |
|
80 |
elem: '#' + Notice.tableId, |
|
81 |
url: Feng.ctxPath + '/notice/list', |
|
82 |
page: true, |
|
83 |
height: "full-98", |
|
84 |
cellMinWidth: 100, |
|
85 |
cols: Notice.initColumn() |
|
86 |
}); |
|
87 |
|
|
88 |
// 搜索按钮点击事件 |
|
89 |
$('#btnSearch').click(function () { |
|
90 |
Notice.search(); |
|
91 |
}); |
|
92 |
|
|
93 |
// 添加按钮点击事件 |
|
94 |
$('#btnAdd').click(function () { |
|
95 |
Notice.openAddNotice(); |
|
96 |
}); |
|
97 |
|
|
98 |
// 工具条点击事件 |
|
99 |
table.on('tool(' + Notice.tableId + ')', function (obj) { |
|
100 |
var data = obj.data; |
|
101 |
var layEvent = obj.event; |
|
102 |
|
|
103 |
if (layEvent === 'edit') { |
|
104 |
Notice.onEditNotice(data); |
|
105 |
} else if (layEvent === 'delete') { |
|
106 |
Notice.onDeleteNotice(data); |
|
107 |
} |
|
108 |
}); |
|
109 |
}); |