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