提交 | 用户 | 时间
|
71e81e
|
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 CustomInfo = { |
|
12 |
tableId: "customInfoTable" |
|
13 |
}; |
|
14 |
|
|
15 |
/** |
|
16 |
* 初始化表格的列 |
|
17 |
*/ |
|
18 |
CustomInfo.initColumn = function () { |
|
19 |
return [[ |
|
20 |
{type: 'checkbox'}, |
|
21 |
{field: 'id', hide: true, title: 'id'}, |
|
22 |
{field: 'customerCode', sort: true, title: '客户编号'}, |
|
23 |
{field: 'customerName', sort: true, title: '客户名称'}, |
|
24 |
{field: 'customerType', sort: true, title: '客户类型'}, |
|
25 |
{field: 'contact', sort: true, title: '联系方式'}, |
|
26 |
{field: 'remarks', sort: true, title: '备注'}, |
|
27 |
{field: 'createTime', sort: true, title: '创建时间',minWidth:160}, |
|
28 |
{field: 'createUser', sort: true, title: '创建用户'}, |
|
29 |
{field: 'updateTime', sort: true, title: '修改时间',minWidth:160}, |
|
30 |
{field: 'updateUser', sort: true, title: '修改用户'}, |
|
31 |
{align: 'center', toolbar: '#tableBar', title: '操作'} |
|
32 |
]]; |
|
33 |
}; |
|
34 |
|
|
35 |
/** |
|
36 |
* 点击查询按钮 |
|
37 |
*/ |
|
38 |
CustomInfo.search = function () { |
|
39 |
var queryData = {}; |
|
40 |
queryData['customerCode'] = $("#customerCode").val(); |
|
41 |
queryData['customerName'] = $("#customerName").val(); |
|
42 |
queryData['customerType'] = $("#customerType").val(); |
|
43 |
|
|
44 |
table.reload(CustomInfo.tableId, { |
|
45 |
where: queryData, page: {curr: 1} |
|
46 |
}); |
|
47 |
}; |
|
48 |
|
|
49 |
/** |
|
50 |
* 跳转到添加页面 |
|
51 |
*/ |
|
52 |
CustomInfo.jumpAddPage = function () { |
|
53 |
window.location.href = Feng.ctxPath + '/customInfo/add' |
|
54 |
}; |
|
55 |
|
|
56 |
/** |
|
57 |
* 跳转到编辑页面 |
|
58 |
* |
|
59 |
* @param data 点击按钮时候的行数据 |
|
60 |
*/ |
|
61 |
CustomInfo.jumpEditPage = function (data) { |
|
62 |
window.location.href = Feng.ctxPath + '/customInfo/edit?id=' + data.id |
|
63 |
}; |
|
64 |
|
|
65 |
/** |
|
66 |
* 导出excel按钮 |
|
67 |
*/ |
|
68 |
CustomInfo.exportExcel = function () { |
|
69 |
var checkRows = table.checkStatus(CustomInfo.tableId); |
|
70 |
if (checkRows.data.length === 0) { |
|
71 |
Feng.error("请选择要导出的数据"); |
|
72 |
} else { |
|
73 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
74 |
} |
|
75 |
}; |
|
76 |
|
|
77 |
/** |
|
78 |
* 点击删除 |
|
79 |
* |
|
80 |
* @param data 点击按钮时候的行数据 |
|
81 |
*/ |
|
82 |
CustomInfo.onDeleteItem = function (data) { |
|
83 |
var operation = function () { |
|
84 |
var ajax = new $ax(Feng.ctxPath + "/customInfo/delete", function (data) { |
|
85 |
Feng.success("删除成功!"); |
|
86 |
table.reload(CustomInfo.tableId); |
|
87 |
}, function (data) { |
|
88 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
89 |
}); |
|
90 |
ajax.set("id", data.id); |
|
91 |
ajax.start(); |
|
92 |
}; |
|
93 |
Feng.confirm("是否删除?", operation); |
|
94 |
}; |
|
95 |
|
|
96 |
// 渲染表格 |
|
97 |
var tableResult = table.render({ |
|
98 |
elem: '#' + CustomInfo.tableId, |
|
99 |
url: Feng.ctxPath + '/customInfo/list', |
|
100 |
page: true, |
|
101 |
height: "full-158", |
|
102 |
cellMinWidth: 100, |
|
103 |
cols: CustomInfo.initColumn() |
|
104 |
}); |
|
105 |
|
|
106 |
// 搜索按钮点击事件 |
|
107 |
$('#btnSearch').click(function () { |
|
108 |
CustomInfo.search(); |
|
109 |
}); |
|
110 |
|
|
111 |
// 添加按钮点击事件 |
|
112 |
$('#btnAdd').click(function () { |
|
113 |
|
|
114 |
CustomInfo.jumpAddPage(); |
|
115 |
|
|
116 |
}); |
|
117 |
|
|
118 |
// 导出excel |
|
119 |
$('#btnExp').click(function () { |
|
120 |
CustomInfo.exportExcel(); |
|
121 |
}); |
|
122 |
|
|
123 |
// 工具条点击事件 |
|
124 |
table.on('tool(' + CustomInfo.tableId + ')', function (obj) { |
|
125 |
var data = obj.data; |
|
126 |
var layEvent = obj.event; |
|
127 |
|
|
128 |
if (layEvent === 'edit') { |
|
129 |
CustomInfo.jumpEditPage(data); |
|
130 |
} else if (layEvent === 'delete') { |
|
131 |
CustomInfo.onDeleteItem(data); |
|
132 |
} |
|
133 |
}); |
|
134 |
}); |