index.js
5.31 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
//内部变量
let variableObj = {
progressBar: document.querySelector("#progressBar")
};
/*设置head标题 */
String.prototype.setHeadTitle = function (element, value) {
document.querySelector(element).innerText = value;
};
/*load */
String.prototype.loadTips = function (isshow = false) {
var txt = ";display:none;";
if (isshow) {
txt = ";display:block;";
}
variableObj.progressBar.style = txt;
};
(() => {
var appVm = new Vue({
el: '#bodyApp',
data: {
/* 物料,工序 */
materia1: {},
materia2: {},
materia3: {},
materia4: {},
materia5_1: {},
materia5_2: {},
materia6: {},
/* 工单 */
pipeOrderList: {
title: null,
sumcount: 0,
pipeOrderAll: null,
pipeOrderfinished: null
},
/* 桁车任务 */
girderVehicleList: {},
/* 切割方案 */
cutplan: {},
cutplanTitle: {
index: "序号",
WONumber: "缓存位编码",
wcsProductType: "材质",
materialLength: "长度",
thickness: "壁厚",
flange1: "法兰1",
flange2: "法兰2",
},
/* AGV信息 */
avgList: {},
/* 设备状态 */
equipmentState: null,
/* 页面公共配置数据 */
sysData: {
headTitle: "三一油管看板",
// 华湘
// url: "http://172.16.35.184:10001/api/HuaXiang/Mes/V1/Read",
// 华湘
// url: "http://192.168.0.235:10001/api/HuaXiang/Mes/V1/Read",
// 本地
url: "http://172.16.43.88:10001/api/HuaXiang/Mes/V1/Read",
}
},
created: function () {
/* 所有请求 */
this.init();
},
methods: {
/* 获取数据 */
getData: function () {
"".loadTips(true);
var vm = this;
fetch(this.sysData.url, {
method: 'GET',
mode: 'cors',
}).then(res => res.json()).then(json => {
if (vm.getDataBefore(json)) return;
vm.materia1 = json.Result.materialList.material1[0];
vm.materia2 = json.Result.materialList.material2[0];
vm.materia3 = json.Result.materialList.material3[0];
vm.materia4 = json.Result.materialList.material4[0];
vm.materia5_1 = json.Result.materialList.material5[0];
vm.materia5_2 = json.Result.materialList.material5[1];
vm.materia6 = json.Result.materialList.material6[0];
vm.girderVehicleList = json.Result.girderVehicleList;
vm.equipmentState = json.Result.equipmentState;
vm.cutplan = json.Result.cutplanList;
vm.avgList = json.Result.avgList;
vm.pipeOrderList.sumcount = json.Result.pipeOrderList.pipeOrderfinished.length == 0 ? 0 : json.Result.pipeOrderList.pipeOrderfinished[0].sumcount;
vm.pipeOrderList.pipeOrderfinished = json.Result.pipeOrderList.pipeOrderfinished;
vm.pipeOrderList.pipeOrderAll = json.Result.pipeOrderList.pipeOrderAll;
vm.cutplan = json.Result.cutplanList;
return json;
}).catch(err => {
this.getDataCatch(err);
});
},
/* 获取数据之前判断 */
getDataBefore: function (json) {
var result = false;
console.log('获取的结果', json);
"".loadTips();
if (json.Code != 200 || !json.Status) {
alert(json.Message);
result = true;
}
return result;
},
/* 获取数据异常处理 */
getDataCatch: function (err) {
"".loadTips();
if (err == "TypeError: Failed to fetch") {
alert("app服务404,请检查服务是否开启!当前url"+" \n "+this.sysData.url);
} else {
alert(err);
}
console.log('请求错误', err);
},
/* 设备状态查找 */
getEquipmentState: function (value) {
var isOk = true;
for (var item in this.equipmentState) {
if (item == value) {
isOk = false;
return this.equipmentState[item]
}
}
if (!isOk) return "未知状态"
},
/* 入口 */
init: function () {
this.getData();
}
},
mounted: function () {
// 设置页面title属性值
"".setHeadTitle("#headTitle", this.sysData.headTitle);
this.pipeOrderList.title = `目前${new Date().getFullYear()}年${new Date().getMonth() + 1}月自动生产总产量:`;
}
});
})();