Nesting.js
7.85 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: 1222
}).use(['ztree', 'system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sendData = {},
u = new system.u(),
areaName = "Planned",
tableName = "Nesting",
app = null;
action = {
//计算 调用 initTableMiddle,initTableRightDown 方法
BtnNestingCalculation: function (sysU, toolbarId, obj) {
var cutDetailIds = "";
//工单
var checkStatus2 = table.checkStatus('leftDownList');
if (checkStatus2.data.length > 0) {
var Ids = [];
for (var i = 0; i < checkStatus2.data.length; i++) {
Ids.push(checkStatus2.data[i].id);
}
cutDetailIds = Ids.join(",");
}
sendData.cutDetailIds = cutDetailIds;
var ajaxConfig = {
data: sendData,
type: "post",
url: `/${areaName}/${tableName}/NestingCalculation`,
success: function (result) {
if (sysU.successBefore(result)) return;
app.methods.initTableMiddle(result.data.Middle);
app.methods.initTableRightDown(result.data.RightDown);
$('table').attr({ "lay-size": "sm" });
layer.msg(result.msg, { icon: 6, shade: 0.4, time: 1000 });
}
};
sysU.ajax(ajaxConfig);
},
//保存切割方案
BtnSaveCutPlan: function (sysU, toolbarId, obj) {
var cutDetailIds = "";
//工单
var checkStatus2 = table.checkStatus('leftDownList');
if (checkStatus2.data.length > 0) {
var Ids = [];
for (var i = 0; i < checkStatus2.data.length; i++) {
Ids.push(checkStatus2.data[i].id);
}
cutDetailIds = Ids.join(",");
}
sendData.cutDetailIds = cutDetailIds;
var ajaxConfig = {
data: sendData,
type: "post",
url: `/${areaName}/${tableName}/SaveNestingProgramme`,
success: function (result) {
if (sysU.successBefore(result)) return;
app.methods.initTableMiddle(result.data.Middle);
app.methods.initTableRightDown(result.data.RightDown);
$('table').attr({ "lay-size": "sm" });
layer.msg(result.msg, { icon: 6, shade: 0.4, time: 1000 });
}
};
sysU.ajax(ajaxConfig);
},
//所有动作成功之后
actionSuccess: (falg, index = 1) => {
if (falg === "add" || falg === "edit" || falg === "delete" || falg === "upload") {
} else if (falg === "refresh") {
app.methods.initTableLeftDown();
}
$('table').attr({ "lay-size": "sm" });
}
}
app = {
data: {
//工单
colsLeftDown: [[
{ checkbox: true, fixed: true, isAll: true },
{ field: "id", width: 85, title: "ID" },
{ field: "otherOrderCode", width: 150, title: "工单号" }
]],
tableObjLeftDown: null,
tableElemLeftDown: "leftDownList",
//套料头
colsMiddle: [[
{ field: "id", width: 85, title: "序号"},
{ field: "materialCode", width: 85, title: "物料编码" },
{ field: "pipeLength", width: 85, title: "管材长度(mm)" },
{ field: "lossCount", width: 80, title: "利用率%" },
{ field: "oddmentsLength", width: 80, title: "余料长度(mm)" }
]],
tableObjMiddle: null,
tableElemMiddle: "middleList",
//套料明细
colsMiddleDesc: [[
{ field: "barCode", width: 85, title: "追踪码" },
{ field: "iwpNo", width: 160, title: "工单号" },
{ field: "cuttingLength", width: 110, title: "切割长度(mm)" },
]],
tableObjMiddleDesc: null,
tableElemMiddleDesc: "middleListDesc",
//未套料工单
colsRightDown: [[
{ field: "id", width: 85, title: "ID" },
{ field: "otherOrderCode", width: 150, title: "工单号" }
]],
tableObjRightDown: null,
tableElemRightDown: "rightDownList",
contentLeft: $(".content-left"),
contentRight: $(".content-right"),
selectOption: {
//返回的数据 用于后续操作
selectData: {
}
}
},
methods: {
//工单
initTableLeftDown: function (options) {
var where = sendData;
if (options != undefined) $.extend(where, options);
let opt = {
cols: u.columnRecord(app.data.tableElemLeftDown, app.data.colsLeftDown),
elem: "#" + app.data.tableElemLeftDown,
url: `/${areaName}/${tableName}/GetCutterInfo`,
height: "full-431",
page: false,
where: where,
}
app.data.tableObjLeftDown = u.initTable(opt);
},
//套料方案
initTableMiddle: function (data) {
let opt = {
cols: u.columnRecord(app.data.tableElemMiddle, app.data.colsMiddle),
elem: "#" + app.data.tableElemMiddle,
even: true,
//height: "full-96",
data: data,
limit: Number.MAX_VALUE
};
app.data.tableObjMiddle = table.render(opt);
//监听表格行双击事件
table.on(`rowDouble(${app.data.tableElemMiddle})`, function (obj) {
element.tabChange("tableTabBody", "2");
var rowIndex = $(obj.tr).attr("data-index");
app.methods.initTableMiddleDesc(data[rowIndex].CutPlanDetails);
$('table').attr({ "lay-size": "sm" });
});
},
//套料方案明细
initTableMiddleDesc: function (data) {
let opt = {
cols: u.columnRecord(app.data.tableElemMiddleDesc, app.data.colsMiddleDesc),
elem: "#" + app.data.tableElemMiddleDesc,
even: true,
//height: "full-96",
data: data,
limit: Number.MAX_VALUE
};
app.data.tableObjMiddleDesc = table.render(opt);
},
//未套料工单
initTableRightDown: function (data) {
let opt = {
cols: u.columnRecord(app.data.tableElemRightDown, app.data.colsRightDown),
elem: "#" + app.data.tableElemRightDown,
even: true,
height: "full-431",
data: data,
limit: Number.MAX_VALUE
}
app.data.tableObjRightDown = table.render(opt);
},
initFrom: function () {
var height = u.getFrameHeight() - 60;
app.data.contentLeft.height(height);
app.data.contentRight.height(height);
}
},
registerEvent: function () {
system.queryExtend();
},
init: function () {
app.methods.initFrom();
app.methods.initTableLeftDown();
app.registerEvent();
}
};
app.init();
});