提交 | 用户 | 时间
|
71e81e
|
1 |
/** |
懒 |
2 |
* 详情对话框 |
|
3 |
*/ |
|
4 |
var EquipmentMaintainTaskInfoDlg = { |
|
5 |
data: { |
|
6 |
id: "", |
|
7 |
equipmentNo: "", |
|
8 |
equipmentName: "", |
|
9 |
taskNo: "", |
|
10 |
planNo: "", |
|
11 |
planName: "", |
|
12 |
maintainType: "", |
|
13 |
maintainState: "", |
|
14 |
maintainResult: "", |
|
15 |
reason: "", |
|
16 |
maintainPrice: "", |
|
17 |
externalMaintain: "", |
|
18 |
maintainUser: "", |
|
19 |
spareField1: "", |
|
20 |
spareField2: "", |
|
21 |
finishTime: "", |
|
22 |
maintainTime: "", |
|
23 |
remarks: "" |
|
24 |
} |
|
25 |
}; |
|
26 |
|
|
27 |
layui.use(['table','form', 'admin', 'ax','laydate','upload','formSelects'], function () { |
|
28 |
var $ = layui.jquery; |
|
29 |
var $ax = layui.ax; |
|
30 |
var form = layui.form; |
|
31 |
var admin = layui.admin; |
|
32 |
var table = layui.table; |
|
33 |
|
|
34 |
|
|
35 |
var dataList = new Array(); |
|
36 |
|
|
37 |
/** |
|
38 |
* 物料档案管理 |
|
39 |
*/ |
|
40 |
var EqConfTable = { |
|
41 |
tableId: "eqConfTable" |
|
42 |
}; |
|
43 |
table.render({ |
|
44 |
elem: '#eqConfTable',page: true |
|
45 |
, cols: [[ //标题栏 |
|
46 |
// {type: 'checkbox'}, |
|
47 |
{field: 'maintainContentCode', title: '编号'}, |
|
48 |
{field: 'maintainContentName', title: '名称'}, |
|
49 |
{field: 'maintainContentType', title: '类型'}, |
|
50 |
{field: 'maintainResult', title: '是否保养',templet: '#statusTpl'}, |
|
51 |
{field: 'maintainContent', title: '保养内容描述', edit: 'textarea'}, |
|
52 |
{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 120} |
|
53 |
]] |
|
54 |
,limit: 10 |
|
55 |
, data: dataList |
|
56 |
, even: true |
|
57 |
}); |
|
58 |
|
|
59 |
//获取详情信息,填充表单 |
|
60 |
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainTask/detail?id=" + Feng.getUrlParam("id")); |
|
61 |
var result = ajax.start(); |
|
62 |
form.val('equipmentMaintainTaskForm', result.data); |
|
63 |
var contentPlan = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/detailByMaintainPlanNo?taskNo=" + result.data.taskNo); |
|
64 |
var Planresult = contentPlan.start(); |
|
65 |
|
|
66 |
Planresult.forEach(function (val, index) { |
|
67 |
var obj = { |
|
68 |
'maintainContentCode': val.maintainContentCode, |
|
69 |
'maintainContentName': val.maintainContentName, |
|
70 |
'maintainContentType': val.maintainContentType, |
|
71 |
'maintainContent': val.maintainContent, |
|
72 |
'maintainResult': val.maintainResult, |
|
73 |
|
|
74 |
}; |
|
75 |
dataList.push(obj); |
|
76 |
}); |
|
77 |
table.reload(EqConfTable.tableId, { |
|
78 |
data: dataList |
|
79 |
}); |
|
80 |
table.reload(EqConfTable.tableId, { |
|
81 |
data: Planresult |
|
82 |
}); |
|
83 |
console.log("加载数据后的dataList状态"+dataList); |
|
84 |
|
|
85 |
$('#btnAdds').click(function () { |
|
86 |
console.log("点击保养计划配置") |
|
87 |
EqConfTable.btnForProcess(); |
|
88 |
}); |
|
89 |
|
|
90 |
EqConfTable.btnForProcess = function () { |
|
91 |
layer.open({ |
|
92 |
type: 2, |
|
93 |
title: '保养内容', |
|
94 |
area: ['800px', '650px'], |
|
95 |
content: Feng.ctxPath + '/equipmentMaintainContentConf/addListConf', |
|
96 |
end: function () { |
|
97 |
var info = $("#materialList").val(); |
|
98 |
console.log(info) |
|
99 |
if (info != "") { |
|
100 |
var tempList = eval(info); |
|
101 |
tempList.forEach(function (val, index) { |
|
102 |
var obj = { |
|
103 |
'maintainContentCode': val.maintainContentCode, |
|
104 |
'maintainContentName': val.maintainContentName, |
|
105 |
'maintainContentType': val.maintainContentType, |
|
106 |
'maintainContent': val.maintainContent, |
|
107 |
}; |
|
108 |
dataList.push(obj); |
|
109 |
}); |
|
110 |
table.reload(EqConfTable.tableId, { |
|
111 |
data: dataList |
|
112 |
}); |
|
113 |
$("#materialList").val(""); |
|
114 |
} |
|
115 |
} |
|
116 |
}); |
|
117 |
}; |
|
118 |
|
|
119 |
|
|
120 |
// 工具条点击事件 |
|
121 |
table.on('tool(' + EqConfTable.tableId + ')', function (obj) { |
|
122 |
var data = obj.data; |
|
123 |
var layEvent = obj.event; |
|
124 |
|
|
125 |
if (layEvent === 'delete') { |
|
126 |
EqConfTable.onDeleteItem(data); |
|
127 |
} |
|
128 |
}); |
|
129 |
|
|
130 |
//监听指定开关 |
|
131 |
form.on('switch(state)', function(data){ |
|
132 |
console.log("监听指定开关data id="+data.value); |
|
133 |
// var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/editByState",function (data) { |
|
134 |
// Feng.success("修改成功!"); |
|
135 |
// }, function (data) { |
|
136 |
// Feng.error("修改失败!" + data.responseJSON.message); |
|
137 |
// }); |
|
138 |
// ajax.set("id", data.value); |
|
139 |
// ajax.set("maintainResult", this.checked ? '已保养' : '未保养'); |
|
140 |
// ajax.start(); |
|
141 |
// console.log("监听指定开关data id="); |
|
142 |
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/detail?id=" + data.value); |
|
143 |
var result = ajax.start(); |
|
144 |
console.log(result.data.maintainContentCode); |
|
145 |
|
|
146 |
for (let i = 0; i < dataList.length; i++) { |
|
147 |
if (dataList[i].maintainContentCode === result.data.maintainContentCode) { |
|
148 |
dataList[i].maintainResult = this.checked ? '已保养' : '未保养'; |
|
149 |
} |
|
150 |
} |
|
151 |
}); |
|
152 |
|
|
153 |
table.on('edit(eqConfTable)', function (data) { |
|
154 |
// var value = obj.value, //得到修改后的值 |
|
155 |
// data = obj.data, //得到所在行所有键值 |
|
156 |
// field = obj.field; //得到字段 |
|
157 |
console.log(data.data) |
|
158 |
// var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainContentTask/editByState", function (data) { |
|
159 |
// }, function (data) { |
|
160 |
// Feng.error("更新失败!" + data.responseJSON.message) |
|
161 |
// }); |
|
162 |
// ajax.set(data.data); |
|
163 |
// ajax.start(); |
|
164 |
for (let i = 0; i < dataList.length; i++) { |
|
165 |
if (dataList[i].maintainContentCode === data.data.maintainContentCode) { |
|
166 |
dataList[i].maintainContent = data.value; |
|
167 |
} |
|
168 |
} |
|
169 |
}); |
|
170 |
|
|
171 |
/** |
|
172 |
* 点击删除 |
|
173 |
* |
|
174 |
* @param data 点击按钮时候的行数据 |
|
175 |
*/ |
|
176 |
EqConfTable.onDeleteItem = function (data) { |
|
177 |
let operation = function () { |
|
178 |
for (let i = 0; i < dataList.length; i++) { |
|
179 |
console.log(dataList[i].maintainContentCode) |
|
180 |
console.log(data.maintainContentCode) |
|
181 |
if (dataList[i].maintainContentCode === data.maintainContentCode) { |
|
182 |
dataList.splice(i, 1); |
|
183 |
Feng.success("删除成功!"); |
|
184 |
} |
|
185 |
} |
|
186 |
table.reload(EqConfTable.tableId, { |
|
187 |
data: dataList |
|
188 |
}); |
|
189 |
}; |
|
190 |
Feng.confirm("是否删除?", operation); |
|
191 |
}; |
|
192 |
|
|
193 |
$('#cancel').click(function(){ |
|
194 |
window.location.href = Feng.ctxPath + '/equipmentMaintainTask' |
|
195 |
}); |
|
196 |
|
|
197 |
//表单提交事件 |
|
198 |
form.on('submit(btnSubmit)', function (data) { |
|
199 |
var ajax = new $ax(Feng.ctxPath + "/equipmentMaintainTask/editItem", function (data) { |
|
200 |
Feng.success("更新成功!"); |
|
201 |
window.location.href = Feng.ctxPath + '/equipmentMaintainTask' |
|
202 |
}, function (data) { |
|
203 |
Feng.error("更新失败!" + data.responseJSON.message) |
|
204 |
}); |
|
205 |
ajax.set(data.field); |
|
206 |
ajax.set("dataList", JSON.stringify(dataList)); |
|
207 |
ajax.start(); |
|
208 |
|
|
209 |
return false; |
|
210 |
}); |
|
211 |
|
|
212 |
}); |