EquipmentVisual.js
6.78 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
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,
eqName:""
},
areaName = "equipment",
controllerName = "BaseEquipment",
app = null;
action = {
//页签tabs点击事件
tabVisualTabMethod: function (data) {
if (data.index == 2 || data.index == 3) {
app.methods.initEqFileAndAlarmDataList()
}
},
}
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: "备注" },
]],
tableColsAlarmObj: null,
tableColsAlarmElem: "mainAlarm",
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);
},
initDeviceStatus() {
let myChart = echarts.init(app.data.echartOpt.eqDeviceStatusEle)
window.deviceStatus.series[0].data[0].value = 12
myChart.clear()
myChart.setOption(window.deviceStatus)
},
//文件、报警
initEqFileAndAlarmDataList() {
var ajaxConfig = {
data: { equipmentCode: paramData.eqCode, equipmentTypeCode: paramData.eqType },
url: `/${areaName}/${controllerName}/GetEquipmentFileList`,
success: function (result) {
if (sysU.successBefore(result)) return false;
app.methods.initFileTable(result.Result.fileList);
app.methods.initAlarmTable(result.Result.alarmList);
}
};
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");
$("#bread-visual").text(`设备可视化【${paramData.eqName}】`)
}
},
registerEvent: function () {
},
init: function () {
app.methods.initDeviceStatus()
app.methods.initFrom();
app.registerEvent();
}
};
app.init();
});