提交 | 用户 | 时间
|
b26949
|
1 |
layui.use(['table', 'admin', 'ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var admin = layui.admin; |
|
6 |
var func = layui.func; |
|
7 |
|
|
8 |
/** |
|
9 |
* 油脂管理管理 |
|
10 |
*/ |
|
11 |
var GreaseManage = { |
|
12 |
tableId: "greaseManageTable" |
|
13 |
}; |
|
14 |
|
|
15 |
/** |
|
16 |
* 初始化表格的列 |
|
17 |
*/ |
|
18 |
GreaseManage.initColumn = function () { |
|
19 |
return [[ |
|
20 |
{type: 'checkbox'}, |
|
21 |
{field: 'id', hide: true, title: '主键id'}, |
|
22 |
{field: 'barcode', sort: true, title: '扫码条码'}, |
|
23 |
{field: 'locationCode', sort: true, title: '工位'}, |
|
24 |
{field: 'duaDate', sort: true, title: '到期时间'}, |
|
25 |
{field: 'state', sort: true, title: '状态'}, |
|
26 |
{field: 'createUser', sort: true, title: '更新用户'}, |
|
27 |
{field: 'createTime', sort: true, title: '更新时间'}, |
|
28 |
{field: 'remarks', sort: true, title: '备注'}, |
|
29 |
{field: 'spareField1', sort: true, title: '预留字段1'}, |
|
30 |
{field: 'spareField2', sort: true, title: '预留字段2'}, |
|
31 |
{align: 'center', toolbar: '#tableBar', title: '操作'} |
|
32 |
]]; |
|
33 |
}; |
|
34 |
|
|
35 |
/** |
|
36 |
* 点击查询按钮 |
|
37 |
*/ |
|
38 |
GreaseManage.search = function () { |
|
39 |
var queryData = {}; |
|
40 |
|
|
41 |
|
|
42 |
table.reload(GreaseManage.tableId, { |
|
43 |
where: queryData, page: {curr: 1} |
|
44 |
}); |
|
45 |
}; |
|
46 |
|
|
47 |
/** |
|
48 |
* 跳转到添加页面 |
|
49 |
*/ |
|
50 |
GreaseManage.jumpAddPage = function () { |
|
51 |
window.location.href = Feng.ctxPath + '/greaseManage/add' |
|
52 |
}; |
|
53 |
|
|
54 |
/** |
|
55 |
* 跳转到编辑页面 |
|
56 |
* |
|
57 |
* @param data 点击按钮时候的行数据 |
|
58 |
*/ |
|
59 |
GreaseManage.jumpEditPage = function (data) { |
|
60 |
window.location.href = Feng.ctxPath + '/greaseManage/edit?id=' + data.id |
|
61 |
}; |
|
62 |
|
|
63 |
/** |
|
64 |
* 导出excel按钮 |
|
65 |
*/ |
|
66 |
GreaseManage.exportExcel = function () { |
|
67 |
var checkRows = table.checkStatus(GreaseManage.tableId); |
|
68 |
if (checkRows.data.length === 0) { |
|
69 |
Feng.error("请选择要导出的数据"); |
|
70 |
} else { |
|
71 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
72 |
} |
|
73 |
}; |
|
74 |
|
|
75 |
/** |
|
76 |
* 点击删除 |
|
77 |
* |
|
78 |
* @param data 点击按钮时候的行数据 |
|
79 |
*/ |
|
80 |
GreaseManage.onDeleteItem = function (data) { |
|
81 |
var operation = function () { |
|
82 |
var ajax = new $ax(Feng.ctxPath + "/greaseManage/delete", function (data) { |
|
83 |
Feng.success("删除成功!"); |
|
84 |
table.reload(GreaseManage.tableId); |
|
85 |
}, function (data) { |
|
86 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
87 |
}); |
|
88 |
ajax.set("id", data.id); |
|
89 |
ajax.start(); |
|
90 |
}; |
|
91 |
Feng.confirm("是否删除?", operation); |
|
92 |
}; |
|
93 |
|
|
94 |
// 渲染表格 |
|
95 |
var tableResult = table.render({ |
|
96 |
elem: '#' + GreaseManage.tableId, |
|
97 |
url: Feng.ctxPath + '/greaseManage/list', |
|
98 |
page: true, |
|
99 |
height: "full-158", |
|
100 |
cellMinWidth: 100, |
|
101 |
cols: GreaseManage.initColumn() |
|
102 |
}); |
|
103 |
|
|
104 |
// 搜索按钮点击事件 |
|
105 |
$('#btnSearch').click(function () { |
|
106 |
GreaseManage.search(); |
|
107 |
}); |
|
108 |
|
|
109 |
// 添加按钮点击事件 |
|
110 |
$('#btnAdd').click(function () { |
|
111 |
|
|
112 |
GreaseManage.jumpAddPage(); |
|
113 |
|
|
114 |
}); |
|
115 |
|
|
116 |
// 导出excel |
|
117 |
$('#btnExp').click(function () { |
|
118 |
GreaseManage.exportExcel(); |
|
119 |
}); |
|
120 |
|
|
121 |
// 工具条点击事件 |
|
122 |
table.on('tool(' + GreaseManage.tableId + ')', function (obj) { |
|
123 |
var data = obj.data; |
|
124 |
var layEvent = obj.event; |
|
125 |
|
|
126 |
if (layEvent === 'edit') { |
|
127 |
GreaseManage.jumpEditPage(data); |
|
128 |
} else if (layEvent === 'delete') { |
|
129 |
GreaseManage.onDeleteItem(data); |
|
130 |
} |
|
131 |
}); |
|
132 |
}); |