提交 | 用户 | 时间
|
1ac2bc
|
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 ProductRouteChildInfo = { |
|
12 |
tableId: "productRouteChildInfoTable" |
|
13 |
}; |
|
14 |
|
|
15 |
getDictType(); |
|
16 |
|
|
17 |
/** |
|
18 |
* 初始化表格的列 |
|
19 |
*/ |
|
20 |
ProductRouteChildInfo.initColumn = function () { |
|
21 |
return [[ |
|
22 |
{type: 'checkbox'}, |
|
23 |
{field: 'id', hide: true, title: '主键id'}, |
|
24 |
{field: 'opCode', sort: true, title: '工序编码'}, |
|
25 |
{field: 'opName', sort: true, title: '工序名称'}, |
|
26 |
{field: 'stepNo', sort: true, title: '加工顺序'}, |
|
27 |
// {field: 'opType', sort: true, title: '工序类型'}, |
|
28 |
{ |
|
29 |
field: 'opType', align: "center", title: '工序类型', templet: function (d) { |
|
30 |
switch(d.opType){ |
|
31 |
case "1" : |
|
32 |
return "上线工序"; |
|
33 |
break; |
|
34 |
case "2" : |
|
35 |
return "过程工序"; |
|
36 |
break; |
|
37 |
case "3" : |
|
38 |
return "下线工序"; |
|
39 |
break; |
|
40 |
default : |
|
41 |
} |
|
42 |
} |
|
43 |
}, |
|
44 |
{field: 'remark', sort: true, title: '备注'}, |
|
45 |
{field: 'routeCode', sort: true, title: '流程编码'}, |
|
46 |
{align: 'center', toolbar: '#tableBar', title: '操作'} |
|
47 |
]]; |
|
48 |
}; |
|
49 |
|
|
50 |
function getDictType(){ |
|
51 |
$.ajax({ |
|
52 |
type: "POST", |
|
53 |
contentType: "application/json;charset=UTF-8", |
|
54 |
url: Feng.ctxPath + '/dict/list?dictTypeId=1694972441967951874', |
|
55 |
success: function (result) { |
|
56 |
$.each(result.data, function (index, value) { |
|
57 |
// $('#opType').append(new Option(value.code,value.name));// 下拉菜单里添加元素 |
|
58 |
$('#opType').append(new Option(value.name,value.code));// 下拉菜单里添加元素 |
|
59 |
}); |
|
60 |
layui.form.render("select");//重新渲染 固定写法 |
|
61 |
}, |
|
62 |
}); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* 点击查询按钮 |
|
67 |
*/ |
|
68 |
ProductRouteChildInfo.search = function () { |
|
69 |
var queryData = {}; |
|
70 |
|
|
71 |
queryData['opCode'] = $('#opCode').val(); |
|
72 |
queryData['opName'] = $('#opName').val(); |
|
73 |
queryData['opType'] = $('#opType').val(); |
|
74 |
queryData['routeCode'] = $('#routeCode').val(); |
|
75 |
|
|
76 |
table.reload(ProductRouteChildInfo.tableId, { |
|
77 |
where: queryData, page: {curr: 1} |
|
78 |
}); |
|
79 |
}; |
|
80 |
|
|
81 |
/** |
|
82 |
* 跳转到添加页面 |
|
83 |
*/ |
|
84 |
ProductRouteChildInfo.jumpAddPage = function () { |
|
85 |
// window.location.href = Feng.ctxPath + '/productRouteChildInfo/add' |
|
86 |
func.open({ |
|
87 |
height: 650, |
|
88 |
title: '添加工艺路线子信息', |
|
89 |
content: Feng.ctxPath + '/productRouteChildInfo/add?routeInfoCode=' + $("#routeInfoCode").val(), |
|
90 |
tableId: ProductRouteChildInfo.tableId, |
|
91 |
}); |
|
92 |
}; |
|
93 |
|
|
94 |
/** |
|
95 |
* 跳转到编辑页面 |
|
96 |
* |
|
97 |
* @param data 点击按钮时候的行数据 |
|
98 |
*/ |
|
99 |
ProductRouteChildInfo.jumpEditPage = function (data) { |
|
100 |
// window.location.href = Feng.ctxPath + '/productRouteChildInfo/edit?id=' + data.id |
|
101 |
func.open({ |
|
102 |
height: 650, |
|
103 |
title: '工艺路线子信息', |
|
104 |
content: Feng.ctxPath + '/productRouteChildInfo/edit?id=' + data.id, |
|
105 |
tableId: ProductRouteChildInfo.tableId, |
|
106 |
}); |
|
107 |
}; |
|
108 |
|
|
109 |
// 关闭页面 |
|
110 |
$('#btnBack').click(function () { |
|
111 |
window.location.href = Feng.ctxPath + "/productRouteInfo"; |
|
112 |
}); |
|
113 |
|
|
114 |
/** |
|
115 |
* 导出excel按钮 |
|
116 |
*/ |
|
117 |
ProductRouteChildInfo.exportExcel = function () { |
|
118 |
var checkRows = table.checkStatus(ProductRouteChildInfo.tableId); |
|
119 |
if (checkRows.data.length === 0) { |
|
120 |
Feng.error("请选择要导出的数据"); |
|
121 |
} else { |
|
122 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
123 |
} |
|
124 |
}; |
|
125 |
|
|
126 |
/** |
|
127 |
* 点击删除 |
|
128 |
* |
|
129 |
* @param data 点击按钮时候的行数据 |
|
130 |
*/ |
|
131 |
ProductRouteChildInfo.onDeleteItem = function (data) { |
|
132 |
var operation = function () { |
|
133 |
var ajax = new $ax(Feng.ctxPath + "/productRouteChildInfo/delete", function (data) { |
|
134 |
Feng.success("删除成功!"); |
|
135 |
table.reload(ProductRouteChildInfo.tableId); |
|
136 |
}, function (data) { |
|
137 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
138 |
}); |
|
139 |
ajax.set("id", data.id); |
|
140 |
ajax.start(); |
|
141 |
}; |
|
142 |
Feng.confirm("是否删除?", operation); |
|
143 |
}; |
|
144 |
|
|
145 |
var queryData = {}; |
|
146 |
queryData['routeCode'] = $('#routeInfoCode').val(); |
|
147 |
// 渲染表格 |
|
148 |
var tableResult = table.render({ |
|
149 |
elem: '#' + ProductRouteChildInfo.tableId, |
|
150 |
url: Feng.ctxPath + '/productRouteChildInfo/list', |
|
151 |
page: true, |
|
152 |
height: "full-158", |
|
153 |
cellMinWidth: 100, |
|
154 |
where: queryData, |
|
155 |
cols: ProductRouteChildInfo.initColumn() |
|
156 |
}); |
|
157 |
|
|
158 |
// 搜索按钮点击事件 |
|
159 |
$('#btnSearch').click(function () { |
|
160 |
ProductRouteChildInfo.search(); |
|
161 |
}); |
|
162 |
|
|
163 |
// 添加按钮点击事件 |
|
164 |
$('#btnAdd').click(function () { |
|
165 |
|
|
166 |
ProductRouteChildInfo.jumpAddPage(); |
|
167 |
|
|
168 |
}); |
|
169 |
|
|
170 |
// 导出excel |
|
171 |
$('#btnExp').click(function () { |
|
172 |
ProductRouteChildInfo.exportExcel(); |
|
173 |
}); |
|
174 |
|
|
175 |
// 工具条点击事件 |
|
176 |
table.on('tool(' + ProductRouteChildInfo.tableId + ')', function (obj) { |
|
177 |
var data = obj.data; |
|
178 |
var layEvent = obj.event; |
|
179 |
|
|
180 |
if (layEvent === 'edit') { |
|
181 |
ProductRouteChildInfo.jumpEditPage(data); |
|
182 |
} else if (layEvent === 'delete') { |
|
183 |
ProductRouteChildInfo.onDeleteItem(data); |
|
184 |
} |
|
185 |
}); |
|
186 |
}); |