EquipmentVisual.js
14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
let action = null;
layui.config({
base: "/js/",
version: 1
}).use(['system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
sendDataWhere = null,
paramData = {
eqCode: null,
eqType: null,
otherCoce:null,
eqImg:null,
eqName:""
},
areaName = "equipment",
controllerName = "BaseEquipment",
app = null;
action = {
//页签tabs点击事件
tabVisualTabMethod: function (data) {
if (data.index == 2 || data.index == 3) {
app.methods.initEqFileAndAlarmDataList()
}
else if (data.index == 4) {
app.methods.initEqMaintainDataList();
}
},
//表格行点击事件
customTableCelClick: function (obj, tableId) {
if (tableId == app.data.tableColsEqPartElem) {
app.methods.initEqPartMaintainDataList(obj.data.partCode);
}
},
}
app = {
data: {
colsFile: [[
{ field: "id", width: 100, title: "编码", hide: true },
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{ field: 'fileName', width: 300, title: '文档名称' },
{
field: 'url', width: 300, title: '文件下载', templet: function (d) {
var target = "_blank";
if (d.suffix.indexOf("pdf") > -1 || d.suffix.indexOf("docx") > -1 || d.suffix.indexOf("doc") > -1 || d.suffix.indexOf("xlsx") > -1) {
target = "_self";
}
return `<a href="../../Document/${d.url}" target='${target}' style="color:cornflowerblue;text-decoration: underline;cursor:pointer;">${d.fileName}</a>`;
}
},
{ field: 'size', width: 100, title: '文档大小' },
{ field: 'targetId', title: '设备Code', hide: true },
{ field: 'targetTableName', width: 120, title: '适用的设备', hide: true },
{ field: 'suffix', width: 100, title: '文档类型' },
{ field: 'remark', width: 120, title: '备注' },
{ field: 'createTime', width: 150, title: '创建时间' },
{ field: 'createBy', width: 100, title: '创建人' }
]],
tableColsFileObj: null,
tableColsFileElem: "mainFile",
colsAlarm: [[
{ field: "Id", width: 80, hide: true, title: "Id" },
{ field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },
{ field: "EquipmentCode", width: 200, title: "设备编号", hide: true, },
{ field: "EquipmentName", width: 150, title: "设备名称" },
{ field: "AlarmMessage", width: 400, title: "报警信息" },
{
field: "Errorduration", width: 150, title: "报警持续时间", templet: function (d) {
return app.methods.convertSecondsToTime(d.Errorduration)
}
},
{ field: "CreateTime", width: 150, title: "创建时间" },
{ field: "Remark", width: 150, title: "备注" },
]],
colsEqPart: [[
{ field: "partCode", width: 200, hide: true, title: "部件编码" },
{ field: "partName", width: 200, title: "设备部件" },
{ field: "indicator", width: 200, title: "保养周期", type:"numbers" },
{ field: "indicatorType", width: 280, title: "保养类型" },
{ field: "price", width: 200, title: "保养费用" },
/* { field: "price", width: 100, title: "距离下次保养(天)" },*/
]],
colsEqMaintainRecord: [[
{ field: "EquipmentCode", width: 80, hide: true, title: "设备编码" },
{ field: "EquipmentTypeCode", width: 150, title: "设备类型编码", hide: true },
{ field: "PartCode", width: 80, hide: true, title: "部件编码" },
{ field: "PartName", width: 150, title: "设备部件" },
{ field: "LastMaintainTime", width: 150, title: "上次保养时间" },
{ field: "NextMaintainTime", width: 150, title: "下次保养时间" },
{ field: "MaintainTime", width: 150, title: "本次保养时间" },
{ field: "Maintainer", width: 150, title: "操作人" },
{ field: "MaintainContent", width: 150, title: "保养结果" },
{ field: "MaintainPrice", width: 150, title: "维保费用" },
{ field: "PushStatus", width: 150, title: "推送状态" },
{ field: "Attachment", width: 150, title: "附件" },
{ field: "Remark", width: 150, title: "备注" },
]],
tableColsAlarmObj: null,
tableColsAlarmElem: "mainAlarm",
tableColsEqPartElem: "equipmentPartDt",
tableColsEqMaintainedElem: "maintainedDt",
tableColsEqUnMaintainElem: "unMaintainDt",
echartOpt: {
eqDeviceStatusEle: document.getElementById("deviceStatus"),
},
//下拉框配置
selectOption: {
//返回的数据 用于后续操作
selectData: {
}
},
},
methods: {
//文件列表页签
initFileTable: function (data) {
let options = {
elem: "#" + app.data.tableColsFileElem,
cols: app.data.colsFile,
data: data,
page: false,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsFileObj = sysU.initTable(options);
},
//报警列表页签
initAlarmTable: function (data) {
let options = {
elem: "#" + app.data.tableColsAlarmElem,
cols: app.data.colsAlarm,
data: data,
page: false,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养-设备概述、设备部件
initEqPartTable: function (data) {
//设备概述代码
var paramData = data[0];
if (paramData != undefined) {
$('#maintainNumber').text(`${paramData.maintainNumber}`);
$('#toBeMaintainNumber').text(`${paramData.toBeMaintainNumber}`);
}
else {
$('#maintainNumber').text(0);
$('#toBeMaintainNumber').text(0);
}
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqPartElem,
cols: app.data.colsEqPart,
data: data,
page: true,
limit: Number.MAX_VALUE,
//height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
//设备保养、未保养
app.methods.initEqPartMaintainDataList();
debugger
//$('#equipmentPartDt').next().children()[0].children[1].style.height = '100%'
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养-已保养
initEqMaintainedTable: function (data) {
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqMaintainedElem,
cols: app.data.colsEqMaintainRecord,
data: data,
page: true,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
//设备保养-未保养
initEqUnMaintainTable: function (data) {
//设备部件表格
let options = {
elem: "#" + app.data.tableColsEqUnMaintainElem,
cols: app.data.colsEqMaintainRecord,
data: data,
page: true,
limit: Number.MAX_VALUE,
height: "full-90",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend: function (res, obj) {
}
}
app.data.tableColsAlarmObj = sysU.initTable(options);
},
initDeviceStatus() {
let myChart = echarts.init(app.data.echartOpt.eqDeviceStatusEle)
let val = [
{
"value": data.AlarmProportion,
"name": "故障"
},
{
"value": data.RunProportion,
"name": "运行"
},
{
"value": data.FreeProportion,
"name": "空闲"
},
{
"value": data.OfflineProportion,
"name": "离线"
}
];
window.deviceStatus.series[0].data = val;
myChart.clear()
myChart.setOption(window.deviceStatus)
},
//设备健康
initEquipmentHealthTab(data) {
app.methods.initDeviceStatus(data.EquipmentStatus);
},
//初始化页面
initView() {
var ajaxConfig = {
data: { equipmentCode: paramData.otherCode, equipmentTypeCode: paramData.eqType },
url: `/${areaName}/${controllerName}/GetEquipmentFileList`,
success: function (res) {
if (sysU.successBefore(res)) return false;
var result = res.Result;
app.methods.initEquipmentHealthTab(result.equipmentHealth)
app.methods.initFileTable(result.fileList);
app.methods.initAlarmTable(result.alarmList);
}
};
sysU.ajax(ajaxConfig);
},
//读取设备概述、设备部件保养数据
initEqMaintainDataList() {
var ajaxConfig = {
data: { equipmentCode: paramData.eqCode, equipmentTypeCode: paramData.eqType },
url: `/${areaName}/${controllerName}/GetEquipmentMaintainList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initEqPartTable(result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//设备部件保养、未保养数据
initEqPartMaintainDataList(obj) {
var ajaxConfig = {
data: { eqCode: paramData.eqCode, partCode: obj },
url: `/${areaName}/${controllerName}/GetEquipmentMaintainRecordList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
//加载设备部件保养、未保养 表格
app.methods.initEqMaintainedTable(result.Result.maintainList);
app.methods.initEqUnMaintainTable(result.Result.tobemaintainList);
}
};
sysU.ajax(ajaxConfig);
},
//秒转换小时、分钟
convertSecondsToTime: function (seconds) {
if (typeof seconds !== 'number') return seconds;
var hours = Math.floor(seconds / 3600);
var minutes = Math.floor((seconds % 3600) / 60);
var remainingSeconds = seconds % 60;
var result = '';
if (hours > 0) {
result += hours + '小时';
}
if (minutes > 0) {
result += minutes + '分';
}
result += remainingSeconds + '秒';
return result;
},
//初始化表单
initFrom() {
paramData.eqCode = "".GetUrlParam("eqCode");
paramData.eqType = "".GetUrlParam("eqType");
paramData.eqName = "".GetUrlParam("eqName");
paramData.eqImg = "".GetUrlParam("eqImg");
paramData.otherCode = "".GetUrlParam("otherCode");
$("#bread-visual").text(`设备可视化【${paramData.eqName}】`)
$("#eqName").text(`${paramData.eqName}`) //保养数据-设备名
$("#eqImg").attr('src', `/images/equipment/${paramData.eqImg}`)
}
},
registerEvent: function () {
},
init: function () {
app.methods.initDeviceStatus();
app.methods.initFrom();
app.methods.initView();
app.registerEvent();
}
};
app.init();
});