ManualMaterialRequest.js
8.21 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
let action = null;
layui.config({
base: "/js/",
version: 6222
}).use(['system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
areaName = "distribution",
tableName = "ManualMaterialRequest",
app = null;
action = {
loadData: function (param) {
app.data.currentIndex = param;
app.methods.initData();
},
setData: function (locationCode, askingStatus, callType) {
debugger;
app.data.currentCode = locationCode;
if (askingStatus == 20) {
layer.confirm("确定取消叫料?", { icon: 3 }, function (index) {
app.methods.EscLoadingAsking(locationCode);
layer.close(index);
});
} else if (askingStatus == 10) {
if (callType == 10) {
layer.confirm("确定叫料?", { icon: 3 }, function (index) {
app.methods.LoadingAsking(locationCode);
layer.close(index);
});
}
else {
layer.alert("当前料点是自动料点,由设备呼叫,不能人工呼叫!", { icon: sysU.config.iconoError, shade: 0.4 });
}
}
//else if (askingStatus == 20) {
// layer.alert("已装料的不能取消!", { icon: sysU.config.iconoError, shade: 0.4 });
//} else if (askingStatus == 30) {
// layer.alert("已送料的不能取消!", { icon: sysU.config.iconoError, shade: 0.4 });
//}
}
}
app = {
data: {
startPointEle: $("#startPointEle"),
endPointEle: $("#endPointEle"),
endPointList: [],
currentIndex: "",
currentCode: '',
},
methods: {
//调用头接口
initHead: function () {
var ajaxConfig = {
data: {},
loading: false,
type: "post",
url: `/${areaName}/${tableName}/LoadHead`,
success: function (result) {
if (sysU.successBefore(result)) return;
console.log(result);
app.methods.initElementHead(result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//调用数据接口
initData: function () {
var ajaxConfig = {
data: { keys: app.data.currentIndex },
loading: false,
type: "post",
url: `/${areaName}/${tableName}/LoadData`,
success: function (result) {
if (sysU.successBefore(result)) return;
console.log(result);
app.methods.initElement($("#" + app.data.currentIndex), result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//初始头元素
initElementHead: function (list) {
var startElementList = [];
var endElementList = [];
app.data.endPointList = [];
var key = "";
for (var index = 0; index < list.length; index++) {
if (index == 0) {
key = list[index].key;
}
var str = `<li ${index == 0 ? "class='layui-this'" : ""}
lay-id="${index + 1}" onclick="action.loadData('${list[index].key}')">${list[index].value}
</li>`;
startElementList.push(str);
str = `<div class="layui-tab-item ${index == 0 ? "layui-show" : ""}">
<div class="endPoint-div" id="${list[index].key}"></div>
</div>`;
app.data.endPointList.push(list[index].key);
endElementList.push(str);
}
var result = startElementList.join(" ");
app.data.startPointEle.html("");
app.data.startPointEle.append(result);
result = endElementList.join(" ");
app.data.endPointEle.html("");
app.data.endPointEle.append(result);
if (key != "") {
app.data.currentIndex = key;
app.methods.initData();
}
},
//初始元素
initElement: function (dom, list) {
var strElementList = [];
for (var index = 0; index < list.length; index++) {
var color = "green";
var status = "未叫料";
switch (list[index].askingStatus) {
case 10://未叫料
color = "green";
status = "未叫料";
//if (list[index].callType == 20) {
// color = "gray";
//}
break;
case 20://已叫料
color = "gray";
status = "已叫料";
break;
case 30://已装料
color = "darkgray";
status = "已装料";
break;
case 40://已送料
color = "darkgray";
status = "已送料";
break;
}
var str = `<div class="${list[index].askingStatus != 10 && list[index].askingStatus != 20?
'element-item-disable' : 'element-item'}
${color}" onclick="action.setData('${list[index].locationCode}',
${list[index].askingStatus},
${list[index].callType})">
<div class="element-title">${status}</div>
<div>${list[index].locationName}</div>
</div>`;
strElementList.push(str);
}
var result = strElementList.join(" ");
dom.html("");
dom.append(result);
},
//叫料操作
LoadingAsking: function (locationCode) {
var ajaxConfig = {
data: { locationCode: locationCode },
loading: false,
type: "post",
url: `/${areaName}/${tableName}/LoadingAsking`,
success: function (result) {
if (sysU.successBefore(result)) return;
console.log(result);
//app.methods.initElement($("#" + app.data.currentIndex), result.Result);
}
};
sysU.ajax(ajaxConfig);
},
//取消叫料操作
EscLoadingAsking: function (locationCode) {
var ajaxConfig = {
data: { locationCode: locationCode },
loading: false,
type: "post",
url: `/${areaName}/${tableName}/EscLoadingAsking`,
success: function (result) {
if (sysU.successBefore(result)) return;
console.log(result);
//app.methods.initElement($("#" + app.data.currentIndex), result.Result);
}
};
sysU.ajax(ajaxConfig);
}
},
registerEvent: function () {
},
init: function () {
app.methods.initHead();
app.registerEvent();
setInterval(function () {
app.methods.initData();
}, 1000);
}
};
app.init();
});