提交 | 用户 | 时间
|
3d2401
|
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 LocationInfo = { |
|
12 |
tableId: "locationInfoTable" |
|
13 |
}; |
|
14 |
|
|
15 |
getDictType(); |
|
16 |
|
|
17 |
/** |
|
18 |
* 初始化表格的列 |
|
19 |
*/ |
|
20 |
LocationInfo.initColumn = function () { |
|
21 |
return [[ |
|
22 |
{type: 'checkbox'}, |
|
23 |
{field: 'id', hide: true, title: '主键id'}, |
|
24 |
{field: 'locationCode', sort: true, title: '工位编号'}, |
|
25 |
{field: 'locationName', sort: true, title: '工位名称'}, |
|
26 |
{field: 'locationType', sort: true, title: '工位类型(1自动2半自动3手动)'}, |
|
27 |
{field: 'workshopCode', sort: true, title: '车间编号'}, |
|
28 |
{field: 'productionLineCode', sort: true, title: '产线编号'}, |
|
29 |
{field: 'spareField1', sort: true, title: '预留字段1'}, |
|
30 |
{field: 'spareField2', sort: true, title: '预留字段2'}, |
|
31 |
{field: 'remarks', sort: true, title: '备注'}, |
|
32 |
{field: 'createUser', sort: true, title: '创建用户'}, |
|
33 |
{field: 'createTime', sort: true, title: '创建时间'}, |
|
34 |
{field: 'updateUser', sort: true, title: '更改用户'}, |
|
35 |
{field: 'updateTime', sort: true, title: '更改时间'}, |
|
36 |
{fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'} |
|
37 |
]]; |
|
38 |
}; |
|
39 |
|
|
40 |
/** |
|
41 |
* 点击查询按钮 |
|
42 |
*/ |
|
43 |
LocationInfo.search = function () { |
|
44 |
var queryData = {}; |
|
45 |
|
|
46 |
queryData['locationCode'] = $('#locationCode').val(); |
|
47 |
queryData['locationName'] = $('#locationName').val(); |
|
48 |
queryData['locationType'] = $('#locationType').val(); |
|
49 |
queryData['workshopCode'] = $('#workshopCode').val(); |
|
50 |
queryData['productionLineCode'] = $('#productionLineCode').val(); |
|
51 |
|
|
52 |
table.reload(LocationInfo.tableId, { |
|
53 |
where: queryData, page: {curr: 1} |
|
54 |
}); |
|
55 |
}; |
|
56 |
|
|
57 |
function getDictType(){ |
|
58 |
$.ajax({ |
|
59 |
type: "POST", |
|
60 |
contentType: "application/json;charset=UTF-8", |
|
61 |
url: Feng.ctxPath + '/dict/list?dictTypeId=1703969868646158337', |
|
62 |
success: function (result) { |
|
63 |
$.each(result.data, function (index, value) { |
|
64 |
$('#locationType').append(new Option(value.name,value.code));// 下拉菜单里添加元素 |
|
65 |
}); |
|
66 |
layui.form.render("select");//重新渲染 固定写法 |
|
67 |
}, |
|
68 |
}); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* 跳转到添加页面 |
|
73 |
*/ |
|
74 |
LocationInfo.jumpAddPage = function () { |
|
75 |
window.location.href = Feng.ctxPath + '/locationInfo/add' |
|
76 |
}; |
|
77 |
|
|
78 |
/** |
|
79 |
* 跳转到编辑页面 |
|
80 |
* |
|
81 |
* @param data 点击按钮时候的行数据 |
|
82 |
*/ |
|
83 |
LocationInfo.jumpEditPage = function (data) { |
|
84 |
window.location.href = Feng.ctxPath + '/locationInfo/edit?id=' + data.id |
|
85 |
}; |
|
86 |
|
|
87 |
/** |
|
88 |
* 导出excel按钮 |
|
89 |
*/ |
|
90 |
LocationInfo.exportExcel = function () { |
|
91 |
var checkRows = table.checkStatus(LocationInfo.tableId); |
|
92 |
if (checkRows.data.length === 0) { |
|
93 |
Feng.error("请选择要导出的数据"); |
|
94 |
} else { |
|
95 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
96 |
} |
|
97 |
}; |
|
98 |
|
|
99 |
/** |
|
100 |
* 点击删除 |
|
101 |
* |
|
102 |
* @param data 点击按钮时候的行数据 |
|
103 |
*/ |
|
104 |
LocationInfo.onDeleteItem = function (data) { |
|
105 |
var operation = function () { |
|
106 |
var ajax = new $ax(Feng.ctxPath + "/locationInfo/delete", function (data) { |
|
107 |
Feng.success("删除成功!"); |
|
108 |
table.reload(LocationInfo.tableId); |
|
109 |
}, function (data) { |
|
110 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
111 |
}); |
|
112 |
ajax.set("id", data.id); |
|
113 |
ajax.start(); |
|
114 |
}; |
|
115 |
Feng.confirm("是否删除?", operation); |
|
116 |
}; |
|
117 |
|
|
118 |
// 渲染表格 |
|
119 |
var tableResult = table.render({ |
|
120 |
elem: '#' + LocationInfo.tableId, |
|
121 |
url: Feng.ctxPath + '/locationInfo/list', |
|
122 |
page: true, |
|
123 |
height: "full-158", |
|
124 |
cellMinWidth: 100, |
|
125 |
cols: LocationInfo.initColumn() |
|
126 |
}); |
|
127 |
|
|
128 |
// 搜索按钮点击事件 |
|
129 |
$('#btnSearch').click(function () { |
|
130 |
LocationInfo.search(); |
|
131 |
}); |
|
132 |
|
|
133 |
// 添加按钮点击事件 |
|
134 |
$('#btnAdd').click(function () { |
|
135 |
|
|
136 |
LocationInfo.jumpAddPage(); |
|
137 |
|
|
138 |
}); |
|
139 |
|
|
140 |
// 导出excel |
|
141 |
$('#btnExp').click(function () { |
|
142 |
LocationInfo.exportExcel(); |
|
143 |
}); |
|
144 |
|
|
145 |
// 工具条点击事件 |
|
146 |
table.on('tool(' + LocationInfo.tableId + ')', function (obj) { |
|
147 |
var data = obj.data; |
|
148 |
var layEvent = obj.event; |
|
149 |
|
|
150 |
if (layEvent === 'edit') { |
|
151 |
LocationInfo.jumpEditPage(data); |
|
152 |
} else if (layEvent === 'delete') { |
|
153 |
LocationInfo.onDeleteItem(data); |
|
154 |
} |
|
155 |
}); |
|
156 |
}); |