提交 | 用户 | 时间
|
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 MaterialInfo = { |
|
12 |
tableId: "materialInfoTable" |
|
13 |
}; |
|
14 |
|
|
15 |
/** |
|
16 |
* 初始化表格的列 |
|
17 |
*/ |
|
18 |
MaterialInfo.initColumn = function () { |
|
19 |
return [[ |
|
20 |
{type: 'checkbox'}, |
|
21 |
{field: 'id', hide: true, title: '主键id'}, |
|
22 |
{field: 'materialCode', sort: true, title: '物料编号', width: 138}, |
|
23 |
{field: 'materialName', sort: true, title: '物料名称', width: 330}, |
|
24 |
{field: 'drawingNo', sort: true, title: '图号', width: 165}, |
|
25 |
{field: 'materialSpecs', sort: true, title: '规格', width: 460}, |
|
26 |
{field: 'unit', sort: true, title: '单位'}, |
|
27 |
{field: 'materialScience', sort: true, title: '材料'}, |
|
28 |
{field: 'materialType', sort: true, title: '物料类型', width: 110}, |
|
29 |
{field: 'materialAttribute', sort: true, title: '属性'}, |
|
30 |
{field: 'isPurchase', sort: true, title: '是否采购件', width: 130}, |
|
31 |
{field: 'supplier', sort: true, title: '供应商'}, |
|
32 |
{field: 'remarks', sort: true, title: '备注', width: 138}, |
|
33 |
{field: 'createUser', sort: true, title: '创建用户', width: 110}, |
|
34 |
{field: 'createTime', sort: true, title: '创建时间',minWidth:160}, |
|
35 |
{field: 'updateUser', sort: true, title: '更改用户', width: 110}, |
|
36 |
{field: 'updateTime', sort: true, title: '更改时间',minWidth:160}, |
|
37 |
{align: 'center', toolbar: '#tableBar', title: '操作', width: 125} |
|
38 |
]]; |
|
39 |
}; |
|
40 |
|
|
41 |
/** |
|
42 |
* 点击查询按钮 |
|
43 |
*/ |
|
44 |
MaterialInfo.search = function () { |
|
45 |
var queryData = {}; |
|
46 |
queryData['materialCode'] = $("#materialCode").val(); |
|
47 |
queryData['materialName'] = $("#materialName").val(); |
|
48 |
queryData['materialSpecs'] = $("#materialSpecs").val(); |
|
49 |
queryData['materialType'] = $("#materialType").val(); |
|
50 |
|
|
51 |
|
|
52 |
table.reload(MaterialInfo.tableId, { |
|
53 |
where: queryData, page: {curr: 1} |
|
54 |
}); |
|
55 |
}; |
|
56 |
|
|
57 |
/** |
|
58 |
* 弹出添加对话框 |
|
59 |
*/ |
|
60 |
|
|
61 |
MaterialInfo.jumpAddPage = function () { |
|
62 |
window.location.href = Feng.ctxPath + '/materialInfo/add' |
|
63 |
}; |
|
64 |
|
|
65 |
// 添加按钮点击事件 |
|
66 |
$('#btnAdd').click(function () { |
|
67 |
MaterialInfo.jumpAddPage(); |
|
68 |
}); |
|
69 |
|
|
70 |
/** |
|
71 |
* 点击编辑 |
|
72 |
* |
|
73 |
* @param data 点击按钮时候的行数据 |
|
74 |
*/ |
|
75 |
MaterialInfo.openEditDlg = function (data) { |
|
76 |
// func.open({ |
|
77 |
// title: '修改物料信息', |
|
78 |
// content: Feng.ctxPath + '/materialInfo/edit?id=' + data.id, |
|
79 |
// tableId: MaterialInfo.tableId |
|
80 |
// }); |
|
81 |
window.location.href = Feng.ctxPath + '/materialInfo/edit?id=' + data.id |
|
82 |
|
|
83 |
}; |
|
84 |
|
|
85 |
|
|
86 |
/** |
|
87 |
* 导出excel按钮 |
|
88 |
*/ |
|
89 |
MaterialInfo.exportExcel = function () { |
|
90 |
var checkRows = table.checkStatus(MaterialInfo.tableId); |
|
91 |
if (checkRows.data.length === 0) { |
|
92 |
Feng.error("请选择要导出的数据"); |
|
93 |
} else { |
|
94 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
95 |
} |
|
96 |
}; |
|
97 |
|
|
98 |
/** |
|
99 |
* 点击删除 |
|
100 |
* |
|
101 |
* @param data 点击按钮时候的行数据 |
|
102 |
*/ |
|
103 |
MaterialInfo.onDeleteItem = function (data) { |
|
104 |
var operation = function () { |
|
105 |
var ajax = new $ax(Feng.ctxPath + "/materialInfo/delete", function (data) { |
|
106 |
Feng.success("删除成功!"); |
|
107 |
table.reload(MaterialInfo.tableId); |
|
108 |
}, function (data) { |
|
109 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
110 |
}); |
|
111 |
ajax.set("id", data.id); |
|
112 |
ajax.start(); |
|
113 |
}; |
|
114 |
Feng.confirm("是否删除?", operation); |
|
115 |
}; |
|
116 |
|
|
117 |
// 渲染表格 |
|
118 |
var tableResult = table.render({ |
|
119 |
elem: '#' + MaterialInfo.tableId, |
|
120 |
url: Feng.ctxPath + '/materialInfo/list', |
|
121 |
page: true, |
|
122 |
height: "full-158", |
|
123 |
cellMinWidth: 100, |
|
124 |
cols: MaterialInfo.initColumn() |
|
125 |
}); |
|
126 |
|
|
127 |
// 搜索按钮点击事件 |
|
128 |
$('#btnSearch').click(function () { |
|
129 |
MaterialInfo.search(); |
|
130 |
}); |
|
131 |
|
|
132 |
// 添加按钮点击事件 |
|
133 |
$('#btnAdd').click(function () { |
|
134 |
|
|
135 |
MaterialInfo.openAddDlg(); |
|
136 |
|
|
137 |
}); |
|
138 |
|
|
139 |
// 导出excel |
|
140 |
$('#btnExp').click(function () { |
|
141 |
MaterialInfo.exportExcel(); |
|
142 |
}); |
|
143 |
|
|
144 |
// 工具条点击事件 |
|
145 |
table.on('tool(' + MaterialInfo.tableId + ')', function (obj) { |
|
146 |
var data = obj.data; |
|
147 |
var layEvent = obj.event; |
|
148 |
|
|
149 |
if (layEvent === 'edit') { |
|
150 |
MaterialInfo.openEditDlg(data); |
|
151 |
} else if (layEvent === 'delete') { |
|
152 |
MaterialInfo.onDeleteItem(data); |
|
153 |
} |
|
154 |
}); |
|
155 |
}); |